template<class C>
Inverse.
Definition at line 438 of file Matrix.h. References CxMatrixTem< C >::_data, lubksb(), ludcmp(), CxMatrixTem< C >::nCol(), and CxMatrixTem< C >::nRow(). Referenced by CxMatrixTem< C >::covariance(), CxMatrixTem< C >::CxMatrixTem(), CxMatrixTem< C >::getCol(), CxMatrixTem< C >::getRow(), CxMatrixTem< C >::klm(), CxMatrixTem< C >::operator *(), CxMatrixTem< C >::operator+(), CxMatrixTem< C >::operator=(), and CxMatrixTem< C >::t(). 00439 { 00440 if (nRow() != nCol()) { 00441 CX_CERR << "Inverse: matrix is not square!." << CX_ENDL; 00442 return CxMatrixTem<C>(0, 0); 00443 } 00444 00445 int size = nRow(); 00446 CxMatrixTem<C> m(size,size), tmp(*this); 00447 short* idx = new short [size]; 00448 double d; 00449 00450 if (!ludcmp(tmp._data, size, idx, &d)) { 00451 CX_CERR << "Inverse: singular matrix can't be inverted." << CX_ENDL; 00452 delete [] idx; 00453 return CxMatrixTem<C>(0,0); 00454 } 00455 00456 double * res = new double [size]; 00457 00458 for (int j = 0; j < size; j++) { 00459 for (int i = 0; i < size; i++) 00460 res[i] = 0.0; 00461 res[j] = 1.0; 00462 lubksb(tmp._data, size, idx, res); 00463 for (int i = 0; i < size; i++) 00464 m[i][j] = res[i]; 00465 } 00466 00467 delete [] res; 00468 delete [] idx; 00469 00470 return m; 00471 }
Here is the call graph for this function:
|