| 10 | #include "sparse.h" |
| 11 | |
| 12 | template<typename Scalar> void |
| 13 | initSPD(double density, |
| 14 | Matrix<Scalar,Dynamic,Dynamic>& refMat, |
| 15 | SparseMatrix<Scalar>& sparseMat) |
| 16 | { |
| 17 | Matrix<Scalar,Dynamic,Dynamic> aux(refMat.rows(),refMat.cols()); |
| 18 | initSparse(density,refMat,sparseMat); |
| 19 | refMat = refMat * refMat.adjoint(); |
| 20 | for (int k=0; k<2; ++k) |
| 21 | { |
| 22 | initSparse(density,aux,sparseMat,ForceNonZeroDiag); |
| 23 | refMat += aux * aux.adjoint(); |
| 24 | } |
| 25 | sparseMat.setZero(); |
| 26 | for (int j=0 ; j<sparseMat.cols(); ++j) |
| 27 | for (int i=j ; i<sparseMat.rows(); ++i) |
| 28 | if (refMat(i,j)!=Scalar(0)) |
| 29 | sparseMat.insert(i,j) = refMat(i,j); |
| 30 | sparseMat.finalize(); |
| 31 | } |
| 32 | |
| 33 | template<typename Scalar> void sparse_solvers(int rows, int cols) |
| 34 | { |