TRIQS/nda
2.0.0
Multi-dimensional array library for C++
Toggle main menu visibility
Loading...
Searching...
No Matches
doc_math_expr.cpp
1
#include <
nda/nda.hpp
>
2
#include <iostream>
3
4
int
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
}
nda::make_regular
decltype(auto) make_regular(A &&a)
Make a given object regular.
Definition
basic_functions.hpp:225
nda::pow
auto pow(A &&a, double p)
Function pow for nda::ArrayOrScalar types (lazy and coefficient-wise for nda::Array types).
Definition
mapped_functions.hpp:76
nda::array
basic_array< ValueType, Rank, Layout, 'A', ContainerPolicy > array
Alias template of an nda::basic_array with an 'A' algebra.
Definition
declarations.hpp:64
nda.hpp
Includes all relevant headers for the core nda library.
doc
examples
doc_math_expr.cpp
Generated by
1.17.0