/** * <p> * Checks to see if the matrix is positive semidefinite: * </p> * <p> * x<sup>T</sup> A x ≥ 0<br> * for all x where x is a non-zero vector and A is a symmetric matrix. * </p> * * @param A square symmetric matrix. Not modified. * * @return True if it is positive semidefinite and false if it is not. */ public static bool isPositiveSemidefinite(DMatrixRMaj A) { if (!isSquare(A)) { return(false); } EigenDecomposition_F64 <DMatrixRMaj> eig = DecompositionFactory_DDRM.eig(A.numCols, false); if (eig.inputModified()) { A = (DMatrixRMaj)A.copy(); } eig.decompose(A); for (int i = 0; i < A.numRows; i++) { Complex_F64 v = eig.getEigenvalue(i); if (v.getReal() < 0) { return(false); } } return(true); }
private void checkSplitPerformImplicit() { // check for splits for (int i = x2; i > x1; i--) { if (_implicit.isZero(i, i - 1)) { x1 = i; splits[numSplits++] = i - 1; // reduce the scope of what it is looking at return; } } // first try using known eigenvalues in the same order they were originally found if (onscript) { if (_implicit.steps > _implicit.exceptionalThreshold / 2) { onscript = false; } else { Complex_F64 a = origEigenvalues[indexVal]; // if no splits are found perform an implicit step if (a.isReal()) { _implicit.performImplicitSingleStep(x1, x2, a.getReal()); } else if (x2 - x1 >= 1 && x1 + 2 < N) { _implicit.performImplicitDoubleStep(x1, x2, a.real, a.imaginary); } else { onscript = false; } } } else { // that didn't work so try a modified order if (x2 - x1 >= 1 && x1 + 2 < N) { _implicit.implicitDoubleStep(x1, x2); } else { _implicit.performImplicitSingleStep(x1, x2, _implicit.A.get(x2, x2)); } } }