vp.randla.rp_cholesky
Randomly pivoted Cholesky: F with A ~ F F^T.
Part of the distribution vipyr; it runs from a checkout of the
repository. Planned on PyPI as pip install vipyr.
Signature
vp.randla.rp_cholesky(A, k, seed) Parameters
- A : ndarray[float64], required
- k : int, required
- seed : int, required
Returns
A frozen RpCholeskyResult. Iterating it gives the fields below in order; it also has
params, tests, log and check().
- F : ndarray[float64]
- The n by k factor, with A approximately F F^T.
Raises
- 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
x = np.linspace(0.0, 1.0, 300)
K = np.exp(-0.5 * (x[:, None] - x[None, :]) ** 2 / 0.05**2)
r = vp.randla.rp_cholesky(A=K, k=40, seed=7)
print(np.trace(K) - np.sum(r.F * r.F)) # the trace error
assert r.check() 5.254628842976672e-05Each example ran as written when these pages were generated, and the output shown is what it printed.
Checked against
- Reference
- lib/randla/check_ref.py: on a Gaussian kernel of 500 points (bandwidth 0.05), the trace error tr(A - F F^T) at k = 40 is below the best rank-20 approximation's.
Source
- Viv: lib/randla/api.viv
- The defs it reaches and the calls between them: map of the code