You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
59 lines
1.4 KiB
59 lines
1.4 KiB
#include "matrix.hpp"
|
|
|
|
int main() {
|
|
vector a = vector(2);
|
|
a[0] = cnumber(7, 0);
|
|
a[1] = cnumber(6, 1);
|
|
|
|
vector b = vector(2);
|
|
b[0] = cnumber(5, 0);
|
|
b[1] = cnumber(3, 0);
|
|
|
|
vector c = vector(2);
|
|
c[0] = cnumber(2, 0);
|
|
c[1] = cnumber(1, 1);
|
|
|
|
|
|
vector d = vector(2);
|
|
d[0] = cnumber(1, -1);
|
|
d[1] = cnumber(5, 0);
|
|
|
|
matrix m = matrix(2, 2);
|
|
m[0] = a;
|
|
m[1] = b;
|
|
|
|
matrix n = matrix(2, 2);
|
|
n[0] = c;
|
|
n[1] = d;
|
|
|
|
cout << "The matrix m:" << endl;
|
|
cout << m << endl;
|
|
cout << "The matrix m roted by one pi radian:" << endl;
|
|
cout << m.rotate_by_one_pi() << endl;
|
|
cout << "The determinant of matrix m:" << endl;
|
|
cout << m.determinant() << endl;
|
|
cout << "The matrix m's transpose:" << endl;
|
|
cout << m.transpose() << endl;
|
|
cout << "The matrix m's diagonal:" << endl;
|
|
cout << m.get_diagonal() << endl;
|
|
cout << "The matrix m's off diagonal:" << endl;
|
|
cout << m.get_off_diagonal() << endl;
|
|
cout << "The matrix n" << endl;
|
|
cout << n << endl;
|
|
cout << "The determinant of matrix n:" << endl;
|
|
cout << n.determinant() << endl;
|
|
cout << "The matrix m * n" << endl;
|
|
cout << m * n << endl;
|
|
if (!m.is_hermitian()) {
|
|
cout << "The matrix m is not hermitian, here is the hermitian conjugate:"
|
|
<< endl;
|
|
cout << m.hermitian_conjugate() << endl;
|
|
}
|
|
if (n.is_hermitian()) {
|
|
cout << "The matrix n is hermitian, here is the hermitian conjugate:"
|
|
<< endl;
|
|
cout << n.hermitian_conjugate() << endl;
|
|
}
|
|
return 0;
|
|
}
|