27 #ifndef HERM_PARAM_X_H
28 #define HERM_PARAM_X_H
39 #include <boost/math/constants/constants.hpp>
52 template<
bool OnlyLowerTri=false,
typename Derived1=Eigen::MatrixXd,
typename Derived2=Eigen::MatrixXd>
55 {
using namespace Eigen; EIGEN_STATIC_ASSERT_LVALUE(Derived1); }
57 const int dim = Herm.rows();
58 const int dimtri = dim*(dim-1)/2;
59 eigen_assert(dim == Herm.cols());
60 eigen_assert(x.rows() == dim*dim && x.cols() == 1);
62 typedef typename Derived1::Scalar Scalar;
69 for (n = 1; n < dim; ++n) {
70 for (m = 0; m < n; ++m) {
71 const int k = dim + n*(n-1)/2 + m;
72 const int l = dimtri + k;
73 Herm(n,m) = boost::math::constants::half_root_two<RealScalar>() * Scalar(x(k), x(l));
76 Herm(m,n) = boost::math::constants::half_root_two<RealScalar>() * Scalar(x(k), -x(l));
92 template<
typename Derived1,
typename Derived2>
95 {
using namespace Eigen; EIGEN_STATIC_ASSERT_LVALUE(Derived1); }
97 const int dim = Herm.rows();
98 const int dimtri = dim*(dim-1)/2;
99 eigen_assert(dim == Herm.cols());
100 eigen_assert(x.rows() == dim*dim && x.cols() == 1);
102 typedef typename Derived1::Scalar Scalar;
105 x.
block(0,0,dim,1) = Herm.
real().diagonal();
108 for (n = 1; n < dim; ++n) {
109 for (m = 0; m < n; ++m) {
110 const int k = dim + n*(n-1)/2 + m;
111 const int l = dimtri + k;
112 x(k) = Herm(n,m).
real() * boost::math::constants::root_two<RealScalar>();
113 x(l) = Herm(n,m).
imag() * boost::math::constants::root_two<RealScalar>();
Base namespace for the Tomographer project.
const ImagReturnType imag() const
RealReturnType real() const
Block< Derived > block(Index startRow, Index startCol, Index blockRows, Index blockCols)
DiagonalReturnType diagonal()
void param_x_to_herm(Eigen::MatrixBase< Derived1 > &Herm, const Eigen::DenseBase< Derived2 > &x)
Get the Hermitian matrix parameterized by the "X-parameter" vector x.
void param_herm_to_x(Eigen::DenseBase< Derived1 > &x, const Eigen::MatrixBase< Derived2 > &Herm)
Get the X-parameterization corresponding to a given hermitian matrix.