Here you can find the source of multiplyComplex(double[] one, double[] two)
Parameter | Description |
---|---|
one | the first array |
two | the second array |
public static double[] multiplyComplex(double[] one, double[] two)
//package com.java2s; /*// w w w . ja v a2 s . com * Copyright (C) 2010-2014 Andreas Maier * CONRAD is developed as an Open Source project under the GNU General Public License (GPL). */ public class Main { /** * Multiplies two complex values * @param realOne real part one * @param imagOne imaginary part one * @param realTwo real part two * @param imagTwo imaginary part two * @return an array of two values: first entry is real, second imaginary */ public static double[] multiplyComplex(double realOne, double imagOne, double realTwo, double imagTwo) { double[] revan = new double[2]; revan[0] = (realOne * realTwo) - (imagOne * imagTwo); revan[1] = (imagOne * realTwo) + (realOne * imagTwo); return revan; } /** * Multiplies two arrays of complex numbers pairwise * @param one the first array * @param two the second array * @return the array of null if the lengths of the arrays don't match */ public static double[] multiplyComplex(double[] one, double[] two) { double[] revan = null; if (one.length == two.length) { revan = new double[one.length]; for (int i = 0; i < one.length / 2; i++) { revan[2 * i] = (one[2 * i] * two[2 * i]) - (one[(2 * i) + 1] * two[(2 * i) + 1]); revan[(2 * i) + 1] = (one[(2 * i) + 1] * two[2 * i]) + (one[2 * i] * two[(2 * i) + 1]); } } return revan; } }