NdArray::exp2

Calculate 2 ** element, element-wise.

Description

SciPhp\NdArray NumPhp::exp2()

Parameters

This function has no parameters.

Return Values

A SciPhp\NdArray

Examples

Example #1: Exponential of a vector

use SciPhp\NumPhp as np;

$m np::ar([0123])->exp2();

echo 
"m\n$m";

The above example will output:

m
[1  2  4  8]

Example #2: Exponential of a matrix

use SciPhp\NumPhp as np;

$m np::diag([0123]);

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

See Also