Test of pow2 method, of class FastMath.
()
| 119 | * Test of pow2 method, of class FastMath. |
| 120 | */ |
| 121 | @Test |
| 122 | public void testPow2_double() |
| 123 | { |
| 124 | System.out.println("pow2"); |
| 125 | DoubleList relErrs = new DoubleList(); |
| 126 | int trials = 10000; |
| 127 | for(int i = 0; i < trials; i++) |
| 128 | { |
| 129 | double x = rand.nextDouble()*20; |
| 130 | relErrs.add(relErr(Math.pow(2, x), FastMath.pow2(x))); |
| 131 | } |
| 132 | Collections.sort(relErrs); |
| 133 | assertTrue(relErrs.get((int) (trials*.95)) <= 1e-3); |
| 134 | |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Test of pow method, of class FastMath. |