Construct an array with ones at and below the given diagonal and zeros elsewhere.
SciPhp\NdArray
NumPhp::tri(
int
$rows
[,
int
$cols = null
]
[,
int
$k = 0
])
$rows
$cols
$k
use SciPhp\NumPhp as np;
$m = np::tri(4);
print $m;
The above example will output:
[[1 0 0 0] [1 1 0 0] [1 1 1 0] [1 1 1 1]]
use SciPhp\NumPhp as np;
$m = np::tri(3, 5);
print $m;
The above example will output:
[[1 0 0 0 0] [1 1 0 0 0] [1 1 1 0 0]]
use SciPhp\NumPhp as np;
$m = np::tri(3, 5, 1);
print $m;
The above example will output:
[[1 1 0 0 0] [1 1 1 0 0] [1 1 1 1 0]]
use SciPhp\NumPhp as np;
$m = np::tri(3, 5, -1);
print $m;
The above example will output:
[[0 0 0 0 0] [1 0 0 0 0] [1 1 0 0 0]]