Class TestHypotAtan

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      (package private) static double atan​(double x)
      atan from http://www.netlib.org/fdlibm/.
      (package private) static double fastAtan​(double x)  
      static double hypotA​(double x, double y)
      Implementation of hypot taken from https://stackoverflow.com/questions/3764978/why-hypot-function-is-so-slow.
      static double hypotB​(double x, double y)
      hypot.
      static double hypotC​(double x, double y)
      hypot.
      static void main​(String[] args)
      Measure performance of atan2, hypot, sine and cosine.
    • Method Detail

      • main

        public static void main​(String[] args)
        Measure performance of atan2, hypot, sine and cosine.
        Parameters:
        args - String[]; the command line arguments (not used)
      • hypotA

        public static double hypotA​(double x,
                                    double y)
        Implementation of hypot taken from https://stackoverflow.com/questions/3764978/why-hypot-function-is-so-slow.
        Parameters:
        x - double; x
        y - double; y
        Returns:
        double; the hypot of x, and y
      • hypotB

        public static double hypotB​(double x,
                                    double y)
        hypot.
        Parameters:
        x - double; x
        y - double; y
        Returns:
        sqrt(x*x +y*y) without intermediate overflow or underflow. Note Math.hypot(double, double) is unnecessarily slow. This returns the identical result to Math.hypot with reasonable run times (~40 nsec vs. 800 nsec). The logic for computing z is copied from "Freely Distributable Math Library" fdlibm's e_hypot.c. This minimizes rounding error to provide 1 ulb accuracy.
      • hypotC

        public static double hypotC​(double x,
                                    double y)
        hypot. C.F. Borges, An Improved Algorithm for hypot(a, b). arXiv:1904.09481v6 [math.NA] 14 Jun 2019.
        Parameters:
        x - double; x
        y - double; y
        Returns:
        sqrt(x*x +y*y) without intermediate overflow or underflow.
      • atan

        static double atan​(double x)
        atan from http://www.netlib.org/fdlibm/.
        Parameters:
        x - double
        Returns:
        atan(x)
      • fastAtan

        static double fastAtan​(double x)
        Parameters:
        x - param
        Returns:
        atan(x)