cMHN 1.1
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_FUNCTIONS_BROADCAST_H
4#define pRC_CORE_TENSOR_FUNCTIONS_BROADCAST_H
5
8
9namespace pRC
10{
11 template<Size... Bs>
12 struct Broadcast;
13
14 template<Size... Bs, class X, class R = RemoveReference<X>,
16 If<IsSatisfied<(sizeof...(Bs) == typename R::Dimension())>> = 0>
17 static inline constexpr auto broadcast(X &&a)
18 {
20 return TensorViews::Broadcast<typename R::Type,
21 decltype(typename R::Sizes() * Sizes<Bs...>()), Sizes<Bs...>, V>(
22 view(forward<X>(a)));
23 }
24
25 template<Size... Bs, class X, class R = RemoveReference<X>,
27 If<IsInvocable<Broadcast<Bs...>, X &>> = 0>
28 static inline constexpr auto broadcast(X &&a)
29 {
30 return eval(broadcast<Bs...>(a));
31 }
32}
33#endif // pRC_CORE_TENSOR_FUNCTIONS_BROADCAST_H
Definition sequence.hpp:56
Definition broadcast.hpp:11
Definition cholesky.hpp:18
static constexpr X eval(X &&a)
Definition eval.hpp:11
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
std::size_t Size
Definition type_traits.hpp:20
static constexpr X view(X &&a)
Definition view.hpp:12
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
Constant< Bool, B > IsSatisfied
Definition type_traits.hpp:71
static constexpr auto broadcast(X &&a)
Definition broadcast.hpp:17
std::is_invocable< F, Args... > IsInvocable
Definition type_traits.hpp:134