Skip to content

Latest commit

 

History

History
164 lines (102 loc) · 4.59 KB

File metadata and controls

164 lines (102 loc) · 4.59 KB

rffti

Initialize a workspace array for performing a real-valued Fourier transform.

Usage

var rffti = require( '@stdlib/fft/base/fftpack/rffti' );

rffti( N, workspace, strideW, offsetW )

Initializes a workspace array for performing a real-valued Fourier transform.

var Float64Array = require( '@stdlib/array/float64' );

var N = 8;
var workspace = new Float64Array( ( 2*N ) + 34 );

rffti( N, workspace, 1, 0 );

var twiddleFactors = workspace.slice( N, 2*N );
// returns <Float64Array>[ 0, ~0.707, ~0.707, 0, 0, 0, 0, 0 ]

var factors = workspace.slice( 2*N, ( 2*N ) + 4 );
// returns <Float64Array>[ 8, 2, 2, 4 ]

The function accepts the following arguments:

  • N: length of the sequence to transform.
  • workspace: workspace array.
  • strideW: stride length for workspace.
  • offsetW: starting index for workspace.

Notes

  • The workspace array is divided into three sections:

              size = N                 N            2+ceil(log2(N)/2)
                   ↓                   ↓                  ↓
        | scratch / workspace | twiddle factors | radix factor table |
                   ↑                   ↑                  ↑
    i = 0         ...         N       ...       2N       ...
    
    • scratch/workspace: used as a scratch space when performing transforms. This section is not updated during initialization.
    • twiddle factors: a table of reusable complex-exponential constants stored as cosine/sine pairs.
    • radix factor table: a table containing the sequence length N, the number of factors into which N was decomposed, and the individual integer radix factors.
  • In general, a workspace array should have 2N + 34 indexed elements (as log2(N)/2 ≤ 32 for all 2^64). During initialization, only the sections for storing twiddle factors and the factorization of N are updated.

  • The radix factor table is comprised as follows:

    | sequence_length | number_of_factors | integer_factors |
    
  • If N equals 1, the function returns early without modifying the workspace, as a single data point is its own Fourier transform.

Examples

var Float64Array = require( '@stdlib/array/float64' );
var rffti = require( '@stdlib/fft/base/fftpack/rffti' );

var N = 8;
var workspace = new Float64Array( ( 2*N ) + 34 );

rffti( N, workspace, 1, 0 );

console.log( 'Sequence length: %d', N );
console.log( 'Twiddle factors:' );
var i;
for ( i = N; i < 2*N; i++ ) {
    console.log( '  workspace[%d] = %d', i, workspace[ i ] );
}

console.log( 'Factorization:' );
var nf = workspace[ ( 2*N ) + 1 ];

console.log( '  number of factors: %d', nf );
for ( i = 0; i < nf; i++ ) {
    console.log( '  factor[%d]: %d', i, workspace[ ( 2*N ) + 2 + i ] );
}