#include #include #include #include using Vector = std::vector; using Matrix = std::vector; #ifdef DEBUG void print_matrix(Matrix); #endif Matrix concatenate_vectors(Vector p1, Vector p2, Vector p3, Vector p4) { Matrix mat; mat.push_back(p1); mat.push_back(p2); mat.push_back(p3); mat.push_back(p4); return mat; } Matrix transpose(Matrix mat) { Matrix t; // new matrix int n = mat.size(); int m = mat[0].size(); for(int i=0;i 1e-16) return false; } } return true; } Vector matrix_eigenvalues(Matrix mat) { Matrix A = mat; for(int k=0;k<1000000;k++) { Matrix basis = gram_schmidt(A); Matrix basisT = transpose(basis); Matrix t1 = matrix_multiply(A, basis); Matrix t2 = matrix_multiply(basisT, t1); if(is_upper_triangular(t2)) break; A = t2; } Vector eig; for(int i=0;i