コード例 #1
0
 /**
  * Create a buffer for one patch of the given double matrix. The returned buffer encompasses
  * <TT>theRowRange</TT> of rows, and <TT>theColRange</TT> of columns, in <TT>theMatrix</TT>. Each
  * range's stride may be 1 or greater than 1.
  *
  * @param theMatrix Matrix.
  * @param theRowRange Range of rows to include.
  * @param theColRange Range of columns to include.
  * @return Buffer.
  * @exception NullPointerException (unchecked exception) Thrown if <TT>theMatrix</TT> is null,
  *     <TT>theRowRange</TT> is null, or <TT>theColRange</TT> is null.
  * @exception IndexOutOfBoundsException (unchecked exception) Thrown if <TT>theMatrix</TT>'s
  *     allocation does not include <TT>theRowRange</TT> and <TT>theColRange</TT>.
  */
 public static DoubleBuf patchBuffer(double[][] theMatrix, Range theRowRange, Range theColRange) {
   if (theMatrix == null) {
     throw new NullPointerException("DoubleBuf.patchBuffer(): theMatrix is null");
   }
   int nr = Arrays.rowLength(theMatrix);
   if (0 > theRowRange.lb() || theRowRange.ub() >= nr) {
     throw new IndexOutOfBoundsException(
         "DoubleBuf.patchBuffer(): theMatrix row index range = 0.."
             + (nr - 1)
             + ", theRowRange = "
             + theRowRange);
   }
   int nc = Arrays.colLength(theMatrix, theRowRange.lb());
   if (0 > theColRange.lb() || theColRange.ub() >= nc) {
     throw new IndexOutOfBoundsException(
         "DoubleBuf.patchBuffer(): theMatrix column index range = 0.."
             + (nc - 1)
             + ", theColRange = "
             + theColRange);
   }
   if (theRowRange.stride() == 1 && theColRange.stride() == 1) {
     return new DoubleMatrixBuf_1(theMatrix, theRowRange, theColRange);
   } else {
     return new DoubleMatrixBuf(theMatrix, theRowRange, theColRange);
   }
 }
コード例 #2
0
 /**
  * Create a buffer for the entire given double 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 DoubleBuf buffer(double[][] theMatrix) {
   if (theMatrix == null) {
     throw new NullPointerException("DoubleBuf.buffer(): theMatrix is null");
   }
   int nr = Arrays.rowLength(theMatrix);
   int nc = Arrays.colLength(theMatrix, 0);
   return new DoubleMatrixBuf_1(theMatrix, new Range(0, nr - 1), new Range(0, nc - 1));
 }
コード例 #3
0
 /**
  * Create a buffer for the entire given double array. The returned buffer encompasses all the
  * elements in <TT>theArray</TT>.
  *
  * @param theArray Array.
  * @return Buffer.
  * @exception NullPointerException (unchecked exception) Thrown if <TT>theArray</TT> is null.
  */
 public static DoubleBuf buffer(double[] theArray) {
   if (theArray == null) {
     throw new NullPointerException("DoubleBuf.buffer(): theArray is null");
   }
   int nr = Arrays.length(theArray);
   return new DoubleArrayBuf_1(theArray, new Range(0, nr - 1));
 }
コード例 #4
0
 /**
  * Create a buffer for one slice of the given double array. The returned buffer encompasses
  * <TT>theRange</TT> of elements in <TT>theArray</TT>. The range's stride may be 1 or greater than
  * 1.
  *
  * @param theArray Array.
  * @param theRange Range of elements to include.
  * @return Buffer.
  * @exception NullPointerException (unchecked exception) Thrown if <TT>theArray</TT> is null or
  *     <TT>theRange</TT> is null.
  * @exception IndexOutOfBoundsException (unchecked exception) Thrown if <TT>theArray</TT> does not
  *     include all the indexes in <TT>theRange</TT>.
  */
 public static DoubleBuf sliceBuffer(double[] theArray, Range theRange) {
   if (theArray == null) {
     throw new NullPointerException("DoubleBuf.sliceBuffer(): theArray is null");
   }
   int nr = Arrays.length(theArray);
   if (0 > theRange.lb() || theRange.ub() >= nr) {
     throw new IndexOutOfBoundsException(
         "DoubleBuf.sliceBuffer(): theArray index range = 0.."
             + (nr - 1)
             + ", theRange = "
             + theRange);
   }
   if (theRange.stride() == 1) {
     return new DoubleArrayBuf_1(theArray, theRange);
   } else {
     return new DoubleArrayBuf(theArray, theRange);
   }
 }