cr.sparse.la.orth

cr.sparse.la.orth(A, rcond=None)[source]

Constructs an orthonormal basis for the range of A using SVD

Parameters
  • A (jax.numpy.ndarray) – Input matrix of size (M, N) where M is the dimension of the ambient vector space and N is the number of vectors in A

  • rcond (float) – Relative condition number. Singular values s smaller than rcond * max(s) are considered zero. Default: floating point eps * max(M,N).

Returns

Returns a tuple consisting of
  • the left singular vectors of A

  • the effective rank of A

Return type

(jax.numpy.ndarray, int)

To get the ONB, follow the two step process:

Q, r = orth(A)
Q = Q[:, :r]

Examples

>>> A = jnp.array([[2, 0, 0], [0, 5, 0]])  # rank 2 array
>>> Q, rank = orth(A)
>>> print(Q)
[[0. 1.]
[1. 0.]]
>>> print(rank)
2

The implementation is adapted from scipy.linalg.orth. However, the return type is different. We return the rank of the matrix separately. This is done so that orth can be JIT compiled. Dynamic slices are not supported by JIT.