Package cds.healpix.common.math
Class FastMath
java.lang.Object
cds.healpix.common.math.FastMath
Comes from the Apache FastMath class, and is thus under the Apache licence.
- Author:
- F.-X. Pineau
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic double
acos
(double x) Compute the arc cosine of a number.static double
asin
(double x) Compute the arc sine of a number.static double
atan
(double x) Arctangent functionstatic double
copySign
(double magnitude, double sign) Returns the first argument with the sign of the second argument.static double
cosQ
(double xa) Compute cosine in the first quadrant by subtracting input from PI/2 and then calling sinQ.static double
sinQ
(double xa, double xb) Compute sine over the first quadrant (0 < x < pi/2).static double
sqrt
(double a) Compute the square root of a number.
-
Field Details
-
SAFE_MIN
public static final double SAFE_MIN- See Also:
-
-
Constructor Details
-
FastMath
public FastMath()
-
-
Method Details
-
sinQ
public static double sinQ(double xa, double xb) Compute sine over the first quadrant (0 < x < pi/2). Use combination of table lookup and rational polynomial expansion.- Parameters:
xa
- number from which sine is requestedxb
- second param- Returns:
- sin(xa + xb)
-
cosQ
public static double cosQ(double xa) Compute cosine in the first quadrant by subtracting input from PI/2 and then calling sinQ. This is more accurate as the input approaches PI/2.- Parameters:
xa
- number from which cosine is requested- Returns:
- cos(xa + xb)
-
asin
public static double asin(double x) Compute the arc sine of a number.- Parameters:
x
- number on which evaluation is done- Returns:
- arc sine of x
-
atan
public static double atan(double x) Arctangent function- Parameters:
x
- a number- Returns:
- atan(x)
-
acos
public static double acos(double x) Compute the arc cosine of a number.- Parameters:
x
- number on which evaluation is done- Returns:
- arc cosine of x
-
sqrt
public static double sqrt(double a) Compute the square root of a number.Note: this implementation currently delegates to
Math.sqrt(double)
- Parameters:
a
- number on which evaluation is done- Returns:
- square root of a
-
copySign
public static double copySign(double magnitude, double sign) Returns the first argument with the sign of the second argument. A NaNsign
argument is treated as positive.- Parameters:
magnitude
- the value to returnsign
- the sign for the returned value- Returns:
- the magnitude with the same sign as the
sign
argument
-