List of usage examples for java.lang StrictMath sin
public static native double sin(double a);
From source file:Main.java
public static void main(String[] args) { double d1 = (90 * Math.PI) / 180, d2 = 0.0, d3 = (1.0 / 0.0); System.out.println("Trigonometric sine of d1 = " + StrictMath.sin(d1)); System.out.println("Trigonometric sine of d2 = " + StrictMath.sin(d2)); System.out.println("Trigonometric sine of d3 = " + StrictMath.sin(d3)); }
From source file:net.nicoulaj.benchmarks.math.DoubleSin.java
@GenerateMicroBenchmark public void strictmath(BlackHole hole) { for (int i = 0; i < data.length - 1; i++) hole.consume(StrictMath.sin(data[i])); }
From source file:org.deidentifier.arx.risk.Gamma.java
/** * Approximates the trigamma function. Java port of the * "The Lightspeed Matlab toolbox" version 2.7 by Tom Minka see: * http://research.microsoft.com/en-us/um/people/minka/software/lightspeed/ * /*w w w .j a va 2s.co m*/ * @param x * input value * @return approximation of trigamma for x */ static double trigamma(double x) { /* Illegal arguments */ if (Double.isInfinite(x) || Double.isNaN(x)) { return Double.NaN; } /* Singularities */ if (x == 0.0d) { return Double.NEGATIVE_INFINITY; } /* Negative values */ /* * Use the derivative of the digamma reflection formula: -trigamma(-x) = * trigamma(x+1) - (pi*csc(pi*x))^2 */ if (x < 0.0d) { double r = StrictMath.PI / StrictMath.sin(-StrictMath.PI * x); return -trigamma(1.0d - x) + (r * r); } /* Use Taylor series if argument <= small */ if (x <= SMALL_TRIGAMMA) { return (1.0d / (x * x)) + TRIGAMMA_1 + (TETRAGAMMA_1 * x); } double result = 0.0d; /* Reduce to trigamma(x+n) where ( X + N ) >= B */ while (x < LARGE_TRIGAMMA) { result += 1.0d / (x * x); x++; } /* Apply asymptotic formula when X >= B */ /* This expansion can be computed in Maple via asympt(Psi(1,x),x) */ if (x >= LARGE_DIGAMMA) { double r = 1.0d / (x * x); result += (0.5d * r) + ((1.0d + (r * (B2 + (r * (B4 + (r * (B6 + (r * (B8 + (r * B10)))))))))) / x); } return result; }
From source file:org.esa.beam.util.math.FastMathPerformance.java
public void testSin() { System.gc();//from www. j a va 2s . c o m double x = 0; long time = System.nanoTime(); for (int i = 0; i < RUNS; i++) x += StrictMath.sin(i * F1); long strictTime = System.nanoTime() - time; System.gc(); double y = 0; time = System.nanoTime(); for (int i = 0; i < RUNS; i++) y += FastMath.sin(i * F1); long fastTime = System.nanoTime() - time; System.gc(); double z = 0; time = System.nanoTime(); for (int i = 0; i < RUNS; i++) z += Math.sin(i * F1); long mathTime = System.nanoTime() - time; report("sin", x + y + z, strictTime, fastTime, mathTime); }