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