3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-27 06:43:40 +01:00
dft_tools/doc/reference/arrays/play_with_concept_0.cpp

22 lines
643 B
C++
Raw Normal View History

#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;
}