Buckets:
| # utils/maths | |
| Helper module for mathematical processing. | |
| These functions and classes are only used internally, | |
| meaning an end-user shouldn't need to access anything here. | |
| * [utils/maths](#module_utils/maths) | |
| * _static_ | |
| * [`.interpolate_data(input)`](#module_utils/maths.interpolate_data) | |
| * [`.permute_data(array, dims, axes)`](#module_utils/maths.permute_data) ⇒ <code>*</code> | |
| * [`.softmax(arr)`](#module_utils/maths.softmax) ⇒ <code>T</code> | |
| * [`.log_softmax(arr)`](#module_utils/maths.log_softmax) ⇒ <code>T</code> | |
| * [`.dot(arr1, arr2)`](#module_utils/maths.dot) ⇒ <code>number</code> | |
| * [`.cos_sim(arr1, arr2)`](#module_utils/maths.cos_sim) ⇒ <code>number</code> | |
| * [`.magnitude(arr)`](#module_utils/maths.magnitude) ⇒ <code>number</code> | |
| * [`.min(arr)`](#module_utils/maths.min) ⇒ <code>*</code> | |
| * [`.max(arr)`](#module_utils/maths.max) ⇒ <code>*</code> | |
| * [`.medianFilter(data, windowSize)`](#module_utils/maths.medianFilter) | |
| * [`.round(num, decimals)`](#module_utils/maths.round) ⇒ <code>number</code> | |
| * [`.bankers_round(x)`](#module_utils/maths.bankers_round) ⇒ <code>number</code> | |
| * [`.dynamic_time_warping(matrix)`](#module_utils/maths.dynamic_time_warping) ⇒ <code>Array.<Array<number>></code> | |
| * _inner_ | |
| * [~P2FFT](#module_utils/maths..P2FFT) | |
| * [`new P2FFT(size)`](#new_module_utils/maths..P2FFT_new) | |
| * [`.createComplexArray()`](#module_utils/maths..P2FFT+createComplexArray) ⇒ <code>Float64Array</code> | |
| * [`.fromComplexArray(complex, [storage])`](#module_utils/maths..P2FFT+fromComplexArray) ⇒ <code>Array.<number></code> | |
| * [`.toComplexArray(input, [storage])`](#module_utils/maths..P2FFT+toComplexArray) ⇒ <code>Float64Array</code> | |
| * [`.transform(out, data)`](#module_utils/maths..P2FFT+transform) ⇒ <code>void</code> | |
| * [`.realTransform(out, data)`](#module_utils/maths..P2FFT+realTransform) | |
| * [`.inverseTransform(out, data)`](#module_utils/maths..P2FFT+inverseTransform) ⇒ <code>void</code> | |
| * [`._transform4(out, data, inv)`](#module_utils/maths..P2FFT+_transform4) ⇒ <code>void</code> | |
| * [`._singleTransform2(data, out, outOff, off, step)`](#module_utils/maths..P2FFT+_singleTransform2) ⇒ <code>void</code> | |
| * [`._singleTransform4(data, out, outOff, off, step, inv)`](#module_utils/maths..P2FFT+_singleTransform4) ⇒ <code>void</code> | |
| * [`._realTransform4(out, data, inv)`](#module_utils/maths..P2FFT+_realTransform4) | |
| * [`._singleRealTransform2(data, out, outOff, off, step)`](#module_utils/maths..P2FFT+_singleRealTransform2) ⇒ <code>void</code> | |
| * [`._singleRealTransform4(data, out, outOff, off, step, inv)`](#module_utils/maths..P2FFT+_singleRealTransform4) | |
| * [~NP2FFT](#module_utils/maths..NP2FFT) | |
| * [`new NP2FFT(fft_length)`](#new_module_utils/maths..NP2FFT_new) | |
| * [`~AnyTypedArray`](#module_utils/maths..AnyTypedArray) : <code>Int8Array</code> | <code>Uint8Array</code> | <code>Uint8ClampedArray</code> | <code>Int16Array</code> | <code>Uint16Array</code> | <code>Int32Array</code> | <code>Uint32Array</code> | <code>Float16Array</code> | <code>Float32Array</code> | <code>Float64Array</code> | |
| * * * | |
| <a id="module_utils/maths.interpolate_data" class="group"></a> | |
| ## `utils/maths.interpolate_data(input)` | |
| **Kind**: static method of [<code>utils/maths</code>](#module_utils/maths) | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>input</td><td><code>TypedArray</code></td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths.permute_data" class="group"></a> | |
| ## `utils/maths.permute_data(array, dims, axes)` ⇒ <code>*</code> | |
| Helper method to permute a `AnyTypedArray` directly | |
| **Kind**: static method of [<code>utils/maths</code>](#module_utils/maths) | |
| **Returns**: <code>*</code> - The permuted array and the new shape. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>array</td><td><code>T</code></td> | |
| </tr><tr> | |
| <td>dims</td><td><code>Array.<number></code></td> | |
| </tr><tr> | |
| <td>axes</td><td><code>Array.<number></code></td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths.softmax" class="group"></a> | |
| ## `utils/maths.softmax(arr)` ⇒ <code>T</code> | |
| Compute the softmax of an array of numbers. | |
| **Kind**: static method of [<code>utils/maths</code>](#module_utils/maths) | |
| **Returns**: <code>T</code> - The softmax array. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>arr</td><td><code>T</code></td><td><p>The array of numbers to compute the softmax of.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths.log_softmax" class="group"></a> | |
| ## `utils/maths.log_softmax(arr)` ⇒ <code>T</code> | |
| Calculates the logarithm of the softmax function for the input array. | |
| **Kind**: static method of [<code>utils/maths</code>](#module_utils/maths) | |
| **Returns**: <code>T</code> - The resulting log_softmax array. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>arr</td><td><code>T</code></td><td><p>The input array to calculate the log_softmax function for.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths.dot" class="group"></a> | |
| ## `utils/maths.dot(arr1, arr2)` ⇒ <code>number</code> | |
| Calculates the dot product of two arrays. | |
| **Kind**: static method of [<code>utils/maths</code>](#module_utils/maths) | |
| **Returns**: <code>number</code> - The dot product of arr1 and arr2. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>arr1</td><td><code>Array.<number></code></td><td><p>The first array.</p> | |
| </td> | |
| </tr><tr> | |
| <td>arr2</td><td><code>Array.<number></code></td><td><p>The second array.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths.cos_sim" class="group"></a> | |
| ## `utils/maths.cos_sim(arr1, arr2)` ⇒ <code>number</code> | |
| Computes the cosine similarity between two arrays. | |
| **Kind**: static method of [<code>utils/maths</code>](#module_utils/maths) | |
| **Returns**: <code>number</code> - The cosine similarity between the two arrays. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>arr1</td><td><code>Array.<number></code></td><td><p>The first array.</p> | |
| </td> | |
| </tr><tr> | |
| <td>arr2</td><td><code>Array.<number></code></td><td><p>The second array.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths.magnitude" class="group"></a> | |
| ## `utils/maths.magnitude(arr)` ⇒ <code>number</code> | |
| Calculates the magnitude of a given array. | |
| **Kind**: static method of [<code>utils/maths</code>](#module_utils/maths) | |
| **Returns**: <code>number</code> - The magnitude of the array. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>arr</td><td><code>Array.<number></code></td><td><p>The array to calculate the magnitude of.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths.min" class="group"></a> | |
| ## `utils/maths.min(arr)` ⇒ <code>*</code> | |
| Returns the value and index of the minimum element in an array. | |
| **Kind**: static method of [<code>utils/maths</code>](#module_utils/maths) | |
| **Returns**: <code>*</code> - the value and index of the minimum element, of the form: [valueOfMin, indexOfMin] | |
| **Throws**: | |
| - <code>Error</code> If array is empty. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>arr</td><td><code>T</code></td><td><p>array of numbers.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths.max" class="group"></a> | |
| ## `utils/maths.max(arr)` ⇒ <code>*</code> | |
| Returns the value and index of the maximum element in an array. | |
| **Kind**: static method of [<code>utils/maths</code>](#module_utils/maths) | |
| **Returns**: <code>*</code> - the value and index of the maximum element, of the form: [valueOfMax, indexOfMax] | |
| **Throws**: | |
| - <code>Error</code> If array is empty. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>arr</td><td><code>T</code></td><td><p>array of numbers.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths.medianFilter" class="group"></a> | |
| ## `utils/maths.medianFilter(data, windowSize)` | |
| Performs median filter on the provided data. Padding is done by mirroring the data. | |
| **Kind**: static method of [<code>utils/maths</code>](#module_utils/maths) | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>data</td><td><code>AnyTypedArray</code></td><td><p>The input array</p> | |
| </td> | |
| </tr><tr> | |
| <td>windowSize</td><td><code>number</code></td><td><p>The window size</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths.round" class="group"></a> | |
| ## `utils/maths.round(num, decimals)` ⇒ <code>number</code> | |
| Helper function to round a number to a given number of decimals | |
| **Kind**: static method of [<code>utils/maths</code>](#module_utils/maths) | |
| **Returns**: <code>number</code> - The rounded number | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>num</td><td><code>number</code></td><td><p>The number to round</p> | |
| </td> | |
| </tr><tr> | |
| <td>decimals</td><td><code>number</code></td><td><p>The number of decimals</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths.bankers_round" class="group"></a> | |
| ## `utils/maths.bankers_round(x)` ⇒ <code>number</code> | |
| Helper function to round a number to the nearest integer, with ties rounded to the nearest even number. | |
| Also known as "bankers' rounding". This is the default rounding mode in python. For example: | |
| 1.5 rounds to 2 and 2.5 rounds to 2. | |
| **Kind**: static method of [<code>utils/maths</code>](#module_utils/maths) | |
| **Returns**: <code>number</code> - The rounded number | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>x</td><td><code>number</code></td><td><p>The number to round</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths.dynamic_time_warping" class="group"></a> | |
| ## `utils/maths.dynamic_time_warping(matrix)` ⇒ <code>Array.<Array<number>></code> | |
| Measures similarity between two temporal sequences (e.g., input audio and output tokens | |
| to generate token-level timestamps). | |
| **Kind**: static method of [<code>utils/maths</code>](#module_utils/maths) | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>matrix</td><td><code>Array.<Array<number>></code></td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths..P2FFT" class="group"></a> | |
| ## utils/maths~P2FFT | |
| Implementation of Radix-4 FFT. | |
| P2FFT class provides functionality for performing Fast Fourier Transform on arrays | |
| which are a power of two in length. | |
| Code adapted from https://www.npmjs.com/package/fft.js | |
| **Kind**: inner class of [<code>utils/maths</code>](#module_utils/maths) | |
| * [~P2FFT](#module_utils/maths..P2FFT) | |
| * [`new P2FFT(size)`](#new_module_utils/maths..P2FFT_new) | |
| * [`.createComplexArray()`](#module_utils/maths..P2FFT+createComplexArray) ⇒ <code>Float64Array</code> | |
| * [`.fromComplexArray(complex, [storage])`](#module_utils/maths..P2FFT+fromComplexArray) ⇒ <code>Array.<number></code> | |
| * [`.toComplexArray(input, [storage])`](#module_utils/maths..P2FFT+toComplexArray) ⇒ <code>Float64Array</code> | |
| * [`.transform(out, data)`](#module_utils/maths..P2FFT+transform) ⇒ <code>void</code> | |
| * [`.realTransform(out, data)`](#module_utils/maths..P2FFT+realTransform) | |
| * [`.inverseTransform(out, data)`](#module_utils/maths..P2FFT+inverseTransform) ⇒ <code>void</code> | |
| * [`._transform4(out, data, inv)`](#module_utils/maths..P2FFT+_transform4) ⇒ <code>void</code> | |
| * [`._singleTransform2(data, out, outOff, off, step)`](#module_utils/maths..P2FFT+_singleTransform2) ⇒ <code>void</code> | |
| * [`._singleTransform4(data, out, outOff, off, step, inv)`](#module_utils/maths..P2FFT+_singleTransform4) ⇒ <code>void</code> | |
| * [`._realTransform4(out, data, inv)`](#module_utils/maths..P2FFT+_realTransform4) | |
| * [`._singleRealTransform2(data, out, outOff, off, step)`](#module_utils/maths..P2FFT+_singleRealTransform2) ⇒ <code>void</code> | |
| * [`._singleRealTransform4(data, out, outOff, off, step, inv)`](#module_utils/maths..P2FFT+_singleRealTransform4) | |
| * * * | |
| <a id="new_module_utils/maths..P2FFT_new" class="group"></a> | |
| ### `new P2FFT(size)` | |
| **Throws**: | |
| - <code>Error</code> FFT size must be a power of two larger than 1. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>size</td><td><code>number</code></td><td><p>The size of the input array. Must be a power of two larger than 1.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths..P2FFT+createComplexArray" class="group"></a> | |
| ### `p2FFT.createComplexArray()` ⇒ <code>Float64Array</code> | |
| Create a complex number array with size `2 * size` | |
| **Kind**: instance method of [<code>P2FFT</code>](#module_utils/maths..P2FFT) | |
| **Returns**: <code>Float64Array</code> - A complex number array with size `2 * size` | |
| * * * | |
| <a id="module_utils/maths..P2FFT+fromComplexArray" class="group"></a> | |
| ### `p2FFT.fromComplexArray(complex, [storage])` ⇒ <code>Array.<number></code> | |
| Converts a complex number representation stored in a Float64Array to an array of real numbers. | |
| **Kind**: instance method of [<code>P2FFT</code>](#module_utils/maths..P2FFT) | |
| **Returns**: <code>Array.<number></code> - An array of real numbers representing the input complex number representation. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>complex</td><td><code>Float64Array</code></td><td><p>The complex number representation to be converted.</p> | |
| </td> | |
| </tr><tr> | |
| <td>[storage]</td><td><code>Array.<number></code></td><td><p>An optional array to store the result in.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths..P2FFT+toComplexArray" class="group"></a> | |
| ### `p2FFT.toComplexArray(input, [storage])` ⇒ <code>Float64Array</code> | |
| Convert a real-valued input array to a complex-valued output array. | |
| **Kind**: instance method of [<code>P2FFT</code>](#module_utils/maths..P2FFT) | |
| **Returns**: <code>Float64Array</code> - The complex-valued output array. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>input</td><td><code>Float64Array</code></td><td><p>The real-valued input array.</p> | |
| </td> | |
| </tr><tr> | |
| <td>[storage]</td><td><code>Float64Array</code></td><td><p>Optional buffer to store the output array.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths..P2FFT+transform" class="group"></a> | |
| ### `p2FFT.transform(out, data)` ⇒ <code>void</code> | |
| Performs a Fast Fourier Transform (FFT) on the given input data and stores the result in the output buffer. | |
| **Kind**: instance method of [<code>P2FFT</code>](#module_utils/maths..P2FFT) | |
| **Throws**: | |
| - <code>Error</code> Input and output buffers must be different. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>out</td><td><code>Float64Array</code></td><td><p>The output buffer to store the result.</p> | |
| </td> | |
| </tr><tr> | |
| <td>data</td><td><code>Float64Array</code></td><td><p>The input data to transform.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths..P2FFT+realTransform" class="group"></a> | |
| ### `p2FFT.realTransform(out, data)` | |
| Performs a real-valued forward FFT on the given input buffer and stores the result in the given output buffer. | |
| The input buffer must contain real values only, while the output buffer will contain complex values. The input and | |
| output buffers must be different. | |
| **Kind**: instance method of [<code>P2FFT</code>](#module_utils/maths..P2FFT) | |
| **Throws**: | |
| - <code>Error</code> If the input and output buffers are the same. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>out</td><td><code>Float64Array</code></td><td><p>The output buffer.</p> | |
| </td> | |
| </tr><tr> | |
| <td>data</td><td><code>Float64Array</code></td><td><p>The input buffer containing real values.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths..P2FFT+inverseTransform" class="group"></a> | |
| ### `p2FFT.inverseTransform(out, data)` ⇒ <code>void</code> | |
| Performs an inverse FFT transformation on the given `data` array, and stores the result in `out`. | |
| The `out` array must be a different buffer than the `data` array. The `out` array will contain the | |
| result of the transformation. The `data` array will not be modified. | |
| **Kind**: instance method of [<code>P2FFT</code>](#module_utils/maths..P2FFT) | |
| **Throws**: | |
| - <code>Error</code> If `out` and `data` refer to the same buffer. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>out</td><td><code>Float64Array</code></td><td><p>The output buffer for the transformed data.</p> | |
| </td> | |
| </tr><tr> | |
| <td>data</td><td><code>Float64Array</code></td><td><p>The input data to transform.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths..P2FFT+_transform4" class="group"></a> | |
| ### `p2FFT._transform4(out, data, inv)` ⇒ <code>void</code> | |
| Performs a radix-4 implementation of a discrete Fourier transform on a given set of data. | |
| **Kind**: instance method of [<code>P2FFT</code>](#module_utils/maths..P2FFT) | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>out</td><td><code>Float64Array</code></td><td><p>The output buffer for the transformed data.</p> | |
| </td> | |
| </tr><tr> | |
| <td>data</td><td><code>Float64Array</code></td><td><p>The input buffer of data to be transformed.</p> | |
| </td> | |
| </tr><tr> | |
| <td>inv</td><td><code>number</code></td><td><p>A scaling factor to apply to the transform.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths..P2FFT+_singleTransform2" class="group"></a> | |
| ### `p2FFT._singleTransform2(data, out, outOff, off, step)` ⇒ <code>void</code> | |
| Performs a radix-2 implementation of a discrete Fourier transform on a given set of data. | |
| **Kind**: instance method of [<code>P2FFT</code>](#module_utils/maths..P2FFT) | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>data</td><td><code>Float64Array</code></td><td><p>The input buffer of data to be transformed.</p> | |
| </td> | |
| </tr><tr> | |
| <td>out</td><td><code>Float64Array</code></td><td><p>The output buffer for the transformed data.</p> | |
| </td> | |
| </tr><tr> | |
| <td>outOff</td><td><code>number</code></td><td><p>The offset at which to write the output data.</p> | |
| </td> | |
| </tr><tr> | |
| <td>off</td><td><code>number</code></td><td><p>The offset at which to begin reading the input data.</p> | |
| </td> | |
| </tr><tr> | |
| <td>step</td><td><code>number</code></td><td><p>The step size for indexing the input data.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths..P2FFT+_singleTransform4" class="group"></a> | |
| ### `p2FFT._singleTransform4(data, out, outOff, off, step, inv)` ⇒ <code>void</code> | |
| Performs radix-4 transformation on input data of length 8 | |
| **Kind**: instance method of [<code>P2FFT</code>](#module_utils/maths..P2FFT) | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>data</td><td><code>Float64Array</code></td><td><p>Input data array of length 8</p> | |
| </td> | |
| </tr><tr> | |
| <td>out</td><td><code>Float64Array</code></td><td><p>Output data array of length 8</p> | |
| </td> | |
| </tr><tr> | |
| <td>outOff</td><td><code>number</code></td><td><p>Index of output array to start writing from</p> | |
| </td> | |
| </tr><tr> | |
| <td>off</td><td><code>number</code></td><td><p>Index of input array to start reading from</p> | |
| </td> | |
| </tr><tr> | |
| <td>step</td><td><code>number</code></td><td><p>Step size between elements in input array</p> | |
| </td> | |
| </tr><tr> | |
| <td>inv</td><td><code>number</code></td><td><p>Scaling factor for inverse transform</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths..P2FFT+_realTransform4" class="group"></a> | |
| ### `p2FFT._realTransform4(out, data, inv)` | |
| Real input radix-4 implementation | |
| **Kind**: instance method of [<code>P2FFT</code>](#module_utils/maths..P2FFT) | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>out</td><td><code>Float64Array</code></td><td><p>Output array for the transformed data</p> | |
| </td> | |
| </tr><tr> | |
| <td>data</td><td><code>Float64Array</code></td><td><p>Input array of real data to be transformed</p> | |
| </td> | |
| </tr><tr> | |
| <td>inv</td><td><code>number</code></td><td><p>The scale factor used to normalize the inverse transform</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths..P2FFT+_singleRealTransform2" class="group"></a> | |
| ### `p2FFT._singleRealTransform2(data, out, outOff, off, step)` ⇒ <code>void</code> | |
| Performs a single real input radix-2 transformation on the provided data | |
| **Kind**: instance method of [<code>P2FFT</code>](#module_utils/maths..P2FFT) | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>data</td><td><code>Float64Array</code></td><td><p>The input data array</p> | |
| </td> | |
| </tr><tr> | |
| <td>out</td><td><code>Float64Array</code></td><td><p>The output data array</p> | |
| </td> | |
| </tr><tr> | |
| <td>outOff</td><td><code>number</code></td><td><p>The output offset</p> | |
| </td> | |
| </tr><tr> | |
| <td>off</td><td><code>number</code></td><td><p>The input offset</p> | |
| </td> | |
| </tr><tr> | |
| <td>step</td><td><code>number</code></td><td><p>The step</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths..P2FFT+_singleRealTransform4" class="group"></a> | |
| ### `p2FFT._singleRealTransform4(data, out, outOff, off, step, inv)` | |
| Computes a single real-valued transform using radix-4 algorithm. | |
| This method is only called for len=8. | |
| **Kind**: instance method of [<code>P2FFT</code>](#module_utils/maths..P2FFT) | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>data</td><td><code>Float64Array</code></td><td><p>The input data array.</p> | |
| </td> | |
| </tr><tr> | |
| <td>out</td><td><code>Float64Array</code></td><td><p>The output data array.</p> | |
| </td> | |
| </tr><tr> | |
| <td>outOff</td><td><code>number</code></td><td><p>The offset into the output array.</p> | |
| </td> | |
| </tr><tr> | |
| <td>off</td><td><code>number</code></td><td><p>The offset into the input array.</p> | |
| </td> | |
| </tr><tr> | |
| <td>step</td><td><code>number</code></td><td><p>The step size for the input array.</p> | |
| </td> | |
| </tr><tr> | |
| <td>inv</td><td><code>number</code></td><td><p>The value of inverse.</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths..NP2FFT" class="group"></a> | |
| ## utils/maths~NP2FFT | |
| NP2FFT class provides functionality for performing Fast Fourier Transform on arrays | |
| which are not a power of two in length. In such cases, the chirp-z transform is used. | |
| For more information, see: https://math.stackexchange.com/questions/77118/non-power-of-2-ffts/77156#77156 | |
| **Kind**: inner class of [<code>utils/maths</code>](#module_utils/maths) | |
| * * * | |
| <a id="new_module_utils/maths..NP2FFT_new" class="group"></a> | |
| ### `new NP2FFT(fft_length)` | |
| Constructs a new NP2FFT object. | |
| <table> | |
| <thead> | |
| <tr> | |
| <th>Param</th><th>Type</th><th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| <tr> | |
| <td>fft_length</td><td><code>number</code></td><td><p>The length of the FFT</p> | |
| </td> | |
| </tr> </tbody> | |
| </table> | |
| * * * | |
| <a id="module_utils/maths..AnyTypedArray" class="group"></a> | |
| ## `utils/maths~AnyTypedArray` : <code>Int8Array</code> | <code>Uint8Array</code> | <code>Uint8ClampedArray</code> | <code>Int16Array</code> | <code>Uint16Array</code> | <code>Int32Array</code> | <code>Uint32Array</code> | <code>Float16Array</code> | <code>Float32Array</code> | <code>Float64Array</code> | |
| **Kind**: inner typedef of [<code>utils/maths</code>](#module_utils/maths) | |
| * * * | |
| <EditOnGithub source="https://github.com/huggingface/transformers.js/blob/main/docs/source/api/utils/maths.md" /> |
Xet Storage Details
- Size:
- 25.3 kB
- Xet hash:
- 66d78b197eb89b4e21a3c3f2ffecb2be2b4b9087862b7e4ad6a15bad82fe830f
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.