cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
broadcast.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_VIEWS_BROADCAST_H
4#define pRC_CORE_TENSOR_VIEWS_BROADCAST_H
5
7
8namespace pRC::TensorViews
9{
10 template<class T, class N, class B, class V>
11 class Broadcast;
12
13 template<class T, Size... Ns, Size... Bs, class V>
14 requires IsTensorView<V>
15 class Broadcast<T, Sizes<Ns...>, Sizes<Bs...>, V>
16 : public View<T, Sizes<Ns...>,
17 Broadcast<T, Sizes<Ns...>, Sizes<Bs...>, V>>
18 {
19 private:
20 using Base = View<T, Sizes<Ns...>, Broadcast>;
21
22 public:
23 template<class X>
25 Broadcast(X &&a)
26 : mA(forward<X>(a))
27 {
28 }
29
30 template<IsConvertible<Index>... Is>
31 requires(sizeof...(Is) == Base::Dimension)
32 constexpr decltype(auto) operator()(Is const... indices)
33 {
34 return asConst(mA((indices % (Ns / Bs))...));
35 }
36
37 template<IsConvertible<Index>... Is>
38 requires(sizeof...(Is) == Base::Dimension)
39 constexpr decltype(auto) operator()(Is const... indices) const
40 {
41 return mA((indices % (Ns / Bs))...);
42 }
43
44 constexpr decltype(auto) operator()(
45 typename Base::Subscripts const &subscripts)
46 {
47 return this->call(subscripts);
48 }
49
50 constexpr decltype(auto) operator()(
51 typename Base::Subscripts const &subscripts) const
52 {
53 return this->call(subscripts);
54 }
55
56 constexpr decltype(auto) operator[](Index const index) = delete;
57 constexpr decltype(auto) operator[](Index const index) const = delete;
58
59 private:
60 V mA;
61 };
62}
63#endif // pRC_CORE_TENSOR_VIEWS_BROADCAST_H
Definition value.hpp:12
Definition sequence.hpp:29
Definition broadcast.hpp:11
Definition declarations.hpp:20
Definition concepts.hpp:28
Definition declarations.hpp:36
pRC::Float<> T
Definition externs_nonTT.hpp:1
Definition declarations.hpp:18
Size Index
Definition basics.hpp:32
std::size_t Size
Definition basics.hpp:31
static constexpr AddConst< X > & asConst(X &a)
Definition basics.hpp:71