pRC
multi-purpose Tensor Train library for C++
Loading...
Searching...
No Matches
from_cores.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_TENSOR_TRAIN_COMMON_FUNCTIONS_FROM_CORES_H
4#define pRC_TENSOR_TRAIN_COMMON_FUNCTIONS_FROM_CORES_H
5
9
11{
12 template<class... Xs, If<All<pRC::IsTensorish<RemoveReference<Xs>>...>> = 0>
13 static inline constexpr auto fromCores(Xs &&...cores)
14 {
15 constexpr auto Dimension = sizeof...(Xs);
17
18 auto ret = []()
19 {
21 3)
22 {
23 using N = Sizes<RemoveReference<Xs>::size(1)...>;
24 using Ranks =
27 decltype(chip<Dimension - 1>(
29
31 }
33 4)
34 {
35 using M = Sizes<RemoveReference<Xs>::size(1)...>;
36 using N = Sizes<RemoveReference<Xs>::size(2)...>;
37 using Ranks =
40 decltype(chip<Dimension - 1>(
42
44 }
45 }();
46
48 [&ret, &cores...](auto const... seq)
49 {
50 ((ret.template core<seq>() = forward<Xs>(cores)), ...);
51 });
52
53 return ret;
54 }
55}
56#endif // pRC_TENSOR_TRAIN_COMMON_FUNCTIONS_FROM_CORES_H
Definition sequence.hpp:56
static constexpr auto size()
Definition sequence.hpp:88
Definition type_traits.hpp:17
Definition type_traits.hpp:17
Definition from_cores.hpp:11
static constexpr auto fromCores(Xs &&...cores)
Definition from_cores.hpp:13
std::remove_reference_t< T > RemoveReference
Definition type_traits.hpp:56
std::enable_if_t< B{}, int > If
Definition type_traits.hpp:68
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 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