Here you can find the source of divideAbsolute(double[] one, double[] two)
Parameter | Description |
---|---|
one | the first array |
two | the second array |
public static double[] divideAbsolute(double[] one, double[] two)
//package com.java2s; /*// w ww. j a v a 2 s. c om * Copyright (C) 2010-2014 Andreas Maier * CONRAD is developed as an Open Source project under the GNU General Public License (GPL). */ public class Main { /** * Divides two arrays of complex numbers. The absolute value of the second array is used to divide the complex first array. * @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[] divideAbsolute(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] / abs(i, two)); revan[(2 * i) + 1] = (one[(2 * i) + 1] / abs(i, two)); } } return revan; } /** * Computes the absolute value of the complex number at position pos in the array * @param pos the position * @param array the array which contains the values * @return the absolute value */ public static double abs(int pos, double[] array) { return Math.sqrt(Math.pow(array[pos * 2], 2) + Math.pow(array[(2 * pos) + 1], 2)); } /** * Computes the absolute values of the complex number at posx, posy in the 2D array array. * * @param posx x position * @param posy y position * @param array the array * @return the absolute value of the complex number */ public static double abs(int posx, int posy, double[][] array) { return Math.sqrt(Math.pow(array[posx][posy * 2], 2) + Math.pow(array[posx][(2 * posy) + 1], 2)); } }