50 typedef typename CMatrix::Scalar
Scalar;
51 typedef typename CMatrix::Index
Index;
55 Index rows = C.rows(), cols = C.cols();
57 TmpVec d(rows), e(rows), l(cols), p(rows), q(rows), r(rows);
62 std::vector<T> tripletList;
64 for (
Index i = 0; i < rows; ++i)
75 l = C.transpose() * p;
77 alpha = rho / p.dot(q);
82 p = (rho/rho_1) * p + r;
85 l = C.transpose() * e;
87 for (
Index j=0; j<l.size(); ++j)
89 tripletList.push_back(T(i,j,l(j)));
94 CINV.setFromTriplets(tripletList.begin(), tripletList.end());
110 typedef typename TMatrix::Scalar
Scalar;
111 typedef typename TMatrix::Index
Index;
114 Scalar rho = 1.0, rho_1, lambda, gamma;
115 Index xSize = x.size();
116 TmpVec p(xSize), q(xSize), q2(xSize),
117 r(xSize), old_z(xSize), z(xSize),
119 std::vector<bool> satured(C.rows());
121 iter.setRhsNorm(
sqrt(b.dot(b)));
122 if (iter.rhsNorm() == 0.0) iter.setRhsNorm(1.0);
135 bool transition =
false;
136 for (
Index i = 0; i < C.rows(); ++i)
138 Scalar al = C.row(i).dot(x) - f.coeff(i);
149 for (
typename CMatrix::InnerIterator it(C,i); it; ++it)
150 z.coeffRef(it.index()) -= bb*it.value();
160 if (iter.finished(rho))
break;
161 if (transition || iter.first()) gamma = 0.0;
162 else gamma = (std::max)(0.0, (rho - old_z.dot(z)) / rho_1);
168 lambda = rho / q.dot(p);
169 for (
Index i = 0; i < C.rows(); ++i)
173 Scalar bb = C.row(i).dot(p) - f[i];
175 lambda = (std::min)(lambda, (f.coeff(i)-C.row(i).dot(x)) / bb);
void constrained_cg(const TMatrix &A, const CMatrix &C, VectorX &x, const VectorB &b, const VectorF &f, IterationController &iter)
Definition ConstrainedConjGrad.h:106