vp.linalg.enorm
The Euclidean norm of x, with no overflow or underflow in the sum of squares (MINPACK enorm). An empty x has norm 0.
Part of the distribution vipyr; it runs from a checkout of the
repository. Planned on PyPI as pip install vipyr.
Signature
vp.linalg.enorm(x) Parameters
- x : ndarray[float64], required
- Range: rank 1.
Returns
A frozen EnormResult. Iterating it gives the fields below in order; it also has
params, tests, log and check().
- norm : float
Raises
- vipyr.ParameterError
- A ValueError: an argument outside its range, choices, rank or shape, or one of a group given without the rest; its .param names the argument.
- TypeError
- An argument of the wrong type, or an unknown keyword.
- vipyr.VivBuildError
- An ImportError: no C compiler, or the program's C does not build.
Examples
import numpy as np
import vipyr as vp
r = vp.linalg.enorm(x=np.array([3e200, 4e200]))
print(r.norm)
assert r.check() 4.9999999999999995e+200Each example ran as written when these pages were generated, and the output shown is what it printed.
Checked against
- Reference
- mpmath at 50 digits, sqrt(sum x_i^2), at every scale from subnormal to 10300; scipy.linalg.norm where no partial sum overflows
- Compared by
- relative error
- Tolerance
- rel 10−14, vs_scipy 10−14
- Why that tolerance
- a sum of n <= 100 squares in three scaled accumulators, then a square root: the summation bound is about n u / 2 = 1.1 × 10−14 at n = 100, for enorm and for SciPy's norm alike
Credits
- A port of MINPACK (Argonne National Laboratory), under MINPACK's BSD-style copyright notice (1999, University of Chicago), which the port and the Fortran in lib/minpack/ref both carry. This product includes software developed by the University of Chicago, as Operator of Argonne National Laboratory.
Source
- Manifest: kernels/k1/k1.export.toml
- Viv: kernels/k1/norms.viv
- Viv: lib/minpack/enorm.viv
- The defs it reaches and the calls between them: map of the code