00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <iostream>
00023 #include <cmath>
00024 #include <iomanip>
00025
00026 #include "linalg/matrix.h"
00027 #include "linalg/vector.h"
00028 #include "linalg/lawrap.h"
00029
00030 using namespace std;
00031 using namespace LinAlg;
00032
00033 int main()
00034 {
00035 Matrix<REAL> A(4,4,"5 2 3 1 2 8 1 1 3 1 8 5 1 1 5 10");
00036 Vector<REAL> v(4);
00037 Matrix<REAL> * P = new Matrix<REAL> [4];
00038 for (int i=0; i<4; ++i) P[i].Set(4,4);
00039
00040 cout << "A = \n" << A << endl;
00041
00042 Syep(A,v,P);
00043 for (int i=0; i<4; ++i)
00044 cout << "P[" << i << "] =\n" << P[i] << endl;
00045
00046 Matrix<REAL> Check(4,4);
00047 for (int i=0; i<4; ++i)
00048 for (int j=0; j<4; ++j)
00049 for (int k=0; k<4; ++k)
00050 Check(i,j) = Check(i,j) + v(k)*P[k](i,j);
00051 cout << "v0*P0 + v1*P1 + v2*P2 + v3*P3 =\n" << Check << endl;
00052
00053 for (int i=0; i<4; ++i)
00054 {
00055 double trace=0.0;
00056 for (int j=0; j<4; ++j)
00057 trace += P[i](j,j);
00058 cout << "trace(P[" << i << "]) = " << trace << endl;
00059 }
00060
00061 delete [] P;
00062
00063 return 0;
00064 }