25 #ifndef SRC_NUMERICS_INCLUDE_CORBO_NUMERICS_MATRIX_UTILITIES_H_ 26 #define SRC_NUMERICS_INCLUDE_CORBO_NUMERICS_MATRIX_UTILITIES_H_ 28 #include <Eigen/Cholesky> 31 #include <type_traits> 42 template <
typename Derived>
45 return matrix.rows() == matrix.cols();
58 if (q * q != numel)
return false;
70 template <
typename DerivedA,
typename DerivedB>
73 return matrix1.rows() == matrix2.rows() && matrix1.cols() == matrix2.cols();
84 template <
typename DerivedA,
typename DerivedB,
typename... Derived>
102 template <
typename Derived>
120 template <
typename Derived>
128 auto eig_min = eigenvalues.minCoeff();
129 auto eig_max = eigenvalues.maxCoeff();
143 template <
typename Derived>
146 if (matrix.rows() == 0 || matrix.cols() == 0)
return -1.0;
150 double sigma_max = sing_vals[0];
151 double sigma_min = sing_vals[sing_vals.size() - 1];
155 return sigma_max / sigma_min;
163 template <
typename Derived>
172 for (
int i = 0; i < sing_inv.size(); ++i)
174 if (sing_inv[i] > tolerance)
175 sing_inv[i] = 1.0 / sing_inv[i];
184 #endif // SRC_NUMERICS_INCLUDE_CORBO_NUMERICS_MATRIX_UTILITIES_H_ Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
bool have_equal_size(const Eigen::MatrixBase< DerivedA > &matrix1, const Eigen::MatrixBase< DerivedB > &matrix2)
Determine if two matrices exhibit equal sizes/dimensions.
double compute_condition_number(const Eigen::MatrixBase< Derived > &matrix)
Compute condition number of matrix using SVD.
const MatrixUType & matrixU() const
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
void compute_pseudo_inverse(const Eigen::MatrixBase< Derived > &matrix, Eigen::MatrixBase< Derived > &pinvmat, double tolerance=1e-6)
Compute the pseudo inverse using SVD.
bool is_square(const Eigen::MatrixBase< Derived > &matrix)
Determine if a given matrix is square.
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const AbsReturnType abs() const
bool is_positive_definite(const Eigen::MatrixBase< Derived > &matrix)
Determine if a given matrix is positive definiteThe current implementation performs Eigen's Cholesky ...
JacobiSVD< PlainObject > jacobiSvd(unsigned int computationOptions=0) const
double compute_condition_number_square_matrix(const Eigen::MatrixBase< Derived > &matrix)
Compute condition number of a square matrix using the EigenvaluesThis method computes the eigenvalues...
Standard Cholesky decomposition (LL^T) of a matrix and associated features.
EIGEN_DEVICE_FUNC const Scalar & q
ComputationInfo info() const
Reports whether previous computation was successful.
Two-sided Jacobi SVD decomposition of a rectangular matrix.
const SingularValuesType & singularValues() const
NoAlias< Derived, Eigen::MatrixBase > noalias()
const MatrixVType & matrixV() const
EigenvaluesReturnType eigenvalues() const
Computes the eigenvalues of a matrix.
Base class for all dense matrices, vectors, and expressions.