18
19
20
24#include "./arithmetic.hpp"
25#include "./concepts.hpp"
26#include "./array_adapter.hpp"
27#include "./layout/idx_map.hpp"
28#include "./layout/permutation.hpp"
30#include "./traits.hpp"
38
39
40
43
44
45
46
47
48
55
56
57
58
59
60
61
62
63
64
65 template <
int Rank, uint64_t StaticExtents, uint64_t StrideOrder,
layout_prop_e LayoutProp>
66 std::ostream &operator<<(std::ostream &sout,
idx_map<Rank, StaticExtents, StrideOrder, LayoutProp>
const &idxm) {
67 return sout <<
" Lengths : " << idxm.lengths() <<
"\n"
68 <<
" Strides : " << idxm.strides() <<
"\n"
69 <<
" StaticExtents : " << decode<Rank>(StaticExtents) <<
"\n"
70 <<
" MemoryStrideOrder : " << idxm.stride_order <<
"\n"
71 <<
" Flags : " << LayoutProp <<
"\n";
77
78
79
82
83
84
85
86
87
88
90 std::ostream &operator<<(std::ostream &sout, A
const &a)
91 requires(is_regular_or_view_v<A>)
94 if constexpr (A::rank == 1) {
96 auto const &len = a.indexmap().lengths();
97 for (size_t i = 0; i < len[0]; ++i) sout << (i > 0 ?
"," :
"") << a(i);
102 if constexpr (A::rank == 2) {
103 auto const &len = a.indexmap().lengths();
105 for (size_t i = 0; i < len[0]; ++i) {
106 sout << (i == 0 ?
"[" :
" [");
107 for (size_t j = 0; j < len[1]; ++j) sout << (j > 0 ?
"," :
"") << a(i, j);
108 sout <<
"]" << (i == len[0] - 1 ?
"" :
"\n");
115 if constexpr (A::rank > 2) {
117 for (
bool first =
true;
auto &v : a) {
118 sout << (first ?
"" :
",") << v;
128
129
130
131
132
133
134
135
136 template <
int R,
typename F>
137 std::ostream &operator<<(std::ostream &sout,
array_adapter<R, F>
const &aa) {
138 return sout <<
"array_adapter of shape " << aa.shape();
143 template <
char OP, Array A>
146 template <
char OP, ArrayOrScalar L, ArrayOrScalar R>
151
152
153
154
155
156
157
158
159 template <
char OP, Array A>
160 std::ostream &operator<<(std::ostream &sout,
expr_unary<OP, A>
const &ex) {
161 return sout << OP << ex.a;
165
166
167
168
169
170
171
172
173
174 template <
char OP, ArrayOrScalar L, ArrayOrScalar R>
175 std::ostream &operator<<(std::ostream &sout,
expr<OP, L, R>
const &ex) {
176 return sout <<
"(" << ex.l <<
" " << OP <<
" " << ex.r <<
")";
180
181
182
183
184
185
186
187 template <
typename F,
typename... As>
188 std::ostream &operator<<(std::ostream &sout,
expr_call<F, As...>
const &) {
189 return sout <<
"mapped";
Adapter that consists of a shape and a callable object, which takes R integers as arguments (just lik...
Layout that specifies how to map multi-dimensional indices to a linear/flat index.
constexpr bool has_contiguous(layout_prop_e lp)
Checks if a layout property has the contiguous property.
constexpr bool has_strided_1d(layout_prop_e lp)
Checks if a layout property has the strided_1d property.
constexpr bool has_smallest_stride_is_one(layout_prop_e lp)
Checks if a layout property has the smallest_stride_is_one property.
layout_prop_e
Compile-time guarantees of the memory layout of an array/view.
A lazy function call expression on arrays/views.
Lazy unary expression for nda::Array types.
Lazy binary expression for nda::ArrayOrScalar types.