38 #include <visp3/core/vpConfig.h>
40 #ifndef DOXYGEN_SHOULD_SKIP_THIS
42 #include <visp3/core/vpMatrix.h>
43 #include <visp3/core/vpMath.h>
44 #include <visp3/core/vpColVector.h>
47 #include <visp3/core/vpException.h>
48 #include <visp3/core/vpMatrixException.h>
51 #include <visp3/core/vpDebug.h>
82 vpMatrix::LUDcmp(
unsigned int *perm,
int& d)
86 unsigned int i,imax=0,j,k;
87 double big,dum,sum_,temp;
94 if ((temp=fabs(
rowPtrs[i][j])) > big) big=temp;
96 if (std::fabs(big) <= std::numeric_limits<double>::epsilon())
100 "Singular vpMatrix in LUDcmp")) ;
116 if ( (dum=vv[i]*fabs(sum_)) >= big) {
132 if (std::fabs(
rowPtrs[j][j]) <= std::numeric_limits<double>::epsilon())
136 for (i=j+1;i<n;i++)
rowPtrs[i][j] *= dum;
162 void vpMatrix::LUBksb(
unsigned int *perm,
vpColVector& b)
172 unsigned int ip=perm[i];
176 for (
unsigned int j=ii;j<=i-1;j++) sum_ -=
rowPtrs[i][j]*b[j];
179 else if (std::fabs(sum_) > std::numeric_limits<double>::epsilon()) {
195 for (
unsigned int j=i+1;j<n;j++) sum_ -=
rowPtrs[i][j]*b[j];
199 #endif // doxygen should skip this
239 "Cannot invert a non-square vpMatrix")) ;
246 for (i=0; i<
rowNum; i++) {
247 for (j=0; j<
rowNum; j++) {
248 B[i][j] = (i == j) ? 1 : 0;
255 unsigned int *perm =
new unsigned int[
rowNum];
269 c_tmp =0 ; c_tmp[j-1] = 1 ;
270 A.LUBksb(perm, c_tmp);
271 for (
unsigned int k=0 ; k < c_tmp.
getRows() ; k++)
272 B[k][j-1] = c_tmp[k] ;
Implementation of a matrix and operations on matrices.
error that can be emited by ViSP classes.
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.
Implementation of column vector and the associated operations.
vpMatrix inverseByLU() const
error that can be emited by the vpMatrix class and its derivates
double ** rowPtrs
Address of the first element of each rows.