Definition at line 5 of file autodiff.C.
◆ CPPUNIT_TEST() [1/3]
◆ CPPUNIT_TEST() [2/3]
◆ CPPUNIT_TEST() [3/3]
FParserAutodiffTest::CPPUNIT_TEST |
( |
runTests |
| ) |
|
◆ CPPUNIT_TEST_SUITE()
◆ CPPUNIT_TEST_SUITE_END()
FParserAutodiffTest::CPPUNIT_TEST_SUITE_END |
( |
| ) |
|
◆ registerDerivativeRepeatTest()
void FParserAutodiffTest::registerDerivativeRepeatTest |
( |
| ) |
|
|
inline |
Definition at line 172 of file autodiff.C.
177 std::string func =
"x*a";
178 R.SetADFlags(FunctionParserAD::ADCacheDerivatives,
true);
181 R.Parse(func,
"x,a");
185 R.RegisterDerivative(
"a",
"x",
"a");
193 FunctionParserAD dR(R);
194 CPPUNIT_ASSERT_EQUAL (dR.AutoDiff(
"x"), -1);
198 FunctionParserAD d2R(dR);
199 CPPUNIT_ASSERT_EQUAL (d2R.AutoDiff(
"x"), -1);
204 for (x = -1.0; x < 1.0; x+=0.3726)
205 for (a = -1.0; a < 1.0; a+=0.2642)
206 for (y = -1.0; y < 1.0; y+=0.3156)
208 LIBMESH_ASSERT_FP_EQUAL(R.Eval(p), x*a, 1.e-12);
209 LIBMESH_ASSERT_FP_EQUAL(dR.Eval(p), a+x*a, 1.e-12);
210 LIBMESH_ASSERT_FP_EQUAL(d2R.Eval(p), 2*a+x*a, 1.e-12);
◆ registerDerivativeTest()
void FParserAutodiffTest::registerDerivativeTest |
( |
| ) |
|
|
inline |
Definition at line 132 of file autodiff.C.
135 std::string func =
"x*a";
136 R.SetADFlags(FunctionParserAD::ADCacheDerivatives,
true);
139 R.Parse(func,
"x,a");
143 R.RegisterDerivative(
"a",
"x",
"y");
151 FunctionParserAD dR(R);
152 CPPUNIT_ASSERT_EQUAL (dR.AutoDiff(
"x"), -1);
156 FunctionParserAD d2R(dR);
157 CPPUNIT_ASSERT_EQUAL (d2R.AutoDiff(
"x"), -1);
162 for (x = -1.0; x < 1.0; x+=0.3726)
163 for (a = -1.0; a < 1.0; a+=0.2642)
164 for (y = -1.0; y < 1.0; y+=0.3156)
166 LIBMESH_ASSERT_FP_EQUAL(R.Eval(p), x*a, 1.e-12);
167 LIBMESH_ASSERT_FP_EQUAL(dR.Eval(p), a+x*y, 1.e-12);
168 LIBMESH_ASSERT_FP_EQUAL(d2R.Eval(p), 2*y, 1.e-12);
◆ runTests()
void FParserAutodiffTest::runTests |
( |
| ) |
|
|
inline |
Definition at line 121 of file autodiff.C.
123 const unsigned int ntests =
tests.size();
125 unsigned int passed = 0;
126 for (
unsigned i = 0; i < ntests; ++i)
127 passed +=
tests[i].run() ? 1 : 0;
129 CPPUNIT_ASSERT_EQUAL (passed, ntests);
References tests.
◆ setUp()
virtual void FParserAutodiffTest::setUp |
( |
| ) |
|
|
inlinevirtual |
Definition at line 95 of file autodiff.C.
97 tests.push_back(ADTest(
"log(x*x) + log2(2*x) + log10(4*x)", 0.1, 3.0));
98 tests.push_back(ADTest(
"sin(-x) + cos(2*x) + tan(4*x)", -5.0, 5.0, 1e-7, 1e-5, 100));
99 tests.push_back(ADTest(
"sinh(-x) + cosh(x/2) + tanh(x/3)", -4.0, 4.0, 0.0001, 1e-5, 100));
100 tests.push_back(ADTest(
"plog(-x,0.01)", 0.001, 0.05, 0.00001, 1e-5, 100));
101 tests.push_back(ADTest(
"2 + 4*x + 8*x^2 + 16*x^3 + 32*x^4", -5.0, 5.0, 1e-5,1e-4));
102 tests.push_back(ADTest(
"1/x^2", 0.01, 2.0, 1e-8));
103 tests.push_back(ADTest(
"sqrt(x*2)", 0.001, 2.0, 1e-6));
104 tests.push_back(ADTest(
"abs(x*2)", -1.99, 2.0));
105 tests.push_back(ADTest(
"asin(-x)", -0.99, 0.99));
106 tests.push_back(ADTest(
"acos(-x)", -0.99, 0.99));
107 tests.push_back(ADTest(
"atan(-x)", -99, 99));
108 tests.push_back(ADTest(
"x*sin(-x)*log(x)*tanh(x)", 0.001, 5, 1e-8));
109 tests.push_back(ADTest(
"exp(-x) + 2*exp2(x)", -1.0, 2.0));
110 tests.push_back(ADTest(
"hypot(2*x,1) - hypot(1,4*x)", -10, 10.0));
111 tests.push_back(ADTest(
"if(x<0, (-x)^3, x^3)", -1.0, 1.0));
112 tests.push_back(ADTest(
"max(x^2-0.5,0)", -1.5, 1.5));
113 tests.push_back(ADTest(
"min(x^2-0.5,0)", -1.5, 1.5));
114 tests.push_back(ADTest(
"atan2(x,1) + atan2(2,x)", -0.99, 0.99));
115 tests.push_back(ADTest(
"0.767^sin(x)", -1.5, 1.5));
116 tests.push_back(ADTest(
"A := sin(x) + tanh(x); A + sqrt(A) - x", -1.5, 1.5));
117 tests.push_back(ADTest(
"3*sin(2*x)*sin(2*x)", -5.0, 5.0, 1e-7, 1e-5, 100));
118 tests.push_back(ADTest(
"erf(0.5*x)", -2., 2., 1e-6, 1e-5, 100));
References tests.
◆ tests
std::vector<ADTest> FParserAutodiffTest::tests |
|
private |
The documentation for this class was generated from the following file: