@Test public void precomputedFactorsAreComputedOnceAndForAll() { double[] f2 = hammingWindow.getPrecomputedFactors(WINDOW_SIZE); assertThat(f2, sameInstance(f1)); }
@Override protected double[] getPrecomputedFactors(int windowSize) { synchronized (HammingWindowFunction.class) { double[] factors; if(factorsByWindowSize.containsKey(windowSize)) { factors = factorsByWindowSize.get(windowSize); } else { factors = new double[windowSize]; int sizeMinusOne = windowSize - 1; for(int i = 0; i < windowSize; i++) { factors[i] = 0.54d - (0.46d * Math.cos((TWO_PI * i) / sizeMinusOne)); } factorsByWindowSize.put(windowSize, factors); } return factors; } }
HammingWindowFunction extends WindowFunction { @Override protected double[] getPrecomputedFactors(int windowSize) { synchronized (HammingWindowFunction.class) { double[] factors; if(factorsByWindowSize.containsKey(windowSize)) { factors = factorsByWindowSize.get(windowSize); } else { factors = new double[windowSize]; int sizeMinusOne = windowSize - 1; for(int i = 0; i < windowSize; i++) { factors[i] = 0.54d - (0.46d * Math.cos((TWO_PI * i) / sizeMinusOne)); } factorsByWindowSize.put(windowSize, factors); } return factors; } } }
HammingWindowFunction extends WindowFunction { @Override protected double[] getPrecomputedFactors(int windowSize) { synchronized (HammingWindowFunction.class) { double[] factors; if(factorsByWindowSize.containsKey(windowSize)) { factors = factorsByWindowSize.get(windowSize); } else { factors = new double[windowSize]; int sizeMinusOne = windowSize - 1; for(int i = 0; i < windowSize; i++) { factors[i] = 0.54d - (0.46d * Math.cos((TWO_PI * i) / sizeMinusOne)); } factorsByWindowSize.put(windowSize, factors); } return factors; } } HammingWindowFunction(int windowSize); }
HammingWindowFunction extends WindowFunction { @Override protected double[] getPrecomputedFactors(int windowSize) { synchronized (HammingWindowFunction.class) { double[] factors; if(factorsByWindowSize.containsKey(windowSize)) { factors = factorsByWindowSize.get(windowSize); } else { factors = new double[windowSize]; int sizeMinusOne = windowSize - 1; for(int i = 0; i < windowSize; i++) { factors[i] = 0.54d - (0.46d * Math.cos((TWO_PI * i) / sizeMinusOne)); } factorsByWindowSize.put(windowSize, factors); } return factors; } } HammingWindowFunction(int windowSize);  }
HammingWindowFunction extends WindowFunction { @Override protected double[] getPrecomputedFactors(int windowSize) { synchronized (HammingWindowFunction.class) { double[] factors; if(factorsByWindowSize.containsKey(windowSize)) { factors = factorsByWindowSize.get(windowSize); } else { factors = new double[windowSize]; int sizeMinusOne = windowSize - 1; for(int i = 0; i < windowSize; i++) { factors[i] = 0.54d - (0.46d * Math.cos((TWO_PI * i) / sizeMinusOne)); } factorsByWindowSize.put(windowSize, factors); } return factors; } } HammingWindowFunction(int windowSize);   }