3
0
mirror of https://github.com/triqs/dft_tools synced 2024-11-01 03:33:50 +01:00
dft_tools/doc/reference/arrays/play_with_concept_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

22 lines
643 B
C++

#include <triqs/arrays.hpp>
#include <triqs/arrays/make_immutable_array.hpp>
using triqs::arrays::array;
using triqs::arrays::range;
using triqs::clef::placeholder;
int main() {
placeholder<0> i_;
placeholder<1> j_;
auto a = make_immutable_array(1.0 / (2 + i_ + j_), i_ = range(0, 2), j_ = range(0, 2));
std::cout << "a = " << a << std::endl;
std::cout << "a = " << array<double, 2>(a) << std::endl;
// or if you prefer using a lambda...
auto b = make_immutable_array([](int i, int j) { return i - j; }, range(0, 2), range(0, 2));
std::cout << "b = " << b << std::endl;
std::cout << "b = " << array<double, 2>(b) << std::endl;
}