Example usage for java.lang StrictMath cos

List of usage examples for java.lang StrictMath cos

Introduction

In this page you can find the example usage for java.lang StrictMath cos.

Prototype

public static native double cos(double a);

Source Link

Document

Returns the trigonometric cosine of an angle.

Usage

From source file:Main.java

public static void main(String[] args) {

    double d1 = (60 * (Math.PI)) / 180, d2 = 0.0, d3 = (1.0 / 0.0);

    System.out.println("Trigonometric cosine of d1 = " + StrictMath.cos(d1));

    System.out.println("Trigonometric cosine of d2 = " + StrictMath.cos(d2));

    System.out.println("Trigonometric cosine of d3 = " + StrictMath.cos(d3));
}

From source file:net.nicoulaj.benchmarks.math.DoubleCos.java

@GenerateMicroBenchmark
public void strictmath(BlackHole hole) {
    for (int i = 0; i < data.length - 1; i++)
        hole.consume(StrictMath.cos(data[i]));
}

From source file:org.esa.beam.util.math.FastMathPerformance.java

public void testCos() {
    System.gc();/* ww  w .j  a v  a 2s  . c  o m*/
    double x = 0;
    long time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        x += StrictMath.cos(i * F1);
    long strictTime = System.nanoTime() - time;

    System.gc();
    double y = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        y += FastMath.cos(i * F1);
    long fastTime = System.nanoTime() - time;

    System.gc();
    double z = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        z += Math.cos(i * F1);
    long mathTime = System.nanoTime() - time;

    report("cos", x + y + z, strictTime, fastTime, mathTime);
}

From source file:org.esa.beam.util.math.FastMathTest.java

@Test
public void testMathCosStrict() {
    for (double i = 0; i < numItr; ++i) {
        double val = StrictMath.cos(i);
    }/*from  w  w  w  .j a v a2s.  c om*/
}