averbraeck / djunits

Delft Java UNIT System for using strongly-typed quantities and units
BSD 3-Clause "New" or "Revised" License
1 stars 0 forks source link

get() methods on vectors and matrices should throw `IndexOutOfBoundsException` #30

Open averbraeck opened 2 hours ago

averbraeck commented 2 hours ago

The Vector.get() abstract class throws a ValueRuntimeException when the index of the get() method is out of bounds. It should throw an IndexOutOfBoundsException instead, since it explains the issue much clearer.

The same holds for the Matrix.get(row, column). For the Matrix abstract class, the following methods should also get an IndexOutOfBoundsException:

Note that the methods public abstract V getDiagonal() and public abstract S[] getDiagonalScalars() still throw a ValueRuntimeException when the matrix is not square.

averbraeck commented 2 hours ago

The class DoubleVector has several methods that need to throw an IndexOutOfBoundsException instead of a ValueRuntimeException:

The method protected final void checkSize(final DoubleVector<?, ?, ?> other) still throws a ValueRuntimeException when vectors have unequal size.

averbraeck commented 1 hour ago

The class DoubleVectorData has a method:

public static DoubleVectorData instantiate(final Map<Integer, ? extends Number> valueMap, 
    final int size, final Scale scale, final StorageType storageType)

This method threw ValueRuntimeException for almost everything. Now it throws:

averbraeck commented 1 hour ago

The class DoubleMatrix has several methods that need to throw an IndexOutOfBoundsException instead of a ValueRuntimeException:

The methods that expect a square matrix still throw a ValueRuntimeException when the matrix is not square.

averbraeck commented 1 hour ago

The class FloatVector has several methods that need to throw an IndexOutOfBoundsException instead of a ValueRuntimeException:

The method protected final void checkSize(final FloatVector<?, ?, ?> other) still throws a ValueRuntimeException when vectors have unequal size.