コード例 #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 one slice of the given shared 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(SharedDoubleArray theArray, Range theRange) {
   if (theArray == null) {
     throw new NullPointerException("DoubleBuf.sliceBuffer(): theArray is null");
   }
   int nr = theArray.length();
   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 SharedDoubleArrayBuf_1(theArray, theRange);
   } else {
     return new SharedDoubleArrayBuf(theArray, theRange);
   }
 }