#include #include #include "matrix.h" using namespace p4840; using namespace std; template void print_matrix(Matrix m) { for(int i = 0; i < m.rows(); i++) { for(int j = 0; j < m.cols(); j++) { cout << i << " " << j << " " << m(i,j) << endl; } } } int main() { Matrix m1(2,2); Matrix m2(2,2); cout << "CHECK ASSIGNMENT m1 = v \n"; m1 = 3.; print_matrix(m1); cout << "CHECK ASSIGNMENT m1(i,j) = v \n"; m1(0,0) = 1.; m1(1,1) = 1.; m1(0,1) = 0.5; m1(1,0) = 0.5; print_matrix(m1); for(int j = 0; j < 4; j++) { cout << j << " " << m1[j] << endl; } cout << "CHECK COPY m2 = m1 \n"; m2 = m1; print_matrix(m2); cout << "CHECK ADDITION m2 += m1 \n"; m2 += m1; print_matrix(m2); cout << "CHECK ADDITION m1 = m2 + m2\n"; m1 = m2+m2; print_matrix(m1); cout << "CHECK PRODUCT m2 *= 2\n"; m2 *= 2; print_matrix(m2); cout << "SHOW INTEGER MATRIX\n"; Matrix m3(2,2); m3 = 5.2; print_matrix(m3); cout << "SHOW COMPLEX MATRIX\n"; Matrix > m4(2,2); for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) m4(i,j) = complex(i,j); print_matrix(m4); }