diff options
author | Anton Gladky <gladk@debian.org> | 2014-01-15 17:49:52 +0100 |
---|---|---|
committer | Anton Gladky <gladk@debian.org> | 2014-01-15 17:49:52 +0100 |
commit | 4cd4be97a7165e6e45ee60aee23b9342af03c491 (patch) | |
tree | 21fc8f3075724c3ff265b66d6d43768dde280f02 | |
parent | 548216b7ca396dea5ecd55e177e38de0f80e8396 (diff) |
Port unsupported constrained CG to Eigen3
-rw-r--r-- | unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h b/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h index 3f18beeeb..dc0093eb9 100644 --- a/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h +++ b/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h @@ -58,7 +58,9 @@ void pseudo_inverse(const CMatrix &C, CINVMatrix &CINV) Scalar rho, rho_1, alpha; d.setZero(); - CINV.startFill(); // FIXME estimate the number of non-zeros + typedef Triplet<double> T; + std::vector<T> tripletList; + for (Index i = 0; i < rows; ++i) { d[i] = 1.0; @@ -84,11 +86,12 @@ void pseudo_inverse(const CMatrix &C, CINVMatrix &CINV) // FIXME add a generic "prune/filter" expression for both dense and sparse object to sparse for (Index j=0; j<l.size(); ++j) if (l[j]<1e-15) - CINV.fill(i,j) = l[j]; + tripletList.push_back(T(i,j,l(j))); + d[i] = 0.0; } - CINV.endFill(); + CINV.setFromTriplets(tripletList.begin(), tripletList.end()); } @@ -103,6 +106,7 @@ template<typename TMatrix, typename CMatrix, void constrained_cg(const TMatrix& A, const CMatrix& C, VectorX& x, const VectorB& b, const VectorF& f, IterationController &iter) { + using std::sqrt; typedef typename TMatrix::Scalar Scalar; typedef typename TMatrix::Index Index; typedef Matrix<Scalar,Dynamic,1> TmpVec; |