3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-26 06:14:14 +01:00
dft_tools/doc/tutorials/array_tutorial_7.cpp
tayral edd1ff4529 Restructuring documentation.
A first general restructuration of the doc according to the pattern [tour|tutorial|reference].
In the reference part, objects are documented per topic.
In each topic, [definition|c++|python|hdf5] (not yet implemented)
2014-10-18 12:21:08 +01:00

23 lines
479 B
C++

#include <triqs/arrays.hpp>
#include <triqs/arrays/functional/map.hpp>
using triqs::arrays::array;
double f(int i) { return i * 10; }
int main() {
auto F = triqs::arrays::map(std::function<double(int)>(f));
array<int, 2> A(2, 2);
A() = 2;
array<double, 2> B, C;
A() = 2;
B = F(A);
C = F(2 * A); // works also with expressions of course
std::cout << "A = " << A << std::endl;
std::cout << "F(A) = " << B << std::endl;
std::cout << "F(2*A) = " << C << std::endl;
}