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