42 #include <visp/vpConfig.h>
44 #include <visp/vpMatrix.h>
45 #include <visp/vpMath.h>
46 #include <visp/vpColVector.h>
49 #include <visp/vpException.h>
50 #include <visp/vpMatrixException.h>
53 #include <visp/vpDebug.h>
56 #ifdef VISP_HAVE_LAPACK
57 extern "C" int dgeqrf_(
int *m,
int *n,
double*a,
int *lda,
double *tau,
double *work,
int *lwork,
int *info);
58 extern "C" int dormqr_(
char *side,
char *trans,
int *m,
int *n,
59 int *k,
double *a,
int *lda,
double *tau,
double *c__,
60 int *ldc,
double *work,
int *lwork,
int *info);
61 extern "C" int dorgqr_(
int *,
int *,
int *,
double *,
int *,
62 double *,
double *,
int *,
int *);
63 extern "C" int dtrtri_(
char *uplo,
char *diag,
int *n,
double *a,
int *lda,
int *info);
66 int allocate_work(
double** work){
67 int dimWork = (int)((*work)[0]);
69 *work =
new double[dimWork];
72 #ifdef VISP_HAVE_LAPACK
76 int lda = (int)rowNum;
77 int dimTau = std::min(rowNum,colNum);
79 double *tau =
new double[dimTau];
80 double *work =
new double[1];
107 std::cout <<
"dgeqrf_:Preparation:" << -info <<
"th element had an illegal value" << std::endl;
110 dimWork = allocate_work(&work);
133 std::cout <<
"dgeqrf_:" << -info <<
"th element had an illegal value" << std::endl;
141 dtrtri_((
char*)
"U",(
char*)
"N",&dimTau,C.
data,&lda,&info);
144 std::cout <<
"dtrtri_:"<< -info <<
"th element had an illegal value" << std::endl;
146 std::cout <<
"dtrtri_:R("<< info <<
"," <<info <<
")"<<
" is exactly zero. The triangular matrix is singular and its inverse can not be computed." << std::endl;
147 std::cout <<
"R=" << std::endl << C << std::endl;
155 for(
unsigned int i=0;i<C.
getRows();i++)
156 for(
unsigned int j=0;j<C.
getRows();j++)
157 if(j>i) C[i][j] = 0.;
167 dormqr_((
char*)
"R", (
char*)
"T", &rowNum, &colNum, &dimTau, A.
data, &lda, tau, C.
data, &ldc, work, &dimWork, &info);
169 std::cout <<
"dormqr_:Preparation"<< -info <<
"th element had an illegal value" << std::endl;
172 dimWork = allocate_work(&work);
174 dormqr_((
char*)
"R", (
char*)
"T", &rowNum, &colNum, &dimTau, A.
data, &lda, tau, C.
data, &ldc, work, &dimWork, &info);
177 std::cout <<
"dormqr_:"<< -info <<
"th element had an illegal value" << std::endl;
224 #if defined(VISP_HAVE_LAPACK)
233 "Cannot invert a non-square vpMatrix")) ;
235 #ifdef VISP_HAVE_LAPACK
Definition of the vpMatrix class.
double * data
address of the first element of the data array
vpMatrix inverseByQR() const
unsigned int rowNum
number of rows
unsigned int getCols() const
Return the number of columns of the matrix.
error that can be emited by the vpMatrix class and its derivates
unsigned int colNum
number of columns
unsigned int getRows() const
Return the number of rows of the matrix.
vpMatrix inverseByQRLapack() const