cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
scale.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_FUNCTIONS_SCALE_H
4#define pRC_CORE_TENSOR_FUNCTIONS_SCALE_H
5
11
12namespace pRC
13{
14 template<class XA, class XB, IsTensorish RA = RemoveReference<XA>,
15 IsTensorish RB = RemoveReference<XB>>
16 requires(RA::Dimension == 0 || RB::Dimension == 0) &&
17 IsInvocable<TensorProduct, XA, XB>
18 static inline constexpr auto operator*(XA &&a, XB &&b)
19 {
20 return tensorProduct(forward<XA>(a), forward<XB>(b));
21 }
22
23 template<class XA, class XB, IsTensorish RA = RemoveReference<XA>,
24 IsTensorish RB = RemoveReference<XB>>
25 requires(RA::Dimension == 0 && RB::Dimension != 0) &&
26 IsInvocable<Div, typename RB::template ChangeType<typename RA::Type>,
27 XB>
28 static inline constexpr auto operator/(XA &&a, XB &&b)
29 {
31 forward<XA>(a)()) /
32 forward<XB>(b);
33 }
34
35 template<class XA, class XB, IsTensorish RA = RemoveReference<XA>,
36 IsTensorish RB = RemoveReference<XB>>
37 requires(RA::Dimension != 0 && RB::Dimension == 0) &&
38 IsInvocable<Div, XA,
39 typename RA::template ChangeType<typename RB::Type>>
40 static inline constexpr auto operator/(XA &&a, XB &&b)
41 {
42 return forward<XA>(a) /
44 forward<XB>(b)());
45 }
46
47 template<class XA, class XB, IsTensorish RA = RemoveReference<XA>,
48 class RB = RemoveReference<XB>>
49 requires IsDefined<Tensor<RB>> && IsInvocable<Mul, XA, Tensor<RB>>
50 static inline constexpr auto operator*(XA &&a, XB &&b)
51 {
52 return forward<XA>(a) * unit<Tensor<RB>>(forward<XB>(b));
53 }
54
55 template<class XA, class XB, class RA = RemoveReference<XA>,
56 IsTensorish RB = RemoveReference<XB>>
57 requires IsDefined<Tensor<RA>> && IsInvocable<Mul, Tensor<RA>, XB>
58 static inline constexpr auto operator*(XA &&a, XB &&b)
59 {
60 return unit<Tensor<RA>>(forward<XA>(a)) * forward<XB>(b);
61 }
62
63 template<class XA, class XB, IsTensorish RA = RemoveReference<XA>,
64 class RB = RemoveReference<XB>>
65 requires IsDefined<Tensor<RB>> && IsInvocable<Div, XA, Tensor<RB>>
66 static inline constexpr auto operator/(XA &&a, XB &&b)
67 {
68 return forward<XA>(a) / unit<Tensor<RB>>(forward<XB>(b));
69 }
70
71 template<class XA, class XB, class RA = RemoveReference<XA>,
72 IsTensorish RB = RemoveReference<XB>>
73 requires IsDefined<Tensor<RA>> && IsInvocable<Div, Tensor<RA>, XB>
74 static inline constexpr auto operator/(XA &&a, XB &&b)
75 {
76 return unit<Tensor<RA>>(forward<XA>(a)) / forward<XB>(b);
77 }
78}
79#endif // pRC_CORE_TENSOR_FUNCTIONS_SCALE_H
Definition cholesky.hpp:10
static constexpr auto unit()
Definition unit.hpp:13
static constexpr auto operator*(JacobiRotation< TA > const &a, JacobiRotation< TB > const &b)
Definition jacobi_rotation.hpp:298
static constexpr auto tensorProduct(XA &&a, XB &&b)
Definition tensor_product.hpp:17
static constexpr auto operator/(Sequence< T, As... > const, Sequence< T, Bs... > const)
Definition sequence.hpp:179