TRIQS/nda 2.0.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
doc_arith_expr.cpp
1#include <nda/nda.hpp>
2#include <iostream>
3
4int main() {
5 // create two arrays A and B
6 auto A = nda::array<int, 2>({{1, 2}, {3, 4}});
7 auto B = nda::array<int, 2>({{5, 6}, {7, 8}});
8
9 // add them elementwise
10 auto ex = A + B; // ex is an nda::expr object
11
12 // evaluate the lazy expression by constructing a new array
13 nda::array<int, 2> C = ex;
14 std::cout << C << std::endl;
15
16 // evaluate the lazy expression using nda::make_regular
17 auto D = nda::make_regular(ex);
18 std::cout << D << std::endl;
19}
decltype(auto) make_regular(A &&a)
Make a given object regular.
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.