pRC
multi-purpose Tensor Train library for C++
Loading...
Searching...
No Matches
narrow.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_TENSOR_FUNCTIONS_NARROW_H
4#define pRC_CORE_TENSOR_FUNCTIONS_NARROW_H
5
8
9namespace pRC
10{
29 template<Index... Ns, class F, class... Xs,
31 If<IsSame<decltype(chip<Ns...>(
32 typename RemoveReference<Xs>::Sizes()))...>> = 0,
33 If<True<decltype(chip<Ns...>(makeSeries<Index,
35 static inline constexpr auto narrow(F &&f, Xs &&...args)
36 {
37 return expand(
39 Common<typename RemoveReference<Xs>::Dimension...>{}>()),
40 [&f, &args...](auto const... seq)
41 {
42 return exclude<seq...>(forward<F>(f), forward<Xs>(args)...);
43 });
44 }
45
64 template<class F, Index... Ns, class... Xs,
66 If<IsSame<decltype(chip<Ns...>(
67 typename RemoveReference<Xs>::Sizes()))...>> = 0,
68 If<True<decltype(chip<Ns...>(makeSeries<Index,
70 static inline constexpr auto narrow(Xs &&...args)
71 {
72 return narrow<Ns...>(F(), forward<Xs>(args)...);
73 }
74}
75#endif // pRC_CORE_TENSOR_FUNCTIONS_NARROW_H
Definition cholesky.hpp:18
std::remove_reference_t< T > RemoveReference
Definition type_traits.hpp:56
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
static constexpr auto makeSeries()
Definition sequence.hpp:361
typename CommonTypes< Ts... >::Type Common
Definition common.hpp:55
static constexpr Conditional< IsSatisfied< C >, RemoveConstReference< X >, X > copy(X &&a)
Definition copy.hpp:13
static constexpr auto chip(Sequence< T, Is... > const)
Definition sequence.hpp:561
static constexpr decltype(auto) expand(Sequence< T, Seq... > const, F &&f, Xs &&...args)
forwards the values in a pRC::Sequence to a function as parameters
Definition sequence.hpp:354
Size Index
Definition type_traits.hpp:21
static constexpr auto narrow(F &&f, Xs &&...args)
Performs an operation only along given dimensions of Tensors.
Definition narrow.hpp:35
static constexpr auto exclude(F &&f, Xs &&...args)
Definition exclude.hpp:43