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)
177 for (
unsigned int j=ii;j<=i-1;j++) sum_ -=
rowPtrs[i][j]*b[j];
180 else if (std::fabs(sum_) > std::numeric_limits<double>::epsilon()) {
196 for (
unsigned int j=i+1;j<n;j++) sum_ -=
rowPtrs[i][j]*b[j];
200 #endif // doxygen should skip this
240 "Cannot invert a non-square vpMatrix")) ;
247 for (i=0; i<
rowNum; i++) {
248 for (j=0; j<
rowNum; j++) {
249 B[i][j] = (i == j) ? 1 : 0;
256 unsigned int *perm =
new unsigned int[
rowNum];
270 c_tmp =0 ; c_tmp[j-1] = 1 ;
271 A.LUBksb(perm, c_tmp);
272 for (
unsigned int k=0 ; k < c_tmp.
getRows() ; k++)
273 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.