18
19
20
24#include "./clef/clef.hpp"
25#include "./declarations.hpp"
26#include "./exceptions.hpp"
27#include "./layout/for_each.hpp"
28#include "./mem/address_space.hpp"
29#include "./traits.hpp"
31#include <itertools/itertools.hpp>
44
45
46
49
50
51
52
53
54
55
56
57
58
59
60 template <
typename T, mem::
AddressSpace AdrSp = mem::Host,
std::integral Int,
auto Rank>
61 auto zeros(std::array<Int, Rank>
const &shape) {
62 static_assert(AdrSp != mem::None);
63 if constexpr (Rank == 0)
65 else if constexpr (AdrSp == mem::Host)
66 return array<T, Rank>::zeros(shape);
68 return cuarray<T, Rank>::zeros(shape);
72
73
74
75
76
77
78
79
80
81
82 template <
typename T, mem::
AddressSpace AdrSp = mem::Host,
std::integral... Ints>
84 return zeros<T, AdrSp>(std::array<
long,
sizeof...(Ints)>{
static_cast<
long>(is)...});
88
89
90
91
92
93
94
95
96
97
98 template <
typename T,
std::integral Int,
auto Rank>
99 auto ones(std::array<Int, Rank>
const &shape)
100 requires(nda::is_scalar_v<T>)
102 if constexpr (Rank == 0)
104 else {
return array<T, Rank>::ones(shape); }
108
109
110
111
112
113
114
115
116
117 template <
typename T,
std::integral... Ints>
119 return ones<T>(std::array<
long,
sizeof...(Ints)>{is...});
123
124
125
126
127
128
129
130
131 template <
std::integral Int =
long>
132 auto arange(
long first,
long last,
long step = 1) {
133 auto r = range(first, last, step);
134 auto a = array<Int, 1>(r.size());
135 for (
auto [x, v] : itertools::zip(a, r)) x = v;
140
141
142
143
144
145
146
147 template <
std::integral Int =
long>
149 return arange<Int>(0, last);
153
154
155
156
157
158
159
160
161
162
163
164 template <
typename RealType =
double,
std::integral Int,
auto Rank>
165 auto rand(std::array<Int, Rank>
const &shape)
166 requires(std::is_floating_point_v<RealType>)
168 if constexpr (Rank == 0) {
169 auto static gen = std::mt19937{};
170 auto static dist = std::uniform_real_distribution<>{0.0, 1.0};
173 return array<RealType, Rank>::rand(shape);
178
179
180
181
182
183
184
185
186
187
188 template <
typename RealType =
double,
std::integral... Ints>
190 return rand<RealType>(std::array<
long,
sizeof...(Ints)>{is...});
194
195
196
197
198
199
200
201
202
209
210
211
212
213
214
215
216
217
224
225
226
227
228
229
230
231
232
233
234
235
236
237 template <
typename A,
typename A_t = std::decay_t<A>>
239 if constexpr (Array<A>
and not is_regular_v<A>) {
241 }
else if constexpr (
requires {
typename A_t::regular_t; }) {
242 if constexpr (
not std::is_same_v<A_t,
typename A_t::regular_t>)
243 return typename A_t::regular_t{std::forward<A>(a)};
245 return std::forward<A>(a);
247 return std::forward<A>(a);
252
253
254
255
256
257
258
259
260 template <MemoryArray A>
262 if constexpr (
not mem::on_host<A>) {
263 return get_regular_host_t<A>{std::forward<A>(a)};
265 return std::forward<A>(a);
270
271
272
273
274
275
276
277
278 template <MemoryArray A>
280 if constexpr (
not mem::on_device<A>) {
281 return get_regular_device_t<A>{std::forward<A>(a)};
283 return std::forward<A>(a);
288
289
290
291
292
293
294
295
296 template <MemoryArray A>
298 if constexpr (
not mem::on_unified<A>) {
299 return get_regular_unified_t<A>{std::forward<A>(a)};
301 return std::forward<A>(a);
306
307
308
309
310
311
312
313
314
315
316
317 template <
typename A>
319 requires(is_regular_or_view_v<A>)
321 if (a.shape() == sha)
return;
322 if constexpr (is_regular_v<A>) {
325 NDA_RUNTIME_ERROR <<
"Error in nda::resize_or_check_if_view: Size mismatch: " << a.shape() <<
" != " << sha;
330
331
332
333
334
335
336
337
338
339
340
341 template <
typename T,
int R,
typename LP,
char A,
typename CP>
347
348
349
350
351
352
353
354
355
356
357
358
359 template <
typename T,
int R,
typename LP,
char A,
typename AP,
typename OP>
365
366
367
368
369
370
371
372
373
374
375
376 template <
typename T,
int R,
typename LP,
char A,
typename CP>
378 return array_view<T, R>{a};
382
383
384
385
386
387
388
389
390
391
392
393
394 template <
typename T,
int R,
typename LP,
char A,
typename AP,
typename OP>
396 return array_view<T, R>{a};
400
401
402
403
404
405
406
407
408
409
410
411 template <
typename T,
int R,
typename LP,
char A,
typename CP>
413 return array_const_view<T, R>{a};
417
418
419
420
421
422
423
424
425
426
427
428
429 template <
typename T,
int R,
typename LP,
char A,
typename AP,
typename OP>
431 return array_const_view<T, R>{a};
435
436
437
438
439
440
441
442
443
444
445
446 template <
typename T,
int R,
typename LP,
char A,
typename CP>
448 return matrix_view<T, LP>{a};
452
453
454
455
456
457
458
459
460
461
462
463
464 template <
typename T,
int R,
typename LP,
char A,
typename AP,
typename OP>
466 return matrix_view<T, LP>{a};
470
471
472
473
474
475
476
477
478
479 template <Array LHS, Array RHS>
483 static_assert(std::equality_comparable_with<get_value_t<LHS>, get_value_t<RHS>>,
484 "Error in nda::operator==: Only defined when elements are comparable");
486 if (lhs.shape() != rhs.shape())
return false;
488 nda::for_each(lhs.shape(), [&](
auto &&...x) { r &= (lhs(x...) == rhs(x...)); });
493
494
495
496
497
498
499
500
501
502 template <ArrayOfRank<1> A,
std::
ranges::contiguous_range R>
508
509
510
511
512
513
514
515
516
517 template <
std::
ranges::contiguous_range R, ArrayOfRank<1> A>
523
524
525
526
527
528
529
530
531 template <Array A,
typename F>
533 nda::for_each(a.shape(), [&a, &f](
auto &&...x) {
534 if constexpr (clef::is_function<std::decay_t<
decltype(f(x...))>>) {
535 clef_auto_assign(a(x...), f(x...));
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559 template <MemoryArray A>
562 using opt_t = std::optional<std::tuple<
int,
int,
int>>;
564 auto const &shape = a.indexmap().lengths();
565 auto const &strides = a.indexmap().strides();
566 auto const &order = a.indexmap().stride_order;
568 int data_size = shape[order[0]] * strides[order[0]];
569 int block_size = data_size;
570 int block_str = data_size;
573 for (
auto n : range(A::rank)) {
574 auto inner_size = (n == A::rank - 1) ? 1 : strides[order[n + 1]] * shape[order[n + 1]];
575 if (strides[order[n]] != inner_size) {
576 if (block_size < data_size)
579 n_blocks = a.size() / inner_size;
580 block_size = inner_size;
581 block_str = strides[order[n]];
584 ASSERT(n_blocks * block_size == a.size());
585 ASSERT(n_blocks * block_str == shape[order[0]] * strides[order[0]]);
586 return opt_t{std::make_tuple(n_blocks, block_size, block_str)};
590
591
592
593
594
595
596
597
598
599
600
601
602 template <size_t Axis = 0, Array A0, Array... As>
605 auto constexpr rank = A0::rank;
606 static_assert(Axis < rank);
607 static_assert(have_same_rank_v<A0, As...>);
608 static_assert(have_same_value_type_v<A0, As...>);
609 for (
auto ax [[maybe_unused]] : range(rank)) {
EXPECTS(ax == Axis
or ((a0.extent(ax) == as.extent(ax))
and ...
and true)); }
612 auto new_shape = a0.shape();
613 new_shape[Axis] = (as.extent(Axis) + ... + new_shape[Axis]);
614 auto new_array = array<get_value_t<A0>, rank>(new_shape);
617 auto slice_Axis = [](Array
auto &a, range r) {
618 auto all_or_range = std::make_tuple(range::all, r);
619 return [&]<
auto... Is>(std::index_sequence<Is...>) {
return a(std::get<Is == Axis>(all_or_range)...); }(std::make_index_sequence<rank>{});
625 slice_Axis(new_array, range(offset, offset + a_view.extent(Axis))) = a_view;
626 offset += a_view.extent(Axis);
void swap(nda::basic_array_view< V1, R1, LP1, A1, AP1, OP1 > &a, nda::basic_array_view< V2, R2, LP2, A2, AP2, OP2 > &b)=delete
std::swap is deleted for nda::basic_array_view.
Iterator for nda::basic_array and nda::basic_array_view types.
A generic view of a multi-dimensional array.
basic_array_view(A &&a) noexcept
Generic constructor from any nda::MemoryArray type.
const_iterator end() const noexcept
Get a const iterator to the end of the view/array.
ValueType const * data() const noexcept
Get a pointer to the actual data (in general this is not the beginning of the memory block for a view...
auto as_array_view() const
static constexpr bool is_stride_order_C() noexcept
Is the stride order of the view/array in C-order?
iterator begin() noexcept
Get an iterator to the beginning of the view/array.
ValueType * data() noexcept
Get a pointer to the actual data (in general this is not the beginning of thr memory block for a view...
basic_array_view & operator=(RHS const &rhs) noexcept
Assignment operator makes a deep copy of the contents of an nda::ArrayOfRank object.
auto & operator/=(RHS const &rhs) noexcept
Division assignment operator.
static constexpr int rank
Number of dimensions of the view.
decltype(auto) operator[](T const &idx) const &noexcept(has_no_boundcheck)
Subscript operator to access the 1-dimensional view/array.
auto const & shape() const noexcept
Get the shape of the view/array.
static __inline__ decltype(auto) call(Self &&self, Ts const &...idxs) noexcept(has_no_boundcheck)
Implementation of the function call operator.
basic_array_view(layout_t const &idxm, ValueType *p) noexcept
Construct a view from a bare pointer to some contiguous data and a memory layout.
__inline__ decltype(auto) operator()(Ts const &...idxs) &noexcept(has_no_boundcheck)
Non-const overload of nda::basic_array_view::operator()(Ts const &...) const &.
decltype(auto) operator[](T const &x) &&noexcept(has_no_boundcheck)
Rvalue overload of nda::basic_array_view::operator[](T const &) const &.
basic_array_view(R &rg) noexcept
Construct a 1-dimensional view of a general contiguous range.
basic_array_view & operator=(basic_array_view const &rhs) noexcept
Copy assignment operator makes a deep copy of the contents of the view.
basic_array_view(std::array< ValueType, N > &a) noexcept
Construct a 1-dimensional view of a std::array.
auto const & strides() const noexcept
Get the strides of the view/array (see nda::idx_map for more details on how we define strides).
long shape(int i) const noexcept
storage_t storage() &&noexcept
Get the data storage of the view/array.
decltype(auto) operator[](T const &x) &noexcept(has_no_boundcheck)
Non-const overload of nda::basic_array_view::operator[](T const &) const &.
decltype(auto) operator()(_linear_index_t idx) noexcept
Non-const overload of nda::basic_array_view::operator()(_linear_index_t) const.
auto & operator+=(RHS const &rhs) noexcept
Addition assignment operator.
auto indices() const noexcept
Get a range that generates all valid index tuples.
basic_array_view()=default
Default constructor constructs an empty view with a default constructed memory handle and layout.
long is_contiguous() const noexcept
Is the memory layout of the view/array contiguous?
auto & operator=(R const &rhs) noexcept
Assignment operator makes a deep copy of a general contiguous range and assigns it to the 1-dimension...
storage_t & storage() &noexcept
Get the data storage of the view/array.
static constexpr bool is_stride_order_Fortran() noexcept
Is the stride order of the view/array in Fortran-order?
decltype(auto) operator()(_linear_index_t idx) const noexcept
Access the element of the view/array at the given nda::_linear_index_t.
__inline__ decltype(auto) operator()(Ts const &...idxs) const &noexcept(has_no_boundcheck)
Function call operator to access the view/array.
auto & operator*=(RHS const &rhs) noexcept
Multiplication assignment operator.
basic_array_view(std::array< std::remove_const_t< ValueType >, N > const &a) noexcept
Construct a 1-dimensional view of a std::array.
friend void deep_swap(basic_array_view a, basic_array_view b) noexcept
Swap two views by swapping their data.
iterator end() noexcept
Get an iterator to the end of the view/array.
long size() const noexcept
Get the total size of the view/array.
auto & operator-=(RHS const &rhs) noexcept
Subtraction assignment operator.
bool empty() const
Is the view/array empty?
basic_array_view(std::array< long, Rank > const &shape, ValueType *p) noexcept
Construct a view from a bare pointer to some contiguous data and a shape.
bool is_empty() const noexcept
friend void swap(basic_array_view &a, basic_array_view &b) noexcept
Swap two views by swapping their memory handles and layouts.
constexpr auto stride_order() const noexcept
Get the stride order of the memory layout of the view/array (see nda::idx_map for more details on how...
const_iterator cbegin() const noexcept
Get a const iterator to the beginning of the view/array.
basic_array_view(layout_t const &idxm, storage_t st)
Construct a view from a given layout and memory handle.
static constexpr int iterator_rank
Rank of the nda::array_iterator for the view/array.
basic_array_view(basic_array_view &&)=default
Default move constructor moves the memory handle and layout.
void rebind(basic_array_view< T, R, LP, A, AP, OP > v) noexcept
Rebind the current view to another view.
basic_array_view(basic_array_view const &)=default
Default copy constructor copies the memory handle and layout.
__inline__ decltype(auto) operator()(Ts const &...idxs) &&noexcept(has_no_boundcheck)
Rvalue overload of nda::basic_array_view::operator()(Ts const &...) const &.
long extent(int i) const noexcept
Get the extent of the ith dimension.
constexpr auto const & indexmap() const noexcept
Get the memory layout of the view/array.
const_iterator begin() const noexcept
Get a const iterator to the beginning of the view/array.
const_iterator cend() const noexcept
Get a const iterator to the end of the view/array.
storage_t const & storage() const &noexcept
Get the data storage of the view/array.
A generic multi-dimensional array.
auto & operator+=(RHS const &rhs) noexcept
Addition assignment operator.
decltype(auto) operator[](T const &idx) const &noexcept(has_no_boundcheck)
Subscript operator to access the 1-dimensional view/array.
basic_array(basic_array< ValueType, 2, LayoutPolicy, A2, ContainerPolicy > &&a) noexcept
Construct a 2-dimensional array from another 2-dimensional array with a different algebra.
basic_array & operator=(RHS const &rhs)
Assignment operator makes a deep copy of an nda::ArrayOfRank object.
static constexpr bool is_stride_order_Fortran() noexcept
Is the stride order of the view/array in Fortran-order?
ValueType const * data() const noexcept
Get a pointer to the actual data (in general this is not the beginning of the memory block for a view...
ValueType * data() noexcept
Get a pointer to the actual data (in general this is not the beginning of thr memory block for a view...
long shape(int i) const noexcept
const_iterator cbegin() const noexcept
Get a const iterator to the beginning of the view/array.
static constexpr int rank
Number of dimensions of the array.
static constexpr bool is_stride_order_C() noexcept
Is the stride order of the view/array in C-order?
storage_t & storage() &noexcept
Get the data storage of the view/array.
basic_array(basic_array< ValueType, Rank, LayoutPolicy, A, CP > a) noexcept
Construct an array from another array with a different algebra and/or container policy.
auto const & strides() const noexcept
Get the strides of the view/array (see nda::idx_map for more details on how we define strides).
basic_array(Ints... is)
Construct an array with the given dimensions.
static basic_array ones(Ints... is)
Make a one-initialized array with the given dimensions.
const_iterator begin() const noexcept
Get a const iterator to the beginning of the view/array.
auto as_array_view() const
Convert the current array to a view with an 'A' (array) algebra.
long extent(int i) const noexcept
Get the extent of the ith dimension.
basic_array(std::initializer_list< ValueType > const &l)
Construct a 1-dimensional array from an initializer list.
decltype(auto) operator[](T const &x) &&noexcept(has_no_boundcheck)
Rvalue overload of nda::basic_array_view::operator[](T const &) const &.
long is_contiguous() const noexcept
Is the memory layout of the view/array contiguous?
basic_array(std::initializer_list< std::initializer_list< ValueType > > const &l2)
Construct a 2-dimensional array from a double nested initializer list.
decltype(auto) operator()(_linear_index_t idx) noexcept
Non-const overload of nda::basic_array_view::operator()(_linear_index_t) const.
__inline__ decltype(auto) operator()(Ts const &...idxs) &noexcept(has_no_boundcheck)
Non-const overload of nda::basic_array_view::operator()(Ts const &...) const &.
bool empty() const
Is the view/array empty?
void resize(std::array< long, Rank > const &shape)
Resize the array to a new shape.
basic_array(Int sz, RHS const &val)
Construct a 1-dimensional array with the given size and initialize each element to the given scalar v...
static basic_array ones(std::array< Int, Rank > const &shape)
Make a one-initialized array with the given shape.
constexpr auto stride_order() const noexcept
Get the stride order of the memory layout of the view/array (see nda::idx_map for more details on how...
auto & operator/=(RHS const &rhs) noexcept
Division assignment operator.
auto as_array_view()
Convert the current array to a view with an 'A' (array) algebra.
basic_array(A const &a)
Construct an array from an nda::ArrayOfRank object with the same rank by copying each element.
static basic_array zeros(Ints... is)
Make a zero-initialized array with the given dimensions.
auto indices() const noexcept
Get a range that generates all valid index tuples.
static __inline__ decltype(auto) call(Self &&self, Ts const &...idxs) noexcept(has_no_boundcheck)
Implementation of the function call operator.
void resize(Ints const &...is)
Resize the array to a new shape.
storage_t storage() &&noexcept
Get the data storage of the view/array.
basic_array()
Default constructor constructs an empty array with a default constructed memory handle and layout.
bool is_empty() const noexcept
auto & operator=(R const &rhs) noexcept
Assignment operator makes a deep copy of a general contiguous range and assigns it to the 1-dimension...
storage_t const & storage() const &noexcept
Get the data storage of the view/array.
basic_array & operator=(basic_array const &)=default
Default copy assignment copies the memory handle and layout from the right hand side array.
basic_array & operator=(basic_array< ValueType, Rank, LayoutPolicy, A, CP > const &rhs)
Assignment operator makes a deep copy of another array with a different algebra and/or container poli...
basic_array(basic_array const &a)=default
Default copy constructor copies the memory handle and layout.
basic_array(std::initializer_list< std::initializer_list< std::initializer_list< ValueType > > > const &l3)
Construct a 3-dimensional array from a triple nested initializer list.
iterator begin() noexcept
Get an iterator to the beginning of the view/array.
basic_array(layout_t const &layout)
Construct an array with the given memory layout.
static basic_array rand(Ints... is)
Make a random-initialized array with the given dimensions.
basic_array(layout_t const &layout, storage_t &&storage) noexcept
Construct an array with the given memory layout and with an existing memory handle/storage.
static constexpr int iterator_rank
Rank of the nda::array_iterator for the view/array.
auto & operator-=(RHS const &rhs) noexcept
Subtraction assignment operator.
const_iterator end() const noexcept
Get a const iterator to the end of the view/array.
basic_array(basic_array &&)=default
Default move constructor moves the memory handle and layout.
__inline__ decltype(auto) operator()(Ts const &...idxs) &&noexcept(has_no_boundcheck)
Rvalue overload of nda::basic_array_view::operator()(Ts const &...) const &.
basic_array(std::array< Int, Rank > const &shape)
Construct an array with the given shape.
const_iterator cend() const noexcept
Get a const iterator to the end of the view/array.
auto const & shape() const noexcept
Get the shape of the view/array.
long size() const noexcept
Get the total size of the view/array.
decltype(auto) operator[](T const &x) &noexcept(has_no_boundcheck)
Non-const overload of nda::basic_array_view::operator[](T const &) const &.
auto & operator*=(RHS const &rhs) noexcept
Multiplication assignment operator.
basic_array & operator=(basic_array &&)=default
Default move assignment moves the memory handle and layout from the right hand side array.
static basic_array zeros(std::array< Int, Rank > const &shape)
Make a zero-initialized array with the given shape.
__inline__ decltype(auto) operator()(Ts const &...idxs) const &noexcept(has_no_boundcheck)
Function call operator to access the view/array.
constexpr auto const & indexmap() const noexcept
Get the memory layout of the view/array.
iterator end() noexcept
Get an iterator to the end of the view/array.
decltype(auto) operator()(_linear_index_t idx) const noexcept
Access the element of the view/array at the given nda::_linear_index_t.
static basic_array rand(std::array< Int, Rank > const &shape)
Make a random-initialized array with the given shape.
#define CUSOLVER_CHECK(X, info,...)
#define NDA_RUNTIME_ERROR
auto rand(std::array< Int, Rank > const &shape)
Make an array of the given shape and initialize it with random values from the uniform distribution o...
decltype(auto) make_regular(A &&a)
Make a given object regular.
void resize_or_check_if_view(A &a, std::array< long, A::rank > const &sha)
Resize a given regular array to the given shape or check if a given view as the correct shape.
decltype(auto) to_unified(A &&a)
Convert an nda::MemoryArray to its regular type on unified memory.
auto make_const_view(basic_array< T, R, LP, A, CP > const &a)
Make an nda::basic_array_view with a const value type from a given nda::basic_array.
auto zeros(Ints... is)
Make an array of the given shape on the given address space and zero-initialize it.
auto zeros(std::array< Int, Rank > const &shape)
Make an array of the given shape on the given address space and zero-initialize it.
auto rand(Ints... is)
Make an array of the given dimensions and initialize it with random values from the uniform distribut...
auto arange(long first, long last, long step=1)
Make a 1-dimensional integer array and initialize it with values of a given nda::range.
decltype(auto) to_host(A &&a)
Convert an nda::MemoryArray to its regular type on host memory.
auto make_matrix_view(basic_array_view< T, R, LP, A, AP, OP > const &a)
Make an nda::matrix_view of a given nda::basic_array_view.
auto arange(long last)
Make a 1-dimensional integer array and initialize it with values of a given nda::range with a step si...
auto make_matrix_view(basic_array< T, R, LP, A, CP > const &a)
Make an nda::matrix_view of a given nda::basic_array.
auto ones(Ints... is)
Make an array with the given dimensions and one-initialize it.
auto make_const_view(basic_array_view< T, R, LP, A, AP, OP > const &a)
Make an nda::basic_array_view with a const value type from a given nda::basic_array_view.
decltype(auto) to_device(A &&a)
Convert an nda::MemoryArray to its regular type on device memory.
auto make_array_view(basic_array< T, R, LP, A, CP > const &a)
Make an nda::array_view of a given nda::basic_array.
auto make_array_const_view(basic_array< T, R, LP, A, CP > const &a)
Make an nda::array_const_view of a given nda::basic_array.
auto ones(std::array< Int, Rank > const &shape)
Make an array of the given shape and one-initialize it.
auto make_array_const_view(basic_array_view< T, R, LP, A, AP, OP > const &a)
Make an nda::array_const_view of a given nda::basic_array_view.
auto make_array_view(basic_array_view< T, R, LP, A, AP, OP > const &a)
Make an nda::array_view of a given nda::basic_array_view.
auto concatenate(A0 const &a0, As const &...as)
Join a sequence of nda::Array types along an existing axis.
long first_dim(A const &a)
Get the extent of the first dimension of the array.
constexpr uint64_t static_extents(int i0, Is... is)
Encode the given shape into a single integer using the nda::encode function.
bool operator==(LHS const &lhs, RHS const &rhs)
Equal-to comparison operator for two nda::Array objects.
long second_dim(A const &a)
Get the extent of the second dimension of the array.
void clef_auto_assign(A &&a, F &&f)
Overload of nda::clef::clef_auto_assign function for nda::Array objects.
auto get_block_layout(A const &a)
Check if a given nda::MemoryArray has a block-strided layout.
layout_prop_e
Compile-time guarantees of the memory layout of an array/view.
AddressSpace
Enum providing identifiers for the different memory address spaces.
static constexpr do_not_initialize_t do_not_initialize
Instance of nda::mem::do_not_initialize_t.
static constexpr init_zero_t init_zero
Instance of nda::mem::init_zero_t.
constexpr uint64_t encode(std::array< int, N > const &a)
Encode a std::array<int, N> in a uint64_t.
#define EXPECTS_WITH_MESSAGE(X,...)
Contiguous layout policy with C-order (row-major order).
A small wrapper around a single long integer to be used as a linear index.
Generic layout policy with arbitrary order.
Memory policy using an nda::mem::handle_borrowed.
Accessor type of the nda::default_accessor.
static __inline__ T * offset(pointer p, std::ptrdiff_t i) noexcept
Offset the pointer by a certain number of elements.
static __inline__ reference access(pointer p, std::ptrdiff_t i) noexcept
Access a specific element of the data.
Default accessor for various array and view types.
Tag used in constructors to indicate that the memory should be initialized to zero.
Accessor type of the nda::no_alias_accessor.
static __inline__ reference access(pointer p, std::ptrdiff_t i) noexcept
Access a specific element of the data.
static __inline__ T * offset(pointer p, std::ptrdiff_t i) noexcept
Offset the pointer by a certain number of elements.
Accessor for array and view types with no aliasing.