42 #include <visp/vpConfig.h>
44 #ifndef DOXYGEN_SHOULD_SKIP_THIS
46 #include <visp/vpMatrix.h>
47 #include <visp/vpMath.h>
48 #include <visp/vpColVector.h>
51 #include <visp/vpException.h>
52 #include <visp/vpMatrixException.h>
55 #include <visp/vpDebug.h>
86 vpMatrix::LUDcmp(
unsigned int *perm,
int& d)
90 unsigned int i,imax=0,j,k;
91 double big,dum,sum,temp;
98 if ((temp=fabs(
rowPtrs[i][j])) > big) big=temp;
100 if (std::fabs(big) <= std::numeric_limits<double>::epsilon())
104 "\n\t\tSingular vpMatrix in LUDcmp")) ;
120 if ( (dum=vv[i]*fabs(sum)) >= big) {
136 if (std::fabs(
rowPtrs[j][j]) <= std::numeric_limits<double>::epsilon())
140 for (i=j+1;i<n;i++)
rowPtrs[i][j] *= dum;
166 void vpMatrix::LUBksb(
unsigned int *perm,
vpColVector& b)
181 for (
unsigned int j=ii;j<=i-1;j++) sum -=
rowPtrs[i][j]*b[j];
184 else if (std::fabs(sum) > std::numeric_limits<double>::epsilon()) {
200 for (
unsigned int j=i+1;j<n;j++) sum -=
rowPtrs[i][j]*b[j];
204 #endif // doxygen should skip this
244 "Cannot invert a non-square vpMatrix")) ;
251 for (i=0; i<
rowNum; i++) {
252 for (j=0; j<
rowNum; j++) {
253 B[i][j] = (i == j) ? 1 : 0;
260 unsigned int *perm =
new unsigned int[
rowNum];
268 c_tmp =0 ; c_tmp[j-1] = 1 ;
269 A.LUBksb(perm, c_tmp);
270 for (
unsigned int k=0 ; k < c_tmp.
getRows() ; k++)
271 B[k][j-1] = c_tmp[k] ;
Definition of the vpMatrix class.
double ** rowPtrs
address of the first element of each rows
unsigned int rowNum
number of rows
Class that provides a data structure for the column vectors as well as a set of operations on these v...
vpMatrix inverseByLU() const
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.