Dot product of two matrices.
SciPhp\NdArray
NdArray::dot(
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);
$p = $m->dot($n);
echo "m=n\n$m", "p=m.n\n$p";
The above example will output:
m=n [[1 2 3] [4 5 6] [7 8 9]] p=m.n [[30 36 42 ] [66 81 96 ] [102 126 150]]
use SciPhp\NumPhp as np;
$m = np::linspace(1, 6, 6)->reshape(2, 3);
$n = np::linspace(1, 12, 12)->reshape(3, 4);
$p = $m->dot($n);
echo "m\n$m", "n\n$n", "p=m.n\n$p";
The above example will output:
m [[1 2 3] [4 5 6]] n [[1 2 3 4 ] [5 6 7 8 ] [9 10 11 12]] p=m.n [[38 44 50 56 ] [83 98 113 128]]
use SciPhp\NumPhp as np;
$m = np::linspace(1, 6, 6)->reshape(2, 3);
$p = $m->dot(5);
echo "m\n$m", "p=m.5\n$p";
The above example will output:
m [[1 2 3] [4 5 6]] p=m.5 [[5 10 15] [20 25 30]]