Here you can find the source of multiply(final float[] complexA, final float[] complexB, final boolean overwriteA)
public static float[] multiply(final float[] complexA, final float[] complexB, final boolean overwriteA)
//package com.java2s; /**// w w w . ja v a 2 s . c om * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License 2 * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * An execption is the FFT implementation of Dave Hale which we use as a library, * wich is released under the terms of the Common Public License - v1.0, which is * available at http://www.eclipse.org/legal/cpl-v10.html * * @author Stephan Preibisch */ public class Main { public static float[] multiply(final float[] complexA, final float[] complexB, final boolean overwriteA) { if (complexA.length != complexB.length) { return null; } float[] complexResult = null; if (!overwriteA) { complexResult = new float[complexA.length]; } // this is the amount of complex numbers // the actual array size is twice as high final int wComplex = complexA.length / 2; // we compute: (a + bi) * (c + di) float a, b, c, d; if (!overwriteA) { for (int pos = 0; pos < wComplex; pos++) { a = complexA[pos * 2]; b = complexA[pos * 2 + 1]; c = complexB[pos * 2]; d = complexB[pos * 2 + 1]; // compute new real part complexResult[pos * 2] = multiplyComplexReal(a, b, c, d); // compute new imaginary part complexResult[pos * 2 + 1] = multiplyComplexImg(a, b, c, d); } } else { for (int pos = 0; pos < wComplex; pos++) { a = complexA[pos * 2]; b = complexA[pos * 2 + 1]; c = complexB[pos * 2]; d = complexB[pos * 2 + 1]; // compute new real part complexA[pos * 2] = multiplyComplexReal(a, b, c, d); // compute new imaginary part complexA[pos * 2 + 1] = multiplyComplexImg(a, b, c, d); } } if (overwriteA) { return complexA; } return complexResult; } public static float multiplyComplexReal(final float a, final float b, final float c, final float d) { return a * c - b * d; } public static float multiplyComplexImg(final float a, final float b, final float c, final float d) { return a * d + b * c; } }