identity#
- class brainunit.math.identity(n, dtype=None, unit=Unit('1'))#
Return the identity quantity or array.
The identity array is a square array with ones on the main diagonal.
- Parameters:
- Returns:
out –
n x narray with its main diagonal set to one and all other elements zero.- Return type:
Array| saiunit.Quantity
Examples
>>> import saiunit as u >>> u.math.identity(3) Array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]], dtype=float32) >>> u.math.identity(2, unit=u.second) Quantity([[1. 0.] [0. 1.]], "s")