tri#
- class saiunit.math.tri(N, M=None, k=0, dtype=None, unit=Unit('1'))#
Return an array with ones at and below the given diagonal and zeros elsewhere.
- Parameters:
N (
int) – Number of rows in the array.M (
int|None) – Number of columns in the array. By default,Mis taken equal toN.k (
int) – The sub-diagonal at and below which the array is filled.k = 0is the main diagonal,k < 0is below it, andk > 0is above. The default is 0.dtype (
str|type[Any] |dtype|SupportsDType|None) – Data type of the returned array. The default isfloat.unit (saiunit.Unit) – Unit of the returned
Quantity.
- Returns:
out – Array of shape
(N, M)with its lower triangle filled with ones and zero elsewhere; i.e.T[i, j] == 1forj <= i + k, 0 otherwise.- Return type:
Array| saiunit.Quantity
Examples
>>> import saiunit as u >>> u.math.tri(3) Array([[1., 0., 0.], [1., 1., 0.], [1., 1., 1.]], dtype=float32) >>> u.math.tri(2, 3, unit=u.meter) Quantity([[1. 0. 0.] [1. 1. 0.]], "m")