mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-12 19:20:36 +08:00
Port unsupported constrained CG to Eigen3
(grafted from 4cd4be97a7165e6e45ee60aee23b9342af03c491 )
This commit is contained in:
parent
395214bcc3
commit
d65a6aeb20
@ -62,7 +62,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;
|
||||
@ -88,11 +90,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());
|
||||
}
|
||||
|
||||
|
||||
@ -107,6 +110,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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user