Java Array Sort sortEigenValues(int n, double[] d, double[][] v)

Here you can find the source of sortEigenValues(int n, double[] d, double[][] v)

Description

sort Eigen Values

License

Open Source License

Declaration

private static void sortEigenValues(int n, double[] d, double[][] v) 

Method Source Code

//package com.java2s;
//  it under the terms of the GNU Lesser General Public License as published by

public class Main {
    private static void sortEigenValues(int n, double[] d, double[][] v) {

        for (int i = 0; i < n - 1; i++) {
            int k = i;
            double p = d[i];
            for (int j = i + 1; j < n; j++) {
                if (d[j] < p) { // NH find smallest k>i
                    k = j;/*from  w  w w.  j av a  2  s.c om*/
                    p = d[j];
                }
            }
            if (k != i) {
                d[k] = d[i]; // swap k and i
                d[i] = p;
                for (int j = 0; j < n; j++) {
                    p = v[j][i];
                    v[j][i] = v[j][k];
                    v[j][k] = p;
                }
            }
        }

    }
}

Related

  1. sortedMerge(int[] a, int[] b)
  2. sortedMerge(int[] aIds, double[] aVals, int[] bIds, double[] bVals, int[] resIds, double[] resVals)
  3. sortedPointersInto(double d[])
  4. sortedPointersInto_tryingToImproveSpeed(final double d[])
  5. sortedPointersInto_usingStrictfp(final double d[])
  6. sortIndex(double[] A)
  7. sortIndex(double[] doubleArray)
  8. sortIndexes(final T[] array)
  9. sortIndexesDescending(final double[] in)