Skip to content
Snippets Groups Projects
Verified Commit 60e1a395 authored by Tobias Hangleiter's avatar Tobias Hangleiter
Browse files

Add missing imaginary unit

parent 93dd9924
Branches
Tags
1 merge request!175Add missing imaginary unit in fourier_space.derivative
......@@ -115,16 +115,25 @@ def Id(x: _S, f: _T, *_, **__) -> Tuple[_S, _T]:
def derivative(x, f, deriv_order: int = 0, overwrite_x: bool = False,
**_) -> Tuple[np.ndarray, np.ndarray]:
"""Perform (anti-)derivatives.
r"""Compute the (anti-)derivative.
The sign convention is according to the following defintion of the
Fourier transform:
.. math::
\hat{f}(\omega) &= \int_{-\infty}^\infty\mathrm{d}t
e^{-i\omega t} f(t) \\
f(t) &= \int_{-\infty}^\infty\frac{\mathrm{d}\omega}{2\pi}
e^{i\omega t} \hat{f}(\omega)
.. note::
For negative antiderivatives, the zero-frequency component is
set to zero (due to zero-division).
For negative ``deriv_order`` (antiderivatives), the
zero-frequency component is set to zero (due to zero-division).
Parameters
----------
x : array_like
The data to be filtered.
Target data.
f : array_like
Frequencies corresponding to the last axis of `x`.
deriv_order : int
......@@ -136,7 +145,7 @@ def derivative(x, f, deriv_order: int = 0, overwrite_x: bool = False,
x = np.array(x, copy=not overwrite_x)
f = np.asanyarray(f)
with np.errstate(invalid='ignore', divide='ignore'):
x *= (2*np.pi*f)**deriv_order
x *= (2j*np.pi*f)**deriv_order
if deriv_order < 0:
x[..., (f == 0).nonzero()] = 0
return x, f
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment