# Error when calculating eigenvalues

Hello,

I am using the command eigh but I get the error message saying the following:

G0038 : Not all the eigenvalues can be computed [AFFINE2_simple.GAU, line 336]

Error handling is controlled with the low bit of the trap flag.
trap 0 set _eigerr and terminate with message
trap 1 set _eigerr and continue execution

Is there any way I can implement this? that the execution will continue? could I trust the results if that is the case?

0

The steps to use the trap in this context are:

1. Set the first bit of the trap value to 1.
2. Call eig or eigh.
3. Check to see if the first value of the output is a scalar error code.
4. If it is a scalar error code, decode the value to see which is the first correctly computed eigenvalue.

Here is an example, assuming that x is a matrix that has been created previously:

```//Set trap to 1
trap 1;

//Call 'eig' or 'eigh'
val = eig(x);

//Turn trap back off
trap 0;

//Check to see if the first element of the output is a scalar error code
if (scalerr(val[1]);
print "The first calculated eigenvalue is element number" scalerr(val[1]);
endif;
```

aptech

1,773

0

The steps to use the trap in this context are:

1. Set the first bit of the trap value to 1.
2. Call eig or eigh.
3. Check to see if the first value of the output is a scalar error code.
4. If it is a scalar error code, decode the value to see which is the first correctly computed eigenvalue.

Here is an example, assuming that x is a matrix that has been created previously:

```//Set trap to 1
trap 1;

//Call 'eig' or 'eigh'
val = eig(x);

//Turn trap back off
trap 0;

//Check to see if the first element of the output is a scalar error code
if (scalerr(val[1]);
print "The first calculated eigenvalue is element number" scalerr(val[1]);
endif;
```