Computes the eigenvalue decomposition of the given matrix

@param A
Matrix to factorize. Overwritten on return
@return The current eigenvalue decomposition
@throws NotConvergedException
540603
public SymmBandEVD factor(LowerSymmBandMatrix A)
            throws NotConvergedException {
        if (uplo != UpLo.Lower)
            throw new IllegalArgumentException(
                    "Eigenvalue computer configured for lower-symmetrical matrices");

        return factor(A, A.getData(), A.numSubDiagonals());
    }
483340
public static SymmPackEVD factorize(Matrix A) throws NotConvergedException {
        return new SymmPackEVD(A.numRows(), true)
                .factor(new UpperSymmPackMatrix(A));
    }
1056939
public SymmPackEVD factor(LowerSymmPackMatrix A)
            throws NotConvergedException {
        if (uplo != UpLo.Lower)
            throw new IllegalArgumentException(
                    "Eigenvalue computer configured for lower-symmetrical matrices");

        return factor(A, A.getData());
    }
1109413
public static EVD eigen(Matrix A, int k, String which) {
        return eigen(A, k, which, 1E-8, 10 * A.nrows());
    }
516223
public static FloatMatrix SVDValues(ComplexFloatMatrix A) {
        int m = A.rows;
        int n = A.columns;
        FloatMatrix S = new FloatMatrix(min(m, n));
        float[] rwork = new float[5*min(m,n)];

        int info = NativeBlas.cgesvd('N', 'N', m, n, A.dup().data, 0, m, S.data, 0, null, 0, 1, null, 0, min(m,n), rwork, 0);

        if (info > 0) {
          throw new LapackConvergenceException("GESVD", info + " superdiagonals of an intermediate bidiagonal form failed to converge.");
        }

        return S;
    }
24866
public QRP factor(Matrix A) {
        if (Q.numRows() != A.numRows())
            throw new IllegalArgumentException("Q.numRows() != A.numRows()");
        else if (R.numColumns() != A.numColumns())
            throw new IllegalArgumentException(
                    "R.numColumns() != A.numColumns()");

        // copy A values in Afact
        Afact.zero();
        for (MatrixEntry e : A) {
            Afact.set(e.row(), e.column(), e.get());
        }

        intW info = new intW(0);
        LAPACK lapack = LAPACK.getInstance();

        // the dgeqp3 work array is a different size than the dorgqr
        // one (I'm not entirely convinced that we should be
        // persisting the work arrays as fields).
        double[] factorWorkOptimalSize = {0.0};
        double[] factorWork;

        lapack.dgeqp3(m, n, Afact.getData(), Matrices.ld(m), jpvt, tau,
                factorWorkOptimalSize, -1, info);
        factorWork = new double[(int) factorWorkOptimalSize[0]];

        /*
         * Calculate factorisation
         */
        lapack.dgeqp3(m, n, Afact.getData(), Matrices.ld(m), jpvt, tau,
                factorWork, factorWork.length, info);

        if (info.val < 0) {
            throw new IllegalArgumentException("DGEQP3 was " + info.val);
        }

        /*
         * Get R from Afact
         */
        R.zero();
        for (MatrixEntry e : Afact) {
            if (e.row() <= e.column() && e.column() < R.numColumns()) {
                R.set(e.row(), e.column(), e.get());
            }
        }

        /*
         * Calculate the rank based on a precision EPS
         */
        final double EPS = 1e-12;
        for (rank = 0; rank < k; rank++) {
            if (Math.abs(R.get(rank, rank)) < EPS)
                break;
        }

        /*
         * Explicit the orthogonal matrix
         */
        lapack.dorgqr(m, m, k, Afact.getData(), Matrices.ld(m), tau, work,
                work.length, info);
        for (MatrixEntry e : Afact) {
            if (e.column() < Q.numColumns())
                Q.set(e.row(), e.column(), e.get());
        }

        if (info.val < 0)
            throw new IllegalArgumentException();

        // Adjust the permutation to zero offset
        for (int i = 0; i < jpvt.length; i++) {
            --jpvt[i];
        }

        return this;
    }
822504
public static FloatMatrix symmetricEigenvalues(FloatMatrix A) {
        A.assertSquare();
        FloatMatrix eigenvalues = new FloatMatrix(A.rows);
        int isuppz[] = new int[2 * A.rows];
        SimpleBlas.syevr('N', 'A', 'U', A.dup(), 0, 0, 0, 0, 0, eigenvalues, dummyFloat, isuppz);
        return eigenvalues;
    }
228844
public static DoubleMatrix[] fullSVD(DoubleMatrix A) {
        int m = A.rows;
        int n = A.columns;

        DoubleMatrix U = new DoubleMatrix(m, m);
        DoubleMatrix S = new DoubleMatrix(min(m, n));
        DoubleMatrix V = new DoubleMatrix(n, n);

        int info = NativeBlas.dgesvd('A', 'A', m, n, A.dup().data, 0, m, S.data, 0, U.data, 0, m, V.data, 0, n);

        if (info > 0) {
          throw new LapackConvergenceException("GESVD", info + " superdiagonals of an intermediate bidiagonal form failed to converge.");
        }

        return new DoubleMatrix[]{U, S, V.transpose()};
    }
1123424
@Override
    public boolean decompose(DMatrixRBlock A) {
        if( A.numCols != A.numRows )
            throw new IllegalArgumentException("A must be square");

        this.T = A;

        if( lower )
            return decomposeLower();
        else
            return decomposeUpper();
    }
1005103
public SymmDenseEVD factor(LowerSymmDenseMatrix A)
            throws NotConvergedException {
        if (uplo != UpLo.Lower)
            throw new IllegalArgumentException(
                    "Eigenvalue computer configured for lower-symmetrical matrices");

        return factor(A, A.getData());
    }
389380
public static EVD eigen(Matrix A, int k, Ritz ritz) {
        return eigen(A, k, ritz, 1E-8, 10 * A.nrows());
    }
1028725
private static EigenPair[] processDecomposition(EigenvalueDecomposition evd) {
    double[] eigenvalues = evd.getRealEigenvalues();
    double[][] eigenvectors = evd.getV();

    EigenPair[] eigenPairs = new EigenPair[eigenvalues.length];
    for(int i = 0; i < eigenvalues.length; i++) {
      double e = Math.abs(eigenvalues[i]);
      double[] v = VMath.getCol(eigenvectors, i);
      eigenPairs[i] = new EigenPair(v, e);
    }
    Arrays.sort(eigenPairs, Comparator.reverseOrder());
    return eigenPairs;
  }
1001982
public static DMatrixRMaj convertToMatrix( Se3_F64 m , DMatrixRMaj A ) {
		if( A == null )
			A = new DMatrixRMaj(3,4);
		else
			A.reshape(3,4);
		CommonOps_DDRM.insert(m.R,A,0,0);
		A.data[3] = m.T.x;
		A.data[7] = m.T.y;
		A.data[11] = m.T.z;
		return A;
	}
464262
public static DenseDoubleMatrix2D inverse(final double[][] matrix) {
		double epsilon = UJMPSettings.getInstance().getTolerance();
		int rows = matrix.length;
		int cols = matrix[0].length;
		double[][] s = new double[cols][cols];
		for (int c = 0; c < cols; c++) {
			s[c][c] = 1.0;
		}
		final double[][] t = new double[rows][rows];
		for (int r = 0; r < rows; r++) {
			t[r][r] = 1.0;
		}
		int maxDiag = Math.min(rows, cols);

		int diag = 0;
		for (; diag < maxDiag; diag++) {

			// get the largest value for the pivot
			swapPivot(matrix, diag, s, t);

			if (matrix[diag][diag] == 0.0) {
				break;
			}

			// divide through to make pivot identity
			double divisor = matrix[diag][diag];
			if (Math.abs(divisor) < epsilon) {
				matrix[diag][diag] = 0.0;
				break;
			}

			divideRowBy(matrix, diag, diag, divisor);
			divideRowBy(t, diag, 0, divisor);
			matrix[diag][diag] = 1.0;

			// remove values down remaining rows
			for (int row = diag + 1; row < rows; row++) {
				double factor = matrix[row][diag];
				if (factor != 0.0) {
					addRowTimes(matrix, diag, diag, row, factor);
					addRowTimes(t, diag, 0, row, factor);
					matrix[row][diag] = 0.0;
				}
			}

			// remove values across remaining cols - some optimization could
			// be done here because the changes to the original matrix at this
			// point only touch the current diag column
			for (int col = diag + 1; col < cols; col++) {
				double factor = matrix[diag][col];
				if (factor != 0.0) {
					addColTimes(matrix, diag, diag, col, factor);
					addColTimes(s, diag, 0, col, factor);
					matrix[diag][col] = 0.0;
				}
			}
		}

		double[][] result = times(s, t, diag);
		return new ArrayDenseDoubleMatrix2D(result);
	}
1080917
public static BandCholesky factorize(UpperSPDBandMatrix A) {
        return new BandCholesky(A.numRows(), A.ku, true).factor(A);
    }
1035019
private static int[] elmhes(DenseMatrix A) {
        int n = A.nrows();
        int[] perm = new int[n];

        for (int m = 1; m < n - 1; m++) {
            double x = 0.0;
            int i = m;
            for (int j = m; j < n; j++) {
                if (Math.abs(A.get(j, m - 1)) > Math.abs(x)) {
                    x = A.get(j, m - 1);
                    i = j;
                }
            }
            perm[m] = i;
            if (i != m) {
                for (int j = m - 1; j < n; j++) {
                    double swap = A.get(i, j);
                    A.set(i, j, A.get(m, j));
                    A.set(m, j, swap);
                }
                for (int j = 0; j < n; j++) {
                    double swap = A.get(j, i);
                    A.set(j, i, A.get(j, m));
                    A.set(j, m, swap);
                }
            }
            if (x != 0.0) {
                for (i = m + 1; i < n; i++) {
                    double y = A.get(i, m - 1);
                    if (y != 0.0) {
                        y /= x;
                        A.set(i, m - 1, y);
                        for (int j = m; j < n; j++) {
                            A.sub(i, j, y * A.get(m, j));
                        }
                        for (int j = 0; j < n; j++) {
                            A.add(j, m, y * A.get(j, i));
                        }
                    }
                }
            }
        }

        return perm;
    }
516966
@Override
    public boolean decompose( ZMatrixRMaj A ) {
        init(A);

        for( int k = 0; k < N-1; k++ ) {
            similarTransform(k);
        }

        return true;
    }