3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-26 14:23:38 +01:00
dft_tools/test/triqs/clef/math_functions.cpp
Olivier Parcollet f2c7d449cc First commit : triqs libs version 1.0 alpha1
for earlier commits, see TRIQS0.x repository.
2013-07-17 19:24:07 +02:00

41 lines
1.1 KiB
C++

#include "./common.hpp"
#include <triqs/clef/adapters/vector.hpp>
double foo(double x) { return x/2;}
int foo(int x) { return x/2;}
double bar(double x, double y) { return x+y;}
namespace triqs { namespace clef {
using ::foo;
using ::bar;
template<typename T>
typename std::enable_if<!triqs::clef::is_any_lazy<T>::value,T>::type
inc (T const & x) { return x+1;}
// using ::inc;
// moving the declaration up and using using:: does not work on gcc4.4
// however not using using:: does not work on icc 11 !
TRIQS_CLEF_MAKE_FNT_LAZY (bar) ;
TRIQS_CLEF_MAKE_FNT_LAZY ( inc) ;
TRIQS_CLEF_MAKE_FNT_LAZY ( foo) ;
}}
namespace tql= triqs::clef;
int main() {
using std::cout; using std::endl;
TEST ( tql::eval ( cos(x_) ,x_=2) );
TEST ( tql::eval ( cos(2*x_+1) ,x_=2) );
TEST ( tql::eval ( abs(2*x_-1) ,x_=2) );
TEST ( tql::eval ( abs(2*x_-1) ,x_=-2) );
TEST ( tql::eval ( floor(2*x_-1) ,x_=2.3) );
TEST ( tql::eval ( pow(2*x_+1,2) ,x_=2.0) );
TEST ( tql::eval ( foo(2*x_+1) , x_ = 2) );
TEST ( tql::eval ( foo(2*x_+1) , x_ = 2.0) );
TEST ( tql::eval ( bar(2*x_+1,x_ -1) , x_ = 2) );
TEST ( tql::eval ( inc(2*x_+1) , x_ = 2) );
}