Exception Types

This section lists the exception types that may be thrown by classes in the Extreme Optimization Mathematics Library for .NET.

In addition to the exceptions listed below, many standard exceptions may also be thrown. For instance, when the index for a vector or matrix is out of range, an ArgumentOutOfRangeException is thrown. When a user tries to obtain the result from a descendant of ManagedIterativeAlgorithm<T> before the algorithm has terminated, an InvalidOperationException is thrown. This behavior is consistent with Microsoft's guidelines for throwing exceptions.

ConvergenceException

This exception indicates that an algorithm failed to converge. This exception is only thrown if the ThrowExceptionOnFailure property is set to true. See the ManagedIterativeAlgorithm<T> interface for details.

TotalLossOfPrecisionException

In some rare cases, round-off error can cause the result of an operation to have no correct significant digits at all. When this happens, an exception of type TotalLossOfPrecisionException is thrown.

Round-off errors are the result of the finite precision of floating-point numbers. Only a few numbers can be represented exactly. The main contributing factor to total loss of precision is when two numbers of approximately equal size are subtracted.

ComponentReadOnlyException

Many matrices have a clearly defined structure. For example, all elements above the diagonal of a lower triangular matrix are zero. If the matrix is also unit diagonal, then its diagonal elements have the fixed value of 1.

Changing the value of one of these elements would cause the vector or matrix to lose its structure. This is not allowed. In this case, a ComponentReadOnlyException is thrown.

The exception is also thrown when a vector or matrix is marked as read-only and an attempt is made to set one or more elements.

DimensionMismatchException

There are many reasons why a DimensionMismatchException may be thrown. In every case, the dimensions of some or all of the Vector<T> or Matrix<T> objects involved in an operation are not compatible. Some examples of requirements that may be violated, resulting in a DimensionMismatchException, are:

  • A method requires a Matrix<T> to be square. The matrix that was supplied is rectangular.
  • An operation on two Vector objects requires that the two vectors have the same length. Most operations on vectors have this requirement.
  • A multiplication of a Matrix and a Vector requires that either the number of rows or the number of columns in the matrix equals the length of the vector.
  • A multiplication of two matrices requires that the 'inner' dimensions are the same.

This exception type has four properties that give more information about the cause of the problem:

Property

Description

FirstDimensionType

The DimensionType of the first parameter involved in the operation.

FirstParameterName

The name of the first parameter involved in the operation.

SecondDimensionType

The DimensionType of the second parameter involved in the operation. If there was only one parameter involved, this property equals DimensionType.Unknown.

SecondParameterName

The name of the second parameter involved in the operation. If there was only one parameter involved, the value of this property is an empty string.

The DimensionType enumeration can have the following values:

Member Name

Description

Unknown

The mismatched dimension is unknown.

Row

The number of rows of a Matrix<T> is mismatched.

Column

The number of columns of a Matrix<T> is mismatched.

Length

The length of a Vector<T> is mismatched.

MatrixNotPositiveDefiniteException

A matrix is positive definite when all its eigenvalues are greater than or equal to zero. A MatrixNotPositiveDefiniteException is thrown when a computation cannot be completed because a Matrix<T> is not positive definite. In particular, for the Cholesky Decomposition of a symmetrical or Hermitian matrix to exist, the matrix must be positive definite.

MatrixSingularException

A MatrixSingularException is thrown when a computation cannot be completed because a Matrix<T> is singular.