Table of Contents

Class FourierModule

Namespace
NumSharp
Assembly
NumSharp.dll

The numpy.fft module surface, reachable as fft. Holds the 18 public transforms/helpers (standard fft/ifft/fft2/ifft2/fftn/ifftn, real rfft/irfft/rfft2/irfft2/rfftn/irfftn, hermitian hfft/ihfft, and helpers fftfreq/rfftfreq/fftshift/ifftshift).

The transforms and fftfreq/rfftfreq are members of the Fft sub-engine (FftEngine): each method here keeps its signature and its documentation and makes one call into the sub-engine of its operand's engine (hfft on the plain view its np.conjugate needs), so an engine assigned to Fft computes every function of this module. The default, DefaultFftEngine, validates and resolves everything NumPy's Python layer does — n/axis/norm/shape/dtype and the N-D→1-D decomposition — then computes through PocketFFTDriver.Execute, the managed port of pocketfft's 1-D engine (bit-identical to NumPy 2.4.2 on the double/complex128 path). fftshift/ifftshift roll the array object and stay compositions over np.roll here.

[ModuleName("np.fft")]
public class FourierModule
Inheritance
FourierModule
Inherited Members

Remarks

Methods

fft(NDArray, int?, int, string, NDArray)

Compute the one-dimensional discrete Fourier Transform.

public NDArray fft(NDArray a, int? n = null, int axis = -1, string norm = null, NDArray @out = null)

Parameters

a NDArray

Input array, can be complex.

n int?

Length of the transformed axis of the output. Cropped/zero-padded from the input; defaults to a.shape[axis].

axis int

Axis over which to compute the FFT (default the last axis).

norm string

Normalization mode: null/"backward"/"ortho"/"forward".

out NDArray

Optional pre-allocated complex output of the appropriate shape.

Returns

NDArray

The transform, complex128 (out itself when given).

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.fft.html

    <p>Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the operand's engine (<xref href="NumSharp.FftEngine.Fft(NumSharp.NDArray%2cSystem.Nullable%7bSystem.Int32%7d%2cSystem.Int32%2cSystem.String%2cNumSharp.NDArray)" data-throw-if-not-resolved="false"></xref>).</p>

Exceptions

ValueError

n below 1, an unknown norm, or an out of the wrong shape or read-only.

IndexError

axis out of range with n omitted.

AxisError

axis out of range with n given.

DTypePromotionError

A text input.

TypeError

An out dtype complex128 cannot be cast to under same_kind.

ArgumentNullException

a is null.

fft2(NDArray, int[], int[], string, NDArray)

Compute the 2-dimensional discrete Fourier Transform (over the last two axes by default). fft2 is fftn with a different default for axes.

public NDArray fft2(NDArray a, int[] s = null, int[] axes = null, string norm = null, NDArray @out = null)

Parameters

a NDArray

Input array, can be complex.

s int[]

Shape (length of each transformed axis) of the output; -1 uses the full input length. Defaults to the input shape along axes.

axes int[]

Axes over which to compute the FFT. Default (-2, -1).

norm string

Normalization mode: null/"backward"/"ortho"/"forward".

out NDArray

Optional pre-allocated complex output.

Returns

NDArray

The transform, complex128.

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.fft2.html

    <p>Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the operand's engine (<xref href="NumSharp.FftEngine.Fft2(NumSharp.NDArray%2cSystem.Int32%5b%5d%2cSystem.Int32%5b%5d%2cSystem.String%2cNumSharp.NDArray)" data-throw-if-not-resolved="false"></xref>).</p>

Exceptions

ValueError

s and axes of different lengths, a length below 1, an unknown norm, or an unfit out.

IndexError

An axis out of range.

AxisError

An axis out of range for a one-dimensional transform.

DTypePromotionError

A text input.

ArgumentNullException

a is null.

fftfreq(long, double, string)

Return the Discrete Fourier Transform sample frequencies: f = [0, 1, ..., n/2-1, -n/2, ..., -1] / (dn) (n even); f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (dn) (n odd).

public NDArray fftfreq(long n, double d = 1, string device = null)

Parameters

n long

Window length: any C# integer converts (NumPy's Python int / np.integer). A floating n does not compile, C#'s form of NumPy's ValueError: n should be an integer; a ulong needs a cast.

d double

Sample spacing (inverse of the sampling rate). Default 1.

device string

Array-API device; must be null or "cpu".

Returns

NDArray

A float64 array of length n.

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.fftfreq.html

    <p>One integer signature since API-parity batch 6 (the <code>int</code> form and the <code>double</code> form that only
    threw NumPy's ValueError are gone). Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the default engine
    (<xref href="NumSharp.FftEngine.Fftfreq(System.Int64%2cSystem.Double%2cSystem.String)" data-throw-if-not-resolved="false"></xref>): there is no operand to choose another.</p>

Exceptions

ZeroDivisionError

n * d is zero (float division by zero, checked first).

ValueError

A device other than "cpu" (Device not understood. ...), then a negative n (negative dimensions are not allowed).

fftn(NDArray, int[], int[], string, NDArray)

Compute the N-dimensional discrete Fourier Transform over the given axes (all axes by default). Composition of 1-D fft(NDArray, int?, int, string, NDArray) per axis.

public NDArray fftn(NDArray a, int[] s = null, int[] axes = null, string norm = null, NDArray @out = null)

Parameters

a NDArray

Input array, can be complex.

s int[]

Per-axis output lengths; -1 uses the full input length. Defaults to the input shape along axes.

axes int[]

Axes over which to compute the FFT (default: all axes, or the last len(s) when only s is given).

norm string

Normalization mode: null/"backward"/"ortho"/"forward".

out NDArray

Optional pre-allocated complex output.

Returns

NDArray

The transform, complex128.

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.fftn.html

    <p>Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the operand's engine (<xref href="NumSharp.FftEngine.Fftn(NumSharp.NDArray%2cSystem.Int32%5b%5d%2cSystem.Int32%5b%5d%2cSystem.String%2cNumSharp.NDArray)" data-throw-if-not-resolved="false"></xref>).</p>

Exceptions

ValueError

s and axes of different lengths, a length below 1, an unknown norm, or an unfit out.

IndexError

An axis out of range.

AxisError

An axis out of range for a one-dimensional transform.

DTypePromotionError

A text input.

ArgumentNullException

a is null.

fftshift(NDArray, int)

fftshift(NDArray, NDAxis?) with one int axis: the overload a C# integer binds, forwarding to the NDAxis? form, so every answer and error is that one's.

public NDArray fftshift(NDArray x, int axes)

Parameters

x NDArray

Input array.

axes int

The axis (a negative value counts from the end).

Returns

NDArray

The shifted array.

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.fftshift.html. NumPy's statements: axes is None → axes = tuple(range(ndim)), shift = [dim // 2 for dim in x.shape]; an int → shift = x.shape[axes] // 2; a tuple → shift = [x.shape[ax] // 2 for ax in axes]; then roll(x, shift, axes). One signature for NumPy's int-or-tuple axes since API-parity batch 6; the int and int[] overloads forward here.

Exceptions

IndexError

An axis outside [-ndim, ndim): NumPy reads x.shape[ax] first, so it is Python's tuple index out of range, not an AxisError.

ValueError

A 0-d x with null or () axes: NumPy's roll over no axis of a 0-d array ends in Python's not enough values to unpack (expected 2, got 0).

fftshift(NDArray, int[])

fftshift(NDArray, NDAxis?) with the axes as an int[]: the overload an int[] and a bare null bind, forwarding to the NDAxis? form (a null array is None, any other array NumPy's tuple).

public NDArray fftshift(NDArray x, int[] axes)

Parameters

x NDArray

Input array.

axes int[]

The axes as NumPy's tuple, or null for every axis.

Returns

NDArray

The shifted array.

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.fftshift.html. NumPy's statements: axes is None → axes = tuple(range(ndim)), shift = [dim // 2 for dim in x.shape]; an int → shift = x.shape[axes] // 2; a tuple → shift = [x.shape[ax] // 2 for ax in axes]; then roll(x, shift, axes). One signature for NumPy's int-or-tuple axes since API-parity batch 6; the int and int[] overloads forward here.

Exceptions

IndexError

An axis outside [-ndim, ndim): NumPy reads x.shape[ax] first, so it is Python's tuple index out of range, not an AxisError.

ValueError

A 0-d x with null or () axes: NumPy's roll over no axis of a 0-d array ends in Python's not enough values to unpack (expected 2, got 0).

fftshift(NDArray, NDAxis?)

Shift the zero-frequency component to the center of the spectrum: NumPy's fftshift, which rolls each listed axis by shape[axis] // 2 in ONE roll(NDArray, NDArray, NDAxis?) call.

public NDArray fftshift(NDArray x, NDAxis? axes = null)

Parameters

x NDArray

Input array (a subclass operand gives a plain array: NumPy's asarray).

axes NDAxis?

NumPy's axes: null (every axis), one axis, or a tuple of axes (repeats roll that axis again; () rolls nothing and returns a copy).

Returns

NDArray

A new array, the input's shape and dtype, NumPy's layout (roll's empty_like).

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.fftshift.html. NumPy's statements: axes is None → axes = tuple(range(ndim)), shift = [dim // 2 for dim in x.shape]; an int → shift = x.shape[axes] // 2; a tuple → shift = [x.shape[ax] // 2 for ax in axes]; then roll(x, shift, axes). One signature for NumPy's int-or-tuple axes since API-parity batch 6; the int and int[] overloads forward here.

Exceptions

IndexError

An axis outside [-ndim, ndim): NumPy reads x.shape[ax] first, so it is Python's tuple index out of range, not an AxisError.

ValueError

A 0-d x with null or () axes: NumPy's roll over no axis of a 0-d array ends in Python's not enough values to unpack (expected 2, got 0).

hfft(NDArray, int?, int, string, NDArray)

Compute the FFT of a signal that has Hermitian symmetry (a real spectrum). Defined as irfft(conjugate(a), n, axis, norm=_swap_direction(norm)). The output is real; its length along the axis is n, or 2*(m-1) when n is omitted.

public NDArray hfft(NDArray a, int? n = null, int axis = -1, string norm = null, NDArray @out = null)

Parameters

a NDArray

Input array.

n int?

Length of the transformed axis of the output (default 2*(m-1)).

axis int

Axis over which to compute the FFT (default the last axis).

norm string

Normalization mode: null/"backward"/"ortho"/"forward".

out NDArray

A pre-allocated real output that irfft writes and returns (NumPy 2.5; 2.4 ignored it), or null.

Returns

NDArray

The real result, float64 (out itself when given); a plain array for a numpy.matrix or numpy.char.chararray operand too.

Remarks

Exceptions

ValueError

A length below 1, or an unknown norm (the inverse transforms' text).

IndexError

axis out of range with n omitted.

AxisError

axis out of range with n given.

TypeError

A text input (np.conjugate has no string loop).

ArgumentNullException

a is null.

ifft(NDArray, int?, int, string, NDArray)

Compute the one-dimensional inverse discrete Fourier Transform (ifft(fft(a)) == a).

public NDArray ifft(NDArray a, int? n = null, int axis = -1, string norm = null, NDArray @out = null)

Parameters

a NDArray

Input array, can be complex.

n int?

Length of the transformed axis of the output (default a.shape[axis]).

axis int

Axis over which to compute the inverse FFT (default the last axis).

norm string

Normalization mode: null/"backward"/"ortho"/"forward".

out NDArray

Optional pre-allocated complex output of the appropriate shape.

Returns

NDArray

The inverse transform, complex128 (out itself when given).

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.ifft.html

    <p>Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the operand's engine (<xref href="NumSharp.FftEngine.Ifft(NumSharp.NDArray%2cSystem.Nullable%7bSystem.Int32%7d%2cSystem.Int32%2cSystem.String%2cNumSharp.NDArray)" data-throw-if-not-resolved="false"></xref>).</p>

Exceptions

ValueError

n below 1, an unknown norm, or an out of the wrong shape or read-only.

IndexError

axis out of range with n omitted.

AxisError

axis out of range with n given.

DTypePromotionError

A text input.

TypeError

An out dtype complex128 cannot be cast to under same_kind.

ArgumentNullException

a is null.

ifft2(NDArray, int[], int[], string, NDArray)

Compute the 2-dimensional inverse discrete Fourier Transform (over the last two axes by default). ifft2 is ifftn with a different default for axes. Like NumPy 2.5, the provided out is threaded through the composition (NumPy 2.4 ignored it).

public NDArray ifft2(NDArray a, int[] s = null, int[] axes = null, string norm = null, NDArray @out = null)

Parameters

a NDArray

Input array, can be complex.

s int[]

Per-axis output lengths; -1 uses the full input length.

axes int[]

Axes over which to compute the inverse FFT. Default (-2, -1).

norm string

Normalization mode: null/"backward"/"ortho"/"forward".

out NDArray

A pre-allocated complex output handed to every one-dimensional transform, or null.

Returns

NDArray

The inverse transform, complex128 (out itself when given).

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.ifft2.html

    <p>Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the operand's engine (<xref href="NumSharp.FftEngine.Ifft2(NumSharp.NDArray%2cSystem.Int32%5b%5d%2cSystem.Int32%5b%5d%2cSystem.String%2cNumSharp.NDArray)" data-throw-if-not-resolved="false"></xref>).</p>

Exceptions

ValueError

s and axes of different lengths, a length below 1, or an unknown norm.

IndexError

An axis out of range.

AxisError

An axis out of range for a one-dimensional transform.

DTypePromotionError

A text input.

ArgumentNullException

a is null.

ifftn(NDArray, int[], int[], string, NDArray)

Compute the N-dimensional inverse discrete Fourier Transform (ifftn(fftn(a)) == a). Composition of 1-D ifft(NDArray, int?, int, string, NDArray) per axis.

public NDArray ifftn(NDArray a, int[] s = null, int[] axes = null, string norm = null, NDArray @out = null)

Parameters

a NDArray

Input array, can be complex.

s int[]

Per-axis output lengths; -1 uses the full input length.

axes int[]

Axes over which to compute the inverse FFT (default: all axes).

norm string

Normalization mode: null/"backward"/"ortho"/"forward".

out NDArray

Optional pre-allocated complex output.

Returns

NDArray

The inverse transform, complex128.

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.ifftn.html

    <p>Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the operand's engine (<xref href="NumSharp.FftEngine.Ifftn(NumSharp.NDArray%2cSystem.Int32%5b%5d%2cSystem.Int32%5b%5d%2cSystem.String%2cNumSharp.NDArray)" data-throw-if-not-resolved="false"></xref>).</p>

Exceptions

ValueError

s and axes of different lengths, a length below 1, an unknown norm, or an unfit out.

IndexError

An axis out of range.

AxisError

An axis out of range for a one-dimensional transform.

DTypePromotionError

A text input.

ArgumentNullException

a is null.

ifftshift(NDArray, int)

ifftshift(NDArray, NDAxis?) with one int axis: the overload a C# integer binds, forwarding to the NDAxis? form.

public NDArray ifftshift(NDArray x, int axes)

Parameters

x NDArray

Input array.

axes int

The axis (a negative value counts from the end).

Returns

NDArray

The shifted array.

Remarks

Exceptions

IndexError

An axis outside [-ndim, ndim) (tuple index out of range).

ValueError

A 0-d x with null or () axes (not enough values to unpack (expected 2, got 0)).

ifftshift(NDArray, int[])

ifftshift(NDArray, NDAxis?) with the axes as an int[]: the overload an int[] and a bare null bind, forwarding to the NDAxis? form (a null array is None).

public NDArray ifftshift(NDArray x, int[] axes)

Parameters

x NDArray

Input array.

axes int[]

The axes as NumPy's tuple, or null for every axis.

Returns

NDArray

The shifted array.

Remarks

Exceptions

IndexError

An axis outside [-ndim, ndim) (tuple index out of range).

ValueError

A 0-d x with null or () axes (not enough values to unpack (expected 2, got 0)).

ifftshift(NDArray, NDAxis?)

The inverse of fftshift(NDArray, NDAxis?): NumPy's ifftshift, which rolls each listed axis by -(shape[axis] // 2) (the same as fftshift for an even length, one sample apart for an odd one).

public NDArray ifftshift(NDArray x, NDAxis? axes = null)

Parameters

x NDArray

Input array (a subclass operand gives a plain array: NumPy's asarray).

axes NDAxis?

NumPy's axes: null (every axis), one axis, or a tuple of axes.

Returns

NDArray

A new array, the input's shape and dtype.

Remarks

Exceptions

IndexError

An axis outside [-ndim, ndim) (tuple index out of range).

ValueError

A 0-d x with null or () axes (not enough values to unpack (expected 2, got 0)).

ihfft(NDArray, int?, int, string, NDArray)

Compute the inverse FFT of a signal that has Hermitian symmetry. Defined as conjugate(rfft(a, n, axis, norm=_swap_direction(norm)), out=out). The output is complex; its length along the axis is n//2 + 1.

public NDArray ihfft(NDArray a, int? n = null, int axis = -1, string norm = null, NDArray @out = null)

Parameters

a NDArray

Input array.

n int?

Length of the inverse FFT along the transform axis (default a.shape[axis]).

axis int

Axis over which to compute the inverse FFT (default the last axis).

norm string

Normalization mode: null/"backward"/"ortho"/"forward".

out NDArray

Optional pre-allocated complex output (threaded into rfft and the conjugate).

Returns

NDArray

The conjugated half spectrum, complex128 (out itself when given).

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.ihfft.html

    <p>Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the operand's engine (<xref href="NumSharp.FftEngine.Ihfft(NumSharp.NDArray%2cSystem.Nullable%7bSystem.Int32%7d%2cSystem.Int32%2cSystem.String%2cNumSharp.NDArray)" data-throw-if-not-resolved="false"></xref>).</p>

Exceptions

ValueError

A length below 1, an unknown norm, or an out of the wrong shape or read-only.

IndexError

axis out of range with n omitted.

AxisError

axis out of range with n given.

TypeError

A complex input (rfft's refusal).

DTypePromotionError

A text input.

TypeError

An out dtype complex128 cannot be cast to under same_kind.

ArgumentNullException

a is null.

irfft(NDArray, int?, int, string, NDArray)

Compute the inverse of rfft(NDArray, int?, int, string, NDArray) — a real-valued output. For n output points, n//2+1 input points are used; when n is omitted it defaults to 2*(m-1) where m is the input length along the axis.

public NDArray irfft(NDArray a, int? n = null, int axis = -1, string norm = null, NDArray @out = null)

Parameters

a NDArray

Input array (the non-negative-frequency half-spectrum).

n int?

Length of the transformed (real) axis of the output. Default 2*(m-1).

axis int

Axis over which to compute the inverse FFT (default the last axis).

norm string

Normalization mode: null/"backward"/"ortho"/"forward".

out NDArray

Optional pre-allocated real (float64) output of length n on the axis.

Returns

NDArray

The real signal, float64 (out itself when given).

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.irfft.html

    <p>Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the operand's engine (<xref href="NumSharp.FftEngine.Irfft(NumSharp.NDArray%2cSystem.Nullable%7bSystem.Int32%7d%2cSystem.Int32%2cSystem.String%2cNumSharp.NDArray)" data-throw-if-not-resolved="false"></xref>).</p>

Exceptions

ValueError

n below 1 (an input of length 1 with n omitted gives 0), an unknown norm, or an out of the wrong shape or read-only.

IndexError

axis out of range with n omitted.

AxisError

axis out of range with n given.

DTypePromotionError

A text input.

TypeError

An out dtype float64 cannot be cast to under same_kind.

ArgumentNullException

a is null.

irfft2(NDArray, int[], int[], string, NDArray)

Compute the inverse of rfft2(NDArray, int[], int[], string, NDArray). irfft2 is irfftn with the default axes of (-2, -1). Like NumPy 2.5, the provided out is handed to irfftn (NumPy 2.4 ignored it).

public NDArray irfft2(NDArray a, int[] s = null, int[] axes = null, string norm = null, NDArray @out = null)

Parameters

a NDArray

Input array.

s int[]

Per-axis output lengths; -1 uses the full input length.

axes int[]

Axes over which to compute the inverse FFT. Default (-2, -1).

norm string

Normalization mode: null/"backward"/"ortho"/"forward".

out NDArray

A pre-allocated real output for the final transform, or null.

Returns

NDArray

The real result, float64 (out itself when given).

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.irfft2.html

    <p>Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the operand's engine (<xref href="NumSharp.FftEngine.Irfft2(NumSharp.NDArray%2cSystem.Int32%5b%5d%2cSystem.Int32%5b%5d%2cSystem.String%2cNumSharp.NDArray)" data-throw-if-not-resolved="false"></xref>).</p>

Exceptions

ValueError

s and axes of different lengths, a length below 1, or an unknown norm.

IndexError

An axis out of range, or no axis to transform.

AxisError

An axis out of range for a one-dimensional transform.

DTypePromotionError

A text input.

ArgumentNullException

a is null.

irfftn(NDArray, int[], int[], string, NDArray)

Compute the inverse of rfftn(NDArray, int[], int[], string, NDArray): ifft(NDArray, int?, int, string, NDArray) over all axes but the last, then irfft(NDArray, int?, int, string, NDArray) over the last axis (real output). The last-axis default length is 2*(m-1).

public NDArray irfftn(NDArray a, int[] s = null, int[] axes = null, string norm = null, NDArray @out = null)

Parameters

a NDArray

Input array.

s int[]

Per-axis output lengths; -1 uses the full input length.

axes int[]

Axes over which to compute the inverse FFT (default: all axes).

norm string

Normalization mode: null/"backward"/"ortho"/"forward".

out NDArray

Optional pre-allocated real (float64) output for the final transform.

Returns

NDArray

The real result, float64.

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.irfftn.html

    <p>Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the operand's engine (<xref href="NumSharp.FftEngine.Irfftn(NumSharp.NDArray%2cSystem.Int32%5b%5d%2cSystem.Int32%5b%5d%2cSystem.String%2cNumSharp.NDArray)" data-throw-if-not-resolved="false"></xref>).</p>

Exceptions

ValueError

s and axes of different lengths, a length below 1, an unknown norm, or an unfit out.

IndexError

An axis out of range, or no axis to transform (tuple / list index out of range).

AxisError

An axis out of range for a one-dimensional transform.

DTypePromotionError

A text input.

ArgumentNullException

a is null.

rfft(NDArray, int?, int, string, NDArray)

Compute the one-dimensional discrete Fourier Transform for real input. The output length along the axis is n//2 + 1 (the non-negative-frequency half).

public NDArray rfft(NDArray a, int? n = null, int axis = -1, string norm = null, NDArray @out = null)

Parameters

a NDArray

Input array (taken to be real).

n int?

Number of points along the transform axis to use (default a.shape[axis]).

axis int

Axis over which to compute the FFT (default the last axis).

norm string

Normalization mode: null/"backward"/"ortho"/"forward".

out NDArray

Optional pre-allocated complex output of shape (..., n//2+1, ...).

Returns

NDArray

The half spectrum, complex128 (out itself when given).

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.rfft.html

    <p>Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the operand's engine (<xref href="NumSharp.FftEngine.Rfft(NumSharp.NDArray%2cSystem.Nullable%7bSystem.Int32%7d%2cSystem.Int32%2cSystem.String%2cNumSharp.NDArray)" data-throw-if-not-resolved="false"></xref>).</p>

Exceptions

ValueError

n below 1, an unknown norm, or an out of the wrong shape or read-only.

IndexError

axis out of range with n omitted.

AxisError

axis out of range with n given.

TypeError

A complex input (ufunc 'rfft_n_even' / 'rfft_n_odd' not supported for the input types, ...).

DTypePromotionError

A text input.

TypeError

An out dtype complex128 cannot be cast to under same_kind.

ArgumentNullException

a is null.

rfft2(NDArray, int[], int[], string, NDArray)

Compute the 2-dimensional FFT of a real array. rfft2 is rfftn with the default axes of (-2, -1).

public NDArray rfft2(NDArray a, int[] s = null, int[] axes = null, string norm = null, NDArray @out = null)

Parameters

a NDArray

Input array (taken to be real).

s int[]

Per-axis output lengths; -1 uses the full input length.

axes int[]

Axes over which to compute the FFT. Default (-2, -1).

norm string

Normalization mode: null/"backward"/"ortho"/"forward".

out NDArray

Optional pre-allocated complex output.

Returns

NDArray

The transform, complex128, the last transformed axis halved.

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.rfft2.html

    <p>Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the operand's engine (<xref href="NumSharp.FftEngine.Rfft2(NumSharp.NDArray%2cSystem.Int32%5b%5d%2cSystem.Int32%5b%5d%2cSystem.String%2cNumSharp.NDArray)" data-throw-if-not-resolved="false"></xref>).</p>

Exceptions

ValueError

s and axes of different lengths, a length below 1, an unknown norm, or an unfit out.

IndexError

An axis out of range, or no axis to transform.

AxisError

An axis out of range for a one-dimensional transform.

TypeError

A complex input.

DTypePromotionError

A text input.

ArgumentNullException

a is null.

rfftfreq(long, double, string)

Return the Discrete Fourier Transform sample frequencies for use with rfft / irfft: f = [0, 1, ..., n/2] / (d*n) (the Nyquist component is positive).

public NDArray rfftfreq(long n, double d = 1, string device = null)

Parameters

n long

Window length: any C# integer converts; a floating n does not compile (NumPy's ValueError: n should be an integer). A negative one gives an empty result, as NumPy's arange does.

d double

Sample spacing (inverse of the sampling rate). Default 1.

device string

Array-API device; must be null or "cpu".

Returns

NDArray

A float64 array of length n//2 + 1 (empty when that is not positive).

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.rfftfreq.html

    <p>One integer signature since API-parity batch 6. Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the default
    engine (<xref href="NumSharp.FftEngine.Rfftfreq(System.Int64%2cSystem.Double%2cSystem.String)" data-throw-if-not-resolved="false"></xref>).</p>

Exceptions

ZeroDivisionError

n * d is zero (float division by zero, checked first).

ValueError

A device other than "cpu".

rfftn(NDArray, int[], int[], string, NDArray)

Compute the N-dimensional discrete Fourier Transform for real input: rfft(NDArray, int?, int, string, NDArray) over the LAST transformed axis, then fft(NDArray, int?, int, string, NDArray) over the remaining axes.

public NDArray rfftn(NDArray a, int[] s = null, int[] axes = null, string norm = null, NDArray @out = null)

Parameters

a NDArray

Input array (taken to be real).

s int[]

Per-axis output lengths; the final element is n for rfft, the rest are n for fft. -1 uses the full input length.

axes int[]

Axes over which to compute the FFT (default: all axes).

norm string

Normalization mode: null/"backward"/"ortho"/"forward".

out NDArray

Optional pre-allocated complex output.

Returns

NDArray

The transform, complex128, the last transformed axis halved.

Remarks

https://numpy.org/doc/stable/reference/generated/numpy.fft.rfftn.html

    <p>Computed by <xref href="NumSharp.TensorEngine.Fft" data-throw-if-not-resolved="false"></xref> of the operand's engine (<xref href="NumSharp.FftEngine.Rfftn(NumSharp.NDArray%2cSystem.Int32%5b%5d%2cSystem.Int32%5b%5d%2cSystem.String%2cNumSharp.NDArray)" data-throw-if-not-resolved="false"></xref>).</p>

Exceptions

ValueError

s and axes of different lengths, a length below 1, an unknown norm, or an unfit out.

IndexError

An axis out of range, or no axis to transform (list index out of range).

AxisError

An axis out of range for a one-dimensional transform.

TypeError

A complex input.

DTypePromotionError

A text input.

ArgumentNullException

a is null.