Class FFastLog

    • Field Summary

      • Fields inherited from class micycle.peasygradients.utilities.fastLog.FastLog

        LN2, LN2F, N
    • Constructor Summary

      Constructors 
      Constructor Description
      FFastLog()
      Create a new natural logarithm calculation instance.
      FFastLog​(double base, int n)
      Create a new logarithm calculation instance.
      FFastLog​(int n)
      Create a new logarithm calculation instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      float fastLog​(double x)
      Calculate the logarithm to the base given in the constructor.
      float fastLog​(float x)
      Calculate the logarithm to the base given in the constructor.
      float fastLog2​(double x)
      Calculate the logarithm using base 2.
      float fastLog2​(float x)
      Calculate the logarithm using base 2.
      double getBase()
      Gets the base.
      int getN()
      Gets the number of most significant bits to keep from the mantissa, i.e.
      double getScale()
      Gets the scale to convert from log2 to logB (the base given by FastLog.getBase()) by multiplication.
      float log​(double x)
      Calculate the logarithm to the configured base, handling special cases.
      float log​(float x)
      Calculate the logarithm to the configured base, handling special cases.
      float log2​(double x)
      Calculate the logarithm to base 2, handling special cases.
      float log2​(float x)
      Calculate the logarithm to base 2, handling special cases.
    • Constructor Detail

      • FFastLog

        public FFastLog()
        Create a new natural logarithm calculation instance.
      • FFastLog

        public FFastLog​(int n)
        Create a new logarithm calculation instance. This will hold the pre-calculated log values for base E and a table size depending on a given mantissa quantization.
        Parameters:
        n - The number of bits to keep from the mantissa. Table storage = 2^(n+1) * 4 bytes, e.g. 64Kb for n=13
      • FFastLog

        public FFastLog​(double base,
                        int n)
        Create a new logarithm calculation instance. This will hold the pre-calculated log values for a given base and a table size depending on a given mantissa quantization.
        Parameters:
        base - the logarithm base (e.g. 2 for log duals, 10 for decibels calculations, Math.E for natural log)
        n - The number of bits to keep from the mantissa. Table storage = 2^(n+1) * 4 bytes, e.g. 64Kb for n=13
    • Method Detail

      • getBase

        public double getBase()
        Description copied from class: FastLog
        Gets the base.
        Specified by:
        getBase in class FastLog
        Returns:
        the base
      • getScale

        public double getScale()
        Description copied from class: FastLog
        Gets the scale to convert from log2 to logB (the base given by FastLog.getBase()) by multiplication.
        Specified by:
        getScale in class FastLog
        Returns:
        the scale
      • getN

        public int getN()
        Description copied from class: FastLog
        Gets the number of most significant bits to keep from the mantissa, i.e. the binary precision of the floating point number before computing the log.
        Specified by:
        getN in class FastLog
        Returns:
        the number of most significant bits to keep
      • log2

        public float log2​(float x)
        Description copied from class: FastLog
        Calculate the logarithm to base 2, handling special cases.

        Special cases:

        • If the argument is NaN or less than zero, then the result is NaN.
        • If the argument is positive infinity, then the result is positive infinity.
        • If the argument is positive zero or negative zero, then the result is negative infinity.
        Specified by:
        log2 in class FastLog
        Parameters:
        x - the argument
        Returns:
        log(x)
      • log2

        public float log2​(double x)
        Description copied from class: FastLog
        Calculate the logarithm to base 2, handling special cases.

        Special cases:

        • If the argument is NaN or less than zero, then the result is NaN.
        • If the argument is positive infinity, then the result is positive infinity.
        • If the argument is positive zero or negative zero, then the result is negative infinity.
        Specified by:
        log2 in class FastLog
        Parameters:
        x - the argument
        Returns:
        log(x)
      • fastLog2

        public float fastLog2​(float x)
        Calculate the logarithm using base 2. Requires the argument be finite and positive.

        Special cases:

        • If the argument is NaN, then the result is incorrect (>fastLog2(Float.MAX_VALUE)).
        • If the argument is negative, then the result is incorrect (fastLog2(-x)).
        • If the argument is positive infinity, then the result is incorrect (fastLog2(Float.MAX_VALUE)).
        • If the argument is positive zero or negative zero, then the result is negative infinity.
        Specified by:
        fastLog2 in class FastLog
        Parameters:
        x - the argument (must be strictly positive)
        Returns:
        log2( x )
      • fastLog2

        public float fastLog2​(double x)
        Calculate the logarithm using base 2. Requires the argument be finite and positive.

        Special cases:

        • If the argument is NaN, then the result is incorrect (>fastLog2(Float.MAX_VALUE)).
        • If the argument is negative, then the result is incorrect (fastLog2(-x)).
        • If the argument is positive infinity, then the result is incorrect (fastLog2(Float.MAX_VALUE)).
        • If the argument is positive zero or negative zero, then the result is negative infinity.
        Specified by:
        fastLog2 in class FastLog
        Parameters:
        x - the argument (must be strictly positive)
        Returns:
        log( x )
      • log

        public float log​(float x)
        Description copied from class: FastLog
        Calculate the logarithm to the configured base, handling special cases.

        Special cases:

        • If the argument is NaN or less than zero, then the result is NaN.
        • If the argument is positive infinity, then the result is positive infinity.
        • If the argument is positive zero or negative zero, then the result is negative infinity.
        Specified by:
        log in class FastLog
        Parameters:
        x - the argument
        Returns:
        log(x)
        See Also:
        FastLog.getBase()
      • log

        public float log​(double x)
        Description copied from class: FastLog
        Calculate the logarithm to the configured base, handling special cases.

        Special cases:

        • If the argument is NaN or less than zero, then the result is NaN.
        • If the argument is positive infinity, then the result is positive infinity.
        • If the argument is positive zero or negative zero, then the result is negative infinity.
        Specified by:
        log in class FastLog
        Parameters:
        x - the argument
        Returns:
        log(x)
        See Also:
        FastLog.getBase()
      • fastLog

        public float fastLog​(float x)
        Calculate the logarithm to the base given in the constructor. Requires the argument be finite and positive.

        Special cases:

        • If the argument is NaN, then the result is incorrect (>fastLog(Float.MAX_VALUE)).
        • If the argument is negative, then the result is incorrect (fastLog(-x)).
        • If the argument is positive infinity, then the result is incorrect (fastLog(Float.MAX_VALUE)).
        • If the argument is positive zero or negative zero, then the result is negative infinity.
        Specified by:
        fastLog in class FastLog
        Parameters:
        x - the argument (must be strictly positive)
        Returns:
        log( x )
        See Also:
        FastLog.getBase()
      • fastLog

        public float fastLog​(double x)
        Calculate the logarithm to the base given in the constructor. Requires the argument be finite and positive.

        Special cases:

        • If the argument is NaN, then the result is incorrect (>fastLog(Float.MAX_VALUE)).
        • If the argument is negative, then the result is incorrect (fastLog(-x)).
        • If the argument is positive infinity, then the result is incorrect (fastLog(Float.MAX_VALUE)).
        • If the argument is positive zero or negative zero, then the result is negative infinity.
        Specified by:
        fastLog in class FastLog
        Parameters:
        x - the argument (must be strictly positive)
        Returns:
        log( x )
        See Also:
        FastLog.getBase()