MCPcopy Index your code
hub / github.com/EdwardRaff/JSAT / testPow

Method testPow

JSAT/test/jsat/math/FastMathTest.java:140–158  ·  view source on GitHub ↗

Test of pow method, of class FastMath.

()

Source from the content-addressed store, hash-verified

138 * Test of pow method, of class FastMath.
139 */
140 @Test
141 public void testPow()
142 {
143 System.out.println("pow");
144 DoubleList relErrs = new DoubleList();
145 int trials = 10000;
146 for(int i = 0; i < trials; i++)
147 {
148 double x = rand.nextDouble()*20;
149 double y = rand.nextDouble()*20;
150 relErrs.add(relErr(Math.pow(y, x), FastMath.pow(y, x)));
151 }
152 Collections.sort(relErrs);
153 //most should have lowwer rel error for best cases
154 assertTrue(relErrs.get((int) (trials*.10)) <= 1e-4);//usually does better than this
155 assertTrue(relErrs.get((int) (trials*.50)) <= 1e-3);
156 assertTrue(relErrs.get((int) (trials*.75)) <= 1e-2);
157 assertTrue(relErrs.get((int) (trials*.95)) <= 1e-1);
158 }
159
160 /**
161 * Test of log method, of class FastMath.

Callers

nothing calls this directly

Calls 6

addMethod · 0.95
relErrMethod · 0.95
powMethod · 0.95
getMethod · 0.95
nextDoubleMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected