pycauset.norm
Compute the norm of a vector or matrix.
- Vector input: returns the \(\ell_2\) (Euclidean) norm.
- Matrix input: returns the Frobenius norm.
Parameters
x: A vector or matrix.
Returns
float: The computed norm.
Exceptions
- Raises
TypeErrorifxis not aVectorBaseorMatrixBase.
Examples
import pycauset as pc
v = pc.vector([3.0, 4.0], dtype="float64")
assert pc.norm(v) == 5.0
A = pc.matrix(
[
[3.0, 4.0],
[0.0, 0.0],
],
dtype="float64",
)
assert pc.norm(A) == 5.0