public int rank() { int rank = 0; Matrix[] usv = svd(); Matrix s = usv[1]; for (int i = (int) Math.min(s.getSize(ROW), s.getSize(COLUMN)); --i >= 0;) { if (Math.abs(s.getAsDouble(i, i)) > UJMPSettings.getInstance().getTolerance()) { rank++; } } return rank; }
public int getInt(long... coordinates) { if (min == null || max == null) { calculate(); } double v = getSource().getAsDouble(coordinates); double mi = 0; double ma = 0; switch (getDimension()) { case Matrix.ROW: mi = min.getAsDouble(0, coordinates[COLUMN]); ma = max.getAsDouble(0, coordinates[COLUMN]) + UJMPSettings.getInstance().getTolerance(); break; case Matrix.COLUMN: mi = min.getAsDouble(coordinates[ROW], 0); ma = max.getAsDouble(coordinates[ROW], 0) + UJMPSettings.getInstance().getTolerance(); break; default: mi = min.getAsDouble(0, 0); ma = max.getAsDouble(0, 0) + UJMPSettings.getInstance().getTolerance(); break; } double bs = (ma - mi) / numberOfBins; int i = (int) Math.floor((v - mi) / bs); return i; }
public Matrix pinv(int k) { Matrix[] usv = svd(k); Matrix u = usv[0]; Matrix s = usv[1]; Matrix v = usv[2]; for (int i = (int) Math.min(s.getRowCount(), s.getColumnCount()); --i >= 0;) { double d = s.getAsDouble(i, i); if (Math.abs(d) > UJMPSettings.getInstance().getTolerance()) { s.setAsDouble(1.0 / d, i, i); } else { s.setAsDouble(0.0, i, i); } } return v.mtimes(s.transpose()).mtimes(u.transpose()); }
public double getDouble(long... coordinates) { if (pinv == null) { Matrix[] usv = getSource().svd(); Matrix u = usv[0]; Matrix s = usv[1]; Matrix v = usv[2]; for (int i = (int) Math.min(s.getRowCount(), s.getColumnCount()); --i >= 0;) { double d = s.getAsDouble(i, i); if (Math.abs(d) > UJMPSettings.getInstance().getTolerance()) { s.setAsDouble(1.0 / d, i, i); } else { s.setAsDouble(0.0, i, i); } } pinv = v.mtimes(s.transpose()).mtimes(u.transpose()); } return pinv.getAsDouble(coordinates); }
double epsilon = UJMPSettings.getInstance().getTolerance(); int rows = matrix.length; int cols = matrix[0].length;
double epsilon = UJMPSettings.getInstance().getTolerance(); long rows = matrix.getRowCount(); long cols = matrix.getColumnCount();
double epsilon = UJMPSettings.getInstance().getTolerance(); long rows = matrix.getRowCount(); long cols = matrix.getColumnCount();