40 #include <visp3/core/vpConfig.h> 42 #include <visp3/core/vpColVector.h> 43 #include <visp3/core/vpMath.h> 44 #include <visp3/core/vpMatrix.h> 47 #include <visp3/core/vpException.h> 48 #include <visp3/core/vpMatrixException.h> 51 #include <visp3/core/vpDebug.h> 53 #ifndef DOXYGEN_SHOULD_SKIP_THIS 54 #ifdef VISP_HAVE_LAPACK 55 #ifdef VISP_HAVE_LAPACK_BUILT_IN 56 typedef long int integer;
61 extern "C" int dgeqrf_(integer *m, integer *n,
double *a, integer *lda,
double *tau,
double *work, integer *lwork,
63 extern "C" int dormqr_(
char *side,
char *trans, integer *m, integer *n, integer *k,
double *a, integer *lda,
64 double *tau,
double *c__, integer *ldc,
double *work, integer *lwork, integer *info);
65 extern "C" int dorgqr_(integer *, integer *, integer *,
double *, integer *,
double *,
double *, integer *, integer *);
66 extern "C" int dtrtri_(
char *uplo,
char *diag, integer *n,
double *a, integer *lda, integer *info);
68 int allocate_work(
double **work);
70 int allocate_work(
double **work)
72 unsigned int dimWork = (
unsigned int)((*work)[0]);
74 *work =
new double[dimWork];
79 #ifdef VISP_HAVE_LAPACK 109 vpMatrix vpMatrix::inverseByQRLapack()
const 116 integer rowNum_ = (integer)this->
getRows();
117 integer colNum_ = (integer)this->
getCols();
118 integer lda = (integer)rowNum_;
119 integer dimTau = (std::min)(rowNum_, colNum_);
120 integer dimWork = -1;
121 double *tau =
new double[dimTau];
122 double *work =
new double[1];
149 std::cout <<
"dgeqrf_:Preparation:" << -info <<
"th element had an illegal value" << std::endl;
152 dimWork = allocate_work(&work);
174 std::cout <<
"dgeqrf_:" << -info <<
"th element had an illegal value" << std::endl;
183 dtrtri_((
char *)
"U", (
char *)
"N", &dimTau, C.
data, &lda, &info);
186 std::cout <<
"dtrtri_:" << -info <<
"th element had an illegal value" << std::endl;
188 std::cout <<
"dtrtri_:R(" << info <<
"," << info <<
")" 189 <<
" is exactly zero. The triangular matrix is singular " 190 "and its inverse can not be computed." 192 std::cout <<
"R=" << std::endl << C << std::endl;
201 for (
unsigned int i = 0; i < C.
getRows(); i++)
202 for (
unsigned int j = 0; j < C.
getRows(); j++)
213 dormqr_((
char *)
"R", (
char *)
"T", &rowNum_, &colNum_, &dimTau, A.
data, &lda, tau, C.
data, &ldc, work, &dimWork,
216 std::cout <<
"dormqr_:Preparation" << -info <<
"th element had an illegal value" << std::endl;
219 dimWork = allocate_work(&work);
221 dormqr_((
char *)
"R", (
char *)
"T", &rowNum_, &colNum_, &dimTau, A.
data, &lda, tau, C.
data, &ldc, work, &dimWork,
225 std::cout <<
"dormqr_:" << -info <<
"th element had an illegal value" << std::endl;
239 #endif // #ifndef DOXYGEN_SHOULD_SKIP_THIS 273 #ifdef VISP_HAVE_LAPACK 274 return inverseByQRLapack();
Implementation of a matrix and operations on matrices.
vpMatrix inverseByQR() const
error that can be emited by ViSP classes.
unsigned int getRows() const
Type * data
Address of the first element of the data array.
unsigned int getCols() const
unsigned int rowNum
Number of rows in the array.
unsigned int colNum
Number of columns in the array.
error that can be emited by the vpMatrix class and its derivates