27 #ifndef TOMOGRAPHER_DENSEDM_PARAM_HERM_X_H 28 #define TOMOGRAPHER_DENSEDM_PARAM_HERM_X_H 41 #include <boost/math/constants/constants.hpp> 158 template<
typename DMTypes_>
161 typedef DMTypes_ DMTypes;
182 inline VectorParamType
HermToX(MatrixTypeConstRef Herm)
const 185 VectorParamType x(_dmt.initVectorParamType());
186 const IndexType dimtri = (_dmt.dim2() - _dmt.dim())/2;
188 tomographer_assert((IndexType)_dmt.dim() == Herm.cols());
190 x.block(0,0,_dmt.dim(),1) = Herm.real().diagonal();
192 IndexType k = _dmt.dim();
194 for (n = 1; n < (IndexType)_dmt.dim(); ++n) {
195 for (m = 0; m < n; ++m) {
196 x(k) = Herm(n,m).real() * boost::math::constants::root_two<RealScalar>();
197 x(dimtri + k) = Herm(n,m).imag() * boost::math::constants::root_two<RealScalar>();
210 template<
bool OnlyLowerTri = false>
211 inline MatrixType
XToHerm(VectorParamTypeConstRef x)
const 214 MatrixType Herm(_dmt.initMatrixType());
216 const IndexType dimtri = (_dmt.dim2()-_dmt.dim())/2;
217 tomographer_assert(x.rows() == (IndexType)_dmt.dim2() && x.cols() == 1);
219 Herm.diagonal().real() = x.block(0,0,_dmt.dim(),1);
220 Herm.diagonal().imag().setZero();
222 IndexType k = _dmt.dim();
224 for (n = 1; n < (IndexType)_dmt.dim(); ++n) {
225 for (m = 0; m < n; ++m) {
226 Herm(n,m) = boost::math::constants::half_root_two<RealScalar>() * ComplexScalar(x(k), x(dimtri + k));
229 Herm(m,n) = boost::math::constants::half_root_two<RealScalar>() * ComplexScalar(x(k), -x(dimtri + k));
VectorParamType HermToX(MatrixTypeConstRef Herm) const
Get the X-parameterization corresponding to a given hermitian matrix.
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.
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.