The element-wise square of the matrix.
SciPhp\NdArray
NdArray::square()
This function has no parameters.
The new SciPhp\NdArray
use SciPhp\NumPhp as np;
$m = np::linspace(1, 9, 9)->reshape(3, 3);
$n = $m->square();
echo "m=n\n$m", "n=m*m\n$n";
The above example will output:
m=n [[1 2 3] [4 5 6] [7 8 9]] n=m*m [[1 4 9 ] [16 25 36] [49 64 81]]