3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-26 14:23:38 +01:00
dft_tools/doc/reference/arrays/map_0.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

19 lines
526 B
C++

#include <triqs/arrays.hpp>
using namespace triqs;
int main() {
// declare and init a matrix
clef::placeholder<0> i_;
clef::placeholder<1> j_;
arrays::matrix<int> A(2, 2);
A(i_, j_) << i_ + j_;
// the mapped function
auto F = arrays::map([](int i) { return i * 2.5; });
std::cout << "A = " << A << std::endl;
std::cout << "F(A) = " << F(A) << std::endl; // oops no computation done
std::cout << "F(A) = " << make_matrix(F(A)) << std::endl;
std::cout << "3*F(2*A) = " << make_matrix(3 * F(2 * A)) << std::endl;
}