15.3 Complex matrices and vectors
Stan supports complex matrices, vectors, and row vectors. Variables of these types are declared with sizes in the same way as their real-based counterparts.
complex_vector[3] v;
complex_row_vector[2] rv;
complex_matrix[3, 2] m;
We can construct vectors and matrices using brackets in the same way
as for real-valued vectors and matrices. For example, given the
declaration of rv
above, we could assign it to a constructed row
vector.
2 + 3i, 1.9 - 2.3i]; rv = [
Complex matrices and vectors support all of the standard arithetmic operations including negation, addition, subtraction, and multiplication (division involves a solve, and isn’t a simple arithmetic operation for matrices). They also support transposition.
Furthermore, it is possible to convert back and forth between arrays
and matrices using the to_array
functions.