1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.commons.nabla.forward;
18
19 import org.apache.commons.math3.util.FastMath;
20 import org.apache.commons.nabla.AbstractMathTest;
21 import org.junit.Test;
22
23 public class PowGeneratorTest extends AbstractMathTest {
24
25 @Test
26 public void testReference1(){
27 checkReference(new ReferenceFunction() {
28 public double value(double t) { return FastMath.pow(t, 3.0); }
29 public double firstDerivative(double t) { return 3 * FastMath.pow(t, 2.0); }
30 }, -2, 2, 50, 9.0e-16);
31 }
32
33 @Test
34 public void testReference2(){
35 checkReference(new ReferenceFunction() {
36 public double value(double t) { return FastMath.pow(3.0, t); }
37 public double firstDerivative(double t) { return FastMath.log(3) * FastMath.pow(3, t); }
38 }, -2, 2, 50, 6.0e-15);
39 }
40
41 @Test
42 public void testReference12(){
43 checkReference(new ReferenceFunction() {
44 public double value(double t) { return FastMath.pow(t, t); }
45 public double firstDerivative(double t) { return (1 + FastMath.log(t)) * FastMath.pow(t, t); }
46 }, 0.1, 3.0, 20, 2.0e-14);
47 }
48
49 }