aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-08-05 10:15:28 +0200
committerGravatar Benoit Jacob <jacob.benoit.1@gmail.com>2009-08-05 10:15:28 +0200
commit014c581a5b32330e202e52fc5f9d98d383461da0 (patch)
treef5a1b9fcdd8febb8892f357549675361abc97d16
parentb183a4f879d16b6a8d001b83b21300329291e569 (diff)
fix assertions, improve docs.
we never assert on conditions that depend on the result of a computation!! also the assertion that rank>0 amounts to matrix!=0 which we have to leave under the responsibility of the user.
-rw-r--r--Eigen/src/LU/LU.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/Eigen/src/LU/LU.h b/Eigen/src/LU/LU.h
index 2bdcc4512..7d688c238 100644
--- a/Eigen/src/LU/LU.h
+++ b/Eigen/src/LU/LU.h
@@ -103,9 +103,15 @@ template<typename MatrixType> class LU
/** Constructor.
*
* \param matrix the matrix of which to compute the LU decomposition.
+ * It is required to be nonzero.
*/
LU(const MatrixType& matrix);
+ /** Computes the LU decomposition of the given matrix.
+ *
+ * \param matrix the matrix of which to compute the LU decomposition.
+ * It is required to be nonzero.
+ */
void compute(const MatrixType& matrix);
/** \returns the LU decomposition matrix: the upper-triangular part is U, the
@@ -317,6 +323,7 @@ template<typename MatrixType> class LU
*/
inline void computeInverse(MatrixType *result) const
{
+ ei_assert(m_originalMatrix != 0 && "LU is not initialized.");
solve(MatrixType::Identity(m_lu.rows(), m_lu.cols()), result);
}
@@ -461,7 +468,7 @@ template<typename MatrixType>
template<typename KernelMatrixType>
void LU<MatrixType>::computeKernel(KernelMatrixType *result) const
{
- ei_assert(!isInvertible());
+ ei_assert(m_originalMatrix != 0 && "LU is not initialized.");
const int dimker = dimensionOfKernel(), cols = m_lu.cols();
result->resize(cols, dimker);
@@ -497,6 +504,7 @@ template<typename MatrixType>
const typename LU<MatrixType>::KernelResultType
LU<MatrixType>::kernel() const
{
+ ei_assert(m_originalMatrix != 0 && "LU is not initialized.");
KernelResultType result(m_lu.cols(), dimensionOfKernel());
computeKernel(&result);
return result;
@@ -506,9 +514,7 @@ template<typename MatrixType>
template<typename ImageMatrixType>
void LU<MatrixType>::computeImage(ImageMatrixType *result) const
{
- // can be caused by a rank deficient matrix or by calling computeImage on an
- // unitialized LU object
- ei_assert(m_rank > 0 && "LU is not initialized or Matrix has rank zero.");
+ ei_assert(m_originalMatrix != 0 && "LU is not initialized.");
result->resize(m_originalMatrix->rows(), m_rank);
for(int i = 0; i < m_rank; ++i)
result->col(i) = m_originalMatrix->col(m_q.coeff(i));