in all decs, make the compute() methods return *this

(implements feature request #18)
This commit is contained in:
Benoit Jacob
2009-08-15 23:12:39 -04:00
parent 65fe5f76fd
commit ee982709d3
9 changed files with 40 additions and 23 deletions

View File

@@ -111,8 +111,10 @@ template<typename MatrixType> class LU
*
* \param matrix the matrix of which to compute the LU decomposition.
* It is required to be nonzero.
*
* \returns a reference to *this
*/
void compute(const MatrixType& matrix);
LU& compute(const MatrixType& matrix);
/** \returns the LU decomposition matrix: the upper-triangular part is U, the
* unit-lower-triangular part is L (at least for square matrices; in the non-square
@@ -377,7 +379,7 @@ LU<MatrixType>::LU(const MatrixType& matrix)
}
template<typename MatrixType>
void LU<MatrixType>::compute(const MatrixType& matrix)
LU<MatrixType>& LU<MatrixType>::compute(const MatrixType& matrix)
{
m_originalMatrix = &matrix;
m_lu = matrix;
@@ -447,6 +449,7 @@ void LU<MatrixType>::compute(const MatrixType& matrix)
std::swap(m_q.coeffRef(k), m_q.coeffRef(cols_transpositions.coeff(k)));
m_det_pq = (number_of_transpositions%2) ? -1 : 1;
return *this;
}
template<typename MatrixType>

View File

@@ -87,7 +87,7 @@ template<typename MatrixType> class PartialLU
*/
PartialLU(const MatrixType& matrix);
void compute(const MatrixType& matrix);
PartialLU& compute(const MatrixType& matrix);
/** \returns the LU decomposition matrix: the upper-triangular part is U, the
* unit-lower-triangular part is L (at least for square matrices; in the non-square
@@ -350,7 +350,7 @@ void ei_partial_lu_inplace(MatrixType& lu, IntVector& row_transpositions, int& n
}
template<typename MatrixType>
void PartialLU<MatrixType>::compute(const MatrixType& matrix)
PartialLU<MatrixType>& PartialLU<MatrixType>::compute(const MatrixType& matrix)
{
m_lu = matrix;
m_p.resize(matrix.rows());
@@ -369,6 +369,7 @@ void PartialLU<MatrixType>::compute(const MatrixType& matrix)
std::swap(m_p.coeffRef(k), m_p.coeffRef(rows_transpositions.coeff(k)));
m_isInitialized = true;
return *this;
}
template<typename MatrixType>