NumPhp::sqrt

The non-negative square-root of an array, element-wise.

Description

SciPhp\NdArray NdArray::sqrt( array|NdArray $m )

Parameters

$m
An array [1, 2, 3] or a NdArray.

Return Values

The new SciPhp\NdArray

Examples

Example #1: square-root of the matrix

use SciPhp\NumPhp as np;

$m np::vander([149]);

$n np::sqrt($m);

echo 
"m=n\n$m""n=m*m\n$n";

The above example will output:

m=n
[[1   1   1 ]
 [16  4   1 ]
 [81  9   1 ]]
n=sqrt(m)
[[1  1  1]
 [4  2  1]
 [9  3  1]]

See Also