From 52a3f113cab0c7de829b17b4a8ec364c946432c5 Mon Sep 17 00:00:00 2001 From: daniellga <43149605+daniellga@users.noreply.github.com> Date: Tue, 18 Jun 2024 02:00:48 +0000 Subject: [PATCH] Update docs --- _docs/contents/hfftplanner.qmd | 158 +++ _docs/contents/hrealfftplanner.qmd | 169 +++ docs/about.html | 12 + docs/contents/harray.html | 12 + docs/contents/haudioop.html | 12 + docs/contents/haudiosink.html | 12 + docs/contents/hdatatype.html | 12 + docs/contents/hdecodedaudio.html | 12 + docs/contents/hdecoderstream.html | 12 + docs/contents/hfft.html | 12 + docs/contents/hfftplanner.html | 1009 ++++++++++++++++ docs/contents/hfile.html | 12 + docs/contents/hinterpolationtype.html | 12 + docs/contents/hmetadatatype.html | 12 + docs/contents/hpolynomialdegree.html | 12 + docs/contents/hrealfftplanner.html | 1017 +++++++++++++++++ docs/contents/hresampler.html | 12 + docs/contents/hresamplertype.html | 12 + .../hsincinterpolationparameters.html | 12 + docs/contents/hwindow.html | 12 + docs/contents/hwindowtype.html | 12 + docs/index.html | 12 + docs/search.json | 248 +++- 23 files changed, 2759 insertions(+), 58 deletions(-) create mode 100644 _docs/contents/hfftplanner.qmd create mode 100644 _docs/contents/hrealfftplanner.qmd create mode 100644 docs/contents/hfftplanner.html create mode 100644 docs/contents/hrealfftplanner.html diff --git a/_docs/contents/hfftplanner.qmd b/_docs/contents/hfftplanner.qmd new file mode 100644 index 0000000..921f0be --- /dev/null +++ b/_docs/contents/hfftplanner.qmd @@ -0,0 +1,158 @@ +--- +title: HFftPlanner +--- + +## new + +`new(dtype: HDataType) -> HFftPlanner` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfft.rs#L65) \ + +Creates a new `HFftPlanner` instance. \ +If you plan on creating multiple FFT instances, it is recommended to reuse the same planner for all of them. This is because the planner re-uses internal data +across FFT instances wherever possible, saving memory and reducing setup time. (FFT instances created with one planner will never re-use data and buffers with +FFT instances created by a different planner) \ +In the constructor, the FftPlanner will detect available CPU features. If AVX, SSE, Neon, or WASM SIMD are available, it will set itself up to plan FFTs with +the fastest available instruction set. If no SIMD instruction sets are available, the planner will seamlessly fall back to planning non-SIMD FFTs. \ + +#### Arguments + +* `dtype` \ +A complex `HDataType` to indicate the dtype that the `HFftPlanner` will be working with. \ + +#### Returns + +An `HFftPlanner`. \ +Will return an error if dtype is of a float type. \ + +#### Examples + +```r +library(harmonium) +arr = array(c(1,2,3,4,5,6,7,8,9,10,11,12), c(3,4)) +dtype = HDataType$Float32 +harray = HArray$new_from_values(arr, dtype) +fft_planner = HFftPlanner$new(harray$dtype()) +``` + +_________ + +## fft + +`fft(harray: HArray)` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfft.rs#L115) \ + +Computes the fast fourier transform of a complex `HArray`. \ +The operation is done in-place. \ +FFT (Fast Fourier Transform) refers to a way the discrete Fourier Transform (DFT) can be calculated efficiently, +by using symmetries in the calculated terms. The symmetry is highest when n is a power of 2, and the transform +is therefore most efficient for these sizes. \ + +The function does not normalize outputs. Callers must manually normalize the results by scaling each element by +`1/sqrt(n)`. Multiple normalization steps can be merged into one via pairwise multiplication, so when doing +a forward FFT followed by an inverse callers can normalize once by scaling each element by `1/n`. \ + +Elements in the output are ordered by ascending frequency, with the first element corresponding to frequency 0. \ + +#### Arguments + +* `harray` \ +A complex `HArray`. \ + +#### Returns + +Will return an error if: +* The `HArray`'s dtype is incompatible with the `HFftPlanner`'s dtype. \ +* The `HArray`'s `ndim` is greater than 2. \ + +#### Examples + +```r +library(harmonium) +arr = array(c(1,2,3,4,5,6,7,8,9,10,11,12), c(3,4)) +dtype = HDataType$Float32 +harray = HArray$new_from_values(arr, dtype) +fft_planner = HFftPlanner$new(harray$dtype()) +fft_planner$fft(harray) +``` + +_________ + +## ifft + +`ifft(harray: HArray)` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfft.rs#L158) \ + +Computes the inverse fast fourier transform of a complex `HArray`. \ +The operation is done in-place. \ +FFT (Fast Fourier Transform) refers to a way the discrete Fourier Transform (DFT) can be calculated efficiently, +by using symmetries in the calculated terms. The symmetry is highest when n is a power of 2, and the transform +is therefore most efficient for these sizes. \ + +The function does not normalize outputs. Callers must manually normalize the results by scaling each element by +`1/sqrt(n)`. Multiple normalization steps can be merged into one via pairwise multiplication, so when doing +a forward FFT followed by an inverse callers can normalize once by scaling each element by `1/n`. \ + +#### Arguments + +* `harray` \ +A complex `HArray`. \ + +#### Returns + +Will return an error if: +* The `HArray`'s dtype is incompatible with the `HFftPlanner`'s dtype. \ +* The `HArray`'s `ndim` is greater than 2. \ + +#### Examples + +```r +library(harmonium) +arr = array(c(1+1i,2+2i,3+3i,4+4i,5+5i,6+6i), c(3,2)) +dtype = HDataType$Complex32 +harray = HArray$new_from_values(arr, dtype) +fft_planner = HFftPlanner$new(harray$dtype()) +fft_planner$ifft(harray) +``` + +_________ + +## dtype + +`dtype() -> HDataType` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfft.rs#L185) \ + +Gets the `HFftPlanner`'s dtype. + +#### Returns + +An `HDataType`. + +#### Examples + +```r +arr = array(c(1+1i,2+2i,3+3i,4+4i,5+5i,6+6i), c(3,2)) +dtype = HDataType$Complex32 +harray = HArray$new_from_values(arr, dtype) +fft_planner = HFftPlanner$new(harray$dtype()) +fft_planner$dtype() +``` + +_________ + +## print + +`print()` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfft.rs#L212) \ + +Print the `HFftPlanner`. \ +Differently from R's normal behaviour, `print` doesn't return the value invisibly. \ + +#### Examples + +```r +arr = array(c(1+1i,2+2i,3+3i,4+4i,5+5i,6+6i), c(3,2)) +dtype = HDataType$Complex32 +harray = HArray$new_from_values(arr, dtype) +fft_planner = HFftPlanner$new(harray$dtype()) +fft_planner$print() + +# or similarly: +print(fft_planner) +``` + +_________ diff --git a/_docs/contents/hrealfftplanner.qmd b/_docs/contents/hrealfftplanner.qmd new file mode 100644 index 0000000..139eece --- /dev/null +++ b/_docs/contents/hrealfftplanner.qmd @@ -0,0 +1,169 @@ +--- +title: HRealFftPlanner +--- + +## new + +`new(dtype: HDataType) -> HRealFftPlanner` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfft.rs#L253) \ + +Creates a new `HRealFftPlanner` instance. \ +If you plan on creating multiple FFT instances, it is recommended to reuse the same planner for all of them. This is because the planner re-uses internal data +across FFT instances wherever possible, saving memory and reducing setup time. (FFT instances created with one planner will never re-use data and buffers with +FFT instances created by a different planner) \ +In the constructor, the FftPlanner will detect available CPU features. If AVX, SSE, Neon, or WASM SIMD are available, it will set itself up to plan FFTs with +the fastest available instruction set. If no SIMD instruction sets are available, the planner will seamlessly fall back to planning non-SIMD FFTs. \ + +#### Arguments + +* `dtype` \ +A float `HDataType` to indicate the dtype that the `HFftPlanner` will be working with. \ + +#### Returns + +An `HRealFftPlanner`. \ +Will return an error if dtype is of a complex type. \ + +#### Examples + +```r +library(harmonium) +arr = array(c(1,2,3,4,5,6,7,8,9,10,11,12), c(3,4)) +dtype = HDataType$Float32 +harray = HArray$new_from_values(arr, dtype) +real_fft_planner = HRealFftPlanner$new(harray$dtype()) +``` + +_________ + +## rfft + +`rfft(harray: HArray)` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfft.rs#L305) \ + +Computes the fast fourier transform of a float `HArray`. Transforms a real signal of length `N` to a complex-valued spectrum of length `N/2+1` (with `N/2` rounded down). \ +The operation is not done in-place, although the same external pointer is used to store the new HArray. \ +The FFT of a real signal is Hermitian-symmetric, X[i] = conj(X[-i]) so the output contains only the positive frequencies +below the Nyquist frequency. \ +FFT (Fast Fourier Transform) refers to a way the discrete Fourier Transform (DFT) can be calculated efficiently, +by using symmetries in the calculated terms. The symmetry is highest when n is a power of 2, and the transform +is therefore most efficient for these sizes. \ + +The function does not normalize outputs. Callers must manually normalize the results by scaling each element by +`1/sqrt(n)`. Multiple normalization steps can be merged into one via pairwise multiplication, so when doing +a forward FFT followed by an inverse callers can normalize once by scaling each element by `1/n`. \ + +Elements in the output are ordered by ascending frequency, with the first element corresponding to frequency 0. \ + +#### Arguments + +* `harray` \ +A float `HArray`. \ + +#### Returns + +Will return an error if: +* The `HArray`'s dtype is incompatible with the `HFftPlanner`'s dtype. \ +* The `HArray`'s `ndim` is greater than 2. \ + +#### Examples + +```r +library(harmonium) +arr = array(c(1,2,3,4,5,6,7,8,9,10,11,12), c(3,4)) +dtype = HDataType$Float32 +harray = HArray$new_from_values(arr, dtype) +real_fft_planner = HRealFftPlanner$new(harray$dtype()) +real_fft_planner$rfft(harray) +``` + +_________ + +## irfft + +`irfft(harray: HArray, length: integer)` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfft.rs#L357) \ + +Computes the inverse fast fourier transform of a complex `HArray`. Transforms a complex spectrum of length `N/2+1` (with `N/2` rounded down) to a real-valued +signal of length `N`. \ +The operation is not done in-place, although the same external pointer is used to store the new HArray. \ +The FFT of a real signal is Hermitian-symmetric, X[i] = conj(X[-i]) so the output contains only the positive frequencies +below the Nyquist frequency. \ +FFT (Fast Fourier Transform) refers to a way the discrete Fourier Transform (DFT) can be calculated efficiently, +by using symmetries in the calculated terms. The symmetry is highest when n is a power of 2, and the transform +is therefore most efficient for these sizes. \ + +The function does not normalize outputs. Callers must manually normalize the results by scaling each element by +`1/sqrt(n)`. Multiple normalization steps can be merged into one via pairwise multiplication, so when doing +a forward FFT followed by an inverse callers can normalize once by scaling each element by `1/n`. \ + +#### Arguments + +* `harray` \ +A complex `HArray`. The `HArray`'s dtype must be the complex equivalent of the `HRealFftPlanner`'s dtype. For example if `HRealFftPlanner` dtype is `Float64`, +the `HArray`'s dtype must be `Complex64`. \ +* `length` \ +An integer. The output length of the signal. Since the spectrum is `N/2+1`, the length can be `N` and `N+1`, if `N` is even, or can be `N` and `N-1` if `N` is odd. \ + +#### Returns + +Will return an error if: +* The `HArray`'s dtype is incompatible with the `HFftPlanner`'s dtype. \ +* The `HArray`'s `ndim` is greater than 2. \ +* The `length` argument is not compatible with the spectrum length. \ + +#### Examples + +```r +library(harmonium) +r = as.double(sample(100, 4, replace = TRUE)) +i = as.double(sample(100, 3, replace = TRUE)) +arr = array(complex(real=r, imaginary=c(0,i)), c(4,1)) +dtype = HDataType$Complex32 +harray = HArray$new_from_values(arr, dtype) +real_fft_planner = HRealFftPlanner$new(HDataType$Float32) +real_fft_planner$irfft(harray, 7L) +``` + +_________ + +## dtype + +`dtype() -> HDataType` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfft.rs#L388) \ + +Gets the `HRealFftPlanner`'s dtype. + +#### Returns + +An `HDataType`. + +#### Examples + +```r +arr = array(c(1,2,3,4,5,6,7,8,9,10,11,12), c(3,4)) +dtype = HDataType$Float32 +harray = HArray$new_from_values(arr, dtype) +real_fft_planner = HRealFftPlanner$new(harray$dtype()) +real_fft_planner$dtype() +``` + +_________ + +## print + +`print()` [source](https://github.com/daniellga/harmonium/tree/master/r-harmonium/src/rust/src/hfft.rs#L415) \ + +Print the `HRealFftPlanner`. \ +Differently from R's normal behaviour, `print` doesn't return the value invisibly. \ + +#### Examples + +```r +arr = array(c(1,2,3,4,5,6,7,8,9,10,11,12), c(3,4)) +dtype = HDataType$Float32 +harray = HArray$new_from_values(arr, dtype) +real_fft_planner = HRealFftPlanner$new(harray$dtype()) +real_fft_planner$print() + +# or similarly: +print(real_fft_planner) +``` + +_________ diff --git a/docs/about.html b/docs/about.html index d93e3d5..94c2e1c 100644 --- a/docs/about.html +++ b/docs/about.html @@ -158,6 +158,12 @@ HFft + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +