The following functions and subroutines are part of the math library libm. Some routines are intrinsics and return the same data type (single precision, double precision, or quad precision) as their argument. The rest are non-intrinsics that take a specific data type as an argument and return the same. These non-intrinsics do have to be declared in the routine referencing them.
Here is a list of the intrinsic functions in libm. You need not put them in a type statement. These functions take single, double, or quad precision data as arguments and return the same.
sqrt(x) | asin(x) | cosd(x) |
log(x) | acos(x) | asind(x) |
log10(x) | atan(x) | acosd(x) |
exp(x) | atan2(x,y) | atand(x) |
x**y | sinh(x) | atan2d(x,y) |
sin(x) | cosh(x) | aint(x) |
cos(x) | tanh(x) | anint(x) |
tan(x) | sind(x) | nint(x) |
The functions sind(x), cosd(x), asind(x), acosd(x), atand(x), atan2d(x,y) are not considered intrinsics by the FORTRAN 77 standard.
The following subprograms are double-precision libm functions and subroutines.
In general, these functions do not correspond to standard FORTRAN generic intrinsic functions--data types are determined by the usual data typing rules.
Example: Subroutine and non-Intrinsic double-precision functions:
DOUBLE PRECISION c, d_acosh, d_hypot, d_infinity, s, x, y, z ... z = d_acosh( x ) i = id_finite( x ) z = d_hypot( x, y ) z = d_infinity() CALL d_sincos( x, s, c )
These DOUBLE PRECISION functions need to appear in a DOUBLE PRECISION statement.
Refer to the C library man pages for details: the man page for d_acos(x) is acos(3M)
Table 1-5 Double Precision libm Functions
d_acos( x ) d_acosd( x ) d_acosh( x ) d_acosp( x ) d_acospi( x ) |
DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION |
Function Function Function Function Function |
arc cosine -- arc cosh -- -- |
d_atan( x ) d_atand( x ) d_atanh( x ) d_atanp( x ) d_atanpi( x ) |
DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION |
Function Function Function Function Function |
arc tangent -- arc tanh -- -- |
d_asin( x ) d_asind( x ) d_asinh( x ) d_asinp( x ) d_asinpi( x ) |
DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION |
Function Function Function Function Function |
arc sine -- arc sinh -- -- |
d_atan2(( y, x ) d_atan2d( y, x ) d_atan2pi( y, x ) |
DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION |
Function Function Function |
arc tangent -- -- |
d_cbrt( x ) d_ceil( x ) d_copysign( x, x ) |
DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION |
Function Function Function |
cube root ceiling -- |
d_cos( x ) d_cosd( x ) d_cosh( x ) d_cosp( x ) d_cospi( x ) |
DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION |
Function Function Function Function Function |
cosine -- hyperb cos -- -- |
d_erf( x ) d_erfc( x ) |
DOUBLE PRECISION DOUBLE PRECISION |
Function Function |
error func -- |
d_expm1( x ) d_floor( x ) d_hypot( x, y ) d_infinity( ) |
DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION |
Function Function Function Function |
(e**x)-1 floor hypotenuse -- |
d_j0( x ) d_j1( x ) d_jn( x ) |
DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION |
Function Function Function |
Bessel -- -- |
id_finite( x ) id_fp_class( x ) id_ilogb( x ) id_irint( x ) id_isinf( x ) id_isnan( x ) id_isnormal( x ) id_issubnormal( x ) id_iszero( x ) id_signbit( x ) |
INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER |
Function Function Function Function Function Function Function Function Function Function |
|
d_addran() d_addrans(x, p, l, u) d_lcran() d_lcrans(x, p, l, u ) d_shufrans(x, p, l,u) |
DOUBLE PRECISION n/a DOUBLE PRECISION n/a n/a |
Function Subroutine Function Subroutine Subroutine |
random number generators |
d_lgamma( x ) d_logb( x ) d_log1p( x ) d_log2( x ) |
DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION |
Function Function Function Function |
log gamma -- -- -- |
d_max_normal() d_max_subnormal() d_min_normal() d_min_subnormal() d_nextafter( x, y ) d_quiet_nan( n ) d_remainder( x, y ) d_rint( x ) d_scalb( x, y ) d_scalbn( x, n ) d_signaling_nan( n ) d_significand( x ) |
DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION |
Function Function Function Function Function Function Function Function Function Function Function Function |
|
d_sin( x ) d_sind( x ) d_sinh( x ) d_sinp( x ) d_sinpi( x ) |
DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION |
Function Function Function Function Function |
sine -- hyperb sine -- -- |
d_sincos( x, s, c ) d_sincosd( x, s, c ) d_sincosp( x, s, c ) d_sincospi( x, s, c ) |
n/a n/a n/a n/a |
Subroutine Subroutine Subroutine Subroutine |
sine and cosine -- -- |
d_tan( x ) d_tand( x ) d_tanh( x ) d_tanp( x ) d_tanpi( x ) |
DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION |
Function Function Function Function Function |
tangent -- hyperb tan -- -- |
d_y0( x ) d_y1( x ) d_yn( n, x ) |
DOUBLE PRECISION DOUBLE PRECISION DOUBLE PRECISION |
Function Function Function |
bessel -- -- |
Variables c, l, p, s, u, x, and y are of type DOUBLE PRECISION.
Explicitly type these functions on a DOUBLE PRECISION statement or with an appropriate IMPLICIT statement).
sind(x), asind(x), ... take degrees rather than radians.
See also: intro(3M) and the Numerical Computation Guide.
These subprograms are quadruple-precision (REAL*16) libm functions and subroutines (SPARC only).
In general, these do not correspond to standard generic intrinsic functions; data types are determined by the usual data typing rules.
Samples: Quadruple precision functions:
REAL*16 c, q_acosh, q_hypot, q_infinity, s, x, y, z ... z = q_acosh( x ) i = iq_finite( x ) z = q_hypot( x, y ) z = q_infinity() CALL q_sincos( x, s, c )
The quadruple precision functions must appear in a REAL*16 statement
Table 1-6 Quadruple-Precision libm Functions
q_copysign( x, y ) q_fabs( x ) q_fmod( x ) q_infinity( ) |
REAL*16 REAL*16 REAL*16 REAL*16 |
Function Function Function Function |
iq_finite( x ) iq_fp_class( x ) iq_ilogb( x ) iq_isinf( x ) iq_isnan( x ) iq_isnormal( x ) iq_issubnormal( x ) iq_iszero( x ) iq_signbit( x ) |
INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER |
Function Function Function Function Function Function Function Function Function |
q_max_normal() q_max_subnormal() q_min_normal() q_min_subnormal() q_nextafter( x, y ) q_quiet_nan( n ) q_remainder( x, y ) q_scalbn( x, n ) q_signaling_nan( n ) |
REAL*16 REAL*16 REAL*16 REAL*16 REAL*16 REAL*16 REAL*16 REAL*16 REAL*16 |
Function Function Function Function Function Function Function Function Function |
The variables c, l, p, s, u, x, and y are of type quadruple precision.
Explicitly type these functions with a REAL*16 statement or with an appropriate IMPLICIT statement.
sind(x), asind(x), ... take degrees rather than radians.
If you need to use any other quadruple-precision libm function, you can call it using $PRAGMA C(fcn) before the call. For details, see the chapter on the C-FORTRAN interface in the Fortran Programming Guide.
These subprograms are single-precision libm functions and subroutines.
In general, the functions below provide access to single-precision libm functions that do not correspond to standard FORTRAN generic intrinsic functions--data types are determined by the usual data typing rules.
Samples: Single-precision libm functions:
REAL c, s, x, y, z .. z = r_acosh( x ) i = ir_finite( x ) z = r_hypot( x, y ) z = r_infinity() CALL r_sincos( x, s, c )
These functions need not be explicitly typed with a REAL statement as long as default typing holds. (Variables beginning with "r" are REAL, with "i" are INTEGER.)
For details on these routines, see the C math library man pages (3M). For example, for r_acos(x) see the acos(3M) man page.
Table 1-7 Single-Precision libm functions
r_acos( x ) r_acosd( x ) r_acosh( x ) r_acosp( x ) r_acospi( x ) |
REAL REAL REAL REAL REAL |
Function Function Function Function Function |
arc cosine -- arc cosh -- -- |
r_atan( x ) r_atand( x ) r_atanh( x ) r_atanp( x ) r_atanpi( x ) |
REAL REAL REAL REAL REAL |
Function Function Function Function Function |
arc tangent -- arc tanh -- -- |
r_asin( x ) r_asind( x ) r_asinh( x ) r_asinp( x ) r_asinpi( x ) |
REAL REAL REAL REAL REAL |
Function Function Function Function Function |
arc sine -- arc sinh -- -- |
r_atan2(( y, x ) r_atan2d( y, x ) r_atan2pi( y, x ) |
REAL REAL REAL |
Function Function Function |
arc tangent -- -- |
r_cbrt( x ) r_ceil( x ) r_copysign( x, y ) |
REAL REAL REAL |
Function Function Function |
cube root ceiling -- |
r_cos( x ) r_cosd( x ) r_cosh( x ) r_cosp( x ) r_cospi( x ) |
REAL REAL REAL REAL REAL |
Function Function Function Function Function |
cosine -- hyperb cos -- -- |
r_erf( x ) r_erfc( x ) |
REAL REAL |
Function Function |
err function -- |
r_expm1( x ) r_floor( x ) r_hypot( x, y ) r_infinity( ) r_j0( x ) r_j1( x ) r_jn( x ) |
REAL REAL REAL REAL REAL REAL REAL |
Function Function Function Function Function Function Function |
(e**x)-1 floor hypotenuse bessel -- -- -- |
ir_finite( x ) ir_fp_class( x ) ir_ilogb( x ) ir_irint( x ) ir_isinf( x ) ir_isnan( x ) ir_isnormal( x ) ir_issubnormal( x ) ir_iszero( x ) ir_signbit( x ) |
INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER INTEGER |
Function Function Function Function Function Function Function Function Function Function |
-- -- -- -- -- -- -- -- -- -- |
r_addran() r_addrans( x, p, l, u ) r_lcran() r_lcrans( x, p, l, u ) r_shufrans(x, p, l, u) |
REAl n/a REAL n/a n/a |
Function Subroutine Function Subroutine Subroutine |
random number -- -- -- -- |
r_lgamma( x ) r_logb( x ) r_log1p( x ) r_log2( x ) |
REAL REAL REAL REAL |
Function Function Function Function |
log gamma -- -- -- |
r_max_normal() r_max_subnormal() r_min_normal() r_min_subnormal() r_nextafter( x, y ) r_quiet_nan( n ) r_remainder( x, y ) r_rint( x ) r_scalb( x, y ) r_scalbn( x, n ) r_signaling_nan( n ) r_significand( x ) |
REAL REAL REAL REAL REAL REAL REAL REAL REAL REAL REAL REAL |
Function Function Function Function Function Function Function Function Function Function Function Function |
|
r_sin( x ) r_sind( x ) r_sinh( x ) r_sinp( x ) r_sinpi( x ) |
REAL REAL REAL REAL REAL |
Function Function Function Function Function |
sine -- hyperb sin -- -- |
r_sincos( x, s, c ) r_sincosd( x, s, c ) r_sincosp( x, s, c ) r_sincospi( x, s, c ) |
n/a n/a n/a n/a |
Subroutine Subroutine Subroutine Subroutine |
sine & cosine -- -- -- |
r_tan( x ) r_tand( x ) r_tanh( x ) r_tanp( x ) r_tanpi( x ) |
REAL REAL REAL REAL REAL |
Function Function Function Function Function |
tangent -- hyperb tan -- -- |
r_y0( x ) r_y1( x ) r_yn( n, x ) |
REAL REAL REAL |
Function Function Function |
bessel -- -- |
Variables c, l, p, s, u, x, and y are of type REAL.
Type these functions as explicitly REAL if an IMPLICIT statement is in effect that types names starting with "r" to some other date type.
sind(x), asind(x), ... take degrees rather than radians.
See also: intro(3M) and the Numerical Computation Guide.