diff options
Diffstat (limited to 'eigen/test/sparseqr.cpp')
-rw-r--r-- | eigen/test/sparseqr.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/eigen/test/sparseqr.cpp b/eigen/test/sparseqr.cpp index 451c0e7..e8605fd 100644 --- a/eigen/test/sparseqr.cpp +++ b/eigen/test/sparseqr.cpp @@ -10,11 +10,12 @@ #include <Eigen/SparseQR> template<typename MatrixType,typename DenseMat> -int generate_sparse_rectangular_problem(MatrixType& A, DenseMat& dA, int maxRows = 300) +int generate_sparse_rectangular_problem(MatrixType& A, DenseMat& dA, int maxRows = 300, int maxCols = 150) { + eigen_assert(maxRows >= maxCols); typedef typename MatrixType::Scalar Scalar; int rows = internal::random<int>(1,maxRows); - int cols = internal::random<int>(1,rows); + int cols = internal::random<int>(1,maxCols); double density = (std::max)(8./(rows*cols), 0.01); A.resize(rows,cols); @@ -53,7 +54,7 @@ template<typename Scalar> void test_sparseqr_scalar() b = dA * DenseVector::Random(A.cols()); solver.compute(A); - if(internal::random<float>(0,1)>0.5) + if(internal::random<float>(0,1)>0.5f) solver.factorize(A); // this checks that calling analyzePattern is not needed if the pattern do not change. if (solver.info() != Success) { @@ -88,6 +89,11 @@ template<typename Scalar> void test_sparseqr_scalar() QtQ = Q * Q.adjoint(); idM.resize(Q.rows(), Q.rows()); idM.setIdentity(); VERIFY(idM.isApprox(QtQ)); + + // Q to dense + DenseMat dQ; + dQ = solver.matrixQ(); + VERIFY_IS_APPROX(Q, dQ); } void test_sparseqr() { |