pRC
multi-purpose Tensor Train library for C++
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
27 template<Size... Bs, class X, class R = RemoveReference<X>,
29 If<IsSatisfied<(sizeof...(Bs) == typename R::Dimension())>> = 0>
30 static inline constexpr auto broadcast(X &&a)
31 {
33 return TensorViews::Broadcast<typename R::Type,
34 decltype(typename R::Sizes() * Sizes<Bs...>()), Sizes<Bs...>, V>(
35 view(forward<X>(a)));
36 }
37
54 template<Size... Bs, class X, class R = RemoveReference<X>,
56 If<IsInvocable<Broadcast<Bs...>, X &>> = 0>
57 static inline constexpr auto broadcast(X &&a)
58 {
59 return eval(broadcast<Bs...>(a));
60 }
61}
62#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 X view(X &&a)
Returns a TensorView obtained from a TensorView.
Definition view.hpp:22
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
std::size_t Size
Definition type_traits.hpp:20
static constexpr auto broadcast(X &&a)
Broadcasts a Tensor into one whose mode sizes are a multiple of the mode sizes of the original Tensor...
Definition broadcast.hpp:30
std::is_invocable< F, Args... > IsInvocable
Definition type_traits.hpp:134
Constant< Bool, B > IsSatisfied
Definition type_traits.hpp:71
static constexpr Conditional< IsSatisfied< C >, RemoveConstReference< X >, X > copy(X &&a)
Definition copy.hpp:13