Java Array Normalize normalizeComplexVectorsToUnitVectors(float[] complex)

Here you can find the source of normalizeComplexVectorsToUnitVectors(float[] complex)

Description

normalize Complex Vectors To Unit Vectors

License

Open Source License

Declaration

public static void normalizeComplexVectorsToUnitVectors(float[] complex) 

Method Source Code

//package com.java2s;
/**/* w  w  w  . j  a v  a  2s . 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 void normalizeComplexVectorsToUnitVectors(float[] complex) {
        int wComplex = complex.length / 2;

        double length;

        for (int pos = 0; pos < wComplex; pos++) {
            length = Math.sqrt(Math.pow(complex[pos * 2], 2) + Math.pow(complex[pos * 2 + 1], 2));

            if (length > 1E-5) {
                complex[pos * 2 + 1] /= length;
                complex[pos * 2] /= length;
            } else {
                complex[pos * 2 + 1] = complex[pos * 2] = 0;
            }
        }

    }
}

Related

  1. normalizeArray(double[] array)
  2. normalizeArray(double[] hist)
  3. normalizeArray(String[] raw, int expectedSize)
  4. normalizeArrays(int normalizeToLength, String[]... arraysToNormalize)
  5. normalizeCharacterData(char[] ch, int start, int length)
  6. normalizeComponentsOverwrite(float[][][][] in)
  7. normalizeContingencyTable(final int[][] table)
  8. normalizeCoordsSum(float[] vector, float newSum)
  9. normalizedBySum(double[] values)