28 #ifndef TOMOGRAPHER_DENSEDM_PARAM_HERM_X_H 29 #define TOMOGRAPHER_DENSEDM_PARAM_HERM_X_H 42 #include <boost/math/constants/constants.hpp> 43 #include <boost/serialization/serialization.hpp> 57 template<
typename DMTypes_>
61 typedef DMTypes_ DMTypes;
68 typedef Eigen::Index IndexType;
73 ParamX(DMTypes dmt) : dim(dmt.dim()) { }
82 inline VectorParamType
HermToX(MatrixTypeConstRef Herm)
const 86 const Eigen::Index dim2 = dim*dim;
89 VectorParamType x = VectorParamType::Zero(dim2,1);
90 const Eigen::Index dimtri = (dim2 - dim)/2;
94 x.
block(0,0,dim,1) = Herm.real().diagonal();
98 for (n = 1; n < dim; ++n) {
99 for (m = 0; m < n; ++m) {
100 x(k) = Herm(n,m).real() * boost::math::constants::root_two<RealScalar>();
101 x(dimtri + k) = Herm(n,m).imag() * boost::math::constants::root_two<RealScalar>();
114 template<
bool OnlyLowerTri = false>
115 inline MatrixType
XToHerm(VectorParamTypeConstRef x)
const 117 const Eigen::Index dim2 = dim*dim;
120 MatrixType Herm = MatrixType::Zero(dim,dim);
122 const IndexType dimtri = (dim2-dim)/2;
125 Herm.diagonal().
real() = x.block(0,0,dim,1);
126 Herm.diagonal().
imag().setZero();
130 for (n = 1; n < dim; ++n) {
131 for (m = 0; m < n; ++m) {
132 Herm(n,m) = boost::math::constants::half_root_two<RealScalar>() * ComplexScalar(x(k), x(dimtri + k));
135 Herm(m,n) = boost::math::constants::half_root_two<RealScalar>() * ComplexScalar(x(k), -x(dimtri + k));
152 friend boost::serialization::access;
153 template<
typename Archive>
154 void serialize(Archive & a,
unsigned int )
Base namespace for the Tomographer project.
const ImagReturnType imag() const
Convert hermitian matrices to vectors via their X Parameterization.
RealReturnType real() const
MatrixType XToHerm(VectorParamTypeConstRef x) const
Get the Hermitian matrix parameterized by the "X-parameter" vector x.
Block< Matrix< _Scalar, _Rows, _Cols, _Options, _MaxRows, _MaxCols > > block(Index startRow, Index startCol, Index blockRows, Index blockCols)
ParamX()
Construct an invalid ParamX object – only for use with Boost.Serialization.
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.