29 #include "../../../../Eigen/src/Core/util/NonMPL2.h" 31 #ifndef EIGEN_CONSTRAINEDCG_H 32 #define EIGEN_CONSTRAINEDCG_H 34 #include "../../../../Eigen/Core" 46 template <
typename CMatrix,
typename CINVMatrix>
55 Index
rows = C.rows(),
cols = C.cols();
57 TmpVec
d(rows),
e(rows),
l(
cols),
p(rows),
q(rows), r(rows);
58 Scalar rho, rho_1,
alpha;
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());
104 template<
typename TMatrix,
typename CMatrix,
105 typename VectorX,
typename VectorB,
typename VectorF>
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());
135 bool transition =
false;
136 for (Index
i = 0;
i < C.rows(); ++
i)
138 Scalar al = C.row(
i).dot(x) - f.coeff(
i);
146 Scalar bb = CINV.row(i).dot(
z);
149 for (
typename CMatrix::InnerIterator it(C,i); it; ++it)
150 z.coeffRef(it.index()) -= bb*it.value();
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);
187 #endif // EIGEN_CONSTRAINEDCG_H
void constrained_cg(const TMatrix &A, const CMatrix &C, VectorX &x, const VectorB &b, const VectorF &f, IterationController &iter)
Matrix< Scalar, Dynamic, 1 > VectorX
Namespace containing all symbols from the Eigen library.
iterator iter(handle obj)
void setRhsNorm(double r)
static const Line3 l(Rot3(), 1, 1)
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Eigen::Triplet< double > T
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
EIGEN_DEVICE_FUNC const Scalar & q
cout<< "The eigenvalues of A are:"<< endl<< ces.eigenvalues()<< endl;cout<< "The matrix of eigenvectors, V, is:"<< endl<< ces.eigenvectors()<< endl<< endl;complex< float > lambda
Matrix< Scalar, Dynamic, Dynamic > C
Jet< T, N > sqrt(const Jet< T, N > &f)
void pseudo_inverse(const CMatrix &C, CINVMatrix &CINV)
Controls the iterations of the iterative solvers.
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x