| 11 | |
| 12 | template<typename MatrixType,typename DenseMat> |
| 13 | int generate_sparse_rectangular_problem(MatrixType& A, DenseMat& dA, int maxRows = 300, int maxCols = 150) |
| 14 | { |
| 15 | eigen_assert(maxRows >= maxCols); |
| 16 | typedef typename MatrixType::Scalar Scalar; |
| 17 | int rows = internal::random<int>(1,maxRows); |
| 18 | int cols = internal::random<int>(1,maxCols); |
| 19 | double density = (std::max)(8./(rows*cols), 0.01); |
| 20 | |
| 21 | A.resize(rows,cols); |
| 22 | dA.resize(rows,cols); |
| 23 | initSparse<Scalar>(density, dA, A,ForceNonZeroDiag); |
| 24 | A.makeCompressed(); |
| 25 | int nop = internal::random<int>(0, internal::random<double>(0,1) > 0.5 ? cols/2 : 0); |
| 26 | for(int k=0; k<nop; ++k) |
| 27 | { |
| 28 | int j0 = internal::random<int>(0,cols-1); |
| 29 | int j1 = internal::random<int>(0,cols-1); |
| 30 | Scalar s = internal::random<Scalar>(); |
| 31 | A.col(j0) = s * A.col(j1); |
| 32 | dA.col(j0) = s * dA.col(j1); |
| 33 | } |
| 34 | |
| 35 | // if(rows<cols) { |
| 36 | // A.conservativeResize(cols,cols); |
| 37 | // dA.conservativeResize(cols,cols); |
| 38 | // dA.bottomRows(cols-rows).setZero(); |
| 39 | // } |
| 40 | |
| 41 | return rows; |
| 42 | } |
| 43 | |
| 44 | template<typename Scalar> void test_sparseqr_scalar() |
| 45 | { |