cr.sparse.lop.identity¶
- cr.sparse.lop.identity(in_dim, out_dim=None, axis=0)[source]¶
Returns an identity linear operator from model space to data space
- Parameters
- Returns
An identity linear operator
- Return type
If
out_dim
is not specified, then we assume that both model space and data space have same dimension.Example
A square identity operator:
>>> T = lop.identity(4) >>> T.times(jnp.arange(4) + 0.) DeviceArray([0., 1., 2., 3.], dtype=float32) >>> T.trans(jnp.arange(4)) DeviceArray([0, 1, 2, 3], dtype=int32)
A tall identity operator (output has more dimensions):
>>> T = lop.identity(4, 6) >>> T.times(jnp.arange(4) + 0.) DeviceArray([0., 1., 2., 3., 0., 0.], dtype=float32) >>> T.trans(T.times(jnp.arange(4) + 0.)) DeviceArray([0., 1., 2., 3.], dtype=float32)
A wide identity operator (output has less dimensions):
>>> T = lop.identity(4, 3) >>> T.times(jnp.arange(4) + 0.) DeviceArray([0., 1., 2.], dtype=float32) >>> T.trans(T.times(jnp.arange(4) + 0.)) DeviceArray([0., 1., 2., 0.], dtype=float32)
By default T applies along columns of a matrix (axis=0):
>>> T.times(jnp.arange(20).reshape(4, 5)) DeviceArray([[ 0, 1, 2, 3, 4], [ 5, 6, 7, 8, 9], [10, 11, 12, 13, 14]], dtype=int32)
Identity operator applying along rows of a 2D matrix:
>>> T = lop.identity(4, 3, axis=1) >>> T.times(jnp.arange(20).reshape(5, 4)) DeviceArray([[ 0, 1, 2], [ 4, 5, 6], [ 8, 9, 10], [12, 13, 14], [16, 17, 18]], dtype=int32)