Macaulay2 Engine
Loading...
Searching...
No Matches

◆ solveInvertible()

template<class RingType>
bool DMatLinAlg< RingType >::solveInvertible ( const Mat & B,
Mat & X )

Input: B, a matrix, the right hand side of AX=B A, a square matrix (presumed to be invertible) Output: X, a matrix, solution to the above, if A is invertible returns false iff A is not invertible

Definition at line 535 of file dmat-lu.hpp.

536{
537 // printf("in dmat-lu solveInvertible\n");
538 // possible TODO: incorporate a faster method if we know matrix is
539 // invertible...
540 assert(mLUObject.numRows() == mLUObject.numColumns());
541 assert(mLUObject.numRows() == B.numRows());
542
543 X.resize(mLUObject.numColumns(), B.numColumns());
544 mLUObject.LUinPlace();
545 if (rank() < mLUObject.numRows()) return false;
546 solve(B, X);
547 return true;
548#if 0
549 // The following code doesn't really seem to be any faster than the naive code we have
550 // at least for sizes less than a few thousand rows/columns.
551 Mat B1(ring(), LU.numRows(), LU.numRows()); // square matrix
552 printf("in dmat-lu solveInvertible step 3\n");
553 permuteRows<Mat>(B, mLUObject.permutation(), B1);
554 printf("in dmat-lu solveInvertible step 4\n");
556 printf("in dmat-lu solveInvertible step 5\n");
558 printf("in dmat-lu solveInvertible step 6\n");
559 return true;
560#endif
561}
DMatLUinPlace< RingType > mLUObject
Definition dmat-lu.hpp:64
size_t rank()
Output: returns the approximate rank of A (-1 if fails).
Definition dmat-lu.hpp:332
const RingType & ring() const
Definition dmat-lu.hpp:107
DMat< RingType > Mat
Definition dmat-lu.hpp:61
bool solve(const Mat &B, Mat &X)
Definition dmat-lu.hpp:340
void solveLowerTriangular(const Mat &LU, const Mat &B, Mat &X)
Definition dmat-lu.hpp:478
void solveUpperTriangular(const Mat &LU, const Mat &B, Mat &X)
Definition dmat-lu.hpp:507
void permuteRows(const Mat &B, const std::vector< size_t > permutation, Mat &result)
Definition dmat-lu.hpp:465

References mLUObject, DMat< ACoeffRing >::numColumns(), DMat< ACoeffRing >::numRows(), permuteRows(), rank(), DMat< ACoeffRing >::resize(), ring(), solve(), solveLowerTriangular(), and solveUpperTriangular().

Referenced by MatrixOps::solveInvertible().