aboutsummaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorGravatar Rasmus Munk Larsen <rmlarsen@google.com>2016-04-04 14:20:01 -0700
committerGravatar Rasmus Munk Larsen <rmlarsen@google.com>2016-04-04 14:20:01 -0700
commit86e0ed81f8db5a0c9562b62a67a9ba60ec58dec0 (patch)
tree10d4e195015009b69a76bff39bc824f0e1e8fb09 /test
parent30242b75653fa4128181dba364f540184beff5ac (diff)
Addresses comments on Eigen pull request PR-174.
* Get rid of code-duplication for real vs. complex matrices. * Fix flipped arguments to select. * Make the condition estimation functions free functions. * Use Vector::Unit() to generate canonical unit vectors. * Misc. cleanup.
Diffstat (limited to 'test')
-rw-r--r--test/cholesky.cpp8
-rw-r--r--test/lu.cpp7
2 files changed, 7 insertions, 8 deletions
diff --git a/test/cholesky.cpp b/test/cholesky.cpp
index 148a0b388..b7abc230b 100644
--- a/test/cholesky.cpp
+++ b/test/cholesky.cpp
@@ -91,12 +91,12 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
matX = chollo.solve(matB);
VERIFY_IS_APPROX(symm * matX, matB);
- // Verify that the estimated condition number is within a factor of 10 of the
- // truth.
const MatrixType symmLo_inverse = chollo.solve(MatrixType::Identity(rows,cols));
RealScalar rcond = (RealScalar(1) / matrix_l1_norm<MatrixType, Lower>(symmLo)) /
matrix_l1_norm<MatrixType, Lower>(symmLo_inverse);
RealScalar rcond_est = chollo.rcond();
+ // Verify that the estimated condition number is within a factor of 10 of the
+ // truth.
VERIFY(rcond_est > rcond / 10 && rcond_est < rcond * 10);
// test the upper mode
@@ -160,12 +160,12 @@ template<typename MatrixType> void cholesky(const MatrixType& m)
matX = ldltlo.solve(matB);
VERIFY_IS_APPROX(symm * matX, matB);
- // Verify that the estimated condition number is within a factor of 10 of the
- // truth.
const MatrixType symmLo_inverse = ldltlo.solve(MatrixType::Identity(rows,cols));
RealScalar rcond = (RealScalar(1) / matrix_l1_norm<MatrixType, Lower>(symmLo)) /
matrix_l1_norm<MatrixType, Lower>(symmLo_inverse);
RealScalar rcond_est = ldltlo.rcond();
+ // Verify that the estimated condition number is within a factor of 10 of the
+ // truth.
VERIFY(rcond_est > rcond / 10 && rcond_est < rcond * 10);
diff --git a/test/lu.cpp b/test/lu.cpp
index 53b3fcee4..9787f4d86 100644
--- a/test/lu.cpp
+++ b/test/lu.cpp
@@ -151,10 +151,10 @@ template<typename MatrixType> void lu_invertible()
MatrixType m1_inverse = lu.inverse();
VERIFY_IS_APPROX(m2, m1_inverse*m3);
- // Verify that the estimated condition number is within a factor of 10 of the
- // truth.
RealScalar rcond = (RealScalar(1) / matrix_l1_norm(m1)) / matrix_l1_norm(m1_inverse);
const RealScalar rcond_est = lu.rcond();
+ // Verify that the estimated condition number is within a factor of 10 of the
+ // truth.
VERIFY(rcond_est > rcond / 10 && rcond_est < rcond * 10);
// test solve with transposed
@@ -197,10 +197,9 @@ template<typename MatrixType> void lu_partial_piv()
MatrixType m1_inverse = plu.inverse();
VERIFY_IS_APPROX(m2, m1_inverse*m3);
- // Test condition number estimation.
RealScalar rcond = (RealScalar(1) / matrix_l1_norm(m1)) / matrix_l1_norm(m1_inverse);
- // Verify that the estimate is within a factor of 10 of the truth.
const RealScalar rcond_est = plu.rcond();
+ // Verify that the estimate is within a factor of 10 of the truth.
VERIFY(rcond_est > rcond / 10 && rcond_est < rcond * 10);
// test solve with transposed