/** * Create a buffer for one patch of the given double matrix. The returned buffer encompasses * <TT>theRowRange</TT> of rows, and <TT>theColRange</TT> of columns, in <TT>theMatrix</TT>. Each * range's stride may be 1 or greater than 1. * * @param theMatrix Matrix. * @param theRowRange Range of rows to include. * @param theColRange Range of columns to include. * @return Buffer. * @exception NullPointerException (unchecked exception) Thrown if <TT>theMatrix</TT> is null, * <TT>theRowRange</TT> is null, or <TT>theColRange</TT> is null. * @exception IndexOutOfBoundsException (unchecked exception) Thrown if <TT>theMatrix</TT>'s * allocation does not include <TT>theRowRange</TT> and <TT>theColRange</TT>. */ public static DoubleBuf patchBuffer(double[][] theMatrix, Range theRowRange, Range theColRange) { if (theMatrix == null) { throw new NullPointerException("DoubleBuf.patchBuffer(): theMatrix is null"); } int nr = Arrays.rowLength(theMatrix); if (0 > theRowRange.lb() || theRowRange.ub() >= nr) { throw new IndexOutOfBoundsException( "DoubleBuf.patchBuffer(): theMatrix row index range = 0.." + (nr - 1) + ", theRowRange = " + theRowRange); } int nc = Arrays.colLength(theMatrix, theRowRange.lb()); if (0 > theColRange.lb() || theColRange.ub() >= nc) { throw new IndexOutOfBoundsException( "DoubleBuf.patchBuffer(): theMatrix column index range = 0.." + (nc - 1) + ", theColRange = " + theColRange); } if (theRowRange.stride() == 1 && theColRange.stride() == 1) { return new DoubleMatrixBuf_1(theMatrix, theRowRange, theColRange); } else { return new DoubleMatrixBuf(theMatrix, theRowRange, theColRange); } }
/** * Create a buffer for the entire given double matrix. The returned buffer encompasses all the * rows and all the columns in <TT>theMatrix</TT>. * * @param theMatrix Matrix. * @return Buffer. * @exception NullPointerException (unchecked exception) Thrown if <TT>theMatrix</TT> is null. */ public static DoubleBuf buffer(double[][] theMatrix) { if (theMatrix == null) { throw new NullPointerException("DoubleBuf.buffer(): theMatrix is null"); } int nr = Arrays.rowLength(theMatrix); int nc = Arrays.colLength(theMatrix, 0); return new DoubleMatrixBuf_1(theMatrix, new Range(0, nr - 1), new Range(0, nc - 1)); }