Calculate 2 ** element, element-wise.
SciPhp\NdArray
NumPhp::exp2(
array|NdArray
$m
)
$m
use SciPhp\NumPhp as np;
$m = np::exp2([0, 1, 2, 3]);
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 = np::exp2($m);
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]]