39 #include <visp3/core/vpConfig.h>
41 #include <visp3/core/vpMatrix.h>
42 #include <visp3/core/vpMath.h>
43 #include <visp3/core/vpColVector.h>
46 #include <visp3/core/vpException.h>
47 #include <visp3/core/vpMatrixException.h>
50 #include <visp3/core/vpDebug.h>
52 int allocate_work(
double** work);
54 #ifdef VISP_HAVE_LAPACK_C
55 extern "C" int dgeqrf_(
int *m,
int *n,
double*a,
int *lda,
double *tau,
double *work,
int *lwork,
int *info);
56 extern "C" int dormqr_(
char *side,
char *trans,
int *m,
int *n,
57 int *k,
double *a,
int *lda,
double *tau,
double *c__,
58 int *ldc,
double *work,
int *lwork,
int *info);
59 extern "C" int dorgqr_(
int *,
int *,
int *,
double *,
int *,
60 double *,
double *,
int *,
int *);
61 extern "C" int dtrtri_(
char *uplo,
char *diag,
int *n,
double *a,
int *lda,
int *info);
64 int allocate_work(
double** work)
66 unsigned int dimWork = (
unsigned int)((*work)[0]);
68 *work =
new double[dimWork];
71 #ifdef VISP_HAVE_LAPACK_C
73 int rowNum_ = (int)this->
getRows();
74 int colNum_ = (int)this->
getCols();
75 int lda = (int)rowNum_;
76 int dimTau = std::min(rowNum_,colNum_);
78 double *tau =
new double[dimTau];
79 double *work =
new double[1];
106 std::cout <<
"dgeqrf_:Preparation:" << -info <<
"th element had an illegal value" << std::endl;
109 dimWork = allocate_work(&work);
132 std::cout <<
"dgeqrf_:" << -info <<
"th element had an illegal value" << std::endl;
140 dtrtri_((
char*)
"U",(
char*)
"N",&dimTau,C.
data,&lda,&info);
143 std::cout <<
"dtrtri_:"<< -info <<
"th element had an illegal value" << std::endl;
145 std::cout <<
"dtrtri_:R("<< info <<
"," <<info <<
")"<<
" is exactly zero. The triangular matrix is singular and its inverse can not be computed." << std::endl;
146 std::cout <<
"R=" << std::endl << C << std::endl;
154 for(
unsigned int i=0;i<C.
getRows();i++)
155 for(
unsigned int j=0;j<C.
getRows();j++)
156 if(j>i) C[i][j] = 0.;
165 dormqr_((
char*)
"R", (
char*)
"T", &rowNum_, &colNum_, &dimTau, A.
data, &lda, tau, C.
data, &ldc, work, &dimWork, &info);
167 std::cout <<
"dormqr_:Preparation"<< -info <<
"th element had an illegal value" << std::endl;
170 dimWork = allocate_work(&work);
172 dormqr_((
char*)
"R", (
char*)
"T", &rowNum_, &colNum_, &dimTau, A.
data, &lda, tau, C.
data, &ldc, work, &dimWork, &info);
175 std::cout <<
"dormqr_:"<< -info <<
"th element had an illegal value" << std::endl;
222 #if defined(VISP_HAVE_LAPACK_C)
231 "Cannot invert a non-square vpMatrix")) ;
233 #ifdef VISP_HAVE_LAPACK_C
Implementation of a matrix and operations on matrices.
Type * data
Address of the first element of the data array.
unsigned int getCols() const
Return the number of columns of the 2D array.
unsigned int rowNum
Number of rows in the array.
unsigned int getRows() const
Return the number of rows of the 2D array.
unsigned int colNum
Number of columns in the array.
vpMatrix inverseByQR() const
error that can be emited by the vpMatrix class and its derivates
vpMatrix inverseByQRLapack() const