Skip to content

Commit c9037e0

Browse files
committed
refactor: add M as a parameter
1 parent 7e5e613 commit c9037e0

9 files changed

Lines changed: 161 additions & 260 deletions

File tree

lib/node_modules/@stdlib/fft/base/fftpack/decompose/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ limitations under the License.
4040
var decompose = require( '@stdlib/fft/base/fftpack/decompose' );
4141
```
4242

43-
#### decompose( N, initial, out, stride, offset )
43+
#### decompose( N, M, initial, strideInitial, offsetInitial, out, strideOut, offsetOut )
4444

4545
Factorizes a sequence length into a product of integers.
4646

@@ -49,7 +49,7 @@ var initial = [ 3, 4, 2, 5 ]; // as found in FFTPACK
4949
var N = 630;
5050
var factors = [ 0, 0, 0, 0, 0, 0, 0 ];
5151

52-
var numFactors = decompose( N, initial, factors, 1, 0 );
52+
var numFactors = decompose( N, 4, initial, 1, 0, factors, 1, 0 );
5353
// returns 5
5454

5555
console.log( factors );
@@ -59,10 +59,13 @@ console.log( factors );
5959
The function accepts the following arguments:
6060

6161
- **N**: length of the sequence.
62+
- **M**: number of trial divisors.
6263
- **initial**: array of initial trial divisors.
64+
- **strideInitial**: stride length for `initial`.
65+
- **offsetInitial**: starting index for `initial`.
6366
- **out**: output array for storing factorization results.
64-
- **stride**: stride length for `out`.
65-
- **offset**: starting index for `out`.
67+
- **strideOut**: stride length for `out`.
68+
- **offsetOut**: starting index for `out`.
6669

6770
The function returns the number of factors into which `N` was decomposed.
6871

@@ -82,8 +85,6 @@ The function returns the number of factors into which `N` was decomposed.
8285
[ sequence_length | number_of_factors | integer_factors | unused_storage ]
8386
```
8487
85-
- The function mutates the input array.
86-
8788
</section>
8889
8990
<!-- /.notes -->
@@ -102,7 +103,7 @@ var factors = [ 0, 0, 0, 0 ];
102103
var nf;
103104
var j;
104105
105-
nf = decompose( 12, initial, factors, 1, 0 );
106+
nf = decompose( 12, 4, initial, 1, 0, factors, 1, 0 );
106107
107108
console.log( 'Sequence length: %d', 12 );
108109
console.log( 'Number of factors: %d', nf );

lib/node_modules/@stdlib/fft/base/fftpack/decompose/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function createBenchmark( N ) {
6060

6161
b.tic();
6262
for ( i = 0; i < b.iterations; i++ ) {
63-
d = decompose( N, initial, factors, 1, 0 );
63+
d = decompose( N, 4, initial, 1, 0, factors, 1, 0 );
6464
if ( isnan( d ) ) {
6565
b.fail( 'should not return NaN' );
6666
}

lib/node_modules/@stdlib/fft/base/fftpack/decompose/docs/repl.txt

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
{{alias}}( N, initial, out, stride, offset )
2+
{{alias}}( N, M, initial, strideInitial, offsetInitial, out, strideOut, offsetOut )
33
Factorizes a sequence length into a product of integers.
44

55
Factorization results are stored in the output array sequentially, where
@@ -14,16 +14,25 @@
1414
N: number
1515
Length of the sequence.
1616

17+
M: number
18+
Number of trial divisors.
19+
1720
initial: Collection<number>
1821
Array of initial trial divisors.
1922

23+
strideInitial: number
24+
Stride length for `initial`.
25+
26+
offsetInitial: number
27+
Starting index for `initial`.
28+
2029
out: Collection<number>
2130
Output array for storing factorization results.
2231

23-
stride: number
32+
strideOut: number
2433
Stride length for `out`.
2534

26-
offset: number
35+
offsetOut: number
2736
Starting index for `out`.
2837

2938
Returns
@@ -36,7 +45,7 @@
3645
> var N = 630;
3746
> var initial = [ 3, 4, 2, 5 ];
3847
> var factors = [ 0, 0, 0, 0, 0, 0, 0 ];
39-
> var numFactors = {{alias}}( N, initial, factors, 1, 0 )
48+
> var numFactors = {{alias}}( N, 4, initial, 1, 0, factors, 1, 0 )
4049
5
4150
> factors.slice()
4251
[ 630, 5, 2, 3, 3, 5, 7 ]

lib/node_modules/@stdlib/fft/base/fftpack/decompose/docs/types/index.d.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,23 @@ import { Collection } from '@stdlib/types/array';
2626
* Factorizes a sequence length into a product of integers.
2727
*
2828
* @param N - length of the sequence
29+
* @param M - number of trial divisors
2930
* @param initial - array of initial trial divisors
31+
* @param strideInitial - stride length for `initial`
32+
* @param offsetInitial - starting index for `initial`
3033
* @param out - output array for storing factorization results
31-
* @param stride - stride length for `out`
32-
* @param offset - starting index for `out`
34+
* @param strideOut - stride length for `out`
35+
* @param offsetOut - starting index for `out`
3336
* @returns number of factors into which `N` was decomposed
3437
*
3538
* @example
36-
* var N = 630;
37-
* var initial = [ 3, 4, 2, 5 ]; // as found in FFTPACK
38-
* var factors = [ 0, 0, 0, 0, 0, 0, 0 ];
39+
* var initial = new Float64Array( [ 3, 4, 2, 5 ] );
40+
* var factors = new Float64Array( 4 );
3941
*
40-
* var numFactors = decompose( N, initial, factors, 1, 0 );
41-
* // returns 5
42-
*
43-
* var f = factors.slice();
44-
* // returns [ 630, 5, 2, 3, 3, 5, 7 ]
42+
* var numFactors = decompose( 12, 4, initial, 1, 0, factors, 1, 0 );
43+
* // returns 2
4544
*/
46-
declare function decompose( N: number, initial: Collection<number>, out: Collection<number>, stride: number, offset: number ): number;
45+
declare function decompose( N: number, M: number, initial: Collection<number>, strideInitial: number, offsetInitial: number, out: Collection<number>, strideOut: number, offsetOut: number ): number;
4746

4847

4948
// EXPORTS //

lib/node_modules/@stdlib/fft/base/fftpack/decompose/docs/types/test.ts

Lines changed: 94 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -25,79 +25,124 @@ import decompose = require( './index' );
2525
const initial = [ 3, 4, 2, 5 ];
2626
const out = [ 0, 0, 0, 0, 0, 0, 0 ];
2727

28-
decompose( 12, initial, out, 1, 0 ); // $ExpectType number
28+
decompose( 12, 4, initial, 1, 0, out, 1, 0 ); // $ExpectType number
2929
}
3030

3131
// The compiler throws an error if the function is provided a sequence length which is not a number...
3232
{
3333
const initial = [ 3, 4, 2, 5 ];
3434
const out = [ 0, 0, 0, 0, 0, 0, 0 ];
3535

36-
decompose( '12', initial, out, 1, 0 ); // $ExpectError
37-
decompose( true, initial, out, 1, 0 ); // $ExpectError
38-
decompose( false, initial, out, 1, 0 ); // $ExpectError
39-
decompose( null, initial, out, 1, 0 ); // $ExpectError
40-
decompose( void 0, initial, out, 1, 0 ); // $ExpectError
41-
decompose( [], initial, out, 1, 0 ); // $ExpectError
42-
decompose( {}, initial, out, 1, 0 ); // $ExpectError
43-
decompose( ( x: number ): number => x, initial, out, 1, 0 ); // $ExpectError
36+
decompose( '12', 4, initial, 1, 0, out, 1, 0 ); // $ExpectError
37+
decompose( true, 4, initial, 1, 0, out, 1, 0 ); // $ExpectError
38+
decompose( false, 4, initial, 1, 0, out, 1, 0 ); // $ExpectError
39+
decompose( null, 4, initial, 1, 0, out, 1, 0 ); // $ExpectError
40+
decompose( void 0, 4, initial, 1, 0, out, 1, 0 ); // $ExpectError
41+
decompose( [], 4, initial, 1, 0, out, 1, 0 ); // $ExpectError
42+
decompose( {}, 4, initial, 1, 0, out, 1, 0 ); // $ExpectError
43+
decompose( ( x: number ): number => x, 4, initial, 1, 0, out, 1, 0 ); // $ExpectError
44+
}
45+
46+
// The compiler throws an error if the function is provided a number of trial divisors which is not a number...
47+
{
48+
const initial = [ 3, 4, 2, 5 ];
49+
const out = [ 0, 0, 0, 0, 0, 0, 0 ];
50+
51+
decompose( 12, '4', initial, 1, 0, out, 1, 0 ); // $ExpectError
52+
decompose( 12, true, initial, 1, 0, out, 1, 0 ); // $ExpectError
53+
decompose( 12, false, initial, 1, 0, out, 1, 0 ); // $ExpectError
54+
decompose( 12, null, initial, 1, 0, out, 1, 0 ); // $ExpectError
55+
decompose( 12, void 0, initial, 1, 0, out, 1, 0 ); // $ExpectError
56+
decompose( 12, [], initial, 1, 0, out, 1, 0 ); // $ExpectError
57+
decompose( 12, {}, initial, 1, 0, out, 1, 0 ); // $ExpectError
58+
decompose( 12, ( x: number ): number => x, initial, 1, 0, out, 1, 0 ); // $ExpectError
4459
}
4560

4661
// The compiler throws an error if the function is provided initial trial divisors which is not an array of numbers...
4762
{
4863
const out = [ 0, 0, 0, 0, 0, 0, 0 ];
4964

50-
decompose( 12, '4,2,3,5', out, 1, 0 ); // $ExpectError
51-
decompose( 12, 5, out, 1, 0 ); // $ExpectError
52-
decompose( 12, true, out, 1, 0 ); // $ExpectError
53-
decompose( 12, false, out, 1, 0 ); // $ExpectError
54-
decompose( 12, null, out, 1, 0 ); // $ExpectError
55-
decompose( 12, void 0, out, 1, 0 ); // $ExpectError
56-
decompose( 12, {}, out, 1, 0 ); // $ExpectError
57-
decompose( 12, ( x: number ): number => x, out, 1, 0 ); // $ExpectError
65+
decompose( 12, 4, '4,2,3,5', 1, 0, out, 1, 0 ); // $ExpectError
66+
decompose( 12, 4, 5, 1, 0, out, 1, 0 ); // $ExpectError
67+
decompose( 12, 4, true, 1, 0, out, 1, 0 ); // $ExpectError
68+
decompose( 12, 4, false, 1, 0, out, 1, 0 ); // $ExpectError
69+
decompose( 12, 4, null, 1, 0, out, 1, 0 ); // $ExpectError
70+
decompose( 12, 4, void 0, 1, 0, out, 1, 0 ); // $ExpectError
71+
decompose( 12, 4, {}, 1, 0, out, 1, 0 ); // $ExpectError
72+
decompose( 12, 4, ( x: number ): number => x, 1, 0, out, 1, 0 ); // $ExpectError
73+
}
74+
75+
// The compiler throws an error if the function is provided a stride for initial which is not a number...
76+
{
77+
const initial = [ 3, 4, 2, 5 ];
78+
const out = [ 0, 0, 0, 0, 0, 0, 0 ];
79+
80+
decompose( 12, 4, initial, '1', 0, out, 1, 0 ); // $ExpectError
81+
decompose( 12, 4, initial, true, 0, out, 1, 0 ); // $ExpectError
82+
decompose( 12, 4, initial, false, 0, out, 1, 0 ); // $ExpectError
83+
decompose( 12, 4, initial, null, 0, out, 1, 0 ); // $ExpectError
84+
decompose( 12, 4, initial, void 0, 0, out, 1, 0 ); // $ExpectError
85+
decompose( 12, 4, initial, [], 0, out, 1, 0 ); // $ExpectError
86+
decompose( 12, 4, initial, {}, 0, out, 1, 0 ); // $ExpectError
87+
decompose( 12, 4, initial, ( x: number ): number => x, 0, out, 1, 0 ); // $ExpectError
88+
}
89+
90+
// The compiler throws an error if the function is provided an offset for initial which is not a number...
91+
{
92+
const initial = [ 3, 4, 2, 5 ];
93+
const out = [ 0, 0, 0, 0, 0, 0, 0 ];
94+
95+
decompose( 12, 4, initial, 1, '0', out, 1, 0 ); // $ExpectError
96+
decompose( 12, 4, initial, 1, true, out, 1, 0 ); // $ExpectError
97+
decompose( 12, 4, initial, 1, false, out, 1, 0 ); // $ExpectError
98+
decompose( 12, 4, initial, 1, null, out, 1, 0 ); // $ExpectError
99+
decompose( 12, 4, initial, 1, void 0, out, 1, 0 ); // $ExpectError
100+
decompose( 12, 4, initial, 1, [], out, 1, 0 ); // $ExpectError
101+
decompose( 12, 4, initial, 1, {}, out, 1, 0 ); // $ExpectError
102+
decompose( 12, 4, initial, 1, ( x: number ): number => x, out, 1, 0 ); // $ExpectError
58103
}
59104

60105
// The compiler throws an error if the function is provided an output array which is not an array...
61106
{
62107
const initial = [ 3, 4, 2, 5 ];
63108

64-
decompose( 12, initial, 123, 1, 0 ); // $ExpectError
65-
decompose( 12, initial, true, 1, 0 ); // $ExpectError
66-
decompose( 12, initial, false, 1, 0 ); // $ExpectError
67-
decompose( 12, initial, null, 1, 0 ); // $ExpectError
68-
decompose( 12, initial, void 0, 1, 0 ); // $ExpectError
69-
decompose( 12, initial, {}, 1, 0 ); // $ExpectError
70-
decompose( 12, initial, ( x: number ): number => x, 1, 0 ); // $ExpectError
109+
decompose( 12, 4, initial, 1, 0, 123, 1, 0 ); // $ExpectError
110+
decompose( 12, 4, initial, 1, 0, true, 1, 0 ); // $ExpectError
111+
decompose( 12, 4, initial, 1, 0, false, 1, 0 ); // $ExpectError
112+
decompose( 12, 4, initial, 1, 0, null, 1, 0 ); // $ExpectError
113+
decompose( 12, 4, initial, 1, 0, void 0, 1, 0 ); // $ExpectError
114+
decompose( 12, 4, initial, 1, 0, {}, 1, 0 ); // $ExpectError
115+
decompose( 12, 4, initial, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError
71116
}
72117

73-
// The compiler throws an error if the function is provided a stride which is not a number...
118+
// The compiler throws an error if the function is provided a stride for out which is not a number...
74119
{
75120
const initial = [ 3, 4, 2, 5 ];
76121
const out = [ 0, 0, 0, 0, 0, 0, 0 ];
77122

78-
decompose( 12, initial, out, '1', 0 ); // $ExpectError
79-
decompose( 12, initial, out, true, 0 ); // $ExpectError
80-
decompose( 12, initial, out, false, 0 ); // $ExpectError
81-
decompose( 12, initial, out, null, 0 ); // $ExpectError
82-
decompose( 12, initial, out, void 0, 0 ); // $ExpectError
83-
decompose( 12, initial, out, [], 0 ); // $ExpectError
84-
decompose( 12, initial, out, {}, 0 ); // $ExpectError
85-
decompose( 12, initial, out, ( x: number ): number => x, 0 ); // $ExpectError
123+
decompose( 12, 4, initial, 1, 0, out, '1', 0 ); // $ExpectError
124+
decompose( 12, 4, initial, 1, 0, out, true, 0 ); // $ExpectError
125+
decompose( 12, 4, initial, 1, 0, out, false, 0 ); // $ExpectError
126+
decompose( 12, 4, initial, 1, 0, out, null, 0 ); // $ExpectError
127+
decompose( 12, 4, initial, 1, 0, out, void 0, 0 ); // $ExpectError
128+
decompose( 12, 4, initial, 1, 0, out, [], 0 ); // $ExpectError
129+
decompose( 12, 4, initial, 1, 0, out, {}, 0 ); // $ExpectError
130+
decompose( 12, 4, initial, 1, 0, out, ( x: number ): number => x, 0 ); // $ExpectError
86131
}
87132

88-
// The compiler throws an error if the function is provided an offset which is not a number...
133+
// The compiler throws an error if the function is provided an offset for out which is not a number...
89134
{
90135
const initial = [ 3, 4, 2, 5 ];
91136
const out = [ 0, 0, 0, 0, 0, 0, 0 ];
92137

93-
decompose( 12, initial, out, 1, '0' ); // $ExpectError
94-
decompose( 12, initial, out, 1, true ); // $ExpectError
95-
decompose( 12, initial, out, 1, false ); // $ExpectError
96-
decompose( 12, initial, out, 1, null ); // $ExpectError
97-
decompose( 12, initial, out, 1, void 0 ); // $ExpectError
98-
decompose( 12, initial, out, 1, [] ); // $ExpectError
99-
decompose( 12, initial, out, 1, {} ); // $ExpectError
100-
decompose( 12, initial, out, 1, ( x: number ): number => x ); // $ExpectError
138+
decompose( 12, 4, initial, 1, 0, out, 1, '0' ); // $ExpectError
139+
decompose( 12, 4, initial, 1, 0, out, 1, true ); // $ExpectError
140+
decompose( 12, 4, initial, 1, 0, out, 1, false ); // $ExpectError
141+
decompose( 12, 4, initial, 1, 0, out, 1, null ); // $ExpectError
142+
decompose( 12, 4, initial, 1, 0, out, 1, void 0 ); // $ExpectError
143+
decompose( 12, 4, initial, 1, 0, out, 1, [] ); // $ExpectError
144+
decompose( 12, 4, initial, 1, 0, out, 1, {} ); // $ExpectError
145+
decompose( 12, 4, initial, 1, 0, out, 1, ( x: number ): number => x ); // $ExpectError
101146
}
102147

103148
// The compiler throws an error if the function is provided an unsupported number of arguments...
@@ -107,8 +152,11 @@ import decompose = require( './index' );
107152

108153
decompose(); // $ExpectError
109154
decompose( 12 ); // $ExpectError
110-
decompose( 12, initial ); // $ExpectError
111-
decompose( 12, initial, out ); // $ExpectError
112-
decompose( 12, initial, out, 1 ); // $ExpectError
113-
decompose( 12, initial, out, 1, 0, 123 ); // $ExpectError
155+
decompose( 12, 4 ); // $ExpectError
156+
decompose( 12, 4, initial ); // $ExpectError
157+
decompose( 12, 4, initial, 1 ); // $ExpectError
158+
decompose( 12, 4, initial, 1, 0 ); // $ExpectError
159+
decompose( 12, 4, initial, 1, 0, out ); // $ExpectError
160+
decompose( 12, 4, initial, 1, 0, out, 1 ); // $ExpectError
161+
decompose( 12, 4, initial, 1, 0, out, 1, 0, 123 ); // $ExpectError
114162
}

lib/node_modules/@stdlib/fft/base/fftpack/decompose/examples/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ var factors = [ 0, 0, 0, 0 ];
2525
var nf;
2626
var j;
2727

28-
nf = decompose( 12, initial, factors, 1, 0 );
28+
nf = decompose( 12, 4, initial, 1, 0, factors, 1, 0 );
2929

3030
console.log( 'Sequence length: %d', 12 );
3131
console.log( 'Number of factors: %d', nf );

lib/node_modules/@stdlib/fft/base/fftpack/decompose/lib/index.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,18 @@
3030
* var initial = [ 3, 4, 2, 5 ]; // as found in FFTPACK
3131
* var factors = [ 0, 0, 0, 0, 0, 0, 0 ];
3232
*
33-
* var numFactors = decompose( N, initial, factors, 1, 0 );
33+
* var numFactors = decompose( N, 4, initial, 1, 0, factors, 1, 0 );
3434
* // returns 5
3535
*
36-
* var f = factors.slice();
37-
* // returns [ 630, 5, 2, 3, 3, 5, 7 ]
38-
*
3936
* @example
4037
* var decompose = require( '@stdlib/fft/base/fftpack/decompose' );
4138
*
42-
* var N = 8;
39+
* var N = 12;
4340
* var initial = [ 3, 4, 2, 5 ]; // as found in FFTPACK
4441
* var factors = [ 0, 0, 0, 0 ];
4542
*
46-
* var numFactors = decompose( N, initial, factors, 1, 0 );
43+
* var numFactors = decompose( N, 4, initial, 1, 0, factors, 1, 0 );
4744
* // returns 2
48-
*
49-
* var f = factors.slice();
50-
* // returns [ 8, 2, 2, 4 ]
5145
*/
5246

5347
// MODULES //

0 commit comments

Comments
 (0)