cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
tensor_product.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_VIEWS_TENSOR_PRODUCT_H
4#define pRC_CORE_TENSOR_VIEWS_TENSOR_PRODUCT_H
5
8
9namespace pRC::TensorViews
10{
11 template<class T, class N, class VA, class VB>
12 requires IsTensorView<VA> && IsTensorView<VB>
13 class TensorProduct : public View<T, N, TensorProduct<T, N, VA, VB>>
14 {
15 private:
17
18 public:
19 template<class XA, class XB>
22 TensorProduct(XA &&a, XB &&b)
23 : mA(forward<XA>(a))
24 , mB(forward<XB>(b))
25 {
26 }
27
28 template<IsConvertible<Index>... Is>
29 requires(sizeof...(Is) == Base::Dimension)
30 constexpr decltype(auto) operator()(Is const... indices)
31 {
32 return this->call(indices...);
33 }
34
35 template<IsConvertible<Index>... Is>
36 requires(sizeof...(Is) == Base::Dimension)
37 constexpr decltype(auto) operator()(Is const... indices) const
38 {
39 return this->call(indices...);
40 }
41
42 constexpr decltype(auto) operator()(
43 typename Base::Subscripts const &subscripts)
44 {
46 [this, &subscripts](auto const... seq) -> decltype(auto)
47 {
48 return mA(subscripts[seq]...);
49 }) *
51 [this, &subscripts](auto const... seq) -> decltype(auto)
52 {
53 return mB(subscripts[seq]...);
54 });
55 }
56
57 constexpr decltype(auto) operator()(
58 typename Base::Subscripts const &subscripts) const
59 {
61 [this, &subscripts](auto const... seq) -> decltype(auto)
62 {
63 return mA(subscripts[seq]...);
64 }) *
66 [this, &subscripts](auto const... seq) -> decltype(auto)
67 {
68 return mB(subscripts[seq]...);
69 });
70 }
71
72 constexpr decltype(auto) operator[](Index const index) = delete;
73 constexpr decltype(auto) operator[](Index const index) const = delete;
74
75 private:
76 VA mA;
77 VB mB;
78 };
79}
80#endif // pRC_CORE_TENSOR_VIEWS_TENSOR_PRODUCT_H
Definition tensor_product.hpp:14
TensorProduct(XA &&a, XB &&b)
Definition tensor_product.hpp:22
Definition declarations.hpp:20
Definition concepts.hpp:28
Definition declarations.hpp:18
Size Index
Definition basics.hpp:32
static constexpr auto makeSeries()
Definition sequence.hpp:390
static constexpr auto makeRange()
Definition sequence.hpp:421
static constexpr decltype(auto) expand(Sequence< T, Seq... > const, F &&f, Xs &&...args)
Definition sequence.hpp:383