cMHN 1.2
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
loop.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_TENSOR_TRAIN_OPERATOR_VIEWS_LOOP_H
4#define pRC_TENSOR_TRAIN_OPERATOR_VIEWS_LOOP_H
5
9
11{
12 template<class T, class M, class N, class Ranks, class F, class... Vs>
13 requires((IsTensorView<Vs> || IsOperatorView<Vs>) && ...)
14 class Loop
15 : public Conditional<
17 ResultOf<F, decltype(declval<Vs>().template core<0>())...>>,
18 Assignable<T, M, N, Ranks, Loop<T, M, N, Ranks, F, Vs...>>,
19 View<T, M, N, Ranks, Loop<T, M, N, Ranks, F, Vs...>>>
20 {
21 private:
22 using Base =
24 decltype(declval<Vs>().template core<0>())...>>,
26
27 public:
28 template<class... Xs>
29 requires(IsSame<Vs, RemoveReference<Xs>> && ...)
30 Loop(F f, Xs &&...args)
31 : mF(forward<F>(f))
32 , mArgs(forward<Xs>(args)...)
33 {
34 }
35
36 using Base::operator=;
37
38 template<Index C>
39 constexpr decltype(auto) core()
40 {
42 [this](auto const... ops) -> decltype(auto)
43 {
44 return mF(get<ops>(mArgs).template core<C>()...);
45 });
46 }
47
48 template<Index C>
49 constexpr decltype(auto) core() const
50 {
52 [this](auto const... ops) -> decltype(auto)
53 {
54 return mF(get<ops>(mArgs).template core<C>()...);
55 });
56 }
57
58 private:
59 F mF;
60 Tuple<Vs...> mArgs;
61 };
62}
63#endif // pRC_TENSOR_TRAIN_OPERATOR_VIEWS_LOOP_H
Definition gtest_unittest.cc:5120
Definition value.hpp:12
constexpr decltype(auto) core()
Definition loop.hpp:39
constexpr decltype(auto) core() const
Definition loop.hpp:49
Definition declarations.hpp:25
Definition concepts.hpp:40
Definition concepts.hpp:28
pRC::Float<> T
Definition externs_nonTT.hpp:1
Definition declarations.hpp:23
static constexpr auto makeSeriesFor()
Definition sequence.hpp:399
std::tuple< Ts... > Tuple
Definition basics.hpp:23
std::invoke_result_t< F, Args... > ResultOf
Definition basics.hpp:59
std::conditional_t< B, T, F > Conditional
Definition basics.hpp:56
static constexpr decltype(auto) expand(Sequence< T, Seq... > const, F &&f, Xs &&...args)
Definition sequence.hpp:383