Add two matrices.
SciPhp\NdArray
NumPhp::add(
array|NdArray
$m
,
array|NdArray
$n
)
$m
$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);
$a = np::add($m, $n);
echo "m=n\n$m", "a=m+n\n$a";
The above example will output:
m=n [[1 2 3] [4 5 6] [7 8 9]] a=m+n [[2 4 6 ] [8 10 12] [14 16 18]]
use SciPhp\NumPhp as np;
$m = np::linspace(1, 6, 6)->reshape(2, 3);
$n = np::linspace(1, 3, 3);
$a = np::add($m, $n);
echo "m\n$m", "n\n$n", "a=m+n\n$a";
The above example will output:
m [[1 2 3] [4 5 6]] n [1 2 3] a=m+n [[2 4 6] [5 7 9]]
use SciPhp\NumPhp as np;
$m = np::linspace(1, 6, 6)->reshape(2, 3);
$a = np::add($m, 5);
echo "m\n$m", "a=m.5\n$a";
The above example will output:
m [[1 2 3] [4 5 6]] a=m+5 [[6 7 8 ] [9 10 11]]