10 #include "gtest/gtest.h" 24 EBTerm z(
"z"), u(
"u"),
v(
"v"), w(
"w");
26 EBTerm
a(1),
b(4),
c(8.9);
35 H((
x)) = -
G((
x,
b)) +
c %
b;
37 EXPECT_EQ(std::string(H),
"-(x^2+4^1+3*4*-1)+8.9%4");
38 EXPECT_EQ(
G.args(),
"x,y");
45 H((
x,
y, z)) =
x *
y * z;
46 EXPECT_EQ(std::string(
G),
"x^y");
47 EXPECT_EQ(std::string(
G((
y,
x))),
"y^x");
48 EXPECT_EQ(std::string(H((z,
y,
x))),
"z*y*x");
53 G(
x,
y, z) =
x *
y * z;
54 H(u,
v, w,
x,
y, z) = u +
v + w +
x +
y + z;
56 EXPECT_EQ(std::string(
G(
a,
b,
c)),
"1*4*8.9");
57 EXPECT_EQ(std::string(H(
a,
b,
c,
a,
b,
c)),
"1+4+8.9+1+4+8.9");
58 EXPECT_EQ(std::string(
G(
a,
b,
c) + H(
a,
b,
c,
a,
b,
c)),
"1*4*8.9+1+4+8.9+1+4+8.9");
60 H(u,
v, w,
x,
y, z) = u +
v + w +
G(
y,
x,
x);
61 EXPECT_EQ(std::string(H(
a,
b,
c,
x,
y, z)),
"1+4+8.9+y*x*x");
66 EBTerm def =
x -
y - z;
67 EBTerm left = (
x -
y) - z;
68 EBTerm right =
x - (
y - z);
70 EXPECT_EQ(std::string(def),
"x-y-z");
71 EXPECT_EQ(std::string(left),
"x-y-z");
72 EXPECT_EQ(std::string(right),
"x-(y-z)");
77 EBTerm comp1 = (x < y) + (x >
y);
78 EBTerm comp2 = (x <= y) + (x >=
y);
79 EBTerm comp3 = (
x ==
y) + (
x !=
y);
81 EXPECT_EQ(std::string(comp1),
"(x<y)+(x>y)");
82 EXPECT_EQ(std::string(comp2),
"(x<=y)+(x>=y)");
83 EXPECT_EQ(std::string(comp3),
"(x=y)+(x!=y)");
88 EBTerm comp4 = atan2(
x,
y);
89 EXPECT_EQ(std::string(comp4),
"atan2(x,y)");
95 EXPECT_EQ(std::string(if1),
97 "(x<2*y,x*x+y,y*y+x)");
104 EXPECT_NE(std::string(temp1), std::string(temp2));
110 EBTerm u =
log(
x /
a);
111 u.substitute(EBLogPlogSubstitution(
b));
112 EXPECT_EQ(std::string(u),
"plog(x/1,4)");
116 v.substitute(EBTermSubstitution(
x,
a));
117 EXPECT_EQ(std::string(
v),
123 EBSubstitutionRuleList s(2);
124 EBTermSubstitution s0(
x,
y), s1(
y,
a);
128 EXPECT_EQ(std::string(w),
const std::vector< double > y
ExpressionBuilder adds an interface to derived classes that enables convenient construction of FParse...
static const std::string G
const std::vector< double > x
Real f(Real x)
Test function for Brents method.
TEST_F(ExpressionBuilderTest, test)
auto conditional(const C &, const L &, const R &)
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
static const std::string v