Go to the documentation of this file.
17 #include <Eigen/Dense>
25 #include <mrpt/examples_config.h>
26 string myDataDir(MRPT_EXAMPLES_BASE_DIRECTORY +
string(
"math_matrix_example/"));
34 A.loadFromTextFile(
myDataDir +
string(
"in_for_cholesky.txt"));
37 cout <<
"Cholesky decomposition result:" << endl << B;
43 const double numbers[] = {1, 2, 3, 4, 5, 6};
45 cout <<
"Initialized matrix (I): " << endl << M << endl;
47 const double numbers2[] = {0.5, 4.5, 6.7, 8.9, 15.2};
50 cout <<
"Initialized double vector: " << v1 << endl;
54 cout <<
"Initialized int vector: " << v2 << endl;
70 cout <<
"reading H.txt...";
74 cout <<
"reading C.txt...";
80 cout <<
"Saving RES.txt ...";
87 cout <<
"Should be= 31.434 " << endl;
91 cout <<
"Loaded H: " << endl << H;
93 cout <<
"Should be= 31.434" << endl;
106 std::vector<double> eigenValues;
107 M.
eig(eigenVectors, eigenValues);
108 cout <<
"eigenVectors:\n"
109 << eigenVectors <<
"\n Eigenvalues:\n"
117 cout <<
"RES:\n" << RES;
144 cout <<
"Matrix:\n" << m << endl;
151 cout <<
"Read (text file) in " << 1e6 * t <<
"us:\n" << l << endl;
154 cout <<
"Laplacian:\n" << l << endl;
160 const double numbers[] = {1, 2, 3, 10, 4, 5, 6, 14, 10, -5, -3, 1};
164 vector<CVectorDouble> samples(4);
165 for (
size_t i = 0; i < 4; i++)
167 samples[i].resize(3);
168 for (
size_t j = 0; j < 3; j++) samples[i][j] = Mdyn(i, j);
171 cout <<
"COV (vector of vectors): " << endl
172 << mrpt::math::covVector<vector<CVectorDouble>, Eigen::MatrixXd>(
197 cout <<
"MRPT exception caught: " << e.what() << endl;
202 printf(
"Untyped exception!!");
CMatrixDouble cov(const MATRIX &v)
Computes the covariance matrix from a list of samples in an NxM matrix, where each row is a sample,...
A high-performance stopwatch, with typical resolution of nanoseconds.
void loadFromTextFile(std::istream &f)
Loads a vector/matrix from a text file, compatible with MATLAB text format.
void setSize(size_t row, size_t col, bool zeroNewElements=false)
Changes the size of matrix, maintaining the previous contents.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
bool eig(Derived &eVecs, std::vector< Scalar > &eVals, bool sorted=true) const
Computes the eigenvectors and eigenvalues for a square, general matrix.
bool loadVector(std::istream &f, std::vector< int > &d)
Loads one row of a text file as a numerical std::vector.
double Tac() noexcept
Stops the stopwatch.
A compile-time fixed-size numeric matrix container.
void multiply_HCHt(const MAT_H &H, const MAT_C &C, MAT_R &R, bool accumResultInOutput=false)
R = H * C * H^t.
EIGEN_MAP asEigen()
Get as an Eigen-compatible Eigen::Map object
void setDiagonal(const std::size_t N, const Scalar value)
Resize to NxN, set all entries to zero, except the main diagonal which is set to value
void Tic() noexcept
Starts the stopwatch.
void saveToTextFile(const std::string &file, mrpt::math::TMatrixTextFileFormat fileFormat=mrpt::math::MATRIX_FORMAT_ENG, bool appendMRPTHeader=false, const std::string &userHeader=std::string()) const
Saves the vector/matrix to a file compatible with MATLAB/Octave text format.
void laplacian(const MATIN &g, MATOUT &ret)
Computes the Laplacian of a square graph weight matrix.
MAT_C::Scalar multiply_HCHt_scalar(const VECTOR_H &H, const MAT_C &C)
r (scalar) = H*C*H^t (H: row vector, C: symmetric matrix)
This base provides a set of functions for maths stuff.
void TestMatrixTemplate()
This template class provides the basic functionality for a general 2D any-size, resizable container o...
Page generated by Doxygen 1.8.17 for MRPT 2.0.4 at Sun Jul 19 17:54:30 UTC 2020 | |