MCPcopy Create free account
hub / github.com/TheAlgorithms/Java / paddingPowerOfTwo

Method paddingPowerOfTwo

src/main/java/com/thealgorithms/maths/FFT.java:286–295  ·  view source on GitHub ↗

This method pads an ArrayList with zeros in order to have a size equal to the next power of two of the previous size. @param x The ArrayList to be padded.

(Collection<Complex> x)

Source from the content-addressed store, hash-verified

284 * @param x The ArrayList to be padded.
285 */
286 private static void paddingPowerOfTwo(Collection<Complex> x) {
287 int n = 1;
288 int oldSize = x.size();
289 while (n < oldSize) {
290 n *= 2;
291 }
292 for (int i = 0; i < n - oldSize; i++) {
293 x.add(new Complex());
294 }
295 }
296}

Callers 1

fftMethod · 0.95

Calls 2

sizeMethod · 0.65
addMethod · 0.45

Tested by

no test coverage detected