コード例 #1
0
 /// <summary>
 /// Check if matrices are multiplication compatible
 /// </summary>
 /// <param name="left">Left hand side matrix.</param>
 /// <param name="right">Right hand side matrix.</param>
 /// <exception cref="DimensionMismatchException"> if matrices are not multiplication
 /// compatible.</exception>
 public static void checkMultiplicationCompatible(AnyMatrix left, AnyMatrix right)
 {
     if (left.getColumnDimension() != right.getRowDimension())
     {
         throw new DimensionMismatchException(left.getColumnDimension(),
                                              right.getRowDimension());
     }
 }
コード例 #2
0
 /// <summary>
 /// Check if matrices are subtraction compatible
 /// </summary>
 /// <param name="left">Left hand side matrix.</param>
 /// <param name="right">Right hand side matrix.</param>
 /// <exception cref="MatrixDimensionMismatchException"> if the matrices are not addition
 /// compatible.</exception>
 public static void checkSubtractionCompatible(AnyMatrix left, AnyMatrix right)
 {
     if ((left.getRowDimension() != right.getRowDimension()) ||
         (left.getColumnDimension() != right.getColumnDimension()))
     {
         throw new MatrixDimensionMismatchException(left.getRowDimension(), left.getColumnDimension(),
                                                    right.getRowDimension(), right.getColumnDimension());
     }
 }
コード例 #3
0
 /// <summary>
 /// Check if a column index is valid.
 /// </summary>
 /// <param name="m">Matrix.</param>
 /// <param name="column">Column index to check.</param>
 /// <exception cref="OutOfRangeException"> if <c>column</c> is not a valid index.
 /// </exception>
 public static void checkColumnIndex(AnyMatrix m, int column)
 {
     if (column < 0 || column >= m.getColumnDimension())
     {
         throw new OutOfRangeException <Int32>(new LocalizedFormats("COLUMN_INDEX"), column, 0, m.getColumnDimension() - 1);
     }
 }