75#ifdef ICC_USE_EIGEN_SOLVER
79template<
typename _Matrix_Type_,
typename _Vector_Type_>
80_Vector_Type_ solve(
const _Matrix_Type_ &a,
const _Vector_Type_ y,
icFloatNumber epsilon = std::numeric_limits<icFloatNumber>::epsilon())
82 Eigen::JacobiSVD< _Matrix_Type_ > svd(a ,Eigen::ComputeThinU | Eigen::ComputeThinV);
83 icFloatNumber tolerance = epsilon * std::max(a.cols(), a.rows()) *svd.singularValues().array().abs()(0);
84 return svd.matrixV() * (svd.singularValues().array().abs() > tolerance).select(svd.singularValues().array().inverse(), 0).matrix().asDiagonal() * svd.matrixU().adjoint() * y;
88typedef Eigen::Matrix<icFloatNumber, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> MatrixXn;
89typedef Eigen::Matrix<icFloatNumber, Eigen::Dynamic, 1> VectorXn;
94 CIccEigenMatrixSolver() {}
113 if (nRows==3 && nCols==3) {
126 VectorXn y = Eigen::Map<VectorXn>((
icFloatNumber*)dYVector, nRows);
127 MatrixXn A = Eigen::Map<MatrixXn>((
icFloatNumber*)dMatrix, nRows, nCols);
131 Eigen::Map<VectorXn>(dXVector, nCols) = x;
137CIccEigenMatrixSolver g_EigenSolver;
167 if (nRows==3 && nCols==3) {
246 if (nRows == 3 && nCols == 3) {
float icFloatNumber
All floating point operations/variables in IccProfLib use the icFloatNumber data type.
IIccMatrixInverter * g_pIccMatrixInverter
Global Variable: g_pIccMatrixInverter.
IIccMatrixInverter * IccGetDefaultMatrixInverter()
Name: IccGetDefaultMatrixInverter()
CIccSimpleMatrixInverter g_SimpleInverter
void IccSetMatrixInverter(IIccMatrixInverter *pIccMatrixInverter)
Name: IccSetMatrixInverter(IIccMatrixInverter *pInverter)
IIccMatrixSolver * g_pIccMatrixSolver
Global Variable: g_pIccMatrixSolver.
IIccMatrixSolver * IccGetDefaultMatrixSolver()
Name: IccGetDefaultMatrixSolver()
CIccSimpleMatrixSolver g_SimpleSolver
void IccSetMatrixSolver(IIccMatrixSolver *pIccMatrixSolver)
Name: IccSetMatrixSolver(IIccMatrixSolver *pSolver)
bool icMatrixInvert3x3(icFloatNumber *M)
Name: icMatrixInvert3x3.
void icVectorApplyMatrix3x3(icFloatNumber *result, const icFloatNumber *m, const icFloatNumber *v)
Name: icVectorApplyMatrix3x3.
CIccSimpleMatrixInverter()
virtual bool Invert(icFloatNumber *dMatrix, icUInt16Number nRows, icUInt16Number nCols)
Member Function: Invert.
virtual bool Solve(icFloatNumber *dXVector, const icFloatNumber *dMatrix, const icFloatNumber *dYVector, icUInt16Number nRows, icUInt16Number nCols)
Member Function: Solve.
Structure: IIccMatrixInverter.
Structure: IIccMatrixSolver.
virtual bool Solve(icFloatNumber *dXVector, const icFloatNumber *dMatrix, const icFloatNumber *dYVector, icUInt16Number nRows, icUInt16Number nCols)=0
Member Function: Solve.