NdArray::reciprocal

Return the reciprocal of the argument, element-wise.

Description

SciPhp\NdArray NdArray::reciprocal()

Parameters

This function has no parameters.

Return Values

A SciPhp\NdArray

Examples

Example #1: Get reciprocal of a vector

use SciPhp\NumPhp as np;

$m np::ar([1248])->reciprocal();

echo 
"m\n$m";

The above example will output:

m
[1      0.5    0.25   0.125]

Example #2: Get reciprocal of a matrix

use SciPhp\NumPhp as np;

$m np::ar([124])->vander();

$r $m->reciprocal();

echo 
"m\n$m""r\n$r";

The above example will output:

m
[[1   1   1 ]
 [4   2   1 ]
 [16  4   1 ]]
r
[[1       1       1     ]
 [0.25    0.5     1     ]
 [0.0625  0.25    1     ]]

See Also