Calculate 2 ** element, element-wise.
SciPhp\NdArray
NumPhp::exp2()
This function has no parameters.
use SciPhp\NumPhp as np;
$m = np::ar([0, 1, 2, 3])->exp2();
echo "m\n$m";
The above example will output:
m [1 2 4 8]
use SciPhp\NumPhp as np;
$m = np::diag([0, 1, 2, 3]);
$r = $m->exp2();
echo "m\n$m", "r\n$r";
The above example will output:
m [[0 0 0 0] [0 1 0 0] [0 0 2 0] [0 0 0 3]] r [[1 1 1 1] [1 2 1 1] [1 1 4 1] [1 1 1 8]]