28 #ifndef TOMOGRAPHER_DENSEDM_PARAM_HERM_X_H 29 #define TOMOGRAPHER_DENSEDM_PARAM_HERM_X_H 42 #include <boost/math/constants/constants.hpp> 56 template<
typename DMTypes_>
59 typedef DMTypes_ DMTypes;
80 inline VectorParamType
HermToX(MatrixTypeConstRef Herm)
const 83 VectorParamType x(_dmt.initVectorParamType());
84 const IndexType dimtri = (_dmt.dim2() - _dmt.dim())/2;
86 tomographer_assert((IndexType)_dmt.dim() == Herm.cols());
88 x.block(0,0,_dmt.dim(),1) = Herm.real().diagonal();
90 IndexType k = _dmt.dim();
92 for (n = 1; n < (IndexType)_dmt.dim(); ++n) {
93 for (m = 0; m < n; ++m) {
94 x(k) = Herm(n,m).real() * boost::math::constants::root_two<RealScalar>();
95 x(dimtri + k) = Herm(n,m).imag() * boost::math::constants::root_two<RealScalar>();
108 template<
bool OnlyLowerTri = false>
109 inline MatrixType
XToHerm(VectorParamTypeConstRef x)
const 112 MatrixType Herm(_dmt.initMatrixType());
114 const IndexType dimtri = (_dmt.dim2()-_dmt.dim())/2;
115 tomographer_assert(x.rows() == (IndexType)_dmt.dim2() && x.cols() == 1);
117 Herm.diagonal().real() = x.block(0,0,_dmt.dim(),1);
118 Herm.diagonal().imag().setZero();
120 IndexType k = _dmt.dim();
122 for (n = 1; n < (IndexType)_dmt.dim(); ++n) {
123 for (m = 0; m < n; ++m) {
124 Herm(n,m) = boost::math::constants::half_root_two<RealScalar>() * ComplexScalar(x(k), x(dimtri + k));
127 Herm(m,n) = boost::math::constants::half_root_two<RealScalar>() * ComplexScalar(x(k), -x(dimtri + k));
Base namespace for the Tomographer project.
internal::traits< Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > >::Index Index
Convert hermitian matrices to vectors via their X Parameterization.
MatrixType XToHerm(VectorParamTypeConstRef x) const
Get the Hermitian matrix parameterized by the "X-parameter" vector x.
VectorParamType HermToX(MatrixTypeConstRef Herm) const
Get the X-parameterization corresponding to a given hermitian matrix.
Some C++ utilities, with a tad of C++11 tricks.
ParamX(DMTypes dmt)
Constructor. Just give it the DMTypes instance.
RealScalar_ RealScalar
Real scalar type, given in template parameter. Usually double is fine.