ImageScience 3.0.0

imagescience.utility
Class FMath

java.lang.Object
  extended by imagescience.utility.FMath

public class FMath
extends java.lang.Object

Performs elementary mathematical operations and function evaluations.


Constructor Summary
FMath()
          Default constructor.
 
Method Summary
static double besselj(int n, double x)
          Returns the value at x of the Bessel function of the first kind of order n.
static double besselj0(double x)
          Returns the value at x of the zeroth-order Bessel function of the first kind.
static double besselj1(double x)
          Returns the value at x of the first-order Bessel function of the first kind.
static double bspline(double x, int n, int d)
          Returns the value at x of the dth derivative of the nth-degree centered uniform B-spline basis function.
static int ceil(double d)
          Returns the ceiling of the given value.
static double clip(double d, double min, double max)
          Returns the value of d clipped to the range [min,max].
static int floor(double d)
          Returns the floor of the given value.
static double gauss(double x, double s)
          Returns The value at x of the Gaussian distribution with standard deviation s.
static double lngamma(double x)
          Returns the natural logarithm of the Gamma function at x.
static double lommelu(int n, int t, double u, double v)
          Returns the value at (u,v) of the series expansion of the Lommel U-function of order n evaluated to t terms.
static double lommelv(int n, int t, double u, double v)
          Returns the value at (u,v) of the series expansion of the Lommel V-function of order n evaluated to t terms.
static double max(double d1, double d2)
          Returns the maximum of the given values.
static double max(double d1, double d2, double d3, double d4)
          Returns the maximum of the given values.
static double max(double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8)
          Returns the maximum of the given values.
static double min(double d1, double d2)
          Returns the minimum of the given values.
static double min(double d1, double d2, double d3, double d4)
          Returns the minimum of the given values.
static double min(double d1, double d2, double d3, double d4, double d5, double d6, double d7, double d8)
          Returns the minimum of the given values.
static boolean power2(int i)
          Indicates whether the given integer value is a power of 2.
static int round(double d)
          Returns the given value rounded to the nearest integral value.
static double sinc(double x)
          Returns the value of the sinc function at x.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FMath

public FMath()
Default constructor.

Method Detail

floor

public static int floor(double d)
Returns the floor of the given value.

Parameters:
d - The value whose floor is to be returned.
Returns:
The largest integral value that is not greater than d. This method works only for double values that fall within the range spanned by the integers. In that case, this method yields the same result as the corresponding method in Java's Math class, but is in general much faster and returns an int rather than a double.

ceil

public static int ceil(double d)
Returns the ceiling of the given value.

Parameters:
d - The value whose ceiling is to be returned.
Returns:
The smallest integral value that is not less than d. This method works only for double values that fall within the range spanned by the integers. In that case, this method yields the same result as the corresponding method in Java's Math class, but is in general much faster and returns an int rather than a double.

round

public static int round(double d)
Returns the given value rounded to the nearest integral value.

Parameters:
d - The value whose rounded value is to be returned.
Returns:
The integral value closest to d. This method works only for double values that fall within the range spanned by the integers. In that case, this method yields the same result as the corresponding method in Java's Math class, but is in general much faster and returns an int rather than a double.

clip

public static double clip(double d,
                          double min,
                          double max)
Returns the value of d clipped to the range [min,max].

Parameters:
d - The value to be clipped.
min - The lower bound (minimum value) of the clip range.
max - The upper bound (maximum value) of the clip range.
Returns:
The value of d clipped to the range [min,max]. Guaranteed to be correct only if min <= max.

min

public static double min(double d1,
                         double d2)
Returns the minimum of the given values.

Parameters:
d1 - d2 - The values.
Returns:
The minimum of d1 and d2.

min

public static double min(double d1,
                         double d2,
                         double d3,
                         double d4)
Returns the minimum of the given values.

Parameters:
d1 - d2 - d3 - d4 - The values.
Returns:
The minimum of d1,...,d4.

min

public static double min(double d1,
                         double d2,
                         double d3,
                         double d4,
                         double d5,
                         double d6,
                         double d7,
                         double d8)
Returns the minimum of the given values.

Parameters:
d1 - d2 - d3 - d4 - d5 - d6 - d7 - d8 - The values.
Returns:
The minimum of d1,...,d8.

max

public static double max(double d1,
                         double d2)
Returns the maximum of the given values.

Parameters:
d1 - d2 - The values.
Returns:
The maximum of d1 and d2.

max

public static double max(double d1,
                         double d2,
                         double d3,
                         double d4)
Returns the maximum of the given values.

Parameters:
d1 - d2 - d3 - d4 - The values.
Returns:
The maximum of d1,...,d4.

max

public static double max(double d1,
                         double d2,
                         double d3,
                         double d4,
                         double d5,
                         double d6,
                         double d7,
                         double d8)
Returns the maximum of the given values.

Parameters:
d1 - d2 - d3 - d4 - d5 - d6 - d7 - d8 - The values.
Returns:
The maximum of d1,...,d8.

lngamma

public static double lngamma(double x)
Returns the natural logarithm of the Gamma function at x.

Parameters:
x - The input value. Must be larger than 0.
Returns:
The natural logarithm of the Gamma function at x. Computed using the approximation described by C. Lanczos, "A Precision Approximation of the Gamma Function", SIAM Journal on Numerical Analysis, Series B, vol. 1, 1964, pp. 86-96, as implemented by W. H. Press et al., Numerical Recipes in C: The Art of Scientific Computing, 2nd ed., Cambridge University Press, Cambridge, 1992, Section 6.1.
Throws:
java.lang.IllegalArgumentException - If x is less than or equal to 0.

bspline

public static double bspline(double x,
                             int n,
                             int d)
Returns the value at x of the dth derivative of the nth-degree centered uniform B-spline basis function.

Parameters:
x - The input value.
n - The B-spline degree. Must be larger than or equal to 0.
d - The derivate order. Must be larger than or equal to 0 and less than or equal to n.
Returns:
The value at x of the dth derivative of the nth-degree centered uniform B-spline basis function.
Throws:
java.lang.IllegalArgumentException - If n or d is out of range.

gauss

public static double gauss(double x,
                           double s)
Returns The value at x of the Gaussian distribution with standard deviation s. The distribution is normalized to unit integral.

Parameters:
x - The input value.
s - The standard deviation of the Gaussian distribution.
Returns:
The value at x of the Gaussian distribution with standard deviation s.
Throws:
java.lang.IllegalArgumentException - If s is less than or equal to 0.

sinc

public static double sinc(double x)
Returns the value of the sinc function at x. The sinc function is defined as the limit of sin(x)/x.

Parameters:
x - The input value.
Returns:
The value of the sinc function at x.

besselj0

public static double besselj0(double x)
Returns the value at x of the zeroth-order Bessel function of the first kind.

Parameters:
x - The input value.
Returns:
The value at x of the zeroth-order Bessel function of the first kind. Computed using the algorithm described by W. H. Press et al., Numerical Recipes in C: The Art of Scientific Computing, 2nd ed., Cambridge University Press, Cambridge, 1992, Section 6.5.

besselj1

public static double besselj1(double x)
Returns the value at x of the first-order Bessel function of the first kind.

Parameters:
x - The input value.
Returns:
The value at x of the first-order Bessel function of the first kind. Computed using the algorithm described by W. H. Press et al., Numerical Recipes in C: The Art of Scientific Computing, 2nd ed., Cambridge University Press, Cambridge, 1992, Section 6.5.

besselj

public static double besselj(int n,
                             double x)
Returns the value at x of the Bessel function of the first kind of order n.

Parameters:
n - The order of the Bessel function of the first kind. Must be larger than or equal to 0.
x - The input value.
Returns:
The value at x of the Bessel function of the first kind of order n. Computed using the algorithm described by W. H. Press et al., Numerical Recipes in C: The Art of Scientific Computing, 2nd ed., Cambridge University Press, Cambridge, 1992, Section 6.5.
Throws:
java.lang.IllegalArgumentException - If n is less than 0.

lommelu

public static double lommelu(int n,
                             int t,
                             double u,
                             double v)
Returns the value at (u,v) of the series expansion of the Lommel U-function of order n evaluated to t terms.

Parameters:
n - The order of the Lommel U-function. Must be larger than or equal to 0.
t - The number of terms to which the series expansion is to be computed. Must be larger than 0.
u - The first input value.
v - The second input value. Must be different from 0.
Returns:
The value at (u,v) of the series expansion of the Lommel U-function of order n evaluated to t terms. Computed using a straightforward implementation of the formula given by M. Born and E. Wolf, Principles of Optics, 5th ed., Pergamon Press, Oxford, 1975, Section 8.8.
Throws:
java.lang.IllegalArgumentException - If any of the parameter values is out of range.

lommelv

public static double lommelv(int n,
                             int t,
                             double u,
                             double v)
Returns the value at (u,v) of the series expansion of the Lommel V-function of order n evaluated to t terms.

Parameters:
n - The order of the Lommel V-function. Must be larger than or equal to 0.
t - The number of terms to which the series expansion is to be computed. Must be larger than 0.
u - The first input value. Must be different from 0.
v - The second input value.
Returns:
The value at (u,v) of the series expansion of the Lommel V-function of order n evaluated to t terms. Computed using a straightforward implementation of the formula given by M. Born and E. Wolf, Principles of Optics, 5th ed., Pergamon Press, Oxford, 1975, Section 8.8.
Throws:
java.lang.IllegalArgumentException - If any of the parameter values is out of range.

power2

public static boolean power2(int i)
Indicates whether the given integer value is a power of 2.

Parameters:
i - The integer value to be tested. Should not be larger than 2^30 in magnitude.
Returns:
Value true if i is a power of 2, or false if this is not the case.

ImageScience 3.0.0

Copyright (C) Erik Meijering. Permission to use this software and corresponding documentation for educational, research, and not-for-profit purposes, without a fee and without a signed licensing agreement, is granted, subject to the following terms and conditions.

IT IS NOT ALLOWED TO REDISTRIBUTE, SELL, OR LEASE THIS SOFTWARE, OR DERIVATIVE WORKS THEREOF, WITHOUT PERMISSION IN WRITING FROM THE COPYRIGHT HOLDER. THE COPYRIGHT HOLDER IS FREE TO MAKE VERSIONS OF THE SOFTWARE AVAILABLE FOR A FEE OR COMMERCIALLY ONLY.

IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, OF ANY KIND WHATSOEVER, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.

THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE EXPRESS OR IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE AND CORRESPONDING DOCUMENTATION IS PROVIDED "AS IS". THE COPYRIGHT HOLDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.