TRIQS/nda 2.0.0
Multi-dimensional array library for C++
Loading...
Searching...
No Matches
doc_math_expr.cpp
1#include <nda/nda.hpp>
2#include <iostream>
3
4int main() {
5 // create an array A
6 auto A = nda::array<int, 2>({{1, 2}, {3, 4}});
7
8 // square the elements of A
9 auto ex = nda::pow(A, 2); // ex is a lazy expression
10
11 // evaluate the lazy expression by constructing a new array
12 nda::array<int, 2> A_sq = ex;
13 std::cout << A_sq << std::endl;
14
15 // evaluate the lazy expression using nda::make_regular
16 std::cout << nda::make_regular(ex) << std::endl;
17}
decltype(auto) make_regular(A &&a)
Make a given object regular.
auto pow(A &&a, double p)
Function pow for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
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.