cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
add.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_TENSOR_TRAIN_TENSOR_FUNCTIONS_ADD_H
4#define pRC_TENSOR_TRAIN_TENSOR_FUNCTIONS_ADD_H
5
8
9namespace pRC
10{
11 template<class XA, class XB,
12 TensorTrain::IsTensorish RA = RemoveReference<XA>,
13 TensorTrain::IsTensorish RB = RemoveReference<XB>>
14 requires IsSame<typename RA::Sizes, typename RB::Sizes>
15 static inline constexpr auto operator+(XA &&a, XB &&b)
16 {
17 return enumerate(
18 []<Index C>(auto &&...args) -> decltype(auto)
19 {
20 if constexpr(C == 0)
21 {
23 forward<decltype(args)>(args)...);
24 }
25 else if constexpr(C == RA::Dimension - 1 &&
26 C == RB::Dimension - 1)
27 {
29 forward<decltype(args)>(args)...));
30 }
31 else
32 {
34 forward<decltype(args)>(args)...));
35 }
36 },
37 forward<XA>(a), forward<XB>(b));
38 }
39}
40#endif // pRC_TENSOR_TRAIN_TENSOR_FUNCTIONS_ADD_H
Definition cholesky.hpp:10
Size Index
Definition basics.hpp:32
std::remove_reference_t< T > RemoveReference
Definition basics.hpp:41
static constexpr auto enumerate(F &&f, Xs &&...args)
Definition enumerate.hpp:21
static constexpr auto permute(Sequence< T, Is... > const)
Definition sequence.hpp:487
static constexpr auto exclude(F &&f, Xs &&...args)
Definition exclude.hpp:20
static constexpr auto operator+(Sequence< T, As... > const, Sequence< T, Bs... > const)
Definition sequence.hpp:107