Factorize a sequence length into a product of integers.
var decompose = require( '@stdlib/fft/base/fftpack/decompose' );Factorizes a sequence length into a product of integers.
var initial = [ 3, 4, 2, 5 ]; // as found in FFTPACK
var N = 630;
var factors = [ 0, 0, 0, 0, 0, 0, 0 ];
var numFactors = decompose( N, 4, initial, 1, 0, factors, 1, 0 );
// returns 5
console.log( factors );
// => [ 630, 5, 2, 3, 3, 5, 7 ]The function accepts the following arguments:
- N: length of the sequence.
- M: number of trial divisors.
- initial: array of initial trial divisors.
- si: stride length for
initial. - oi: starting index for
initial. - out: output array for storing factorization results.
- so: stride length for
out. - oo: starting index for
out.
The function returns the number of factors into which N was decomposed.
-
Factorization results are stored in the output array as follows:
[ sequence_length | number_of_factors | integer_factors | unused_storage ]
var decompose = require( '@stdlib/fft/base/fftpack/decompose' );
var initial = [ 3, 4, 2, 5 ]; // as found in FFTPACK
var factors = [ 0, 0, 0, 0 ];
var nf;
var j;
nf = decompose( 12, 4, initial, 1, 0, factors, 1, 0 );
console.log( 'Sequence length: %d', 12 );
console.log( 'Number of factors: %d', nf );
console.log( 'Factors:' );
for ( j = 0; j < nf; j++ ) {
console.log( ' %d', factors[ j+2 ] );
}