예제 #1
0
 /**
  * Check if a column index is valid.
  *
  * @param m matrix containing the submatrix
  * @param column column index to check
  * @exception MatrixIndexException if index is not valid
  */
 public static void checkColumnIndex(final AnyMatrix m, final int column)
     throws MatrixIndexException {
   if (column < 0 || column >= m.getColumnDimension()) {
     throw new MatrixIndexException(
         "column index {0} out of allowed range [{1}, {2}]",
         column, 0, m.getColumnDimension() - 1);
   }
 }
예제 #2
0
 /**
  * Check if matrices are subtraction compatible
  *
  * @param left left hand side matrix
  * @param right right hand side matrix
  * @exception IllegalArgumentException if matrices are not subtraction compatible
  */
 public static void checkSubtractionCompatible(final AnyMatrix left, final AnyMatrix right)
     throws IllegalArgumentException {
   if ((left.getRowDimension() != right.getRowDimension())
       || (left.getColumnDimension() != right.getColumnDimension())) {
     throw MathRuntimeException.createIllegalArgumentException(
         "{0}x{1} and {2}x{3} matrices are not subtraction compatible",
         left.getRowDimension(),
         left.getColumnDimension(),
         right.getRowDimension(),
         right.getColumnDimension());
   }
 }
예제 #3
0
 /**
  * Check if a row index is valid.
  *
  * @param m matrix containing the submatrix
  * @param row row index to check
  * @exception MatrixIndexException if index is not valid
  */
 public static void checkRowIndex(final AnyMatrix m, final int row) {
   if (row < 0 || row >= m.getRowDimension()) {
     throw new MatrixIndexException(
         "row index {0} out of allowed range [{1}, {2}]", row, 0, m.getRowDimension() - 1);
   }
 }