Search in sources :

Example 1 with BooleanMatrixBuf_1

use of edu.rit.mp.buf.BooleanMatrixBuf_1 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)

Example 2 with BooleanMatrixBuf_1

use of edu.rit.mp.buf.BooleanMatrixBuf_1 in project ffx by mjschnie.

the class BooleanBuf method colSliceBuffer.

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

Example 3 with BooleanMatrixBuf_1

use of edu.rit.mp.buf.BooleanMatrixBuf_1 in project ffx by mjschnie.

the class BooleanBuf method buffer.

/**
 * Create a buffer for the entire given Boolean 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 BooleanBuf buffer(boolean[][] theMatrix) {
    if (theMatrix == null) {
        throw new NullPointerException("BooleanBuf.buffer(): theMatrix is null");
    }
    int nr = Arrays.rowLength(theMatrix);
    int nc = Arrays.colLength(theMatrix, 0);
    return new BooleanMatrixBuf_1(theMatrix, new Range(0, nr - 1), new Range(0, nc - 1));
}
Also used : Range(edu.rit.util.Range) BooleanMatrixBuf_1(edu.rit.mp.buf.BooleanMatrixBuf_1)

Aggregations

BooleanMatrixBuf_1 (edu.rit.mp.buf.BooleanMatrixBuf_1)3 Range (edu.rit.util.Range)3 BooleanMatrixBuf (edu.rit.mp.buf.BooleanMatrixBuf)2