10 for (
int i = 0;
auto &x : A) x = i++;
17 for (
int i = 0;
auto &x : B) x = i++;
20 std::cout <<
"A = " << A << std::endl;
21 std::cout <<
"A.size() = " << A.size() << std::endl;
22 std::cout <<
"A.shape() = " << A.shape() << std::endl;
23 std::cout << std::endl;
24 std::cout <<
"B = " << B << std::endl;
25 std::cout <<
"B.size() = " << B.size() << std::endl;
26 std::cout <<
"B.shape() = " << B.shape() << std::endl;
31 std::cout <<
"A = " << A << std::endl;
32 std::cout <<
"B = " << B << std::endl;
33 std::cout <<
"B(2, 1) = " << B(2, 1) << std::endl;
37 std::cout <<
"A = " << A << std::endl;
41 std::cout <<
"A = " << A << std::endl;
45 std::cout <<
"A_v =" << A_v << std::endl;
46 std::cout <<
"A_v.size() = " << A_v.size() << std::endl;
47 std::cout <<
"A_v.shape() = " << A_v.shape() << std::endl;
51 std::cout <<
"A = " << A << std::endl;
54 auto A_s = A(1, nda::range::all);
55 std::cout <<
"A_s = " << A_s << std::endl;
56 std::cout <<
"A_s.size() = " << A_s.size() << std::endl;
57 std::cout <<
"A_s.shape() = " << A_s.shape() << std::endl;
61 std::cout <<
"A_s = " << A_s << std::endl;
62 std::cout <<
"A = " << A << std::endl;
67 std::cout << C + D << std::endl;
72 std::cout <<
"E = " << E << std::endl;
78 std::cout <<
"nda::make_regular(C + D) = " <<
nda::make_regular(C + D) << std::endl;
90 std::cout <<
"C^2 =" << C_sq << std::endl;
94 std::cout <<
"sqrt(C^2) =" << C_sq_sqrt << std::endl;
97 std::cout <<
"trace(M1) = " <<
nda::trace(M1) << std::endl;
104 auto greater1 =
nda::map([](
int x) {
return x > 1; })(C);
105 std::cout <<
"any(C > 1) = " <<
nda::any(greater1) << std::endl;
106 std::cout <<
"all(C > 1) = " <<
nda::all(greater1) << std::endl;
109 std::cout <<
"sum(C) = " <<
nda::sum(C) << std::endl;
110 std::cout <<
"product(C) = " <<
nda::product(C) << std::endl;
113 h5::file out_file(
"ex1.h5",
'w');
114 h5::write(out_file,
"C", C);
118 h5::file in_file(
"ex1.h5",
'r');
119 h5::read(in_file,
"C", C_copy);
120 std::cout <<
"C_copy = " << C_copy << std::endl;
127 std::cout <<
"M3_inv = " << M3_inv << std::endl;
133 std::cout <<
"M3_inv2 = " << M3_inv2 << std::endl;
136 std::cout <<
"M3 * M3_inv = " << M3 * M3_inv << std::endl;
137 std::cout <<
"M3_inv * M3 = " << M3_inv * M3 << std::endl;
142 std::cout <<
"M3 * x = " << M3 * x << std::endl;
145 using namespace nda::clef::literals;
148 std::cout <<
"F = " << F << std::endl;
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.
bool any(A const &a)
Does any of the elements of the array evaluate to true?
auto product(A const &a)
Multiply all the elements of an nda::Array object.
auto min_element(A const &a)
Find the minimum element of an array.
bool all(A const &a)
Do all elements of the array evaluate to true?
decltype(auto) make_regular(A &&a)
Make a given object regular.
auto trace(M const &m)
Get the trace of a 2-dimensional square array/view.
auto pow(A &&a, double p)
Function pow for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
auto sqrt(A &&a)
Function sqrt for non-matrix nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types...
mapped< F > map(F f)
Create a lazy function call expression on arrays/views.
basic_array< ValueType, Rank, Layout, 'A', ContainerPolicy > array
Alias template of an nda::basic_array with an 'A' algebra.
basic_array< ValueType, 1, C_layout, 'V', ContainerPolicy > vector
Alias template of an nda::basic_array with rank 1 and a 'V' algebra.
basic_array< ValueType, 2, Layout, 'M', ContainerPolicy > matrix
Alias template of an nda::basic_array with rank 2 and an 'M' algebra.
constexpr auto j_
Generic placeholder #2.
constexpr auto i_
Generic placeholder #1.
Provides HDF5 support for the nda library.
Includes all relevant headers for the linear algebra functionality.
Includes all relevant headers for the core nda library.