Package org.apache.commons.numbers.core
Enum Norm
- java.lang.Object
-
- java.lang.Enum<Norm>
-
- org.apache.commons.numbers.core.Norm
-
- All Implemented Interfaces:
Serializable
,Comparable<Norm>
public enum Norm extends Enum<Norm>
Norm functions.The implementations provide increased numerical accuracy. Algorithms primary source is the 2005 paper Accurate Sum and Dot Product by Takeshi Ogita, Siegfried M. Rump, and Shin'ichi Oishi published in SIAM J. Sci. Comput.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
of(double[] v)
Computes the norm.double
of(double x, double y)
Computes the norm.double
of(double x, double y, double z)
Computes the norm.static Norm
valueOf(String name)
Returns the enum constant of this type with the specified name.static Norm[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
L1
public static final Norm L1
Manhattan norm (sum of the absolute values of the arguments).
-
L2
public static final Norm L2
- See Also:
- Euclidean norm.
-
LINF
public static final Norm LINF
Maximum norm (maximum of the absolute values of the arguments).
-
-
Method Detail
-
values
public static Norm[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (Norm c : Norm.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static Norm valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum type has no constant with the specified nameNullPointerException
- if the argument is null
-
of
public final double of(double x, double y)
Computes the norm.Special cases:
- If either value is
Double.NaN
, then the result isDouble.NaN
. - If either value is infinite and the other value is not
Double.NaN
, then the result isDouble.POSITIVE_INFINITY
.
- Parameters:
x
- Argument.y
- Argument.- Returns:
- the norm.
- If either value is
-
of
public final double of(double x, double y, double z)
Computes the norm.Special cases:
- If any value is
Double.NaN
, then the result isDouble.NaN
. - If any value is infinite and no value is not
Double.NaN
, then the result isDouble.POSITIVE_INFINITY
.
- Parameters:
x
- Argument.y
- Argument.z
- Argument.- Returns:
- the norm.
- If any value is
-
of
public final double of(double[] v)
Computes the norm.Special cases:
- If any value is
Double.NaN
, then the result isDouble.NaN
. - If any value is infinite and no value is not
Double.NaN
, then the result isDouble.POSITIVE_INFINITY
.
- Parameters:
v
- Argument.- Returns:
- the norm.
- Throws:
IllegalArgumentException
- if the array is empty.
- If any value is
-
-