use of edu.rit.util.Range in project ffx by mjschnie.
the class ObjectBuf method patchBuffers.
/**
* Create an array of buffers for multiple patches of the given object
* matrix. The length of the returned buffer array is equal to the length of
* <TT>theRowRanges</TT> times the length of <TT>theColRanges</TT>. Each
* element of the returned buffer array encompasses the rows given in one
* element of <TT>theRowRanges</TT> array, and the columns given in one
* element of <TT>theColRanges</TT> array, in all possible combinations, of
* <TT>theMatrix</TT>. Each range's stride may be 1 or greater than 1. The
* matrix elements are sent and received as multiple separate objects of
* type <TT>T</TT>.
*
* @param <T> Data type of the objects in the buffer.
* @param theMatrix Matrix.
* @param theRowRanges Array of ranges of rows to include.
* @param theColRanges Array of ranges of columns to include.
* @return Array of buffers.
* @exception NullPointerException (unchecked exception) Thrown if
* <TT>theMatrix</TT> is null,
* <TT>theRowRanges</TT> or any element thereof is null, or
* <TT>theColRanges</TT> or any element thereof is null.
* @exception IndexOutOfBoundsException (unchecked exception) Thrown if
* <TT>theMatrix</TT>'s allocation does not include any element of
* <TT>theRowRanges</TT> or
* <TT>theColRanges</TT>.
*/
public static <T> ObjectBuf<T>[] patchBuffers(T[][] theMatrix, Range[] theRowRanges, Range[] theColRanges) {
int m = theRowRanges.length;
int n = theColRanges.length;
ObjectBuf<T>[] result = (ObjectBuf<T>[]) new ObjectBuf[m * n];
int k = 0;
for (int i = 0; i < m; ++i) {
Range rowrange = theRowRanges[i];
for (int j = 0; j < n; ++j) {
result[k++] = patchBuffer(theMatrix, rowrange, theColRanges[j]);
}
}
return result;
}
use of edu.rit.util.Range in project ffx by mjschnie.
the class ObjectBuf method colSliceBuffer.
/**
* Create a buffer for one column slice of the given object matrix. The
* returned buffer encompasses all the rows, and <TT>theColRange</TT> of
* columns, in <TT>theMatrix</TT>. The range's stride may be 1 or greater
* than 1. The matrix elements are sent and received as multiple separate
* objects of type <TT>T</TT>.
*
* @param <T> Data type of the objects in the buffer.
* @param theMatrix Matrix.
* @param theColRange Range of columns to include.
* @return Buffer.
* @exception NullPointerException (unchecked exception) Thrown if
* <TT>theMatrix</TT> is null or
* <TT>theColRange</TT> is null.
* @exception IndexOutOfBoundsException (unchecked exception) Thrown if
* <TT>theMatrix</TT>'s allocation does not include <TT>theColRange</TT>.
*/
public static <T> ObjectBuf<T> colSliceBuffer(T[][] theMatrix, Range theColRange) {
if (theMatrix == null) {
throw new NullPointerException("ObjectBuf.colSliceBuffer(): theMatrix is null");
}
int nr = Arrays.rowLength(theMatrix);
int nc = Arrays.colLength(theMatrix, 0);
if (0 > theColRange.lb() || theColRange.ub() >= nc) {
throw new IndexOutOfBoundsException("ObjectBuf.colSliceBuffer(): theMatrix column index range = 0.." + (nc - 1) + ", theColRange = " + theColRange);
}
if (theColRange.stride() == 1) {
return new ObjectMatrixBuf_1<T>(theMatrix, new Range(0, nr - 1), theColRange);
} else {
return new ObjectMatrixBuf<T>(theMatrix, new Range(0, nr - 1), theColRange);
}
}
use of edu.rit.util.Range in project ffx by mjschnie.
the class Signed16BitIntegerBuf method buffer.
/**
* Create a buffer for the entire given integer 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 Signed16BitIntegerBuf buffer(int[][] theMatrix) {
if (theMatrix == null) {
throw new NullPointerException("Signed16BitIntegerBuf.buffer(): theMatrix is null");
}
int nr = Arrays.rowLength(theMatrix);
int nc = Arrays.colLength(theMatrix, 0);
return new Signed16BitIntegerMatrixBuf_1(theMatrix, new Range(0, nr - 1), new Range(0, nc - 1));
}
use of edu.rit.util.Range in project ffx by mjschnie.
the class Unsigned8BitIntegerBuf method buffer.
/**
* Create a buffer for the entire given integer 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 Unsigned8BitIntegerBuf buffer(int[][] theMatrix) {
if (theMatrix == null) {
throw new NullPointerException("Unsigned8BitIntegerBuf.buffer(): theMatrix is null");
}
int nr = Arrays.rowLength(theMatrix);
int nc = Arrays.colLength(theMatrix, 0);
return new Unsigned8BitIntegerMatrixBuf_1(theMatrix, new Range(0, nr - 1), new Range(0, nc - 1));
}
use of edu.rit.util.Range in project ffx by mjschnie.
the class Unsigned8BitIntegerBuf method rowSliceBuffer.
/**
* Create a buffer for one row slice of the given integer matrix. The
* returned buffer encompasses <TT>theRowRange</TT> of rows, and all the
* columns, in <TT>theMatrix</TT>. The range's stride may be 1 or greater
* than 1.
*
* @param theMatrix Matrix.
* @param theRowRange Range of rows to include.
* @return Buffer.
* @exception NullPointerException (unchecked exception) Thrown if
* <TT>theMatrix</TT> is null or
* <TT>theRowRange</TT> is null.
* @exception IndexOutOfBoundsException (unchecked exception) Thrown if
* <TT>theMatrix</TT>'s allocation does not include <TT>theRowRange</TT>.
*/
public static Unsigned8BitIntegerBuf rowSliceBuffer(int[][] theMatrix, Range theRowRange) {
if (theMatrix == null) {
throw new NullPointerException("Unsigned8BitIntegerBuf.rowSliceBuffer(): theMatrix is null");
}
int nr = Arrays.rowLength(theMatrix);
if (0 > theRowRange.lb() || theRowRange.ub() >= nr) {
throw new IndexOutOfBoundsException("Unsigned8BitIntegerBuf.rowSliceBuffer(): theMatrix row index range = 0.." + (nr - 1) + ", theRowRange = " + theRowRange);
}
int nc = Arrays.colLength(theMatrix, theRowRange.lb());
if (theRowRange.stride() == 1) {
return new Unsigned8BitIntegerMatrixBuf_1(theMatrix, theRowRange, new Range(0, nc - 1));
} else {
return new Unsigned8BitIntegerMatrixBuf(theMatrix, theRowRange, new Range(0, nc - 1));
}
}
Aggregations