emath

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 26, 2026 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package emath ports numpy.emath (lib.scimath): math functions that return mathematically valid answers in the complex domain instead of NaN.

Translated in part from NumPy (numpy/lib/_scimath_impl.py), BSD-3-Clause; see LICENSES/numpy-BSD3-CLAUSE.txt.

Documented deviation from numpy: numpy preserves the real dtype when no imaginary part would appear (emath.sqrt([1,4]) stays float64); these functions ALWAYS return *numgo.Array[complex128] with a zero imaginary part for in-domain elements. Use Array.Real to extract real parts. Ported from numpy/lib/_scimath_impl.py: the _fix_real_* promotion guards only decide numpy's result dtype, so with a fixed complex128 output the port reduces to applying the math/cmplx function to every element (real inputs get a +0i part, matching numpy's astype(cdouble)).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Arccos

func Arccos[T numgo.Number](a *numgo.Array[T]) *numgo.Array[complex128]

Arccos returns the element-wise inverse cosine: |x| > 1 gives the complex principal value (numpy emath.arccos).

func Arcsin

func Arcsin[T numgo.Number](a *numgo.Array[T]) *numgo.Array[complex128]

Arcsin returns the element-wise inverse sine: |x| > 1 gives the complex principal value (numpy emath.arcsin).

func Arctanh

func Arctanh[T numgo.Number](a *numgo.Array[T]) *numgo.Array[complex128]

Arctanh returns the element-wise inverse hyperbolic tangent: |x| > 1 gives the complex principal value, ±1 gives ±Inf (numpy emath.arctanh).

func Log

func Log[T numgo.Number](a *numgo.Array[T]) *numgo.Array[complex128]

Log returns the element-wise natural logarithm: real negative elements give the principal complex value (numpy emath.log).

func Log2

func Log2[T numgo.Number](a *numgo.Array[T]) *numgo.Array[complex128]

Log2 returns the element-wise base-2 logarithm (numpy emath.log2), computed as Log(x)/ln2 like numpy's complex log2.

func Log10

func Log10[T numgo.Number](a *numgo.Array[T]) *numgo.Array[complex128]

Log10 returns the element-wise base-10 logarithm (numpy emath.log10), computed as Log(x)/ln10 like numpy's complex log10.

func Logn

func Logn[T numgo.Number](n float64, x *numgo.Array[T]) *numgo.Array[complex128]

Logn returns the element-wise log base n of x (numpy emath.logn, note the argument order). A negative base is handled in the complex domain, like numpy's _fix_real_lt_zero(n).

func Power

func Power[T numgo.Number](x, p *numgo.Array[T]) *numgo.Array[complex128]

Power returns x**p element-wise after broadcasting x and p (numpy emath.power): negative real bases give complex results.

shortcut: Go's cmplx.Pow computes exp(p*log(x)), so integral exponents on negative bases carry ~1e-16 imaginary residue where numpy's complex power yields exactly 0i; within test tolerance.

func Sqrt

func Sqrt[T numgo.Number](a *numgo.Array[T]) *numgo.Array[complex128]

Sqrt returns the element-wise square root: negative real elements give an imaginary result (numpy emath.sqrt).

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL