cMHN 1.1
C++ library for learning MHNs with pRC
Loading...
Searching...
No Matches
print.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-2-Clause
2
3#ifndef pRC_CORE_CONTAINER_FUNCTIONS_PRINT_H
4#define pRC_CORE_CONTAINER_FUNCTIONS_PRINT_H
5
10
11namespace pRC
12{
13 template<class S>
14 static inline auto print(Allocation const alloc, S &&stream)
15 {
16 switch(alloc)
17 {
19 print("pRC::Allocation::Stack", stream);
20 break;
22 print("pRC::Allocation::Heap", stream);
23 break;
24 default:
25 print("pRC::Allocation::Unknown", stream);
26 break;
27 }
28 }
29 template<Size... Ns, class S>
30 static inline auto print(Subscripts<Ns...> const &a, S &&stream)
31 {
33
34 print("(", stream);
35 if constexpr(sizeof...(Ns) > 0)
36 {
37 print(a[0], stream);
38
39 expand(makeRange<Index, 1, sizeof...(Ns)>(),
40 [&a, &stream](auto const... seq)
41 {
42 ((print(", ", stream), print(a[seq], stream)), ...);
43 });
44 }
45 print(")", stream);
46 }
47
48 template<Size N, class S>
49 static inline auto print(Indices<N> const &a, S &&stream)
50 {
52
53 print("(", stream);
54 if constexpr(N > 0)
55 {
56 print(a[0], stream);
57
59 [&a, &stream](auto const... seq)
60 {
61 ((print(", ", stream), print(a[seq], stream)), ...);
62 });
63 }
64 print(")", stream);
65 }
66
67 template<Allocation A, class T, Size... Ns, class S>
68 static inline auto print(CommonArray<A, T, Ns...> const &arg, S &&stream)
69 {
71 print(":\n", stream);
72 range<Sizes<Ns...>>(
73 [&arg, &stream](auto const... indices)
74 {
76
77 print(": ", stream);
78 print(arg(indices...), stream);
79 print('\n', stream);
80 });
81 }
82}
83#endif // pRC_CORE_CONTAINER_FUNCTIONS_PRINT_H
Definition type_traits.hpp:49
Definition indices.hpp:15
Definition sequence.hpp:56
Definition subscripts.hpp:20
TN::Subscripts S
Definition externs_nonTT.hpp:9
pRC::Float<> T
Definition externs_nonTT.hpp:1
Definition cholesky.hpp:18
static constexpr auto arg(Complex< T > const &a)
Definition arg.hpp:12
static constexpr auto makeConstantSequence()
Definition sequence.hpp:402
Size Index
Definition type_traits.hpp:21
std::size_t Size
Definition type_traits.hpp:20
static auto print(String< N > const &string, std::FILE *stream)
Definition print.hpp:18
static constexpr auto range(F &&f, Xs &&...args)
Definition range.hpp:16
static constexpr auto makeRange()
Definition sequence.hpp:379
static auto alloc(Size size, Size const alignment=alignof(std::max_align_t))
Definition allocation.hpp:60
static constexpr auto name()
Definition type_name.hpp:11
Allocation
Definition allocation.hpp:19
static constexpr decltype(auto) expand(Sequence< T, Seq... > const, F &&f, Xs &&...args)
Definition sequence.hpp:344