Package org.flag4j.linalg
Class VectorNorms
java.lang.Object
org.flag4j.linalg.VectorNorms
Utility class for computing norms of vectors. To compute the infinite norm see
TensorNorms.infNorm(ComplexDenseTensorBase)
or TensorNorms.infNorm(RealDenseTensorBase)
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic double
Computes the infinity norm of a vector.static double
Computes the infinity norm of a tensor, matrix, or vector.static double
infNorm
(CooCVector src) Computes the infinity norm of a vector.static double
Computes the infinity norm of a tensor, matrix, or vector.private static double
norm
(double... src) Computes the 2-norm of a vector.private static double
norm
(double[] src, double p) Computes thep
-norm of a vector.static double
Computes the 2-norm of this vector.static double
Computes the p-norm of this vector.static double
Computes the 2-norm of this vector.static double
Computes the p-norm of this vector.static double
norm
(CooCVector src) Computes the 2-norm of this vector.static double
norm
(CooCVector src, double p) Computes the p-norm of this vector.static double
Computes the 2-norm of this vector.static double
Computes the p-norm of this vector.private static double
Computes the 2-norm of a vector.private static double
Computes thep
-norm of a vector.
-
Constructor Details
-
VectorNorms
private VectorNorms()
-
-
Method Details
-
norm
Computes the 2-norm of this vector. This is equivalent tonorm(src, 2)
.- Parameters:
src
- Vector to compute norm of.- Returns:
- the 2-norm of this vector.
-
norm
Computes the p-norm of this vector.- Parameters:
src
- Vector to compute norm of.p
- The p value in the p-norm.
- If p is inf, then this method computes the maximum/infinite norm.- Returns:
- The p-norm of this vector.
- Throws:
IllegalArgumentException
- If p is less than 1.
-
norm
-
norm
Computes the p-norm of this vector.- Parameters:
src
- Vector to compute norm of.p
- The p value in the p-norm.
- If p is inf, then this method computes the maximum/infinite norm.- Returns:
- The p-norm of this vector.
- Throws:
IllegalArgumentException
- If p is less than 1.
-
norm
-
norm
Computes the p-norm of this vector. Warning, if p is large in absolute value, overflow issues may occur.- Parameters:
p
- The p value in the p-norm.
- If p isDouble.POSITIVE_INFINITY
, then this method computes the maximum/infinite norm.
- If p isDouble.NEGATIVE_INFINITY
, then this method computes the minimum norm.- Returns:
- The p-norm of this vector.
-
norm
Computes the 2-norm of this vector. This is equivalent tonorm(src, 2)
.- Parameters:
src
- Vector to compute norm of.- Returns:
- the 2-norm of this vector.
-
norm
Computes the p-norm of this vector.- Parameters:
src
- Vector to compute norm of.p
- The p value in the p-norm.
- If p is inf, then this method computes the maximum/infinite norm.- Returns:
- The p-norm of this vector.
- Throws:
IllegalArgumentException
- If p is less than 1.
-
infNorm
Computes the infinity norm of a tensor, matrix, or vector. That is, the largest absolute value.- Parameters:
src
- The vector to compute the norm of.- Returns:
- The infinity norm of the source vector.
-
infNorm
Computes the infinity norm of a vector. That is, the largest absolute value.- Parameters:
src
- The vector to compute the norm of.- Returns:
- The infinity norm of the source vector.
-
infNorm
Computes the infinity norm of a tensor, matrix, or vector. That is, the largest absolute value.- Parameters:
src
- The vector to compute the norm of.- Returns:
- The infinity norm of the source vector.
-
infNorm
Computes the infinity norm of a vector. That is, the largest absolute value.- Parameters:
src
- The vector to compute the norm of.- Returns:
- The infinity norm of the source vector.
-
norm
private static double norm(double... src) Computes the 2-norm of a vector.- Parameters:
src
- Entries of the vector (or non-zero entries if vector is sparse).- Returns:
- The 2-norm of the vector.
-
norm
Computes the 2-norm of a vector.- Parameters:
src
- Entries of the vector (or non-zero entries if vector is sparse).- Returns:
- The 2-norm of the vector.
-
norm
private static double norm(double[] src, double p) Computes thep
-norm of a vector.- Parameters:
src
- Entries of the vector (or non-zero entries if vector is sparse).p
- Thep
value in thep
-norm.
- Ifp
isDouble.POSITIVE_INFINITY
, then this method computes the maximum/infinite norm.
- Ifp
isDouble.NEGATIVE_INFINITY
, then this method computes the minimum norm.
Warning, ifp
is large in absolute value, overflow errors may occur.- Returns:
- The
p
-norm of the vector.
-
norm
Computes thep
-norm of a vector.- Parameters:
src
- Entries of the vector (or non-zero entries if vector is sparse).p
- Thep
value in thep
-norm.
- Ifp
isDouble.POSITIVE_INFINITY
, then this method computes the maximum/infinite norm.
- Ifp
isDouble.NEGATIVE_INFINITY
, then this method computes the minimum norm.
Warning, ifp
is large in absolute value, overflow errors may occur.- Returns:
- The
p
-norm of the vector.
-