Package org.flag4j.linalg
Class TensorNorms
java.lang.Object
org.flag4j.linalg.TensorNorms
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptiondouble
Computes the maximum/infinite norm of this tensor.static double
infNorm
(ComplexDenseTensorBase<?, ?> src) Computes the infinity norm of a tensor, matrix, or vector.static double
infNorm
(RealDenseTensorBase<?, ?> src) Computes the infinity norm of a tensor, matrix, or vector.double
Computes the 2-norm of this tensor.double
Computes the p-norm of this tensor.static double
Computes the 2-norm of this tensor as if the tensor was a vector (i.e.static double
Computes the p-norm of this tensor.static double
norm
(CooCTensor src) Computes the 2-norm of this tensor.double
norm
(CooCTensor src, double p) Computes the p-norm of this tensor.static double
Computes the 2-norm of this tensor.double
Computes the p-norm of this tensor.protected static double
tensorNormL2
(double[] src) Computes the L2 norm of a tensor.static double
tensorNormL2
(CNumber[] src) Computes the L2 norm of a tensor (i.e.protected static double
tensorNormLp
(double[] src, double p) Computes the Lp norm of a tensor.static double
tensorNormLp
(CNumber[] src, double p) Computes the Lp norm of a tensor (i.e.
-
Constructor Details
-
TensorNorms
private TensorNorms()
-
-
Method Details
-
infNorm
Computes the infinity norm of a tensor, matrix, or vector. That is, the largest absolute value.- Parameters:
src
- The tensor, matrix, or vector to compute the norm of.- Returns:
- The infinity norm of the source tensor, matrix, or vector.
-
infNorm
Computes the infinity norm of a tensor, matrix, or vector. That is, the largest value by magnitude.- Parameters:
src
- The tensor, matrix, or vector to compute the norm of.- Returns:
- The infinity norm of the source tensor, matrix, or vector.
-
norm
Computes the 2-norm of this tensor as if the tensor was a vector (i.e. as if byVectorNorm(Tensor.toVector())
). This is equivalent tonorm(src, 2)
.- Parameters:
src
- Tensor to compute norm of.- Returns:
- the 2-norm of this tensor.
-
norm
Computes the p-norm of this tensor.- Parameters:
src
- Tensor to compute norm of.p
- Thep
value in the p-norm.
- Ifp
is inf, then this method computes the maximum/infinite norm.- Returns:
- The p-norm of this tensor.
- Throws:
IllegalArgumentException
- If p is less than 1.
-
norm
Computes the 2-norm of this tensor. This is equivalent tonorm(src, 2)
.- Returns:
- the 2-norm of this tensor.
-
norm
Computes the p-norm of this tensor.- Parameters:
src
- Tensor 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 tensor.
- Throws:
IllegalArgumentException
- If p is less than 1.
-
infNorm
Computes the maximum/infinite norm of this tensor.- Parameters:
src
- Tensor to compute norm of.- Returns:
- The maximum/infinite norm of this tensor.
-
norm
Computes the 2-norm of this tensor. This is equivalent tonorm(src, 2)
.- Parameters:
src
- Tensor to compute norm of.- Returns:
- the 2-norm of this tensor.
-
norm
Computes the p-norm of this tensor.- Parameters:
src
- Tensor 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 tensor.
- Throws:
IllegalArgumentException
- If p is less than 1.
-
norm
Computes the 2-norm of this tensor. This is equivalent tonorm(src, 2)
.- Parameters:
src
- Tensor to compute norm of.- Returns:
- the 2-norm of this tensor.
-
norm
Computes the p-norm of this tensor.- Parameters:
src
- Tensor 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 tensor.
- Throws:
IllegalArgumentException
- If p is less than 1.
-
tensorNormL2
protected static double tensorNormL2(double[] src) Computes the L2 norm of a tensor.- Parameters:
src
- Entries of the tensor.- Returns:
- The L2 norm of the tensor.
-
tensorNormLp
protected static double tensorNormLp(double[] src, double p) Computes the Lp norm of a tensor.- Parameters:
src
- Entries of the tensor.p
- Thep
parameter of the Lp norm.- Returns:
- The Lp norm of the tensor.
-
tensorNormL2
Computes the L2 norm of a tensor (i.e. the Frobenius norm).- Parameters:
src
- Entries of the tensor.- Returns:
- The L2 norm of the tensor.
-
tensorNormLp
Computes the Lp norm of a tensor (i.e. the Frobenius norm).- Parameters:
src
- Entries of the tensor.p
- Thep
parameter of the Lp norm.- Returns:
- The Lp norm of the tensor.
-