diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2009-09-28 09:40:18 -0400 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2009-09-28 09:40:18 -0400 |
commit | 67bf7c90c5c41d8b62411c298d657908537118ea (patch) | |
tree | 5c1606a4ab8174f93d7b561b543644be83fcbbe9 /test/main.h | |
parent | de942a44c2459a19a12b0b6309cbc226867ea691 (diff) |
* update test to expose bug #57
* update createRandomMatrixOfRank to support fixed size
Diffstat (limited to 'test/main.h')
-rw-r--r-- | test/main.h | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/test/main.h b/test/main.h index 8c93e856c..51b719814 100644 --- a/test/main.h +++ b/test/main.h @@ -248,18 +248,22 @@ template<typename MatrixType> void createRandomMatrixOfRank(int desired_rank, int rows, int cols, MatrixType& m) { typedef typename ei_traits<MatrixType>::Scalar Scalar; + enum { Rows = MatrixType::RowsAtCompileTime, Cols = MatrixType::ColsAtCompileTime }; + typedef Matrix<Scalar, Dynamic, 1> VectorType; + typedef Matrix<Scalar, Rows, Rows> MatrixAType; + typedef Matrix<Scalar, Cols, Cols> MatrixBType; - MatrixType a = MatrixType::Random(rows,rows); + MatrixAType a = MatrixAType::Random(rows,rows); MatrixType d = MatrixType::Identity(rows,cols); - MatrixType b = MatrixType::Random(cols,cols); + MatrixBType b = MatrixBType::Random(cols,cols); // set the diagonal such that only desired_rank non-zero entries reamain const int diag_size = std::min(d.rows(),d.cols()); d.diagonal().segment(desired_rank, diag_size-desired_rank) = VectorType::Zero(diag_size-desired_rank); - HouseholderQR<MatrixType> qra(a); - HouseholderQR<MatrixType> qrb(b); + HouseholderQR<MatrixAType> qra(a); + HouseholderQR<MatrixBType> qrb(b); m = qra.matrixQ() * d * qrb.matrixQ(); } |