NumPhp::exp2

Calculate 2 ** element, element-wise.

Description

SciPhp\NdArray NumPhp::exp2( array|NdArray $m )

Parameters

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

Return Values

A SciPhp\NdArray

Examples

Example #1: Exponential of a vector

use SciPhp\NumPhp as np;

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

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

See Also

  • NumPhp::exp() - Calculate the exponential of all elements in the input array.
  • NumPhp::expm1() - Calculate the exponential of all elements in the input array.
  • NumPhp::log() - Return the natural logarithm, element-wise.
  • NumPhp::log10() - Return the base 10 logarithm, element-wise.