Test of log2 method, of class FastMath.
()
| 54 | * Test of log2 method, of class FastMath. |
| 55 | */ |
| 56 | @Test |
| 57 | public void testLog2() |
| 58 | { |
| 59 | System.out.println("log2"); |
| 60 | DoubleList relErrs = new DoubleList(); |
| 61 | int trials = 10000; |
| 62 | for(int i = 0; i < trials; i++) |
| 63 | { |
| 64 | double x = rand.nextDouble()*1000; |
| 65 | relErrs.add(relErr(Math.log(x)/Math.log(2), FastMath.log2(x))); |
| 66 | } |
| 67 | Collections.sort(relErrs); |
| 68 | assertTrue(relErrs.get((int) (trials*.95)) <= 1e-3); |
| 69 | } |
| 70 | |
| 71 | /** |
| 72 | * Test of log2_2pd1 method, of class FastMath. |