detsymm_test.cpp
#include <iostream>
#include "Array/ArrayIo.h"
#include "LinAlg/LinAlg.h"
using namespace std;
int main()
{
Array2D< double > A(3, 3);
Array2D< double > x(3, 3);
Array < double > lambda(3);
unsigned curr_row,
curr_col;
double det(0.);
double bottom_triangle[9] =
{
7., 0., 0.,
-2., 6., 0.,
0., -2., 0.
};
for (curr_row = 0; curr_row < 3; curr_row++) {
for (curr_col = 0; curr_col < 3; curr_col++) {
A(curr_row, curr_col) = bottom_triangle[curr_row*3+curr_col];
x(curr_row, curr_col) = 0.;
}
lambda(curr_row) = 0.;
}
cout << "input matrix:" << endl;
writeArray(A, cout);
det = detsymm(A, x, lambda);
cout << "the determinate of the matrix is " << det << endl << endl;
cout << "matrix of eigenvectors:" << endl;
writeArray(x, cout);
cout << "vector of eigenvalues:" << endl;
writeArray(lambda, cout);
if(fabs(det- -28)<1.e-6) exit(EXIT_SUCCESS);
else exit(EXIT_FAILURE);
}