mirror of
https://github.com/triqs/dft_tools
synced 2024-11-01 03:33:50 +01:00
2c542647fd
- change : all objects are by default stored now by reference, not by copy any more. Unless the trait force_copy_in_expr is true. - rvalue refs are moved into the tree - simplifies a lot the writing of lazy method, objects. - added a macro for methods - tests ok. Further check needed to control absence of copies... - improved documentation
42 lines
936 B
C++
42 lines
936 B
C++
#include "./common.hpp"
|
|
|
|
int main() {
|
|
F1 f(7);
|
|
|
|
TEST((x_ >> (2*x_ +1) )(10));
|
|
|
|
triqs::clef::function<double(double,double)> f2;
|
|
f2(x_,y_) = x_ + y_;
|
|
TEST(f2(2,3));
|
|
f2(x_,y_) << x_ + 2*y_;
|
|
TEST(f2(2,3));
|
|
|
|
std::function<double(double,double)> ff2(f2);
|
|
TEST(ff2(2,3));
|
|
|
|
triqs::clef::function<double(double)> f1 ( f(x_) + 2*x_ ,x_);
|
|
TEST(f1(3));
|
|
|
|
triqs::clef::function<double(double,double)> g2;
|
|
g2(x_,y_) << x_ - y_ + f2(x_,2*y_);
|
|
TEST(g2(2,3));
|
|
|
|
std::function<double(double,double)> ff8 = make_function( x_ + y_, x_, y_);
|
|
TEST(ff8(2,3));
|
|
|
|
std::function<double(double)> f3;
|
|
f3 = x_>> f(x_) + 2*x_;
|
|
TEST(f3(3));
|
|
|
|
auto h = make_function( 2*x_ + y_ + 1, x_);
|
|
// is a lazy expression expression with placeholder y_, returning a function...
|
|
std::cout << tql::eval(h, y_=1) << std::endl;
|
|
TEST(tql::eval( h, y_=1) (10));
|
|
TEST(h);
|
|
|
|
auto hh = var(x_, y_) >> 2*x_ + y_;
|
|
std::cout << hh (3,1) << std::endl;
|
|
|
|
}
|
|
|