Go to the documentation of this file.00001
00002
00003
00016
00017 #define WANT_STREAM // include iostream and iomanipulators
00018
00019 #include "newmatap.h"
00020 #include "newmatio.h"
00021
00022 #ifdef use_namespace
00023 using namespace RBD_LIBRARIES;
00024 #endif
00025
00026
00027 int my_main()
00028 {
00029 Tracer tr("my_main ");
00030
00031 int n = 7;
00032 int i, j;
00033
00034
00035 SymmetricMatrix H(n);
00036
00037
00038 for (i = 1; i <= n; ++i) for (j = 1; j <= i; ++j)
00039 H(i, j) = 1.0 / (i + j - 1);
00040
00041
00042 cout << "SymmetricMatrix H" << endl;
00043 cout << setw(10) << setprecision(7) << H << endl;
00044
00045
00046 Matrix U; DiagonalMatrix D;
00047 eigenvalues(H, D, U);
00048 cout << "Eigenvalues of H" << endl;
00049 cout << setw(17) << setprecision(14) << D.as_column() << endl;
00050 cout << "Eigenvector matrix, U" << endl;
00051 cout << setw(10) << setprecision(7) << U << endl;
00052
00053
00054 cout << "U * U.t() (should be near identity)" << endl;
00055 cout << setw(10) << setprecision(7) << (U * U.t()) << endl;
00056
00057
00058 cout << "U * D * U.t() (should be near H)" << endl;
00059 cout << setw(10) << setprecision(7) << (U * D * U.t()) << endl;
00060
00061 return 0;
00062 }
00063
00064
00065
00066
00067 int main()
00068 {
00069 Try { return my_main(); }
00070 Catch(BaseException) { cout << BaseException::what() << "\n"; }
00071 CatchAll { cout << "\nProgram fails - exception generated\n\n"; }
00072 return 0;
00073 }
00074
00075