元素累加累乘
mat.sum()
mat.prod()
平均值
mat.mean()
最值
mat.minCoeff()
mat.maxCoeff()
迹
mat.trace()
对角元素
mat.diagonal()
特征值与特征向量
EigenSolver<Matrix3d> eigen_solver(mat);
eigen_solver.pseudoEigenvalueMatrix()
eigen_solver.pseudoEigenvectors()
代码示例
#include <iostream>
#include <cstring>
#include "Eigen/Dense"
using namespace std;
using namespace Eigen;
int main()
{
Matrix2d mat;
mat << 1, 2,
3, 4;
cout << "Here is mat.sum(): " << mat.sum() << endl;
cout << "Here is mat.prod(): " << mat.prod() << endl;
cout << "Here is mat.mean(): " << mat.mean() << endl;
cout << "Here is mat.minCoeff(): " << mat.minCoeff() << endl;
cout << "Here is mat.maxCoeff(): " << mat.maxCoeff() << endl;
cout << "Here is mat.trace(): " << mat.trace() << endl;
Matrix3d mat;
mat << 1, 2, 4,
3, 4, 5,
9, 8, 7;
cout << mat.diagonal() << endl;
cout << mat.eigenvalues() << endl;
EigenSolver<Matrix3d> eigen_solver(mat);
MatrixXd eig_value = eigen_solver.pseudoEigenvalueMatrix();
cout << "matrix values = \n" << eig_value << endl;
MatrixXd eig_vector = eigen_solver.pseudoEigenvectors();
cout << "matrix vectors = \n" << eig_vector << endl;
}