private void runEVD() { int gramDimension = symmGramMatrix.numRows(); try { symmDenseEVD = no.uib.cipr.matrix.SymmDenseEVD.factorize(this.symmGramMatrix); } catch (NotConvergedException e) { throw new RuntimeException(e); } // initial eigenpairs eigenvalues = symmDenseEVD.getEigenvalues(); double[] Vt_1D = symmDenseEVD.getEigenvectors().getData(); eigenvectors = LinearAlgebraUtils.reshape1DArray(Vt_1D, gramDimension, gramDimension); // sort eigenpairs in descending order according to the magnitude of eigenvalues EigenPair[] eigenPairs = LinearAlgebraUtils.createReverseSortedEigenpairs(eigenvalues, eigenvectors); eigenvalues = LinearAlgebraUtils.extractEigenvaluesFromEigenpairs(eigenPairs); eigenvectors = ArrayUtils.transpose(LinearAlgebraUtils.extractEigenvectorsFromEigenpairs(eigenPairs)); } }
/** * Convenience method for computing the full eigenvalue decomposition of the * given matrix * * @param A * Matrix to factorize. Upper part extracted, and the matrix is * not modified * @return Newly allocated decomposition * @throws NotConvergedException */ public static SymmDenseEVD factorize(Matrix A) throws NotConvergedException { return new SymmDenseEVD(A.numRows(), true) .factor(new UpperSymmDenseMatrix(A)); }
/** * Computes the eigenvalue decomposition of the given matrix * * @param A * Matrix to factorize. Overwritten on return * @return The current eigenvalue decomposition * @throws NotConvergedException */ 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()); }
/** * Convenience method for computing the full eigenvalue decomposition of the * given matrix * * @param A * Matrix to factorize. Upper part extracted, and the matrix is * not modified * @return Newly allocated decomposition * @throws NotConvergedException */ public static SymmDenseEVD factorize(Matrix A) throws NotConvergedException { return new SymmDenseEVD(A.numRows(), true) .factor(new UpperSymmDenseMatrix(A)); }
/** * Computes the eigenvalue decomposition of the given matrix * * @param A * Matrix to factorize. Overwritten on return * @return The current eigenvalue decomposition * @throws NotConvergedException */ public SymmDenseEVD factor(UpperSymmDenseMatrix A) throws NotConvergedException { if (uplo != UpLo.Upper) throw new IllegalArgumentException( "Eigenvalue computer configured for upper-symmetrical matrices"); return factor(A, A.getData()); }
@Override public long process(BenchmarkMatrix[] inputs, BenchmarkMatrix[] outputs, long numTrials) { DenseMatrix matA = inputs[0].getOriginal(); DenseMatrix V = null; double []D = null; long prev = System.nanoTime(); for( long i = 0; i < numTrials; i++ ) { try { // the input matrix is over written SymmDenseEVD e = SymmDenseEVD.factorize(matA); V = e.getEigenvectors(); D = e.getEigenvalues(); } catch (NotConvergedException e) { throw new RuntimeException(e); } } long elapsedTime = System.nanoTime()-prev; if( outputs != null ) { outputs[0] = new RowMajorBenchmarkMatrix(RowMajorOps.diag(D)); outputs[1] = new MtjBenchmarkMatrix(V); } return elapsedTime; } }
/** * Computes the eigenvalue decomposition of the given matrix * * @param A * Matrix to factorize. Overwritten on return * @return The current eigenvalue decomposition * @throws NotConvergedException */ public SymmDenseEVD factor(UpperSymmDenseMatrix A) throws NotConvergedException { if (uplo != UpLo.Upper) throw new IllegalArgumentException( "Eigenvalue computer configured for upper-symmetrical matrices"); return factor(A, A.getData()); }
private void runEVD() { int gramDimension = symmGramMatrix.numRows(); try { symmDenseEVD = no.uib.cipr.matrix.SymmDenseEVD.factorize(this.symmGramMatrix); } catch (NotConvergedException e) { throw new RuntimeException(e); } // initial eigenpairs eigenvalues = symmDenseEVD.getEigenvalues(); double[] Vt_1D = symmDenseEVD.getEigenvectors().getData(); eigenvectors = LinearAlgebraUtils.reshape1DArray(Vt_1D, gramDimension, gramDimension); // sort eigenpairs in descending order according to the magnitude of eigenvalues EigenPair[] eigenPairs = LinearAlgebraUtils.createReverseSortedEigenpairs(eigenvalues, eigenvectors); eigenvalues = LinearAlgebraUtils.extractEigenvaluesFromEigenpairs(eigenPairs); eigenvectors = ArrayUtils.transpose(LinearAlgebraUtils.extractEigenvectorsFromEigenpairs(eigenPairs)); } }
/** * Computes the eigenvalue decomposition of the given matrix * * @param A * Matrix to factorize. Overwritten on return * @return The current eigenvalue decomposition * @throws NotConvergedException */ 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()); }
SymmDenseEVD evd = SymmDenseEVD.factorize(m_Correlation); m_Eigenvectors = Matrices.getArray(evd.getEigenvectors()); m_Eigenvalues = evd.getEigenvalues();
SymmDenseEVD evdCw = SymmDenseEVD.factorize(Cw); Matrix evCw = evdCw.getEigenvectors(); double[] evs = evdCw.getEigenvalues(); SymmDenseEVD evd = SymmDenseEVD.factorize(symmMatrix); System.err.println("Eigenvectors of symmetric matrix :\n" + evd.getEigenvectors()); System.err.println("Eigenvalues of symmetric matrix :\n" + Utils.arrayToString(evd.getEigenvalues()) + "\n"); for (int i = 0; i < evd.getEigenvalues().length; i++) { if (Utils.gr(evd.getEigenvalues()[i], 0)) { indices.add(i); cols[index++] = indices.get(i); int[] rows = new int[evd.getEigenvectors().numRows()]; for (int i = 0; i < rows.length; i++) { rows[i] = i; Matrix reducedMatrix = Matrices.getSubMatrix(evd.getEigenvectors(), rows, cols);
SymmDenseEVD evd = SymmDenseEVD.factorize(m_Correlation); m_Eigenvectors = Matrices.getArray(evd.getEigenvectors()); m_Eigenvalues = evd.getEigenvalues();
SymmDenseEVD evd = SymmDenseEVD.factorize(m_correlation); m_eigenvectors = Matrices.getArray(evd.getEigenvectors()); m_eigenvalues = evd.getEigenvalues();
SymmDenseEVD evd = SymmDenseEVD.factorize(m_correlation); m_eigenvectors = Matrices.getArray(evd.getEigenvectors()); m_eigenvalues = evd.getEigenvalues();