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);
}
}
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);
}
}
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;
}
}
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));
}
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);
}
}
Aggregations