Search in sources :

Example 56 with Range

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

the class FloatBuf method colSliceBuffer.

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

Example 57 with Range

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

the class LongBuf method colSliceBuffer.

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

Example 58 with Range

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

the class Comm method createComm.

/**
 * Create a new communicator. <I>Every</I> process in this communicator must
 * call the <TT>createComm()</TT> method. Each process passes true or false
 * for the <TT>participate</TT> argument to state whether the process will
 * participate in the new communicator. At least one process must
 * participate in the new communicator. Messages to set up the new
 * communicator are sent to all processes in this communicator, using the
 * given message tag.
 * <P>
 * In processes participating in the new communicator, the new communicator
 * is returned. The participating processes appear in the same order by rank
 * in the new communicator as in this communicator. The process can call the
 * new communicator's <TT>rank()</TT> method to determine the process's rank
 * in the new communicator.
 * <P>
 * In processes not participating in the new communicator, null is returned.
 *
 * @param participate True if this process will participate in the new
 * communicator; false otherwise.
 * @param tag Message tag.
 *
 * @return New communicator if this process will participate in the new
 * communicator; null otherwise.
 *
 * @exception IOException Thrown if an I/O error occurred.
 */
public Comm createComm(boolean participate, int tag) throws IOException {
    // Set up array of socket addresses for all processes.
    InetSocketAddress[] address = new InetSocketAddress[mySize];
    ObjectBuf<InetSocketAddress>[] addressbuf = ObjectBuf.sliceBuffers(address, new Range(0, mySize - 1).subranges(mySize));
    // Create channel group for new communicator, if participating.
    ChannelGroup channelgroup = null;
    InetSocketAddress myaddress = null;
    if (participate) {
        channelgroup = new ChannelGroup(new InetSocketAddress(myChannelGroup.listenAddress().getAddress(), 0));
        myaddress = channelgroup.listenAddress();
        address[myRank] = myaddress;
    }
    // All-gather channel group socket addresses into every process.
    allGather(tag, addressbuf[myRank], addressbuf);
    // Close up gaps in the socket address array if any.
    int off = 0;
    int newsize = 0;
    int newrank = -1;
    for (int i = 0; i < mySize; ++i) {
        if (address[i] == null) {
            ++off;
        } else {
            if (i == myRank) {
                newrank = i - off;
            }
            address[i - off] = address[i];
            ++newsize;
        }
    }
    // Verify size of new communicator.
    if (newsize == 0) {
        throw new IOException("Comm.createComm(): No processes in communicator");
    }
    // Return new communicator if participating.
    if (participate) {
        return new Comm(newsize, newrank, myHost, channelgroup, address);
    } else // Return null if not participating.
    {
        return null;
    }
}
Also used : InetSocketAddress(java.net.InetSocketAddress) IOException(java.io.IOException) InterruptedIOException(java.io.InterruptedIOException) ObjectBuf(edu.rit.mp.ObjectBuf) Range(edu.rit.util.Range) ChannelGroup(edu.rit.mp.ChannelGroup)

Example 59 with Range

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

the class ShortBuf method buffer.

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

Example 60 with Range

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

the class ShortBuf method colSliceBuffer.

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

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