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_>
60 typedef DMTypes_ DMTypes;
81 inline VectorParamType
HermToX(MatrixTypeConstRef Herm)
const 84 VectorParamType x(_dmt.initVectorParamType());
85 const IndexType dimtri = (_dmt.dim2() - _dmt.dim())/2;
89 x.block(0,0,(IndexType)_dmt.dim(),1) = Herm.real().diagonal();
91 IndexType k = (IndexType)_dmt.dim();
93 for (n = 1; n < (IndexType)_dmt.dim(); ++n) {
94 for (m = 0; m < n; ++m) {
95 x(k) = Herm(n,m).real() * boost::math::constants::root_two<RealScalar>();
96 x(dimtri + k) = Herm(n,m).imag() * boost::math::constants::root_two<RealScalar>();
109 template<
bool OnlyLowerTri = false>
110 inline MatrixType
XToHerm(VectorParamTypeConstRef x)
const 113 MatrixType Herm(_dmt.initMatrixType());
115 const IndexType dimtri = (IndexType)(_dmt.dim2()-_dmt.dim())/2;
118 Herm.diagonal().real() = x.block(0,0,(IndexType)_dmt.dim(),1);
119 Herm.diagonal().imag().setZero();
121 IndexType k = (IndexType)_dmt.dim();
123 for (n = 1; n < (IndexType)_dmt.dim(); ++n) {
124 for (m = 0; m < n; ++m) {
125 Herm(n,m) = boost::math::constants::half_root_two<RealScalar>() * ComplexScalar(x(k), x(dimtri + k));
128 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.
#define tomographer_assert(...)
Assertion test macro.
RealScalar_ RealScalar
Real scalar type, given in template parameter. Usually double is fine.