discretize.utils.Identity#
- class discretize.utils.Identity(positive=True)[source]#
Carries out arithmetic operations involving the identity.
This class was designed to manage basic arithmetic operations between the identity matrix and
numpy.ndarray
of any shape. It is a short circuiting evaluation that will return the expected values.- Parameters:
- positivebool,
optional
Whether it is a positive (or negative) Identity matrix
- positivebool,
Attributes
Return the Identity class as an operator.
Return the dimension of Identity class, i.e. None.
Return the shape of Identity class, i.e. None.
Methods
Return the transpose of the Identity class, i.e. itself.
Examples
>>> 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