Xped
Loading...
Searching...
No Matches
DiagCoeffBinaryOp.hpp
Go to the documentation of this file.
1#ifndef XPED_DIAG_COEFF_BINARY_OP_H_
2#define XPED_DIAG_COEFF_BINARY_OP_H_
3
4#include <assert.hpp>
5
7
8#include "TensorBase.hpp"
9
10namespace Xped {
11
12template <typename XprTypeLeft, typename XprTypeRight>
13class DiagCoeffBinaryOp;
14
15template <typename XprTypeLeft, typename XprTypeRight>
16struct TensorTraits<DiagCoeffBinaryOp<XprTypeLeft, XprTypeRight>>
17{
18 static constexpr std::size_t Rank = XprTypeLeft::Rank;
19 static constexpr std::size_t CoRank = XprTypeLeft::CoRank;
20 typedef typename XprTypeLeft::Scalar Scalar;
21 typedef typename XprTypeLeft::Symmetry Symmetry;
22 using AllocationPolicy = typename XprTypeLeft::AllocationPolicy;
23};
24
25template <typename XprTypeLeft, typename XprTypeRight>
26class DiagCoeffBinaryOp : public TensorBase<DiagCoeffBinaryOp<XprTypeLeft, XprTypeRight>>
27{
28public:
29 static inline constexpr std::size_t Rank = XprTypeLeft::Rank;
30 static inline constexpr std::size_t CoRank = XprTypeLeft::CoRank;
31 typedef typename XprTypeLeft::Scalar Scalar;
32 typedef typename XprTypeLeft::Symmetry Symmetry;
33 using AllocationPolicy = typename XprTypeLeft::AllocationPolicy;
34 typedef typename Symmetry::qType qType;
35
36 DiagCoeffBinaryOp(XPED_CONST XprTypeLeft& xpr_l, XPED_CONST XprTypeRight& xpr_r, const std::function<Scalar(Scalar, Scalar)>& coeff_func)
37 : refxpr_l_(xpr_l)
38 , refxpr_r_(xpr_r)
39 , coeff_func_(coeff_func)
40 {
41 static_assert(XprTypeLeft::Rank == XprTypeRight::Rank);
42 static_assert(XprTypeLeft::CoRank == XprTypeRight::CoRank);
43 static_assert(std::is_same<typename XprTypeLeft::Symmetry, typename XprTypeLeft::Symmetry>::value);
44 DEBUG_ASSERT(refxpr_l_.sector() == refxpr_r_.sector());
45 DEBUG_ASSERT(refxpr_l_.dict() == refxpr_r_.dict());
46 DEBUG_ASSERT(refxpr_l_.world() == refxpr_r_.world());
47 DEBUG_ASSERT(refxpr_l_.uncoupledDomain() == refxpr_r_.uncoupledDomain());
48 DEBUG_ASSERT(refxpr_l_.uncoupledCodomain() == refxpr_r_.uncoupledCodomain());
49 DEBUG_ASSERT(refxpr_l_.coupledDomain() == refxpr_r_.coupledDomain());
50 DEBUG_ASSERT(refxpr_l_.coupledCodomain() == refxpr_r_.coupledCodomain());
51 }
52
53 inline const std::string name() const { return "CoeffBinaryOp"; }
54 constexpr std::size_t rank() const { return refxpr_l_.rank(); }
55 constexpr std::size_t corank() const { return refxpr_l_.corank(); }
56
57 inline const auto sector() const { return refxpr_l_.sector(); }
58 inline const qType sector(std::size_t i) const { return refxpr_l_.sector(i); }
59
60 inline const auto block(std::size_t i) const { return PlainInterface::diagBinaryFunc(refxpr_l_.block(i), refxpr_r_.block(i), coeff_func_); }
61 inline auto block(std::size_t i) { return PlainInterface::diagBinaryFunc(refxpr_l_.block(i), refxpr_r_.block(i), coeff_func_); }
62
63 inline const auto dict() const { return refxpr_l_.dict(); }
64
65 inline const mpi::XpedWorld& world() const { return refxpr_l_.world(); }
66
67 inline const auto uncoupledDomain() const { return refxpr_l_.uncoupledDomain(); }
68 inline const auto uncoupledCodomain() const { return refxpr_l_.uncoupledCodomain(); }
69
70 inline const auto coupledDomain() const { return refxpr_l_.coupledDomain(); }
71 inline const auto coupledCodomain() const { return refxpr_l_.coupledCodomain(); }
72
73 inline auto domainTrees(const qType& q) const { return refxpr_l_.cdomainTrees(q); }
74 inline auto codomainTrees(const qType& q) const { return refxpr_l_.codomainTrees(q); }
75
76protected:
77 XPED_CONST XprTypeLeft& refxpr_l_;
78 XPED_CONST XprTypeRight& refxpr_r_;
79 const std::function<Scalar(Scalar, Scalar)> coeff_func_;
80};
81
82} // namespace Xped
83#endif
Definition: DiagCoeffBinaryOp.hpp:27
const auto block(std::size_t i) const
Definition: DiagCoeffBinaryOp.hpp:60
constexpr std::size_t corank() const
Definition: DiagCoeffBinaryOp.hpp:55
constexpr std::size_t rank() const
Definition: DiagCoeffBinaryOp.hpp:54
const auto uncoupledDomain() const
Definition: DiagCoeffBinaryOp.hpp:67
Symmetry::qType qType
Definition: DiagCoeffBinaryOp.hpp:34
const std::string name() const
Definition: DiagCoeffBinaryOp.hpp:53
auto codomainTrees(const qType &q) const
Definition: DiagCoeffBinaryOp.hpp:74
const qType sector(std::size_t i) const
Definition: DiagCoeffBinaryOp.hpp:58
typename XprTypeLeft::AllocationPolicy AllocationPolicy
Definition: DiagCoeffBinaryOp.hpp:33
const auto coupledCodomain() const
Definition: DiagCoeffBinaryOp.hpp:71
DiagCoeffBinaryOp(XPED_CONST XprTypeLeft &xpr_l, XPED_CONST XprTypeRight &xpr_r, const std::function< Scalar(Scalar, Scalar)> &coeff_func)
Definition: DiagCoeffBinaryOp.hpp:36
auto block(std::size_t i)
Definition: DiagCoeffBinaryOp.hpp:61
XprTypeLeft::Symmetry Symmetry
Definition: DiagCoeffBinaryOp.hpp:32
const std::function< Scalar(Scalar, Scalar)> coeff_func_
Definition: DiagCoeffBinaryOp.hpp:79
const auto sector() const
Definition: DiagCoeffBinaryOp.hpp:57
XPED_CONST XprTypeLeft & refxpr_l_
Definition: DiagCoeffBinaryOp.hpp:77
XprTypeLeft::Scalar Scalar
Definition: DiagCoeffBinaryOp.hpp:31
auto domainTrees(const qType &q) const
Definition: DiagCoeffBinaryOp.hpp:73
static constexpr std::size_t CoRank
Definition: DiagCoeffBinaryOp.hpp:30
const mpi::XpedWorld & world() const
Definition: DiagCoeffBinaryOp.hpp:65
static constexpr std::size_t Rank
Definition: DiagCoeffBinaryOp.hpp:29
XPED_CONST XprTypeRight & refxpr_r_
Definition: DiagCoeffBinaryOp.hpp:78
const auto uncoupledCodomain() const
Definition: DiagCoeffBinaryOp.hpp:68
const auto dict() const
Definition: DiagCoeffBinaryOp.hpp:63
const auto coupledDomain() const
Definition: DiagCoeffBinaryOp.hpp:70
Definition: TensorBase.hpp:36
Definition: bench.cpp:62
static MType< Scalar > diagBinaryFunc(MTL &&M_left, MTR &&M_right, const std::function< Scalar(Scalar, Scalar)> &func)
XprTypeLeft::Symmetry Symmetry
Definition: DiagCoeffBinaryOp.hpp:21
XprTypeLeft::Scalar Scalar
Definition: DiagCoeffBinaryOp.hpp:20
typename XprTypeLeft::AllocationPolicy AllocationPolicy
Definition: DiagCoeffBinaryOp.hpp:22
Definition: TensorBase.hpp:10
Definition: Mpi.hpp:34