cMHN 1.2
C++ library for learning MHNs with pRC
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
7
8namespace pRC
9{
10 template<Index... Ns, class F, class... Xs>
11 requires(IsTensorish<RemoveReference<Xs>> && ...) &&
12 (sizeof...(Xs) > 0) &&
13 ((chip<Ns...>(typename TupleElement<0,
15 chip<Ns...>(RemoveReference<Xs>::Sizes())) &&
16 ...)
17 static inline constexpr auto narrow(F &&f, Xs &&...args)
18 {
19 return expand(
21 Common<typename RemoveReference<Xs>::Dimension...>{}>()),
22 [&f, &args...](auto const... seq)
23 {
24 return exclude<seq...>(forward<F>(f), forward<Xs>(args)...);
25 });
26 }
27
28 template<class F, Index... Ns, class... Xs>
29 requires(IsTensorish<RemoveReference<Xs>> && ...) &&
30 requires { narrow<Ns...>(declval<F>(), declval<Xs>()...); }
31 static inline constexpr auto exclude(Xs &&...args)
32 {
33 return narrow<Ns...>(F(), forward<Xs>(args)...);
34 }
35}
36#endif // pRC_CORE_TENSOR_FUNCTIONS_NARROW_H
Definition cholesky.hpp:10
Size Index
Definition basics.hpp:32
std::tuple< Ts... > Tuple
Definition basics.hpp:23
std::remove_reference_t< T > RemoveReference
Definition basics.hpp:41
std::tuple_element_t< I, T > TupleElement
Definition basics.hpp:26
std::common_type_t< Ts... > Common
Definition basics.hpp:53
Sequence< Size, Ns... > Sizes
Definition sequence.hpp:100
static constexpr auto makeSeries()
Definition sequence.hpp:390
static constexpr auto chip(Sequence< T, Is... > const)
Definition sequence.hpp:584
static constexpr auto exclude(F &&f, Xs &&...args)
Definition exclude.hpp:20
static constexpr decltype(auto) expand(Sequence< T, Seq... > const, F &&f, Xs &&...args)
Definition sequence.hpp:383
static constexpr auto narrow(F &&f, Xs &&...args)
Definition narrow.hpp:17