NdArray::square

The element-wise square of the matrix.

Description

SciPhp\NdArray NdArray::square()

Parameters

This function has no parameters.

Return Values

The new SciPhp\NdArray

Examples

Example #1: Square of the matrix

use SciPhp\NumPhp as np;

$m np::linspace(199)->reshape(33);

$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]]

See Also