Subtract two matrices element-wise.
SciPhp\NdArray
NumPhp::subtract(
array|NdArray
$n
)
$n
The new SciPhp\NdArray
use SciPhp\NumPhp as np;
$m = np::linspace(1, 9, 9)->reshape(3, 3);
$n = np::linspace(1, 9, 9)->reshape(3, 3);
$s = $m->subtract($n);
echo "m=n\n$m", "s=m-n\n$s";
The above example will output:
m=n [[1 2 3] [4 5 6] [7 8 9]] s=m-n [[0 0 0] [0 0 0] [0 0 0]]
use SciPhp\NumPhp as np;
$m = np::linspace(1, 6, 6)->reshape(2, 3);
$n = np::linspace(1, 3, 3);
$s = $m->subtract($n);
echo "m\n$m", "n\n$n", "s=m-n\n$s";
The above example will output:
m [[1 2 3] [4 5 6]] n [1 2 3] s=m-n [[0 0 0] [3 3 3]]
use SciPhp\NumPhp as np;
$m = np::linspace(1, 6, 6)->reshape(2, 3);
$s = $m->subtract(3);
echo "m\n$m", "s=m-3\n$s";
The above example will output:
m [[1 2 3] [4 5 6]] s=m-3 [[-2 -1 0 ] [1 2 3 ]]