39 #include <visp3/core/vpConfig.h>
41 #include <visp3/core/vpColVector.h>
42 #include <visp3/core/vpMath.h>
43 #include <visp3/core/vpMatrix.h>
46 #include <visp3/core/vpException.h>
47 #include <visp3/core/vpMatrixException.h>
50 #include <visp3/core/vpDebug.h>
52 #if defined(VISP_HAVE_OPENCV)
53 #include <opencv2/core/core.hpp>
56 #ifdef VISP_HAVE_LAPACK
58 #include <gsl/gsl_linalg.h>
62 typedef MKL_INT integer;
63 #elif !defined(VISP_HAVE_GSL)
64 #ifdef VISP_HAVE_LAPACK_BUILT_IN
65 typedef long int integer;
69 extern "C" void dpotrf_(
char *uplo, integer *n,
double *a, integer *lda, integer *info);
70 extern "C" int dpotri_(
char *uplo, integer *n,
double *a, integer *lda, integer *info);
114 #if defined(VISP_HAVE_LAPACK)
116 #elif defined(VISP_HAVE_OPENCV)
120 "Cholesky. Install Lapack or "
121 "OpenCV 3rd party"));
125 #if defined(VISP_HAVE_LAPACK)
164 #if defined(VISP_HAVE_GSL)
171 cholesky.tda = cholesky.size2;
172 cholesky.data = invA.
data;
176 #if (GSL_MAJOR_VERSION >= 2 && GSL_MINOR_VERSION >= 3)
177 gsl_linalg_cholesky_decomp1(&cholesky);
179 gsl_linalg_cholesky_decomp(&cholesky);
181 gsl_linalg_cholesky_invert(&cholesky);
191 integer rowNum_ = (integer)this->
getRows();
192 integer lda = (integer)rowNum_;
196 dpotrf_((
char *)
"L", &rowNum_, A.
data, &lda, &info);
201 dpotri_((
char *)
"L", &rowNum_, A.
data, &lda, &info);
203 std::cout <<
"cholesky:dpotri_:error" << std::endl;
207 for (
unsigned int i = 0; i < A.
getRows(); i++)
208 for (
unsigned int j = 0; j < A.
getCols(); j++)
218 #if defined(VISP_HAVE_OPENCV)
263 cv::Mat Minv = M.inv(cv::DECOMP_CHOLESKY);
266 memcpy(A.
data, Minv.data, (
size_t)(8 * Minv.rows * Minv.cols));
unsigned int getCols() const
Type * data
Address of the first element of the data array.
unsigned int rowNum
Number of rows in the array.
unsigned int getRows() const
unsigned int colNum
Number of columns in the array.
error that can be emitted by ViSP classes.
@ badValue
Used to indicate that a value is not in the allowed range.
error that can be emitted by the vpMatrix class and its derivatives
@ matrixError
Matrix operation error.
Implementation of a matrix and operations on matrices.
vpMatrix inverseByCholeskyLapack() const
vpMatrix inverseByCholesky() const
vpMatrix inverseByCholeskyOpenCV() const