complex matrix

hello,

i want to initialize a 2x2 matrix with complex numbers but i don't know how i can !
thanks in advance

What exactly is the problem?
To create 2x2 matrix?
Or to create a complex number?
i created 4 complex numbers, but i want to fill them in a matrix 2x2
1
2
using namespace std::complex_literals;
std::complex<double> matrix[2][2] = {{1.0 + 0i, 0.0 + 1i}, {-1.0 + 0i, 0.0 - 1i}};
http://ideone.com/dnjvbk
and if i want to calculate this matrix power N ?
So, calculate it. As per definition An = A·A·A·...·A n times.
https://en.wikipedia.org/wiki/Matrix_multiplication#Matrix_product_.28two_matrices.29
i know how to calculate a matrix product but when i put for example M[2][2]*N[2][2], he tell me that i can't use the operator "*" between matrices.
Of course you cannot. There is no type "Matrix" in C++. You need to make calculations yourself by definition of matrix multilication: ABij = Σ(k=1 → m)AikBkj

Edit: example — http://ideone.com/FcSvhf
http://puu.sh/iC5c1/7209b24f3c.png
Last edited on
hello;
I did the product of two matrix 2x2 but i don't know how i can calculate a matrix power N. Do u have any idea about this problem ?

Thank you
I made an example how to do that. Just continue to multiply resulting matrix by original. N times.
Topic archived. No new replies allowed.