Xped
Loading...
Searching...
No Matches
CoeffUnaryOp.hpp
Go to the documentation of this file.
1#ifndef XPED_COEFF_UNARY_OP_H_
2#define XPED_COEFF_UNARY_OP_H_
3
4#include <assert.hpp>
5
7
8#include "TensorBase.hpp"
9
10namespace Xped {
11
12template <typename, typename>
13class CoeffUnaryOp;
14
15template <typename XprType, typename ReturnScalar>
16struct TensorTraits<CoeffUnaryOp<XprType, ReturnScalar>>
17{
18 static constexpr std::size_t Rank = XprType::Rank;
19 static constexpr std::size_t CoRank = XprType::CoRank;
20 typedef ReturnScalar Scalar;
21 typedef typename XprType::Symmetry Symmetry;
22 using AllocationPolicy = typename XprType::AllocationPolicy;
23};
24
25template <typename XprType, typename ReturnScalar>
26class CoeffUnaryOp : public TensorBase<CoeffUnaryOp<XprType, ReturnScalar>>
27{
28public:
29 static inline constexpr std::size_t Rank = XprType::Rank;
30 static inline constexpr std::size_t CoRank = XprType::CoRank;
31 using Scalar = ReturnScalar;
32 typedef typename XprType::Symmetry Symmetry;
33 using AllocationPolicy = typename XprType::AllocationPolicy;
34 typedef typename Symmetry::qType qType;
35
36 CoeffUnaryOp(XPED_CONST XprType& xpr, const std::function<ReturnScalar(typename XprType::Scalar)>& coeff_func)
37 : refxpr_(xpr)
38 , coeff_func_(coeff_func)
39 {}
40
41 inline const std::string name() const { return "CoeffUnaryOp"; }
42 constexpr std::size_t rank() const { return refxpr_.rank(); }
43 constexpr std::size_t corank() const { return refxpr_.corank(); }
44
45 inline const auto sector() const { return refxpr_.sector(); }
46 inline const qType sector(std::size_t i) const { return refxpr_.sector(i); }
47
48 inline const auto block(std::size_t i) const { return PlainInterface::unaryFunc<ReturnScalar>(refxpr_.block(i), coeff_func_); }
49 inline auto block(std::size_t i) { return PlainInterface::unaryFunc<ReturnScalar>(refxpr_.block(i), coeff_func_); }
50
51 inline const auto dict() const { return refxpr_.dict(); }
52
53 inline const mpi::XpedWorld& world() const { return refxpr_.world(); }
54
55 inline const auto uncoupledDomain() const { return refxpr_.uncoupledDomain(); }
56 inline const auto uncoupledCodomain() const { return refxpr_.uncoupledCodomain(); }
57
58 inline const auto coupledDomain() const { return refxpr_.coupledDomain(); }
59 inline const auto coupledCodomain() const { return refxpr_.coupledCodomain(); }
60
61 inline auto domainTrees(const qType& q) const { return refxpr_.cdomainTrees(q); }
62 inline auto codomainTrees(const qType& q) const { return refxpr_.codomainTrees(q); }
63
64protected:
65 XPED_CONST XprType& refxpr_;
66 const std::function<ReturnScalar(typename XprType::Scalar)> coeff_func_;
67};
68
69} // namespace Xped
70#endif
Definition: CoeffUnaryOp.hpp:27
const auto uncoupledDomain() const
Definition: CoeffUnaryOp.hpp:55
static constexpr std::size_t Rank
Definition: CoeffUnaryOp.hpp:29
static constexpr std::size_t CoRank
Definition: CoeffUnaryOp.hpp:30
auto codomainTrees(const qType &q) const
Definition: CoeffUnaryOp.hpp:62
ReturnScalar Scalar
Definition: CoeffUnaryOp.hpp:31
typename XprType::AllocationPolicy AllocationPolicy
Definition: CoeffUnaryOp.hpp:33
const auto coupledDomain() const
Definition: CoeffUnaryOp.hpp:58
auto domainTrees(const qType &q) const
Definition: CoeffUnaryOp.hpp:61
const qType sector(std::size_t i) const
Definition: CoeffUnaryOp.hpp:46
const auto block(std::size_t i) const
Definition: CoeffUnaryOp.hpp:48
const auto uncoupledCodomain() const
Definition: CoeffUnaryOp.hpp:56
const auto dict() const
Definition: CoeffUnaryOp.hpp:51
const auto sector() const
Definition: CoeffUnaryOp.hpp:45
constexpr std::size_t corank() const
Definition: CoeffUnaryOp.hpp:43
XPED_CONST XprType & refxpr_
Definition: CoeffUnaryOp.hpp:65
constexpr std::size_t rank() const
Definition: CoeffUnaryOp.hpp:42
Symmetry::qType qType
Definition: CoeffUnaryOp.hpp:34
const mpi::XpedWorld & world() const
Definition: CoeffUnaryOp.hpp:53
CoeffUnaryOp(XPED_CONST XprType &xpr, const std::function< ReturnScalar(typename XprType::Scalar)> &coeff_func)
Definition: CoeffUnaryOp.hpp:36
const std::string name() const
Definition: CoeffUnaryOp.hpp:41
XprType::Symmetry Symmetry
Definition: CoeffUnaryOp.hpp:32
auto block(std::size_t i)
Definition: CoeffUnaryOp.hpp:49
const auto coupledCodomain() const
Definition: CoeffUnaryOp.hpp:59
const std::function< ReturnScalar(typename XprType::Scalar)> coeff_func_
Definition: CoeffUnaryOp.hpp:66
Definition: TensorBase.hpp:36
Definition: bench.cpp:62
ReturnScalar Scalar
Definition: CoeffUnaryOp.hpp:20
typename XprType::AllocationPolicy AllocationPolicy
Definition: CoeffUnaryOp.hpp:22
XprType::Symmetry Symmetry
Definition: CoeffUnaryOp.hpp:21
Definition: TensorBase.hpp:10
Definition: Mpi.hpp:34