Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
175 changes: 175 additions & 0 deletions lib/node_modules/@stdlib/fft/base/fftpack/sinti/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
<!--

@license Apache-2.0

Copyright (c) 2026 The Stdlib Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

-->

# sinti

> Initialize a workspace array for performing a sine transform.

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- Package usage documentation. -->

<section class="usage">

## Usage

```javascript
var sinti = require( '@stdlib/fft/base/fftpack/sinti' );
```

#### sinti( N, workspace, strideW, offsetW )

Initializes a workspace array for performing a sine transform.

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var floor = require( '@stdlib/math/base/special/floor' );

var N = 7;
var workspace = new Float64Array( floor( 2.5*N ) + 34 );

var out = sinti( N, workspace, 1, 0 );
// returns <Float64Array>

var bool = ( out === workspace );
// returns true

var sineTable = workspace.slice( 0, floor( N/2 ) );
// returns <Float64Array>[ ~0.765, ~1.414, ~1.848 ]

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

var factors = workspace.slice( floor( 5*N/2 ) + 2, floor(5*N/2) + 2 + 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`.

</section>

<!-- /.usage -->

<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

## Notes

- The workspace array is divided into four sections:

```text
size = N/2 N+1 N+1 2+ceil(log2(N+1)/2)
↓ ↓ ↓ ↓
| sine table | scratch/workspace | twiddle factors | radix factor table |
↑ ↑ ↑ ↑
i = 0 ... N/2 ... (3N/2)+1 ... (5N/2)+2 ...
```

- **sine table**: a table of precomputed sine coefficients used by sine transforms.
- **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+1`, the number of factors into which `N+1` was decomposed, and the individual integer radix factors.

- In general, a workspace array should have `2.5N + 34` indexed elements (as `log2(N+1)/2 ≤ 32` for all `2^64`). During initialization, only the sections for storing the sine coefficients, twiddle factors, and the factorization of `N+1` are updated.

- The radix factor table is comprised as follows:

```text
| sequence_length | number_of_factors | integer_factors |
```

</section>

<!-- /.notes -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var Float64Array = require( '@stdlib/array/float64' );
var zeroTo = require( '@stdlib/array/zero-to' );
var logEach = require( '@stdlib/console/log-each' );
var floor = require( '@stdlib/math/base/special/floor' );
var sinti = require( '@stdlib/fft/base/fftpack/sinti' );

var N = 7;
var workspace = new Float64Array( floor( 2.5*N ) + 34 );

sinti( N, workspace, 1, 0 );
console.log( 'Sequence length: %d', N );

console.log( 'Sine table:' );
var idx = zeroTo( floor( N/2 ), 'generic' );
logEach( ' workspace[ %d ] = %0.4f', idx, workspace.slice( 0, floor( N/2 ) ) );

console.log( 'Twiddle factors:' );
idx = zeroTo( N+1, 'generic' );
logEach( ' workspace[ %d ] = %0.4f', idx, workspace.slice( floor( 3*N/2 ) + 1, floor( 5*N/2 ) + 2 ) );

console.log( 'Factorization:' );
var nf = workspace[ floor( 5*N/2 ) + 3 ];

console.log( ' number of factors: %d', nf );
idx = zeroTo( nf, 'generic' );
logEach( ' factor[ %d ]: %d', idx, workspace.slice( floor( 5*N/2 ) + 4, floor( 5*N/2 ) + 4 + nf ) );
```

</section>

<!-- /.examples -->

<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="references">

</section>

<!-- /.references -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

</section>

<!-- /.links -->
102 changes: 102 additions & 0 deletions lib/node_modules/@stdlib/fft/base/fftpack/sinti/benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2026 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var format = require( '@stdlib/string/format' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var floor = require( '@stdlib/math/base/special/floor' );
var Float64Array = require( '@stdlib/array/float64' );
var pkg = require( './../package.json' ).name;
var sinti = require( './../lib' );


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} N - sequence length
* @returns {Function} benchmark function
*/
function createBenchmark( N ) {
var workspace = new Float64Array( floor( 2.5*N ) + 34 );
return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
sinti( N, workspace, 1, 0 );
if ( isnan( workspace[ floor( 3*N/2 ) + 1 ] ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( workspace[ floor( 3*N/2 ) + 1 ] ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var lengths;
var N;
var f;
var i;

lengths = [
7,
15,
31,
63,
127,
255,
511,
1023
];

for ( i = 0; i < lengths.length; i++ ) {
N = lengths[ i ];
f = createBenchmark( N );
bench( format( '%s:N=%d', pkg, N ), f );
}
}

main();
64 changes: 64 additions & 0 deletions lib/node_modules/@stdlib/fft/base/fftpack/sinti/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@

{{alias}}( N, workspace, strideW, offsetW )
Initializes a workspace array for performing a sine transform.

The workspace array is divided into four sections:

1. sine table: the section ranges from indices 0 to N/2 and is used to
store a table of precomputed sine coefficients used by sine transforms.

2. scratch/workspace: the section ranges from indices N/2 to 3N/2 and is
used while performing transforms. This section is not updated during
initialization.

3. twiddle factors: the section ranges from indices (3N/2)+1 to (5N/2)+1
and stores a table of reusable complex exponential constants as cosine/sine
pairs.

4. radix factor table: the section starts at index (5N/2)+2 and stores the
sequence length N+1, the number of factors into which N+1 was decomposed,
and the individual integer radix factors.

Any remaining array space remains as unused storage.

Parameters
----------
N: integer
Length of the sequence.

workspace: ArrayLikeObject<number>
Workspace array.

strideW: integer
Stride length for `workspace`.

offsetW: integer
Starting index for `workspace`.

Returns
-------
out: ArrayLikeObject<number>
Workspace array.

Examples
--------
> var N = 7;
> var len = {{alias:@stdlib/math/base/special/floor}}( 2.5*N ) + 34;
> var workspace = new {{alias:@stdlib/array/float64}}( len );
> var out = {{alias}}( N, workspace, 1, 0 )
<Float64Array>
> var bool = ( out === workspace )
true
> var ns2 = {{alias:@stdlib/math/base/special/floor}}( N/2 );
> var sineTable = workspace.slice( 0, ns2 )
<Float64Array>[ ~0.765, ~1.414, ~1.848 ]
> var iw = ns2 + N + 1;
> var twiddleFactors = workspace.slice( iw, iw + (N+1) )
<Float64Array>[ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ]
> var fw = ns2 + 2*(N+1);
> var factors = workspace.slice( fw, fw + 4 )
<Float64Array>[ 8, 2, 2, 4 ]

See Also
--------

Loading