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