Intel® oneAPI Math Kernel Library
Ask questions and share information with other developers who use Intel® Math Kernel Library.
6951 Discussions

How to choose tolerance parameters in lamch?

Vishnu
Novice
677 Views

The documentation for LAMCH has many options, with short descriptions:

https://software.intel.com/en-us/mkl-developer-reference-c-lamch

But what exactly does each of them do, and how do I decide which one I want?

Do I use eps, sfmin, or prec?

I tested them for my machine, and the values are:

eps = 1.11022e-16

sfmin = 2.22507e-308

prec = 2.22045e-16

0 Kudos
1 Solution
mecej4
Honored Contributor III
677 Views

You have to assess what tolerance to use (argument ABSTOL to ?syevr) based on your intended use for the eigenvalues that you obtain from the routine. If you specify too high a value, the eigenvalues will be low in accuracy. If you specify too low a value (or zero), the Lapack routine may take longer, or fail, to deliver the demanded accuracy.

If you are unable to assess your accuracy needs, and you will only calculate a handful of eigenvalues once, try with a low value of ABSTOL such as 1e-8. If you are going to calculate millions of eigenvalues, you will have to strike a compromise between speed and accuracy.

It is a mistake to think that ABSTOL can be chosen as equal to any of the values returned by ?lamch. Those values are characteristics of the computer/compiler/library being used. For example, Epsilon is the smallest absolute number for which 1 + Epsilon is different from 1. What you need, instead, is a reasonable value for the accuracy of the result of a much more complex numerical procedure -- not a mere addition. 

View solution in original post

0 Kudos
5 Replies
mecej4
Honored Contributor III
677 Views

The ?lamch functions are service functions that are called from many Lapack routines. Unless you are writing code for a new algorithm yourself, you do not need to concern yourself with the ?lamch routines. Their functionality is now available in other ways in modern languages. For example, the intrinsic function EPSILON in Fortran 90+ has the same meaning as ?lamach('e').

0 Kudos
Vishnu
Novice
677 Views

Yes, but when I call 'dsyevr', and when I calculate eigenvectors, I need to specify a tolerance value. What do I base my choice of tolerance on? And which amongst those values seems appropriate? I'm currently using 'prec'.

0 Kudos
mecej4
Honored Contributor III
678 Views

You have to assess what tolerance to use (argument ABSTOL to ?syevr) based on your intended use for the eigenvalues that you obtain from the routine. If you specify too high a value, the eigenvalues will be low in accuracy. If you specify too low a value (or zero), the Lapack routine may take longer, or fail, to deliver the demanded accuracy.

If you are unable to assess your accuracy needs, and you will only calculate a handful of eigenvalues once, try with a low value of ABSTOL such as 1e-8. If you are going to calculate millions of eigenvalues, you will have to strike a compromise between speed and accuracy.

It is a mistake to think that ABSTOL can be chosen as equal to any of the values returned by ?lamch. Those values are characteristics of the computer/compiler/library being used. For example, Epsilon is the smallest absolute number for which 1 + Epsilon is different from 1. What you need, instead, is a reasonable value for the accuracy of the result of a much more complex numerical procedure -- not a mere addition. 

0 Kudos
Vishnu
Novice
677 Views

According to the documentation of syevr, the tolerance does not determine the accuracy/precision of the eigenvalue, but that of how orthogonal eigenvectors are to each other.

https://software.intel.com/en-us/mkl-developer-reference-c-syevr

But yeah, I get your point. I should decide based on how precise I want my data to be, based on what use I'm going to make of it after.

0 Kudos
mecej4
Honored Contributor III
677 Views

venugopal, vishnu wrote:

According to the documentation of syevr, the tolerance does not determine the accuracy/precision of the eigenvalue, but that of how orthogonal eigenvectors are to each other.

I had only looked at the documentation for SYEVR at Netlib: http://www.netlib.org/lapack/explore-html/d2/d8a/group__double_s_yeigen_gaeed8a131adf56eaa2a9e5b1e0cce5718.html .

As you have pointed out, the description of ABSTOL in the MKL documentation says something different than the Netlib version. We need clarification from the MKL team regarding this difference, since generally we may assume that the APIs for a Netlib Lapack routine and the corresponding Lapack routine in MKL are equivalent.

0 Kudos
Reply