numpy 1.22.4 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
log2(x)

Return the "principal value" (for a description of this, see :None:None:`numpy.log2`) of $log_2(x)$ . For real :None:None:`x > 0`, this is a real number ( log2(0) returns -inf and log2(np.inf) returns inf ). Otherwise, the complex principle value is returned.

Notes

For a log2() that returns NAN when real :None:None:`x < 0`, use :None:None:`numpy.log2` (note, however, that otherwise :None:None:`numpy.log2` and this log2 are identical, i.e., both return -inf for :None:None:`x = 0`, inf for :None:None:`x = inf`, and, notably, the complex principle value if x.imag != 0 ).

Parameters

x : array_like

The value(s) whose log base 2 is (are) required.

Returns

out : ndarray or scalar

The log base 2 of the x value(s). If x was a scalar, so is :None:None:`out`, otherwise an array is returned.

Compute the logarithm base 2 of x.

See Also

numpy.log2

Examples

We set the printing precision so the example can be auto-tested:

>>> np.set_printoptions(precision=4)
>>> np.emath.log2(8)
3.0
>>> np.emath.log2([-4, -8, 8])
array([2.+4.5324j, 3.+4.5324j, 3.+0.j    ])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.lib.scimath.log2

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/lib/scimath.py#380
type: <class 'function'>
Commit: