Search in sources :

Example 11 with Range

use of edu.rit.util.Range in project ffx by mjschnie.

the class Signed16BitIntegerBuf method colSliceBuffer.

/**
 * Create a buffer for one column slice of the given integer 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.
 *
 * @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 Signed16BitIntegerBuf colSliceBuffer(int[][] theMatrix, Range theColRange) {
    if (theMatrix == null) {
        throw new NullPointerException("Signed16BitIntegerBuf.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("Signed16BitIntegerBuf.colSliceBuffer(): theMatrix column index range = 0.." + (nc - 1) + ", theColRange = " + theColRange);
    }
    if (theColRange.stride() == 1) {
        return new Signed16BitIntegerMatrixBuf_1(theMatrix, new Range(0, nr - 1), theColRange);
    } else {
        return new Signed16BitIntegerMatrixBuf(theMatrix, new Range(0, nr - 1), theColRange);
    }
}
Also used : Signed16BitIntegerMatrixBuf_1(edu.rit.mp.buf.Signed16BitIntegerMatrixBuf_1) Signed16BitIntegerMatrixBuf(edu.rit.mp.buf.Signed16BitIntegerMatrixBuf) Range(edu.rit.util.Range)

Example 12 with Range

use of edu.rit.util.Range in project ffx by mjschnie.

the class Signed16BitIntegerBuf method patchBuffers.

/**
 * Create an array of buffers for multiple patches of the given integer
 * 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.
 *
 * @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 Signed16BitIntegerBuf[] patchBuffers(int[][] theMatrix, Range[] theRowRanges, Range[] theColRanges) {
    int m = theRowRanges.length;
    int n = theColRanges.length;
    Signed16BitIntegerBuf[] result = new Signed16BitIntegerBuf[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;
}
Also used : Range(edu.rit.util.Range) SharedSigned16BitIntegerBuf(edu.rit.mp.buf.SharedSigned16BitIntegerBuf) EmptySigned16BitIntegerBuf(edu.rit.mp.buf.EmptySigned16BitIntegerBuf)

Example 13 with Range

use of edu.rit.util.Range in project ffx by mjschnie.

the class Unsigned8BitIntegerBuf method patchBuffers.

/**
 * Create an array of buffers for multiple patches of the given integer
 * 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.
 *
 * @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 Unsigned8BitIntegerBuf[] patchBuffers(int[][] theMatrix, Range[] theRowRanges, Range[] theColRanges) {
    int m = theRowRanges.length;
    int n = theColRanges.length;
    Unsigned8BitIntegerBuf[] result = new Unsigned8BitIntegerBuf[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;
}
Also used : EmptyUnsigned8BitIntegerBuf(edu.rit.mp.buf.EmptyUnsigned8BitIntegerBuf) SharedUnsigned8BitIntegerBuf(edu.rit.mp.buf.SharedUnsigned8BitIntegerBuf) Range(edu.rit.util.Range)

Example 14 with Range

use of edu.rit.util.Range in project ffx by mjschnie.

the class BooleanBuf method patchBuffers.

/**
 * Create an array of buffers for multiple patches of the given Boolean
 * 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. It is
 * assumed that the rows and columns of <TT>theMatrix</TT> are allocated and
 * that each row of <TT>theMatrix</TT> has the same number of columns.
 *
 * @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 BooleanBuf[] patchBuffers(boolean[][] theMatrix, Range[] theRowRanges, Range[] theColRanges) {
    int m = theRowRanges.length;
    int n = theColRanges.length;
    BooleanBuf[] result = new BooleanBuf[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;
}
Also used : EmptyBooleanBuf(edu.rit.mp.buf.EmptyBooleanBuf) SharedBooleanBuf(edu.rit.mp.buf.SharedBooleanBuf) Range(edu.rit.util.Range)

Example 15 with Range

use of edu.rit.util.Range in project ffx by mjschnie.

the class BooleanBuf method rowSliceBuffer.

/**
 * Create a buffer for one row slice of the given Boolean 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 BooleanBuf rowSliceBuffer(boolean[][] theMatrix, Range theRowRange) {
    if (theMatrix == null) {
        throw new NullPointerException("BooleanBuf.rowSliceBuffer(): theMatrix is null");
    }
    int nr = Arrays.rowLength(theMatrix);
    if (0 > theRowRange.lb() || theRowRange.ub() >= nr) {
        throw new IndexOutOfBoundsException("BooleanBuf.rowSliceBuffer(): theMatrix row index range = 0.." + (nr - 1) + ", theRowRange = " + theRowRange);
    }
    int nc = Arrays.colLength(theMatrix, theRowRange.lb());
    if (theRowRange.stride() == 1) {
        return new BooleanMatrixBuf_1(theMatrix, theRowRange, new Range(0, nc - 1));
    } else {
        return new BooleanMatrixBuf(theMatrix, theRowRange, new Range(0, nc - 1));
    }
}
Also used : BooleanMatrixBuf(edu.rit.mp.buf.BooleanMatrixBuf) Range(edu.rit.util.Range) BooleanMatrixBuf_1(edu.rit.mp.buf.BooleanMatrixBuf_1)

Aggregations

Range (edu.rit.util.Range)76 LongRange (edu.rit.util.LongRange)6 BooleanMatrixBuf_1 (edu.rit.mp.buf.BooleanMatrixBuf_1)3 ByteMatrixBuf_1 (edu.rit.mp.buf.ByteMatrixBuf_1)3 CharacterMatrixBuf_1 (edu.rit.mp.buf.CharacterMatrixBuf_1)3 DoubleMatrixBuf_1 (edu.rit.mp.buf.DoubleMatrixBuf_1)3 FloatMatrixBuf_1 (edu.rit.mp.buf.FloatMatrixBuf_1)3 IntegerMatrixBuf_1 (edu.rit.mp.buf.IntegerMatrixBuf_1)3 LongMatrixBuf_1 (edu.rit.mp.buf.LongMatrixBuf_1)3 ObjectMatrixBuf_1 (edu.rit.mp.buf.ObjectMatrixBuf_1)3 ShortMatrixBuf_1 (edu.rit.mp.buf.ShortMatrixBuf_1)3 Signed16BitIntegerMatrixBuf_1 (edu.rit.mp.buf.Signed16BitIntegerMatrixBuf_1)3 Signed8BitIntegerMatrixBuf_1 (edu.rit.mp.buf.Signed8BitIntegerMatrixBuf_1)3 Unsigned16BitIntegerMatrixBuf_1 (edu.rit.mp.buf.Unsigned16BitIntegerMatrixBuf_1)3 Unsigned8BitIntegerMatrixBuf_1 (edu.rit.mp.buf.Unsigned8BitIntegerMatrixBuf_1)3 BooleanMatrixBuf (edu.rit.mp.buf.BooleanMatrixBuf)2 ByteMatrixBuf (edu.rit.mp.buf.ByteMatrixBuf)2 CharacterMatrixBuf (edu.rit.mp.buf.CharacterMatrixBuf)2 DoubleMatrixBuf (edu.rit.mp.buf.DoubleMatrixBuf)2 FloatMatrixBuf (edu.rit.mp.buf.FloatMatrixBuf)2