public static Pair<Integer, Integer> getIndexOfFirstNegative(DoubleMatrix2D a) { for (int i = 0; i < a.rows(); i++) { for (int j = 0; j < a.columns(); j++) { if (a.get(i, j) < 0) { return new Pair<Integer, Integer>(i, j); } } } return null; }
public static Pair<Integer, Integer> getIndexOfFirstZeroIgnoreDiagonal(DoubleMatrix2D a) { for (int i = 0; i < a.rows(); i++) { for (int j = 0; j < a.columns(); j++) { if (i != j && a.get(i, j) == 0) { return new Pair<Integer, Integer>(i, j); } } } return null; }
public static boolean containsNaNs(DoubleMatrix2D a) { for (int i = 0; i < a.rows(); i++) { for (int j = 0; j < a.columns(); j++) { if (Double.isNaN(a.get(i, j))) { return true; } } } return false; }