58extern "C" int dgetrf_(integer *m, integer *n,
double *a, integer *lda, integer *ipiv, integer *info);
59extern "C" void dgetri_(integer *n,
double *a, integer *lda, integer *ipiv,
double *work, integer *lwork,
132 const unsigned int val_2 = 2;
133 const unsigned int val_3 = 3;
138 if (std::fabs(d) < std::numeric_limits<double>::epsilon()) {
147 inv.
resize(val_2, val_2,
false);
149 if (std::fabs(d) < std::numeric_limits<double>::epsilon()) {
154 inv[1][1] = (*this)[0][0] * d;
155 inv[0][0] = (*this)[1][1] * d;
156 inv[0][1] = -(*this)[0][1] * d;
157 inv[1][0] = -(*this)[1][0] * d;
162 inv.
resize(val_3, val_3,
false);
164 if (std::fabs(d) < std::numeric_limits<double>::epsilon()) {
169 const unsigned int index_0 = 0;
170 const unsigned int index_1 = 1;
171 const unsigned int index_2 = 2;
172 inv[index_0][index_0] = (((*this)[index_1][index_1] * (*this)[index_2][index_2]) - ((*this)[index_1][index_2] * (*this)[index_2][index_1])) * d;
173 inv[index_0][index_1] = (((*this)[index_0][index_2] * (*this)[index_2][index_1]) - ((*this)[index_0][index_1] * (*this)[index_2][index_2])) * d;
174 inv[index_0][index_2] = (((*this)[index_0][index_1] * (*this)[index_1][index_2]) - ((*this)[index_0][index_2] * (*this)[index_1][index_1])) * d;
176 inv[index_1][index_0] = (((*this)[index_1][index_2] * (*this)[index_2][index_0]) - ((*this)[index_1][index_0] * (*this)[index_2][index_2])) * d;
177 inv[index_1][index_1] = (((*this)[index_0][index_0] * (*this)[index_2][index_2]) - ((*this)[index_0][index_2] * (*this)[index_2][index_0])) * d;
178 inv[index_1][index_2] = (((*this)[index_0][index_2] * (*this)[index_1][index_0]) - ((*this)[index_0][index_0] * (*this)[index_1][index_2])) * d;
180 inv[index_2][index_0] = (((*this)[index_1][index_0] * (*this)[index_2][index_1]) - ((*this)[index_1][index_1] * (*this)[index_2][index_0])) * d;
181 inv[index_2][index_1] = (((*this)[index_0][index_1] * (*this)[index_2][index_0]) - ((*this)[index_0][index_0] * (*this)[index_2][index_1])) * d;
182 inv[index_2][index_2] = (((*this)[index_0][index_0] * (*this)[index_1][index_1]) - ((*this)[index_0][index_1] * (*this)[index_1][index_0])) * d;
186#if defined(VISP_HAVE_LAPACK)
188#elif defined(VISP_HAVE_EIGEN3)
190#elif defined(VISP_HAVE_OPENCV)
194 "Install Lapack, Eigen3 or OpenCV 3rd party"));
238 const unsigned int val_2 = 2;
239 const unsigned int val_3 = 3;
241 return (*
this)[0][0];
244 return (((*
this)[0][0] * (*
this)[1][1]) - ((*
this)[0][1] * (*
this)[1][0]));
247 const unsigned int index_0 = 0;
248 const unsigned int index_1 = 1;
249 const unsigned int index_2 = 2;
250 return ((((*
this)[index_0][index_0] * (((*
this)[index_1][index_1] * (*
this)[index_2][index_2]) - ((*
this)[index_1][index_2] * (*
this)[index_2][index_1]))) -
251 ((*
this)[index_0][index_1] * (((*
this)[index_1][index_0] * (*
this)[index_2][index_2]) - ((*
this)[index_1][index_2] * (*
this)[index_2][index_0])))) +
252 ((*
this)[index_0][index_2] * (((*
this)[index_1][index_0] * (*
this)[index_2][index_1]) - ((*
this)[index_1][index_1] * (*
this)[index_2][index_0]))));
255#if defined(VISP_HAVE_LAPACK)
257#elif defined(VISP_HAVE_EIGEN3)
259#elif defined(VISP_HAVE_OPENCV)
263 "Install Lapack, Eigen3 or OpenCV 3rd party"));
305#if defined(VISP_HAVE_GSL)
314 unsigned int tda =
static_cast<unsigned int>(A->tda);
315 for (
unsigned int i = 0; i <
rowNum; ++i) {
316 unsigned int k = i * tda;
317 for (
unsigned int j = 0; j <
colNum; ++j)
318 A->data[k + j] = (*
this)[i][j];
326 inverse.tda = inverse.size2;
327 inverse.data = Ainv.
data;
331 gsl_permutation *p = gsl_permutation_alloc(
rowNum);
335 gsl_linalg_LU_decomp(A, p, &s);
336 gsl_linalg_LU_invert(A, p, &inverse);
338 gsl_permutation_free(p);
349 integer dim = (integer)
rowNum;
352 integer lwork = dim * dim;
353 integer *ipiv =
new integer[dim + 1];
354 double *work =
new double[lwork];
358 dgetrf_(&dim, &dim, A.
data, &lda, &ipiv[1], &info);
365 dgetri_(&dim, A.
data, &dim, &ipiv[1], work, &lwork, &info);
406#if defined(VISP_HAVE_GSL)
418 unsigned int tda =
static_cast<unsigned int>(A->tda);
419 for (
unsigned int i = 0; i <
rowNum; i++) {
420 unsigned int k = i * tda;
421 for (
unsigned int j = 0; j <
colNum; j++)
422 A->data[k + j] = (*
this)[i][j];
425 gsl_permutation *p = gsl_permutation_alloc(
rowNum);
429 gsl_linalg_LU_decomp(A, p, &s);
430 det = gsl_linalg_LU_det(A, s);
432 gsl_permutation_free(p);
444 integer dim = (integer)
rowNum;
447 integer *ipiv =
new integer[dim + 1];
451 dgetrf_(&dim, &dim, A.
data, &lda, &ipiv[1], &info);
457 double det = A[0][0];
458 for (
unsigned int i = 1; i <
rowNum; ++i) {
463 for (
int i = 1; i <= dim; ++i) {