28 #ifndef _TOMOGRAPHER_MATHTOOLS_POS_SEMIDEF_UTIL 29 #define _TOMOGRAPHER_MATHTOOLS_POS_SEMIDEF_UTIL 38 #include <Eigen/Eigenvalues> 55 template<
typename VectorType>
60 typedef typename VectorType::Index Index;
63 RealScalar new_excess_trace = 0;
66 for (k = 0; k < vec.size(); ++k) {
68 if (vec(k) < tolerance) {
69 new_excess_trace += tolerance - vec(k);
75 tomographer_assert(trace >= vec.size()*tolerance);
77 RealScalar remove_from_each = new_excess_trace / num_pos;
78 for (k = 0; k < vec.size(); ++k) {
79 if (vec(k) < tolerance) {
82 vec(k) -= remove_from_each;
94 template<
typename MatrixType,
typename Der>
101 rho.template cast<typename MatrixType::Scalar>()
106 forcePosVecKeepSum<RealVectorType>(d, tolerance);
108 return U * d.asDiagonal() * U.adjoint();
119 template<
typename MatrixType>
130 forcePosVecKeepSum<RealVectorType>(d, tolerance);
132 return U * d.cwiseSqrt().asDiagonal() * U.adjoint();
143 template<
typename MatrixType>
154 forcePosVecKeepSum<RealVectorType>(d, tolerance);
156 for (
typename MatrixType::Index k = 0; k < d.size(); ++k) {
157 if (d(k) > tolerance) {
162 return U * d.asDiagonal() * U.adjoint();
Base namespace for the Tomographer project.
const RealVectorType & eigenvalues() const
Some C++ utilities, with a tad of C++11 tricks.
internal::plain_col_type< MatrixType, RealScalar >::type RealVectorType
const MatrixType & eigenvectors() const