cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
jacobi.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef cMHN_NONTT_JACOBI_H
4#define cMHN_NONTT_JACOBI_H
5
7
8#include <prc.hpp>
9
10namespace cMHN::nonTT
11{
25 class T, class X, pRC::Size D, class RX = pRC::RemoveConstReference<X>>
26 X jacobi(nonTT::MHNOperator<T, D> const &op, X const &b)
27 {
28 // starting value for pTheta
29 auto pTheta = eval(pRC::unit<X>(T(1) / pow(T(D), T(2))));
30
31 // get Tensor with diagonal entries of (1-Q)
32 auto dg = apply_diag(op, eval(pRC::unit<X>()));
33
34 for(pRC::Index i = 0; i <= D; ++i)
35 {
36 pTheta = b + apply_offdiag<OT>(op, pTheta);
37 pTheta /= dg;
38 }
39
40 return pTheta;
41 }
42}
43
44#endif // cMHN_NONTT_JACOBI_H
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:24
pRC::Float<> T
Definition externs_nonTT.hpp:1
Definition jacobi.hpp:11
X jacobi(nonTT::MHNOperator< T, D > const &op, X const &b)
Solves the linear system (1-Q)x=b or (1-Q)^Tx=b.
Definition jacobi.hpp:26
static constexpr auto apply_diag(MHNOperator< T1, D > const &op, pRC::Tensor< T2, Ns... > const &x)
apply the diagonal part of (1-Q) to a vector x, given an MHN Q
Definition mhn_operator.hpp:120
Transform
Definition transform.hpp:11
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
Size Index
Definition type_traits.hpp:21
std::size_t Size
Definition type_traits.hpp:20
RemoveConst< RemoveReference< T > > RemoveConstReference
Definition type_traits.hpp:62