9 for (
int i = 0;
auto &x : A) x = i++;
11 std::cout <<
"A_v = " << A_v << std::endl;
15 std::cout <<
"A_vv = " << A_vv << std::endl;
18 static_assert(std::is_same_v<
decltype(A_v)::value_type,
int>);
20 std::cout <<
"A = " << A << std::endl;
24 static_assert(std::is_same_v<
decltype(A_vc)::value_type,
const int>);
28 static_assert(std::is_same_v<
decltype(A_vvc)::value_type,
const int>);
32 std::cout <<
"A = " << A << std::endl;
35 auto S_1 = A(nda::range::all, nda::range(0, 5, 2));
36 std::cout <<
"S_1 = " << S_1 << std::endl;
39 auto S_2 = S_1(nda::range(0, 5, 2), nda::range::all);
40 std::cout <<
"S_2 = " << S_2 << std::endl;
43 auto S_3 = A(nda::range(0, 5, 2), nda::range(0, 5, 2));
44 std::cout <<
"S_3 = " << S_3 << std::endl;
51 std::cout <<
"S_3 = " << S_3 << std::endl;
54 std::cout <<
"S_1 = " << S_1 << std::endl;
55 std::cout <<
"A = " << A << std::endl;
59 std::cout <<
"A = " << A << std::endl;
63 std::cout <<
"S_3.data() == S_3_copy.data() = " << (S_3.data() == S_3_copy.data()) << std::endl;
66 auto S_3_move = std::move(S_3);
67 std::cout <<
"S_3.data() == S_3_move.data() = " << (S_3.data() == S_3_move.data()) << std::endl;
73 std::cout <<
"B = " << B << std::endl;
79 std::cout <<
"C = " << C << std::endl;
83 std::cout <<
"C = " << C << std::endl;
88 std::cout <<
"sum(S_3) = " <<
nda::sum(S_3) << std::endl;
91 std::cout <<
"S_3.data() == C_v.data() = " << (S_3.data() == C_v.
data()) << std::endl;
93 std::cout <<
"S_3.data() == C_v.data() = " << (S_3.data() == C_v.
data()) << std::endl;
96 std::array<double, 5> arr{1.0, 2.0, 3.0, 4.0, 5.0};
98 std::cout <<
"arr_v = " << arr_v << std::endl;
102 std::cout <<
"arr = (";
103 for (
auto x : arr) std::cout <<
" " << x;
104 std::cout <<
" )" << std::endl;
108 for (
int i = 0;
auto &x : D) x = i++;
109 std::cout <<
"D = " << D << std::endl;
113 std::cout <<
"D_t = " << D_t << std::endl;
117 std::cout <<
"D_r = " << D_r << std::endl;
121 std::cout <<
"D_tr = " << D_tr << std::endl;
125 std::cout <<
"D_t_flat = " << D_t_flat << std::endl;
129 std::cout <<
"D_flat = " << D_flat << std::endl;
A generic view of a multi-dimensional 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...
void rebind(basic_array_view< T, R, LP, A, AP, OP > v) noexcept
Rebind the current view to another view.
auto max_element(A const &a)
Find the maximum element of an array.
auto sum(A const &a)
Sum all the elements of an nda::Array object.
auto min_element(A const &a)
Find the minimum element of an array.
decltype(auto) make_regular(A &&a)
Make a given object regular.
auto flatten(A &&a)
Flatten an nda::basic_array or nda::basic_array_view to a 1-dimensional array/view by reshaping it.
auto transpose(A &&a)
Transpose the memory layout of an nda::MemoryArray or an nda::expr_call.
auto reshape(A &&a, std::array< Int, R > const &new_shape)
Reshape an nda::basic_array or nda::basic_array_view.
auto pow(A &&a, double p)
Function pow for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
basic_array_view< ValueType, Rank, Layout, 'A', default_accessor, borrowed<> > array_view
Alias template of an nda::basic_array_view with an 'A' algebra, nda::default_accessor and nda::borrow...
basic_array< ValueType, Rank, Layout, 'A', ContainerPolicy > array
Alias template of an nda::basic_array with an 'A' algebra.
Includes all relevant headers for the core nda library.