1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-11-14 01:45:35 +00:00

pseudoinverse example

This commit is contained in:
Antonin Portelli 2016-02-29 19:49:06 +00:00
parent 7dff22cdcf
commit e90d620096

View File

@ -8,7 +8,7 @@ using namespace Latan;
int main(void) int main(void)
{ {
DMat A(2, 3), B(3, 2); DMat A(2, 3), B(3, 2), C = DMat::Random(6, 6);
const string fileName = "exMat.h5"; const string fileName = "exMat.h5";
A << 1, 2, 3, A << 1, 2, 3,
@ -19,17 +19,20 @@ int main(void)
1.2, 3.5; 1.2, 3.5;
// read // read
cout << "A=\n" << A << '\n' << endl; cout << "A=\n" << A << '\n' << endl;
cout << "B=\n" << B << '\n' << endl; cout << "B=\n" << B << '\n' << endl;
cout << "A*B=\n" << A*B << '\n' << endl; cout << "A*B=\n" << A*B << '\n' << endl;
cout << "cos(A)=\n" << A.unaryExpr(StdMath::cos) << '\n' << endl; cout << "cos(A)=\n" << A.unaryExpr(StdMath::cos) << '\n' << endl;
cout << "C=\n" << C << '\n' << endl;
cout << "inv(C)=\n" << C.inverse() << '\n' << endl;
cout << "pinv(C)=\n" << C.pInverse() << '\n' << endl;
// write // write
cout << "-- saving and loading A*B using '" + fileName + "'..." << endl; cout << "-- saving and loading A*B using '" + fileName + "'..." << endl;
Io::save(A*B, fileName, File::Mode::write); Io::save(A*B, fileName, File::Mode::write);
DMat C = Io::load<DMat>(fileName); DMat D = Io::load<DMat>(fileName);
cout << C << endl; cout << D << endl;
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }