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