Ejemplo n.º 1
0
 /**
  * Check if matrices are multiplication compatible
  *
  * @param left left hand side matrix
  * @param right right hand side matrix
  * @exception IllegalArgumentException if matrices are not multiplication compatible
  */
 public static void checkMultiplicationCompatible(final AnyMatrix left, final AnyMatrix right)
     throws IllegalArgumentException {
   if (left.getColumnDimension() != right.getRowDimension()) {
     throw MathRuntimeException.createIllegalArgumentException(
         "{0}x{1} and {2}x{3} matrices are not multiplication compatible",
         left.getRowDimension(),
         left.getColumnDimension(),
         right.getRowDimension(),
         right.getColumnDimension());
   }
 }
Ejemplo n.º 2
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);
   }
 }