9 Mixed Operations
These functions perform conversions between Stan containers matrix, vector, row vector and arrays.
matrix
to_matrix
(matrix m)
Return the matrix m
itself.
Available since 2.3
complex_matrix
to_matrix
(complex_matrix m)
Return the matrix m
itself.
Available since 2.30
matrix
to_matrix
(vector v)
Convert the column vector v
to a size(v)
by 1 matrix.
Available since 2.3
complex_matrix
to_matrix
(complex_vector v)
Convert the column vector v
to a size(v)
by 1 matrix.
Available since 2.30
matrix
to_matrix
(row_vector v)
Convert the row vector v
to a 1 by size(v)
matrix.
Available since 2.3
complex_matrix
to_matrix
(complex_row_vector v)
Convert the row vector v
to a 1 by size(v)
matrix.
Available since 2.30
matrix
to_matrix
(matrix M, int m, int n)
Convert a matrix A
to a matrix with m
rows and n
columns filled in
column-major order.
Available since 2.15
complex_matrix
to_matrix
(complex_matrix M, int m, int n)
Convert a matrix A
to a matrix with m
rows and n
columns filled in
column-major order.
Available since 2.30
matrix
to_matrix
(vector v, int m, int n)
Convert a vector v
to a matrix with m
rows and n
columns filled in
column-major order.
Available since 2.15
complex_matrix
to_matrix
(complex_vector v, int m, int n)
Convert a vector v
to a matrix with m
rows and n
columns filled in
column-major order.
Available since 2.30
matrix
to_matrix
(row_vector v, int m, int n)
Convert a row_vector v
to a matrix with m
rows and n
columns filled in
column-major order.
Available since 2.15
complex_matrix
to_matrix
(complex_row_vector v, int m, int n)
Convert a row vector v
to a matrix with m
rows and n
columns filled in
column-major order.
Available since 2.30
matrix
to_matrix
(matrix A, int m, int n, int col_major)
Convert a matrix A
to a matrix with m
rows and n
columns filled in
row-major order if col_major
equals 0 (otherwise, they get filled in
column-major order).
Available since 2.15
complex_matrix
to_matrix
(complex_matrix A, int m, int n, int col_major)
Convert a matrix A
to a matrix with m
rows and n
columns filled in
row-major order if col_major
equals 0 (otherwise, they get filled in
column-major order).
Available since 2.30
matrix
to_matrix
(vector v, int m, int n, int col_major)
Convert a vector v
to a matrix with m
rows and n
columns filled in
row-major order if col_major
equals 0 (otherwise, they get filled in
column-major order).
Available since 2.15
complex_matrix
to_matrix
(complex_vector v, int m, int n, int col_major)
Convert a vector v
to a matrix with m
rows and n
columns filled in
row-major order if col_major
equals 0 (otherwise, they get filled in
column-major order).
Available since 2.30
matrix
to_matrix
(row_vector v, int m, int n, int col_major)
Convert a row vector v
to a matrix with m
rows and n
columns filled in
row-major order if col_major
equals 0 (otherwise, they get filled in
column-major order).
Available since 2.15
complex_matrix
to_matrix
(complex_row_vector v, int m, int n, int col_major)
Convert a row vector v
to a matrix with m
rows and n
columns filled in
row-major order if col_major
equals 0 (otherwise, they get filled in
column-major order).
Available since 2.30
matrix
to_matrix
(array[] real a, int m, int n)
Convert a one-dimensional array a
to a matrix with m
rows and n
columns filled in column-major order.
Available since 2.15
matrix
to_matrix
(array[] int a, int m, int n)
Convert a one-dimensional array a
to a matrix with m
rows and n
columns filled in column-major order.
Available since 2.15
complex_matrix
to_matrix
(array[] complex a, int m, int n)
Convert a one-dimensional array a
to a matrix with m
rows and n
columns filled in column-major order.
Available since 2.30
matrix
to_matrix
(array[] real a, int m, int n, int col_major)
Convert a one-dimensional array a
to a matrix with m
rows and n
columns filled in row-major order if col_major
equals 0 (otherwise,
they get filled in column-major order).
Available since 2.15
matrix
to_matrix
(array[] int a, int m, int n, int col_major)
Convert a one-dimensional array a
to a matrix with m
rows and n
columns filled in row-major order if col_major
equals 0 (otherwise,
they get filled in column-major order).
Available since 2.15
complex_matrix
to_matrix
(array[] complex a, int m, int n, int col_major)
Convert a one-dimensional array a
to a matrix with m
rows and n
columns filled in row-major order if col_major
equals 0 (otherwise,
they get filled in column-major order).
Available since 2.30
matrix
to_matrix
(array[] row_vector vs)
Convert a one-dimensional array of row vectors to a matrix, where the size of
the array is the number of rows of the resulting matrix and the length of row
vectors is the number of columns.
Available since 2.28
complex_matrix
to_matrix
(array[] complex_row_vector vs)
Convert a one-dimensional array of row vectors to a matrix, where the size of
the array is the number of rows of the resulting matrix and the length of row
vectors is the number of columns.
Available since 2.30
matrix
to_matrix
(array[,] real a)
Convert the two dimensional array a
to a matrix with the same
dimensions and indexing order.
Available since 2.3
matrix
to_matrix
(array[,] int a)
Convert the two dimensional array a
to a matrix with the same
dimensions and indexing order. If any of the dimensions of a
are zero,
the result will be a \(0 \times 0\) matrix.
Available since 2.3
complex_matrix
to_matrix
(array[,] complex a )
Convert the two dimensional array a
to a matrix with the same
dimensions and indexing order.
Available since 2.30
vector
to_vector
(matrix m)
Convert the matrix m
to a column vector in column-major order.
Available since 2.0
complex_vector
to_vector
(complex_matrix m)
Convert the matrix m
to a column vector in column-major order.
Available since 2.30
vector
to_vector
(vector v)
Return the column vector v
itself.
Available since 2.3
complex_vector
to_vector
(complex_vector v)
Return the column vector v
itself.
Available since 2.30
vector
to_vector
(row_vector v)
Convert the row vector v
to a column vector.
Available since 2.3
complex_vector
to_vector
(complex_row_vector v)
Convert the row vector v
to a column vector.
Available since 2.30
vector
to_vector
(array[] real a)
Convert the one-dimensional array a
to a column vector.
Available since 2.3
vector
to_vector
(array[] int a)
Convert the one-dimensional integer array a
to a column vector.
Available since 2.3
complex_vector
to_vector
(array[] complex a)
Convert the one-dimensional complex array a
to a column vector.
Available since 2.30
row_vector
to_row_vector
(matrix m)
Convert the matrix m
to a row vector in column-major order.
Available since 2.3
complex_row_vector
to_row_vector
(complex_matrix m)
Convert the matrix m
to a row vector in column-major order.
Available since 2.30
row_vector
to_row_vector
(vector v)
Convert the column vector v
to a row vector.
Available since 2.3
complex_row_vector
to_row_vector
(complex_vector v)
Convert the column vector v
to a row vector.
Available since 2.30
row_vector
to_row_vector
(row_vector v)
Return the row vector v
itself.
Available since 2.3
complex_row_vector
to_row_vector
(complex_row_vector v)
Return the row vector v
itself.
Available since 2.30
row_vector
to_row_vector
(array[] real a)
Convert the one-dimensional array a
to a row vector.
Available since 2.3
row_vector
to_row_vector
(array[] int a)
Convert the one-dimensional array a
to a row vector.
Available since 2.3
complex_row_vector
to_row_vector
(array[] complex a)
Convert the one-dimensional complex array a
to a row vector.
Available since 2.30
array[,] real
to_array_2d
(matrix m)
Convert the matrix m
to a two dimensional array with the same
dimensions and indexing order.
Available since 2.3
array[,] complex
to_array_2d
(complex_matrix m)
Convert the matrix m
to a two dimensional array with the same
dimensions and indexing order.
Available since 2.30
array[] real
to_array_1d
(vector v)
Convert the column vector v
to a one-dimensional array.
Available since 2.3
array[] complex
to_array_1d
(complex_vector v)
Convert the column vector v
to a one-dimensional array.
Available since 2.30
array[] real
to_array_1d
(row_vector v)
Convert the row vector v
to a one-dimensional array.
Available since 2.3
array[] complex
to_array_1d
(complex_row_vector v)
Convert the row vector v
to a one-dimensional array.
Available since 2.30
array[] real
to_array_1d
(matrix m)
Convert the matrix m
to a one-dimensional array in column-major order.
Available since 2.3
array[] real
to_array_1d
(complex_matrix m)
Convert the matrix m
to a one-dimensional array in column-major order.
Available since 2.30
array[] real
to_array_1d
(array[...] real a)
Convert the array a
(of any dimension up to 10) to a one-dimensional
array in row-major order.
Available since 2.3
array[] int
to_array_1d
(array[...] int a)
Convert the array a
(of any dimension up to 10) to a one-dimensional
array in row-major order.
Available since 2.3
array[] complex
to_array_1d
(array[...] complex a)
Convert the array a
(of any dimension up to 10) to a one-dimensional
array in row-major order.
Available since 2.30