cr.nimble.subspaces.project_to_subspace

cr.nimble.subspaces.project_to_subspace(U, v)[source]

Projects a vector to a subspace

Parameters
  • U (jax.numpy.ndarray) – ONB for the subspace

  • v (jax.numpy.ndarray) – A vector in the ambient space

Returns

Projection of v onto the subspace spanned by U

Return type

(jax.numpy.ndarray)

Example

>>> A = jnp.eye(6)[:, :3]
>>> v = jnp.arange(6) + 0.
>>> u = project_to_subspace(A, v)
>>> print(A)
[[1. 0. 0.]
[0. 1. 0.]
[0. 0. 1.]
[0. 0. 0.]
[0. 0. 0.]
[0. 0. 0.]]
>>> print(v)
[0. 1. 2. 3. 4. 5.]
>>> print(u)
[0. 1. 2. 0. 0. 0.]