- class discretize.utils.Identity(positive=True)#
Carries out arithmetic operations involving the identity.
This class was designed to manage basic arithmetic operations between the identity matrix and
numpy.ndarrayof any shape. It is a short circuiting evaluation that will return the expected values.
Whether it is a positive (or negative) Identity matrix
>>> import numpy as np >>> from discretize.utils import Identity, Zero >>> Z = Zero() >>> I = Identity() >>> x = np.arange(5) >>> x + I array([1, 2, 3, 4, 5]) >>> I - x array([ 1, 0, -1, -2, -3]) >>> I * x array([0, 1, 2, 3, 4]) >>> I @ x array([0, 1, 2, 3, 4]) >>> I @ Z Zero
Returns the Identity class as an operator
Returns the dimension of Identity class, i.e. None.
Returns the shape of Identity class, i.e. None.
Returns the transpose of the Identity class, i.e. itself.