Source: tests/expression/UserExpression.cpp
19 #include <tests/myratest.h> 24 class PascalExpression
29 const static int Arity=2;
30 typedef double Number;
33 PascalExpression(
int in_N)
38 {
return make_Index(N,N); }
51 static double choose(
int n,
int k)
54 for (
int i = 1; i <= k; ++i)
56 answer *=
static_cast<double>(n-k+i);
57 answer /=
static_cast<double>(i);
67 ADD_TEST(
"UserExpression",
"[expression]")
70 myra::out() << E << std::endl;
Adapts user code (encapsulated in a class) into an Expression.
Expression< UserClass::Arity, typename UserClass::Number > make_UserExpression(const UserClass &u)
Helper function to adapt some user code (encapsulated in a class) into an Expression.
Definition: UserExpression.h:58
Implementation detail of Expression templates.
An interface used to fill containers from Expression's (see Matrix::evaluate(), for example)...
Prints an Expression, by evaluate()'ing it at every Index i.
Results: [PASS]
size 10 by 10 arity-2 Expression of double:
[ 1 1 1 1 1 1 1 1 1 1 ]
[ 1 2 3 4 5 6 7 8 9 10 ]
[ 1 3 6 10 15 21 28 36 45 55 ]
[ 1 4 10 20 35 56 84 120 165 220 ]
[ 1 5 15 35 70 126 210 330 495 715 ]
[ 1 6 21 56 126 252 462 792 1287 2002 ]
[ 1 7 28 84 210 462 924 1716 3003 5005 ]
[ 1 8 36 120 330 792 1716 3432 6435 11440 ]
[ 1 9 45 165 495 1287 3003 6435 12870 24310 ]
[ 1 10 55 220 715 2002 5005 11440 24310 48620 ]
Go back to Summary of /test programs.