Example usage for java.lang StrictMath acos

List of usage examples for java.lang StrictMath acos

Introduction

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

Prototype

public static native double acos(double a);

Source Link

Document

Returns the arc cosine of a value; the returned angle is in the range 0.0 through pi.

Usage

From source file:Main.java

public static void main(String[] args) {

    double d1 = 0.90, d2 = 5.00;

    System.out.println("arc cosine value of " + d1 + " = " + StrictMath.acos(d1));

    // returns NaN if argument is NaN or its absolute value is greater than 1
    System.out.println("arc cosine value of " + d2 + " = " + StrictMath.acos(d2));
}

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

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

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

public void testAcos() {
    System.gc();//w  ww. j a  v a 2  s . co  m
    double x = 0;
    long time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        x += StrictMath.acos(i / 10000000.0);
    long strictTime = System.nanoTime() - time;

    System.gc();
    double y = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        y += FastMath.acos(i / 10000000.0);
    long fastTime = System.nanoTime() - time;

    System.gc();
    double z = 0;
    time = System.nanoTime();
    for (int i = 0; i < RUNS; i++)
        z += Math.acos(i / 10000000.0);
    long mathTime = System.nanoTime() - time;
    report("acos", x + y + z, strictTime, fastTime, mathTime);
}