3#ifndef cMHN_NONTT_MHN_OPERATOR_H
4#define cMHN_NONTT_MHN_OPERATOR_H
21 template<
class T, pRC::Size D>
33 constexpr auto &
theta(pRC::Index
const i, pRC::Index
const j)
const
49 pRC::Tensor<T, D, D> mTheta;
65 template<pRC::Operator::Transform OT = pRC::Operator::Transform::None,
66 pRC::Operator::Restrict OR = pRC::Operator::Restrict::None,
67 pRC::Operator::Hint OH = pRC::Operator::Hint::None,
class T1,
68 pRC::Size
D,
class T2, pRC::Size... Ns,
69 pRC::If<pRC::IsSatisfied<(OR == pRC::Operator::Restrict::None)>> = 0,
70 pRC::If<pRC::IsSatisfied<(OT == pRC::Operator::Transform::None)>> = 0>
72 pRC::Tensor<T2, Ns...>
const &x, pRC::Index
const &i)
76 pRC::range<pRC::Context::CompileTime, D>(
81 pRC::chip<j>(r, 0) *= -op.
theta(i, i);
82 pRC::chip<j>(r, 1) = -pRC::chip<j>(r, 0);
86 pRC::chip<j>(r, 1) *= op.
theta(i, j);
106 template<pRC::Operator::Transform OT = pRC::Operator::Transform::None,
107 pRC::Operator::Restrict OR = pRC::Operator::Restrict::None,
108 pRC::Operator::Hint OH = pRC::Operator::Hint::None,
class T1,
109 pRC::Size
D,
class T2, pRC::Size... Ns,
110 pRC::If<pRC::IsSatisfied<(OR == pRC::Operator::Restrict::None)>> = 0>
112 pRC::Tensor<T2, Ns...>
const &x)
116 for(pRC::Index i = 0; i <
D; ++i)
119 pRC::range<pRC::Context::CompileTime, D>(
124 if constexpr(OT == pRC::Operator::Transform::Transpose)
127 -op.
theta(i, i) * pRC::chip<j>(v, 0) +
128 op.
theta(i, i) * pRC::chip<j>(v, 1);
129 pRC::chip<j>(v, 1) = pRC::zero();
133 pRC::chip<j>(v, 0) *= -op.
theta(i, i);
134 pRC::chip<j>(v, 1) = -pRC::chip<j>(v, 0);
139 pRC::chip<j>(v, 1) *= op.
theta(i, j);
pRC::Size const D
Definition: CalculatePThetaTests.cpp:9
Class storing an MHN operator represented by a theta matrix (for non TT calculations)
Definition: mhn_operator.hpp:23
T Type
Definition: mhn_operator.hpp:25
constexpr auto & theta(pRC::Index const i, pRC::Index const j) const
Definition: mhn_operator.hpp:33
auto & theta()
Definition: mhn_operator.hpp:43
constexpr MHNOperator(pRC::Tensor< T, D, D > const &theta)
Definition: mhn_operator.hpp:28
constexpr auto & theta() const
Definition: mhn_operator.hpp:38
pRC::Float<> T
Definition: externs_nonTT.hpp:1
Definition: learn_theta.hpp:20
static constexpr auto apply(MHNOperator< T1, D > const &op, pRC::Tensor< T2, Ns... > const &x)
apply (1-Q) or its transposed to a vector x, given an MHN Q
Definition: mhn_operator.hpp:111
static constexpr auto applyDerivative(MHNOperator< T1, D > const &op, pRC::Tensor< T2, Ns... > const &x, pRC::Index const &i)
apply the derivative of an MHN Q wrt to theta_ii to a vector x
Definition: mhn_operator.hpp:71