NMath User's Guide

TOC | Previous | Next | Index

38.1 Exception Types (.NET, C#, CSharp, VB, Visual Basic, F#)

The following exception classes inherit from NMathException.

Table 24 – Exception classes

Exception

Description

FFTKernelException

Thrown when MKL or CUDA (NMath Pre­mium only) returns an error condition when computing an FFT.

GpuConfigurationException

Thrown when GPU support (NMath Premium only) cannot be configured as requested.

IndexOutOfRangeException

Thrown when an out of range index is passed to an NMath function.

InvalidArgumentException

Thrown when an invalid argument is passed to an NMath function.

InvalidBinBdryException

Thrown when a histogram operation results in invalid bin boundaries.

KernelLoadException

Thrown when NMath cannot load a kernel assembly.

MatrixNotSquareException

Thrown when a matrix operation requiring a square matrix is presented with a non-square one.

MismatchedSizeException

Exception thrown when an operation is per­formed with operands whose sizes are incompatible with the operation; for example, if you try to add two vectors with different lengths, or take the inner product of matrices A and B when the number of columns of A is not equal to the number of rows of B.

NMathFormatException

Thrown when a method encounters a faulty text representation; for example, if you try to create a vector from a string that has an invalid format.

SingularMatrixException

Thrown when a matrix operation requiring a non-singular matrix is presented with a singular one.

For example, this code attempts to multiply two matrices with different dimensions, and catches a MismatchedSizeException:

Code Example – C#

DoubleComplexMatrix A =
   new DoubleComplexMatrix( 3, 3, new DoubleComplex(1,0) );
DoubleComplexMatrix B =
   new DoubleComplexMatrix( 2, 2, new DoubleComplex(1,0) );

DoubleComplexMatrix C;
try
{
   C = A * B;
}
catch( MismatchedSizeException e )
{
   Console.WriteLine( "Oops - " + e.Message );
}

Code Example – VB

Dim A As New DoubleComplexMatrix(3, 3, New DoubleComplex(1, 0))
Dim B As New DoubleComplexMatrix(2, 2, New DoubleComplex(1, 0))

Dim C As DoubleComplexMatrix
Try
  C = A * B
Catch E As MismatchedSizeException
  Console.WriteLine("Oops - " & E.Message)
End Try

Matrices must have the same dimensions to be combined using the element-wise operators.


Top

Top