HP-UX Floating-Point Guide
Chapter 4 101
HP-UX Math Libraries on HP 9000 Systems
Math Library Basics
Math Library Basics
Math libraries in most computer systems, including HP-UX, are
collections of frequently used mathematical functions. The functions
take one or more arguments and return one or more results. When an
application source file contains a use of a math function, the compiler
automatically generates a call to the appropriate routine name in the
appropriate math library. For example, suppose your Fortran program
contains the following declaration and statement:
DOUBLE PRECISION A, B, Y
.
.
.
Y = A**B
The statement raises A to the power B and assigns the result to Y. The
Fortran compiler emits a call to FTN_DTOD, which is one of the functions
in libcl.a and libcl.sl. libcl is the Fortran and Pascal library.
Conceptually, the definition of a math library function is simple; in this
example, FTN_DTOD merely raises a DOUBLE PRECISION value to the
power of another DOUBLE PRECISION value. However, there are
practical questions about math library functions that the programmer
may need to consider:
1. How accurate is the result returned?
2. How efficient is the function (that is, how fast does it run)?
3. What happens when an error occurs (for example, overflow or invalid
arguments)?
4. What are the calling conventions for the function?
5. What functions are available?
The answers to questions 1 and 2 are implementation-dependent. The
answers to questions 3, 4, and 5 are determined by a variety of
programming environment specifications, such as XPG4.2.
Appendix A partially answers question 5 by listing the functions in the
HP-UX C math library. The Fortran equivalents are the intrinsic
functions; see the HP Fortran 90 Programmer’s Reference or the HP
FORTRAN/9000 Programmer’s Reference for a list of these functions.