Class ApproxAtan


  • public class ApproxAtan
    extends Object
    Similar to the classes in com.metsci.glimpse.util.math.fast, but uses linear interpolation between samples instead of nearest-neighbor.

    Anecdotally, speed is about 7.5x faster than Math.atan(double). With 100k samples, max error is around 1e-10. Max error decreases as the number of samples increases.

    Original domain is unbounded:

         a = y / x
         a ∊ [ -inf, +inf ]
     

    Transform to bounded domain:

         b = a / ( 1.0 + abs( a ) )
         b ∊ [ -1, +1 ]
     

    Invert the transform to compute initial samples:

         a = b / ( 1.0 - abs( b ) )
     
    • Constructor Detail

      • ApproxAtan

        public ApproxAtan​(int numSamples)
    • Method Detail

      • atan

        public double atan​(double a)
      • atan2

        public double atan2​(double y,
                            double x)
      • rawSignBit

        public static int rawSignBit​(double d)