29 #include "../../../../Eigen/src/Core/util/NonMPL2.h" 31 #ifndef EIGEN_CONSTRAINEDCG_H 32 #define EIGEN_CONSTRAINEDCG_H 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>
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();
162 if (iter.
noiseLevel() > 0 && transition) std::cerr <<
"CCG: transition\n";
163 if (transition || iter.
first()) gamma = 0.0;
164 else gamma = (
std::max)(0.0, (rho - old_z.dot(
z)) / rho_1);
170 lambda = rho /
q.dot(p);
171 for (Index
i = 0;
i < C.rows(); ++
i)
175 Scalar bb = C.row(i).dot(p) - f[
i];
177 lambda = (
std::min)(lambda, (f.coeff(i)-C.row(i).dot(x)) / bb);
189 #endif // EIGEN_CONSTRAINEDCG_H
void pseudo_inverse(const CMatrix &C, CINVMatrix &CINV)
Matrix< Scalar, Dynamic, 1 > VectorX
EIGEN_DEVICE_FUNC const SqrtReturnType sqrt() const
Namespace containing all symbols from the Eigen library.
iterator iter(handle obj)
void setRhsNorm(double r)
static const Line3 l(Rot3(), 1, 1)
const mpreal gamma(const mpreal &x, mp_rnd_t r=mpreal::get_default_rnd())
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
void constrained_cg(const TMatrix &A, const CMatrix &C, VectorX &x, const VectorB &b, const VectorF &f, IterationController &iter)
Matrix< Scalar, Dynamic, Dynamic > C
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