A lightweight implementation of norm functions without LinearAlgebra.jl, BLAS, or LAPACK dependencies.
This package provides pure Julia implementations of common norm functions:
norm(x)ornorm(x, 2)- Euclidean norm (default)norm(x, 1)- 1-norm (sum of absolute values)norm(x, Inf)- Infinity norm (maximum absolute value)norm(x, -Inf)- Minimum absolute valuenorm(x, p)- p-norm for anyp ≥ 1norm(x, 0)- Count of non-zero elements
norm(A, 1)- Maximum absolute column sumnorm(A, Inf)- Maximum absolute row sumnorm(A, "fro")ornorm(A, :fro)- Frobenius norm
Note: The spectral norm (norm(A, 2)) is not implemented, as it requires singular value decomposition.
using Pkg
Pkg.add("SimpleNorm")using SimpleNorm
# Vector norms
v = [3.0, 4.0]
norm(v) # 5.0 (Euclidean norm)
norm(v, 1) # 7.0 (1-norm)
norm(v, Inf) # 4.0 (infinity norm)
# Matrix norms
A = [1 2 3; 4 5 6]
norm(A, 1) # 9.0 (max column sum)
norm(A, Inf) # 15.0 (max row sum)
norm(A, "fro") # 9.539392014169456 (Frobenius norm)This package is useful when you need norm computations but want to avoid:
- Binary dependencies (BLAS/LAPACK)
- Heavy LinearAlgebra.jl dependency
- Deployment issues in constrained environments
All implementations are in pure Julia with careful attention to numerical stability, including overflow/underflow prevention in the 2-norm calculation.