@Override public double get(int row, int col) { return mat.get(row,col); }
/** * Constructs and returns a deep copy of the receiver. * <p> * <b>Note that the returned matrix is an independent deep copy.</b> The * returned matrix is not backed by this matrix, so changes in the returned * matrix are not reflected in this matrix, and vice-versa. * * @return a deep copy of the receiver. */ public DoubleMatrix2D copy() { return like().assign(this); }
public void run() { DoubleMatrix2D view = null; for (int r = firstRow; r < lastRow; r++) { for (int c = 0; c < n; c++) { view = matrix.viewPart(r * row_size, c * col_size, height[r], width[c]); histo[r][c].fill_2D((double[]) view.elements(), view.rows(), view.columns(), (int) view .index(0, 0), view.rowStride(), view.columnStride()); } } } });
public static DoubleMatrix2D delete(DoubleMatrix2D m, int idx, int axis) { int[] irow, icol; if (axis == 0) { irow = icat(irange(idx), irange(idx + 1, m.rows())); icol = null; } else { irow = null; icol = icat(irange(idx), irange(idx + 1, m.columns())); } return m.viewSelection(irow, icol).copy(); }
/** * A matrix <tt>A</tt> is <i>diagonally dominant by column</i> if the * absolute value of each diagonal element is larger than the sum of the * absolute values of the off-diagonal elements in the corresponding column. * * <tt>returns true if for all i: abs(A[i,i]) > Sum(abs(A[j,i])); j != i.</tt> * Matrix may but need not be square. * <p> * Note: Ignores tolerance. */ public boolean isDiagonallyDominantByColumn(DoubleMatrix2D A) { cern.jet.math.tdouble.DoubleFunctions F = cern.jet.math.tdouble.DoubleFunctions.functions; int min = Math.min(A.rows(), A.columns()); for (int i = min; --i >= 0;) { double diag = Math.abs(A.getQuick(i, i)); diag += diag; if (diag <= A.viewColumn(i).aggregate(DoubleFunctions.plus, DoubleFunctions.abs)) return false; } return true; }
/** * Modifies the given matrix square matrix <tt>A</tt> such that it is * diagonally dominant by row and column, hence non-singular, hence * invertible. For testing purposes only. * * @param A * the square matrix to modify. * @throws IllegalArgumentException * if <tt>!isSquare(A)</tt>. */ public void generateNonSingular(DoubleMatrix2D A) { checkSquare(A); cern.jet.math.tdouble.DoubleFunctions F = cern.jet.math.tdouble.DoubleFunctions.functions; int min = Math.min(A.rows(), A.columns()); for (int i = min; --i >= 0;) { A.setQuick(i, i, 0); } for (int i = min; --i >= 0;) { double rowSum = A.viewRow(i).aggregate(DoubleFunctions.plus, DoubleFunctions.abs); double colSum = A.viewColumn(i).aggregate(DoubleFunctions.plus, DoubleFunctions.abs); A.setQuick(i, i, Math.max(rowSum, colSum) + i + 1); } }
/** * Returns a string representations of all cells; no alignment considered. */ public String[][] format(DoubleMatrix2D matrix) { String[][] strings = new String[matrix.rows()][matrix.columns()]; for (int row = matrix.rows(); --row >= 0;) strings[row] = formatRow(matrix.viewRow(row)); return strings; }
public static RowMajorMatrix parallelColtToRowMajor(cern.colt.matrix.tdouble.DoubleMatrix2D orig) { if( orig == null ) return null; RowMajorMatrix mat = new RowMajorMatrix(orig.rows(),orig.columns()); for( int i = 0; i < mat.numRows; i++ ) { for( int j = 0; j < mat.numCols; j++ ) { mat.set(i,j,orig.get(i,j)); } } return mat; }
/** * Returns the one-norm of matrix <tt>A</tt>, which is the maximum absolute * column sum. */ public double norm1(DoubleMatrix2D A) { double max = 0; for (int column = A.columns(); --column >= 0;) { max = Math.max(max, norm1(A.viewColumn(column))); } return max; }
public void dswap(DoubleMatrix2D A, DoubleMatrix2D B) { A.checkShape(B); int rows = A.rows(); for (int i = 0; i < rows; i++) A.viewRow(i).swap(B.viewRow(i)); }
public synchronized void set(int i, int j, double value) { content.set(row + i, column + j, value); } };
/** * A square matrix <tt>A</tt> is <i>orthogonal</i> if * <tt>A*transpose(A) = I</tt>. * * @throws IllegalArgumentException * if <tt>!isSquare(A)</tt>. */ public boolean isOrthogonal(DoubleMatrix2D A) { checkSquare(A); return equals(A.zMult(A, null, 1, 0, false, true), cern.colt.matrix.tdouble.DoubleFactory2D.dense.identity(A .rows())); }
public void setMatrix(DoubleMatrix2D A) { if (A.rows() != invdiag.length) throw new IllegalArgumentException("Matrix size differs from preconditioner size"); for (int i = 0; i < invdiag.length; ++i) { invdiag[i] = A.getQuick(i, i); if (invdiag[i] == 0) // Avoid zero-division throw new RuntimeException("Zero diagonal on row " + (i + 1)); else invdiag[i] = 1 / invdiag[i]; } }
/** Returns the carried traffic per link. * * @param x_de Demand-link routing in the form x_de (amount of traffic from demand d, transmitted through link e) * @return Carried traffic per link */ public static DoubleMatrix1D convert_xde2ye(DoubleMatrix2D x_de) { return x_de.zMult(DoubleFactory1D.dense.make(x_de.columns(), 1), null); }
/** * */ protected int m() { return LU.rows(); }
public DoubleMatrix2D assign(cern.colt.function.tdouble.DoubleFunction function) { if (this.isNoView && function instanceof cern.jet.math.tdouble.DoubleMult) { // x[i] = mult*x[i] this.elements.assign(function); } else { super.assign(function); } return this; }