1
0
mirror of https://github.com/aportelli/LatAnalyze.git synced 2024-09-20 05:25:37 +01:00
LatAnalyze/examples/exMat.cpp

38 lines
1.1 KiB
C++
Raw Normal View History

2015-10-01 00:13:34 +01:00
#include <LatAnalyze/Io.hpp>
2014-03-13 18:51:01 +00:00
#include <LatAnalyze/Mat.hpp>
#include <LatAnalyze/Math.hpp>
using namespace std;
using namespace Latan;
int main(void)
{
2016-02-29 19:49:06 +00:00
DMat A(2, 3), B(3, 2), C = DMat::Random(6, 6);
2015-10-01 00:13:34 +01:00
const string fileName = "exMat.h5";
2014-03-12 19:54:27 +00:00
A << 1, 2, 3,
4, 5, 6;
B << 1.0, 2.5,
4.5, 8.9,
1.2, 3.5;
// read
2016-02-29 19:49:06 +00:00
cout << "A=\n" << A << '\n' << endl;
cout << "B=\n" << B << '\n' << endl;
cout << "A*B=\n" << A*B << '\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
2015-10-01 00:13:34 +01:00
cout << "-- saving and loading A*B using '" + fileName + "'..." << endl;
2015-10-07 19:03:19 +01:00
Io::save(A*B, fileName, File::Mode::write);
2015-10-01 00:13:34 +01:00
2016-02-29 19:49:06 +00:00
DMat D = Io::load<DMat>(fileName);
cout << D << endl;
2015-10-01 00:13:34 +01:00
return EXIT_SUCCESS;
}