Go to the documentation of this file.
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>
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>
127 auto& eigenvalues =
matrix.eigenvalues();
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>
170 SingularValuesType sing_inv = svd.singularValues();
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];
179 pinvmat.
noalias() = svd.matrixV() * sing_inv.asDiagonal() * svd.matrixU().transpose();
184 #endif // SRC_NUMERICS_INCLUDE_CORBO_NUMERICS_MATRIX_UTILITIES_H_
const EIGEN_DEVICE_FUNC SqrtReturnType sqrt() const
bool is_positive_definite(const Eigen::MatrixBase< Derived > &matrix)
Determine if a given matrix is positive definite.
bool have_equal_size(const Eigen::MatrixBase< DerivedA > &matrix1, const Eigen::MatrixBase< DerivedB > &matrix2)
Determine if two matrices exhibit equal sizes/dimensions.
NoAlias< Derived, Eigen::MatrixBase > noalias()
Map< Matrix< T, Dynamic, Dynamic, ColMajor >, 0, OuterStride<> > matrix(T *data, int rows, int cols, int stride)
double compute_condition_number_square_matrix(const Eigen::MatrixBase< Derived > &matrix)
Compute condition number of a square matrix using the Eigenvalues.
EIGEN_DEVICE_FUNC const EIGEN_STRONG_INLINE AbsReturnType abs() const
bool is_square(const Eigen::MatrixBase< Derived > &matrix)
Determine if a given matrix is square.
EIGEN_DEVICE_FUNC const Scalar & q
Two-sided Jacobi SVD decomposition of a rectangular matrix.
Standard Cholesky decomposition (LL^T) of a matrix and associated features.
double compute_condition_number(const Eigen::MatrixBase< Derived > &matrix)
Compute condition number of matrix using SVD.
void compute_pseudo_inverse(const Eigen::MatrixBase< Derived > &matrix, Eigen::MatrixBase< Derived > &pinvmat, double tolerance=1e-6)
Compute the pseudo inverse using SVD.
Base class for all dense matrices, vectors, and expressions.
control_box_rst
Author(s): Christoph Rösmann
autogenerated on Wed Mar 2 2022 00:05:56