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