NdArray::log2

Return the base 2 logarithm, element-wise.

Description

SciPhp\NdArray NdArray::log2()

Parameters

This function has no parameters.

Return Values

A SciPhp\NdArray

Examples

Example #1: Get base-2 logarithm of a vector

use SciPhp\NumPhp as np;

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

echo 
"m\n$m";

The above example will output:

m
[0  1  2  3]

Example #2: Get base-2 logarithm of a matrix

use SciPhp\NumPhp as np;

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

$r $m->log2($m);

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

The above example will output:

m
[[1   1   1 ]
 [4   2   1 ]
 [16  4   1 ]]
r
[[0  0  0]
 [2  1  0]
 [4  2  0]]

See Also