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
14 changes: 10 additions & 4 deletions lib/node_modules/@stdlib/fft/base/fftpack/float32/cosqi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Initializes a single-precision floating-point workspace array for performing a q

```javascript
var Float32Array = require( '@stdlib/array/float32' );
var Uint32Array = require( '@stdlib/array/uint32' );

var N = 8;
var workspace = new Float32Array( ( 3*N ) + 34 );
Expand All @@ -62,8 +63,9 @@ var cosineTable = workspace.slice( 0, N );
var twiddleFactors = workspace.slice( 2*N, 3*N );
// returns <Float32Array>[ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ]

var factors = workspace.slice( 3*N, ( 3*N ) + 4 );
// returns <Float32Array>[ 8, 2, 2, 4 ]
var fview = new Uint32Array( workspace.buffer, workspace.byteOffset, workspace.length ); // eslint-disable-line max-len
var factors = fview.slice( 3*N, ( 3*N ) + 4 );
// returns <Uint32Array>[ 8, 2, 2, 4 ]
```

The function accepts the following arguments:
Expand Down Expand Up @@ -118,6 +120,7 @@ The function accepts the following arguments:

```javascript
var Float32Array = require( '@stdlib/array/float32' );
var Uint32Array = require( '@stdlib/array/uint32' );
var zeroTo = require( '@stdlib/array/zero-to' );
var logEach = require( '@stdlib/console/log-each' );
var cosqi = require( '@stdlib/fft/base/fftpack/float32/cosqi' );
Expand All @@ -136,12 +139,15 @@ console.log( 'Twiddle factors:' );
idx = zeroTo( N, 'float32' );
logEach( ' workspace[ %d ] = %0.4f', idx, workspace.slice( 2*N, 3*N ) );

// Create an unsigned integer view over the workspace to read the factorization section:
var fview = new Uint32Array( workspace.buffer, workspace.byteOffset, workspace.length ); // eslint-disable-line max-len

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

console.log( ' number of factors: %d', nf );
idx = zeroTo( nf, 'float32' );
logEach( ' factor[ %d ]: %d', idx, workspace.slice( (3*N)+2, (3*N)+2+nf ) );
logEach( ' factor[ %d ]: %d', idx, fview.slice( (3*N)+2, (3*N)+2+nf ) );
```

</section>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

{{alias}}( N, workspace, strideW, offsetW )
{{alias}}( N, w, strideW, offsetW )
Initializes a single-precision floating-point workspace array for performing
a quarter-wave cosine transform.

Expand Down Expand Up @@ -27,14 +27,14 @@
N: integer
Length of the sequence.

workspace: Float32Array
w: Float32Array
Workspace array.

strideW: integer
Stride length for `workspace`.
Stride length for `w`.

offsetW: integer
Starting index for `workspace`.
Starting index for `w`.

Returns
-------
Expand All @@ -44,17 +44,18 @@
Examples
--------
> var N = 8;
> var workspace = new {{alias:@stdlib/array/float32}}( ( 3*N ) + 34 );
> var out = {{alias}}( N, workspace, 1, 0 )
> var w = new {{alias:@stdlib/array/float32}}( ( 3*N ) + 34 );
> var out = {{alias}}( N, w, 1, 0 )
<Float32Array>
> var bool = ( out === workspace )
> var bool = ( out === w )
true
> var cosineTable = workspace.slice( 0, N )
> var cosineTable = w.slice( 0, N )
<Float32Array>[ ~0.98, ~0.92, ~0.83, ~0.7, ~0.56, ~0.38, ~0.2, ~0.0 ]
> var twiddleFactors = workspace.slice( 2*N, 3*N )
> var twiddleFactors = w.slice( 2*N, 3*N )
<Float32Array>[ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ]
> var factors = workspace.slice( 3*N, ( 3*N ) + 4 )
<Float32Array>[ 8, 2, 2, 4 ]
> var fview = new {{alias:@stdlib/array/uint32}}( w.buffer, w.byteOffset, w.length );
> var factors = fview.slice( 3*N, ( 3*N ) + 4 )
<Uint32Array>[ 8, 2, 2, 4 ]

See Also
--------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
*
* @example
* var Float32Array = require( '@stdlib/array/float32' );
* var Uint32Array = require( '@stdlib/array/uint32' );
*
* var N = 8;
* var workspace = new Float32Array( ( 3*N ) + 34 );
Expand All @@ -49,8 +50,9 @@
* var twiddleFactors = workspace.slice( 2*N, 3*N );
* // returns <Float32Array>[ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ]
*
* var factors = workspace.slice( 3*N, ( 3*N ) + 4 );
* // returns <Float32Array>[ 8, 2, 2, 4 ]
* var fview = new Uint32Array( workspace.buffer, workspace.byteOffset, workspace.length );
* var factors = fview.slice( 3*N, ( 3*N ) + 4 );
* // returns <Uint32Array>[ 8, 2, 2, 4 ]
*/
declare function cosqi( N: number, workspace: Float32Array, strideW: number, offsetW: number ): Float32Array;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
'use strict';

var Float32Array = require( '@stdlib/array/float32' );
var Uint32Array = require( '@stdlib/array/uint32' );
var zeroTo = require( '@stdlib/array/zero-to' );
var logEach = require( '@stdlib/console/log-each' );
var cosqi = require( './../lib' );
Expand All @@ -37,9 +38,12 @@ console.log( 'Twiddle factors:' );
idx = zeroTo( N, 'float32' );
logEach( ' workspace[ %d ] = %0.4f', idx, workspace.slice( 2*N, 3*N ) );

// Create an unsigned integer view over the workspace to read the factorization section:
var fview = new Uint32Array( workspace.buffer, workspace.byteOffset, workspace.length ); // eslint-disable-line max-len

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

console.log( ' number of factors: %d', nf );
idx = zeroTo( nf, 'float32' );
logEach( ' factor[ %d ]: %d', idx, workspace.slice( (3*N)+2, (3*N)+2+nf ) );
logEach( ' factor[ %d ]: %d', idx, fview.slice( (3*N)+2, (3*N)+2+nf ) );
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
*
* @example
* var Float32Array = require( '@stdlib/array/float32' );
* var Uint32Array = require( '@stdlib/array/uint32' );
* var cosqi = require( '@stdlib/fft/base/fftpack/float32/cosqi' );
*
* var N = 8;
Expand All @@ -42,8 +43,9 @@
* var twiddleFactors = workspace.slice( 2*N, 3*N );
* // returns <Float32Array>[ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ]
*
* var factors = workspace.slice( 3*N, ( 3*N ) + 4 );
* // returns <Float32Array>[ 8, 2, 2, 4 ]
* var fview = new Uint32Array( workspace.buffer, workspace.byteOffset, workspace.length );
* var factors = fview.slice( 3*N, ( 3*N ) + 4 );
* // returns <Uint32Array>[ 8, 2, 2, 4 ]
*/

// MODULES //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ var rffti = require( '@stdlib/fft/base/fftpack/float32/rffti' );
*
* @example
* var Float32Array = require( '@stdlib/array/float32' );
* var Uint32Array = require( '@stdlib/array/uint32' );
*
* var N = 8;
* var workspace = new Float32Array( ( 3*N ) + 34 );
Expand All @@ -156,8 +157,9 @@ var rffti = require( '@stdlib/fft/base/fftpack/float32/rffti' );
* var twiddleFactors = workspace.slice( 2*N, 3*N );
* // returns <Float32Array>[ ~0.707, ~0.707, 0, 0, 0, 0, 0, 0 ]
*
* var factors = workspace.slice( 3*N, ( 3*N ) + 4 );
* // returns <Float32Array>[ 8, 2, 2, 4 ]
* var fview = new Uint32Array( workspace.buffer, workspace.byteOffset, workspace.length );
* var factors = fview.slice( 3*N, ( 3*N ) + 4 );
* // returns <Uint32Array>[ 8, 2, 2, 4 ]
*/
function cosqi( N, workspace, strideW, offsetW ) {
var offsetR;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

var tape = require( 'tape' );
var Float32Array = require( '@stdlib/array/float32' );
var Uint32Array = require( '@stdlib/array/uint32' );
var isAlmostSameValue = require( '@stdlib/number/float32/base/assert/is-almost-same-value' );
var cosqi = require( './../lib' );

Expand Down Expand Up @@ -286,6 +287,7 @@ tape( 'the function correctly handles stride and offset parameters', function te
var expected;
var stride;
var offset;
var fview;
var nf;
var N;
var i;
Expand All @@ -297,12 +299,15 @@ tape( 'the function correctly handles stride and offset parameters', function te

cosqi( N, workspace, stride, offset );

t.strictEqual( workspace[ offset + ( 3*N * stride ) ], N, 'returns expected value' );
// Create an unsigned integer view over the workspace to read the factorization section:
fview = new Uint32Array( workspace.buffer, workspace.byteOffset, workspace.length ); // eslint-disable-line max-len

nf = workspace[ offset + ( ( ( 3*N ) + 1 ) * stride ) ];
t.strictEqual( fview[ offset + ( 3*N * stride ) ], N, 'returns expected value' );

nf = fview[ offset + ( ( ( 3*N ) + 1 ) * stride ) ];
t.strictEqual( nf, 2, 'returns expected value' );
t.strictEqual( workspace[ offset + ( ( ( 3*N ) + 2 ) * stride ) ], 2, 'returns expected value' );
t.strictEqual( workspace[ offset + ( ( ( 3*N ) + 3 ) * stride ) ], 4, 'returns expected value' );
t.strictEqual( fview[ offset + ( ( ( 3*N ) + 2 ) * stride ) ], 2, 'returns expected value' );
t.strictEqual( fview[ offset + ( ( ( 3*N ) + 3 ) * stride ) ], 4, 'returns expected value' );

expected = new Float32Array( ( 3*N ) + 34 );
cosqi( N, expected, 1, 0 );
Expand Down
Loading