Table of Contents

Class DefaultFftEngine

Namespace
NumSharp.Backends
Assembly
NumSharp.dll

NumSharp's FftEngine, the default of Fft: NumPy's numpy/fft/_pocketfft.py and numpy/fft/_helper.py statements in NumPy's order - _raw_fft's length, norm, axis and out= checks, _cook_nd_args, _raw_fftnd's axis order, the Hermitian compositions, fftfreq's arithmetic - over three protected virtual kernels that stand for NumPy's _pocketfft_umath ufuncs: C2CKernel(NDArray, int, int, bool, double, NDArray, bool, bool) (fft / ifft), R2CKernel(NDArray, int, int, double, NDArray, bool, bool) (rfft_n_even / rfft_n_odd) and C2RKernel(NDArray, int, int, double, NDArray, bool, bool) (irfft).

public class DefaultFftEngine : FftEngine
Inheritance
DefaultFftEngine
Inherited Members

Remarks

The kernels. Each runs Execute(NDArray, int, int, bool, bool, double, NDArray, bool, bool), NumSharp's managed port of pocketfft (bit for bit with NumPy 2.4.2's on the double path; float32 / float16 operands reproduce NumPy's complex64 / float32 / float16 values in complex128 / float64).

Deriving. Override a kernel to compute the transforms another way (MKL, FFTW, cuFFT): the public members keep running NumPy's statements around it, so the override receives a checked length, a normalized axis, the normalization factor and a shape-checked out=, and every N-D, real and Hermitian function reaches it. Call the base kernel for the operands it does not serve. Assign the instance to Fft of the cached engine.

Nested calls. A member never calls back up into a public np.* facade. Where NumPy's statement calls another numpy.fft function (hfft's irfft, ihfft's rfft, rfft2's rfftn, irfft2's irfftn), it calls this engine's own virtual member, so a subclass that overrides one computes it for every caller; where it calls a main-namespace function (conjugate, arange, concatenate), it calls the member that function's facade dispatches to (the operand engine's Conjugate(NDArray, DType, NDArray, NDArray), the array object's arange and concatenate). The N-D transforms (fft2, ifft2, fftn, ifftn, rfftn, irfftn) run this engine's own _raw_fft statements per axis where NumPy calls its module fft / rfft / ...: NumSharp's intermediate is complex128 where NumPy's is complex64, so only the statements can carry the original operand's precision to every axis.

The statements were the np.fft module's own bodies (FourierModule, until phase PE's E3 of the np-layer dtype plan); P6b of that plan made them call members instead of np.* facades and moved the files under Backends/Default/Fourier/, where ratchet R2 holds them at zero np.* calls. The kernels call the pocketfft port that stays in Fourier/.

Methods

C2CKernel(NDArray, int, int, bool, double, NDArray, bool, bool)

The complex-to-complex transform, NumPy's fft / ifft ufunc: every lane of a along axis cropped or zero-padded to n points, transformed, and scaled by fct. fft, ifft, the N-D complex transforms, every axis but the last of rfftn and irfftn, and hfft / ihfft through them all end here.

protected virtual NDArray C2CKernel(NDArray a, int n, int axis, bool forward, double fct, NDArray @out, bool singlePrecision, bool unitFactor)

Parameters

a NDArray

The operand, real or complex of any numeric dtype (taken as complex128); the statements have refused text.

n int

The transform and output length along the axis, at least 1.

axis int

The transformed axis, already normalized to [0, a.ndim).

forward bool

True for the forward transform (exponent sign -1), false for the inverse.

fct double

The normalization factor applied to the result: 1, 1/sqrt(n) or 1/n, computed in the operand's real dtype and carried as a double.

out NDArray

The output the caller passed, its shape checked against a.shape with the axis replaced by n and its writeability checked; null to allocate one.

singlePrecision bool

The public call's operand is float32 or float16, so NumPy's result is complex64: reproduce its values (NumPy computes in double and rounds, or, for a complex64-precision operand with a float factor, runs its single-precision loop).

unitFactor bool

The factor is NumPy's Python int 1 (norm None or "backward"), which makes NumPy's loop resolution take the double loop even for a complex64-precision operand.

Returns

NDArray

A new complex128 array of a.shape with the axis replaced by n, or out itself holding the result.

Exceptions

TypeError

An out whose dtype complex128 cannot be cast to under same_kind (Cannot cast ufunc 'fft' output from dtype('complex128') to ...).

C2RKernel(NDArray, int, int, double, NDArray, bool, bool)

The complex-to-real transform, NumPy's irfft ufunc: every lane of a along axis read as the non-negative half of a Hermitian spectrum (its first n // 2 + 1 terms, zero-padded when shorter), transformed backward to n real points and scaled by fct. irfft, the last axis of irfftn / irfft2, and hfft end here.

protected virtual NDArray C2RKernel(NDArray a, int n, int axis, double fct, NDArray @out, bool singlePrecision, bool unitFactor)

Parameters

a NDArray

The half spectrum, of any numeric dtype (taken as complex128); the statements have refused text.

n int

The output length per lane, at least 1.

axis int

The transformed axis, already normalized to [0, a.ndim).

fct double

The normalization factor applied to the result, computed in the operand's real dtype.

out NDArray

The output the caller passed, its shape checked (the axis of length n) and its writeability checked; null to allocate one.

singlePrecision bool

The public call's operand is float32 or float16, so NumPy's result is float32 (or float16 for a float16 operand): reproduce its values.

unitFactor bool

The factor is NumPy's Python int 1 (norm None or "backward"), which makes NumPy take the double loop.

Returns

NDArray

A new float64 array of a.shape with the axis replaced by n, or out itself holding the result (a same_kind cast of float64, such as complex128 or float32).

Exceptions

TypeError

An out whose dtype float64 cannot be cast to under same_kind (Cannot cast ufunc 'irfft' output from dtype('float64') to ...).

Fft(NDArray, int?, int, string, NDArray)

NumPy's np.fft.fft(a, n=None, axis=-1, norm=None, out=None): the one-dimensional discrete Fourier transform along axis.

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

Parameters

a NDArray

The input, real or complex (a real input is taken as complex).

n int?

The transform length: the axis is cropped or zero-padded to it; null for the input's length.

axis int

The transformed axis (negative counts from the end).

norm string

null or "backward" (no scaling forward), "ortho" (1/sqrt(n)) or "forward" (1/n).

out NDArray

A pre-allocated output of the result's shape (its dtype a same_kind cast of complex128), or null.

Returns

NDArray

The transform, complex128 (out itself when given).

Remarks

NumPy's statements: n = a.shape[axis] when n is None (Python tuple indexing, so an axis out of range is an IndexError here and an AxisError in _raw_fft when n was given), then _raw_fft(a, n, axis, False, True, norm, out).

Exceptions

ValueError

n below 1 (Invalid number of FFT data points (0) specified.), an unknown norm, or an out of the wrong shape or read-only.

IndexError

axis out of range with n omitted (NumPy's a.shape[axis]: tuple index out of range).

AxisError

axis out of range with n given.

DTypePromotionError

A text input (result_type(a.real.dtype, 1.0) has no common DType).

TypeError

An out dtype the complex128 result cannot be cast to under same_kind (NumPy's UFuncTypeError text).

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

NumPy's np.fft.fft2(a, s=None, axes=(-2, -1), norm=None, out=None): Fftn(NDArray, int[], int[], string, NDArray) over the last two axes by default.

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

Parameters

a NDArray

The input, real or complex.

s int[]

The output length per transformed axis (-1 keeps the input's), or null for the input's.

axes int[]

The transformed axes; null stands for NumPy's default (-2, -1).

norm string

The normalization mode, as for Fft(NDArray, int?, int, string, NDArray).

out NDArray

A pre-allocated output handed to every one-dimensional transform (NumPy's out=out), or null.

Returns

NDArray

The transform, complex128.

Remarks

NumPy's one statement _raw_fftnd(a, s, axes, fft, norm, out=out) with axes=(-2, -1) for null; each axis runs this engine's _raw_fft with the original operand's precision.

Exceptions

ValueError

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

IndexError

An axis out of range (NumPy's take / tuple-index texts; a 0-d input: cannot do a non-empty take from an empty axes.).

AxisError

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

DTypePromotionError

A text input.

Fftfreq(long, double, string)

NumPy's np.fft.fftfreq(n, d=1.0, device=None): the sample frequencies of an n-point transform, [0, 1, ..., (n-1)//2, -(n//2), ..., -1] / (d * n).

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

Parameters

n long

The window length.

d double

The sample spacing.

device string

null or "cpu" (the Array API's device argument).

Returns

NDArray

A new float64 array of n frequencies.

Remarks

NumPy's statements in NumPy's order: val = 1.0 / (n * d) (Python's ZeroDivisionError when the product is zero, for either sign of n), results = empty(n, int, device=device) (the device check, then the negative length), the two arange halves, then results * val. NumPy's isinstance(n, integer_types) guard is the C# parameter type: the np.fft facade's double overload raises it.

Exceptions

ZeroDivisionError

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

ValueError

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

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

NumPy's np.fft.fftn(a, s=None, axes=None, norm=None, out=None): the N-dimensional transform, one Fft(NDArray, int?, int, string, NDArray) per axis in reverse order (_raw_fftnd).

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

Parameters

a NDArray

The input, real or complex.

s int[]

The output length per transformed axis (-1 keeps the input's); null for the input's. Given without axes, the last len(s) axes are transformed.

axes int[]

The transformed axes, or null for all of them.

norm string

The normalization mode, as for Fft(NDArray, int?, int, string, NDArray).

out NDArray

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

Returns

NDArray

The transform, complex128.

Remarks

NumPy's one statement _raw_fftnd(a, s, axes, fft, norm, out=out): _cook_nd_args resolves the lengths and axes, then the axes are transformed in reverse order.

Exceptions

ValueError

Mismatched s / axes, 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.

Hfft(NDArray, int?, int, string, NDArray)

NumPy's np.fft.hfft(a, n=None, axis=-1, norm=None, out=None): the transform of a signal with Hermitian symmetry, irfft(conjugate(a), n, axis, norm=_swap_direction(norm)); the output is real.

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

Parameters

a NDArray

The input (the half of a Hermitian-symmetric signal).

n int?

The output length; null for 2 * (m - 1).

axis int

The transformed axis.

norm string

The normalization mode, swapped before the inverse transform.

out NDArray

A pre-allocated real output irfft writes (NumPy 2.5; 2.4 handed irfft out=None), or null.

Returns

NDArray

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

Remarks

NumPy's statements: n = (a.shape[axis] - 1) * 2 when n is None, new_norm = _swap_direction(norm), then irfft(conjugate(a), n, axis, norm=new_norm, out=out) (NumPy 2.5 hands the out on; 2.4 passed out=None and returned a fresh array): conjugate is the operand engine's Conjugate(NDArray, DType, NDArray, NDArray) (np.conjugate's body without its class-boundary test: the np.fft facade applied that before it called this member, so a is plain), and irfft is this engine's Irfft(NDArray, int?, int, string, NDArray), so a subclass that overrides Irfft computes the inverse transform here too.

Exceptions

ValueError

A length below 1, or an unknown norm (the inverse's 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).

Ifft(NDArray, int?, int, string, NDArray)

NumPy's np.fft.ifft(a, n=None, axis=-1, norm=None, out=None): the one-dimensional inverse discrete Fourier transform, ifft(fft(a)) == a to rounding.

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

Parameters

a NDArray

The input, real or complex.

n int?

The transform length (cropped or zero-padded); null for the input's length.

axis int

The transformed axis.

norm string

null or "backward" (1/n on the inverse), "ortho" or "forward" (no scaling on the inverse).

out NDArray

A pre-allocated output of the result's shape, or null.

Returns

NDArray

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

Remarks

NumPy's statements: the default length as in Fft(NDArray, int?, int, string, NDArray), then _raw_fft(a, n, axis, False, False, norm, out), which swaps the norm's direction first.

Exceptions

ValueError

n below 1, an unknown norm (the inverse's text, with a space after "backward",), 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 the complex128 result cannot be cast to under same_kind.

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

NumPy's np.fft.ifft2(a, s=None, axes=(-2, -1), norm=None, out=None): Ifftn(NDArray, int[], int[], string, NDArray) over the last two axes by default, the out handed to the transforms (NumPy 2.5; 2.4 handed them out=None).

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

Parameters

a NDArray

The input, real or complex.

s int[]

The output length per transformed axis, or null.

axes int[]

The transformed axes; null stands for (-2, -1).

norm string

The normalization mode, as for Ifft(NDArray, int?, int, string, NDArray).

out NDArray

A pre-allocated complex output, or null.

Returns

NDArray

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

Remarks

NumPy's one statement _raw_fftnd(a, s, axes, ifft, norm, out=out): the provided out is threaded through the composition, as for Fft2(NDArray, int[], int[], string, NDArray) (NumPy 2.5; 2.4 passed out=None).

Exceptions

ValueError

Mismatched s / axes, 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.

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

NumPy's np.fft.ifftn(a, s=None, axes=None, norm=None, out=None): the N-dimensional inverse transform, one Ifft(NDArray, int?, int, string, NDArray) per axis in reverse order.

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

Parameters

a NDArray

The input, real or complex.

s int[]

The output length per transformed axis, or null.

axes int[]

The transformed axes, or null for all of them.

norm string

The normalization mode, as for Ifft(NDArray, int?, int, string, NDArray).

out NDArray

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

Returns

NDArray

The inverse transform, complex128.

Remarks

NumPy's one statement _raw_fftnd(a, s, axes, ifft, norm, out=out).

Exceptions

ValueError

Mismatched s / axes, 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.

Ihfft(NDArray, int?, int, string, NDArray)

NumPy's np.fft.ihfft(a, n=None, axis=-1, norm=None, out=None): the inverse of Hfft(NDArray, int?, int, string, NDArray), conjugate(rfft(a, n, axis, norm=_swap_direction(norm), out=out), out=out); the output is complex.

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

Parameters

a NDArray

The real input.

n int?

The number of input points used; null for the input's length.

axis int

The transformed axis.

norm string

The normalization mode, swapped before the forward transform.

out NDArray

A pre-allocated complex output, threaded through rfft and the conjugate, or null.

Returns

NDArray

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

Remarks

NumPy's statements: n = a.shape[axis] when n is None, new_norm = _swap_direction(norm), out = rfft(a, n, axis, norm=new_norm, out=out) (this engine's Rfft(NDArray, int?, int, string, NDArray)), then conjugate(out, out=out) (the operand engine's Conjugate(NDArray, DType, NDArray, NDArray)), here into the caller's out (a new array when none was given).

Exceptions

ValueError

A length below 1, an unknown norm, or an unfit out.

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 the complex128 result cannot be cast to.

Irfft(NDArray, int?, int, string, NDArray)

NumPy's np.fft.irfft(a, n=None, axis=-1, norm=None, out=None): the inverse of Rfft(NDArray, int?, int, string, NDArray), a real output of n points from the half spectrum's first n // 2 + 1 terms.

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

Parameters

a NDArray

The half spectrum.

n int?

The output length; null for NumPy's 2 * (m - 1), m the input's length.

axis int

The transformed axis.

norm string

The normalization mode, as for Ifft(NDArray, int?, int, string, NDArray).

out NDArray

A pre-allocated output of length n on the axis (float64, or a same_kind cast of it such as complex128), or null.

Returns

NDArray

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

Remarks

NumPy's statements: n = (a.shape[axis] - 1) * 2 when n is None (so a length-1 axis gives 0, refused by _raw_fft), then _raw_fft(a, n, axis, True, False, norm, out=out).

Exceptions

ValueError

n below 1 (an input of length 1 with n omitted gives 0), an unknown norm, or an unfit out.

IndexError

axis out of range with n omitted.

AxisError

axis out of range with n given.

DTypePromotionError

A text input.

TypeError

An out dtype the float64 result cannot be cast to under same_kind.

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

NumPy's np.fft.irfft2(a, s=None, axes=(-2, -1), norm=None, out=None): Irfftn(NDArray, int[], int[], string, NDArray) over the last two axes by default, the out handed on (NumPy 2.5; 2.4 handed on out=None).

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

Parameters

a NDArray

The input spectrum.

s int[]

The output length per transformed axis, or null.

axes int[]

The transformed axes; null stands for (-2, -1).

norm string

The normalization mode, as for Ifft(NDArray, int?, int, string, NDArray).

out NDArray

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

Returns

NDArray

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

Remarks

NumPy's one statement return irfftn(a, s, axes, norm, out=out) with axes=(-2, -1) for null: this engine's Irfftn(NDArray, int[], int[], string, NDArray) (the member np.fft.irfftn dispatches to), with the provided out (NumPy 2.5; 2.4 passed out=None). It opens no scope.

Exceptions

ValueError

Mismatched s / axes, 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.

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

NumPy's np.fft.irfftn(a, s=None, axes=None, norm=None, out=None): Ifft(NDArray, int?, int, string, NDArray) over every transformed axis but the last, then Irfft(NDArray, int?, int, string, NDArray) over the last (a real output whose default length is 2 * (m - 1)).

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

Parameters

a NDArray

The input spectrum.

s int[]

The output length per transformed axis, or null.

axes int[]

The transformed axes, or null for all of them.

norm string

The normalization mode, as for Ifft(NDArray, int?, int, string, NDArray).

out NDArray

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

Returns

NDArray

The real result, float64.

Remarks

NumPy's statements: _cook_nd_args(a, s, axes, invreal=1) (the last default length is 2 * (m - 1)), ifft over every axis but the last without the provided out, then irfft over the last with it. Each axis runs this engine's _raw_fft with the original operand's precision.

Exceptions

ValueError

Mismatched s / axes, a length below 1, an unknown norm, or an unfit out.

IndexError

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

AxisError

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

DTypePromotionError

A text input.

R2CKernel(NDArray, int, int, double, NDArray, bool, bool)

The real-to-complex transform, NumPy's rfft_n_even / rfft_n_odd ufunc: every lane of a along axis cropped or zero-padded to n real points and transformed forward, keeping the n // 2 + 1 non-negative frequencies, scaled by fct. rfft, the last axis of rfftn / rfft2, and ihfft end here.

protected virtual NDArray R2CKernel(NDArray a, int n, int axis, double fct, NDArray @out, bool singlePrecision, bool unitFactor)

Parameters

a NDArray

The real operand of any non-complex numeric dtype (taken as float64); the statements have refused complex and text operands.

n int

The number of input points per lane, at least 1.

axis int

The transformed axis, already normalized to [0, a.ndim).

fct double

The normalization factor applied to the result, computed in the operand's real dtype.

out NDArray

The output the caller passed, its shape checked (the axis of length n // 2 + 1) and its writeability checked; null to allocate one.

singlePrecision bool

The public call's operand is float32 or float16, so NumPy's result is complex64: reproduce its values (a float32 operand with a float factor runs NumPy's single-precision loop; the others compute in double and round).

unitFactor bool

The factor is NumPy's Python int 1 (norm None or "backward"), which makes NumPy take the double loop.

Returns

NDArray

A new complex128 array of a.shape with the axis replaced by n // 2 + 1, or out itself holding the result.

Exceptions

TypeError

An out whose dtype complex128 cannot be cast to under same_kind (the message names rfft_n_even or rfft_n_odd by the parity of n).

Rfft(NDArray, int?, int, string, NDArray)

NumPy's np.fft.rfft(a, n=None, axis=-1, norm=None, out=None): the one-dimensional transform of a real input, the non-negative-frequency half (n // 2 + 1 terms).

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

Parameters

a NDArray

The real input (a complex one is refused: NumPy's rfft has no complex loop).

n int?

The number of input points used (cropped or zero-padded); null for the input's length.

axis int

The transformed axis.

norm string

The normalization mode, as for Fft(NDArray, int?, int, string, NDArray).

out NDArray

A pre-allocated complex output of length n // 2 + 1 on the axis, or null.

Returns

NDArray

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

Remarks

NumPy's statements: n = a.shape[axis] when n is None, then _raw_fft(a, n, axis, True, True, norm, out=out), whose ufunc (and its complex-input refusal) is rfft_n_even or rfft_n_odd by the parity of n.

Exceptions

ValueError

n below 1, an unknown norm, or an unfit out.

IndexError

axis out of range with n omitted.

AxisError

axis out of range with n given.

TypeError

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

DTypePromotionError

A text input.

TypeError

An out dtype the complex128 result cannot be cast to under same_kind.

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

NumPy's np.fft.rfft2(a, s=None, axes=(-2, -1), norm=None, out=None): Rfftn(NDArray, int[], int[], string, NDArray) over the last two axes by default.

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

Parameters

a NDArray

The real input.

s int[]

The output length per transformed axis, or null.

axes int[]

The transformed axes; null stands for (-2, -1).

norm string

The normalization mode, as for Fft(NDArray, int?, int, string, NDArray).

out NDArray

A pre-allocated output, or null.

Returns

NDArray

The transform, complex128, the last axis halved.

Remarks

NumPy's one statement return rfftn(a, s, axes, norm, out=out) with axes=(-2, -1) for null: this engine's Rfftn(NDArray, int[], int[], string, NDArray) (the member np.fft.rfftn dispatches to), so a subclass that overrides it computes rfft2 too. It opens no scope (the result is the callee's own).

Exceptions

ValueError

Mismatched s / axes, 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.

TypeError

A complex input.

DTypePromotionError

A text input.

Rfftfreq(long, double, string)

NumPy's np.fft.rfftfreq(n, d=1.0, device=None): the non-negative sample frequencies of an n-point real transform, [0, 1, ..., n//2] / (d * n).

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

Parameters

n long

The window length (a negative one gives an empty result, as NumPy's arange does).

d double

The sample spacing.

device string

null or "cpu".

Returns

NDArray

A new float64 array of n // 2 + 1 frequencies.

Remarks

NumPy's statements in NumPy's order: val = 1.0 / (n * d), N = n // 2 + 1, results = arange(0, N, dtype=int, device=device) (the device check; a negative n gives an empty result, not an error), then results * val.

Exceptions

ZeroDivisionError

n * d is zero.

ValueError

A device other than "cpu".

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

NumPy's np.fft.rfftn(a, s=None, axes=None, norm=None, out=None): Rfft(NDArray, int?, int, string, NDArray) over the last transformed axis, then Fft(NDArray, int?, int, string, NDArray) over the others in reverse order.

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

Parameters

a NDArray

The real input.

s int[]

The output length per transformed axis (the last one is rfft's n), or null.

axes int[]

The transformed axes, or null for all of them.

norm string

The normalization mode, as for Fft(NDArray, int?, int, string, NDArray).

out NDArray

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

Returns

NDArray

The transform, complex128, the last transformed axis halved.

Remarks

NumPy's statements: _cook_nd_args(a, s, axes), rfft over the last axis (rfft(a, s[-1], axes[-1], norm, out=out)), then fft over the others in reverse order, all with the provided out. Each axis runs this engine's _raw_fft with the original operand's precision.

Exceptions

ValueError

Mismatched s / axes, a length below 1, an unknown norm, or an unfit out.

IndexError

An axis out of range, or no axis to transform (a 0-d input, an empty axes: list index out of range).

AxisError

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

TypeError

A complex input.

DTypePromotionError

A text input.