Construct a triangle matrix based on the lower triangle of another one.
SciPhp\NdArray
NdArray::tril(
[
int
$k = 0
])
$k
use SciPhp\NumPhp as np;
$m = np::ar(
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
)->tril();
echo "m\n$m";
The above example will output:
m [[1 0 0] [4 5 0] [7 8 9]]
use SciPhp\NumPhp as np;
$m = np::ar(
[[1, 2, 3],
[4, 5, 6],
[7, 8, 9]]
)->tril(-1);
echo "m\n$m";
The above example will output:
m [[0 0 0] [4 0 0] [7 8 0]]