MATHCW 3CW "09 March 2008" "mathcw-1.00"

Table of contents


NAME

mathcw portable elementary function library

SYNOPSIS

Ada language:
    gnatmake [ flags ] file(s) -L/usr/local/lib -aO/usr/local/lib -largs -lfmcw -lmcw \
             -Xlinker -R/usr/local/lib [ ... ]

C language:
    cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcw [ ... ]
    cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcwf -lmcw [ ... ]
    cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcwd -lmcw [ ... ]
    cc [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcwl -lmcw [ ... ]

C++ language:
    CC [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcw [ ... ]
    CC [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcwf -lmcw [ ... ]
    CC [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcwd -lmcw [ ... ]
    CC [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lmcwl -lmcw [ ... ]

C# language:
    gmcs [ flags ] file(s)
    mcs  [ flags ] file(s)

Fortran language:
    f77 [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lfmcw -lmcw [ ... ]
    f90 [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lfmcw -lmcw [ ... ]
    f95 [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lfmcw -lmcw [ ... ]
    f77 [ flags ] -I/usr/local/include file(s) -L/usr/local/lib -lfmcw -lmcw [ ... ]

Java language:
    javac file(s)

Pascal language:
    gpc [ flags ] file(s)

C/C++ header file:
    #include <mathcw.h>
    #include <fenvcw.h>        (rarely needed)

C++ header file:
    #include <mathcw.hh>


DESCRIPTION

The mathcw library is a highly portable and comprehensive elementary function library for use in programs written in Ada, C, C++, C#, Fortran, Java, and Pascal. It provides the entire mathematical function repertoire of the 1999 ISO C Standard, which is effectively a superset of the corresponding libraries in those other programming languages. The library also supplies a few dozen additional functions. Many scripting languages are implemented in C, and offer at least some of the elementary functions in the C library. The mathcw library offers a way to extend those scripting languages as well. The behavior of the library is intended to conform exactly to the requirements of the 1999 ISO C Standard, and to provide accurate implementations of all of the functions. Some are exact by definition, others are correctly rounded by design, and the remainder are correct to within a few units in the last place. The header file <mathcw.h> can be used in place of <math.h> if access to the additional functions is required. Although a few C99 compilers are now available, it is likely to be several years before they are universal on every platform. The mathcw library offers early access to the much-enhanced C99 elementary function library, even for those systems that still lack C99 compilers. For such systems, use of <mathcw.h> is mandatory to get definitions of function prototypes. The mathcw library also provides all of the functions defined in C99 for access to the floating-point environment. The standard name for the header file that defines their prototypes, type definitions, and preprocessor macros is <fenv.h>; it must be replaced by <fenvcw.h> if the mathcw library is used. It is not possible to mix any native C99 floating-point environment support with that in the mathcw library, because their implementations are almost certain to be incompatible. The -mcwf interface library provides float function wrappers that call the corresponding double functions. This should provide float results that are correctly rounded on all platforms, with possible rare exceptions yet to be determined by exhaustive search, and then handled explicitly. The -mcwd interface library provides double function wrappers that call the corresponding long double functions. This should provide double results that are correctly rounded on platforms with 128-bit long double, with possible rare exceptions. For those architectures with 80-bit long double, the probability of incorrect rounding is about 1/2048. The -mcwl interface library provides long double function wrappers that call the corresponding double functions. This reduces the accuracy, range, and precision, but may nevertheless be useful during porting to new platforms, or for replacing slow long double arithmetic in software with double arithmetic in hardware, or for investigating the library time cost of long double arithmetic. The Ada interface makes the functions available under the same names as in C; there is currently no support for Ada type-generic functions in this interface. The Ada interface is used like this:
with MathCW; use MathCW; ... X := MathCW.sqrt (MathCW.PI);

The library can be used identically from C and C++, but the C++ interface defined in the header file <mathcw.hh> provides a convenient type-generic C++ class where the function names correspond to the names in C for type double, but can be used with float and long double arguments as well. The C++ interface is used like this:

    MathCW mcw;
    ...
    x = mcw.sqrt(MathCW.PI);

The Fortran 77, 90, and 95 interfaces provides access to the library under the same function names as used in C, with the Fortran/C type correspondence REAL == REAL*4 == float, DOUBLE PRECISION == REAL*8 == double, and REAL*16 == long double. The Fortran interfaces require use of two libraries: -lfmcw and -lmcw, in that order.

The Java interface provides a convenient type-generic Java class where the function names correspond to the names in C for type double, but can be used with float arguments as well (Java has no long double type). The Java interface is used like this:

    x = MathCW.sqrt(MathCW.PI);

The three wrapper libraries, -lmcwf, -lmcwd, and -lmcwl, are not currently available from the Java interface, because that interface makes use of an explicitly-named shared library from which the needed functions are dynamically loaded at run time, instead of at link time. The wrapper libraries are, however, usable with the Ada, C++, and Fortran interfaces, which do not require dynamic loading from shared libraries.

The mathcw library is designed to be used on a wide range of architectures, including historical ones (some now available only via software simulators), all modern ones with IEEE 754 arithmetic, and future ones with octuple precision (REAL*32 == long long double, and decimal_long_long_double). All algorithms in the library have been extended to provide accuracy of 235 bits (binary bases) or 70 decimal digits (base 10). The library also supports the 80-bit extended and 128-bit quad types provided by compilers on Hewlett-Packard HP-UX for the IA-64 architecture.

In addition, the mathcw library supports decimal floating-point arithmetic (proposed names: _Decimal32, _Decimal64, _Decimal128, and _Decimal256; preferred aliases: decimal_float, decimal_double, decimal_long_double, and decimal_long_long_double). Decimal arithmetic has been proposed for inclusion in the next ISO C and C++ Standards, and some recent (late 2006) releases of the GNU C compiler provide limited support for the new data types on a few hardware platforms. The decimal-arithmetic versions of functions in mathcw library have been extensively tested with that extended compiler, and tests verify that their accuracy is comparable to the companion functions for nondecimal arithmetic.

A special header file, <deccw.h>, provides definitions for the decimal floating-point types that map them to binary floating-point types as a transitional aid for development of decimal software when decimal arithmetic is not yet available.

The <decfloat.h> header file provides a decimal companion to the standard <float.h> header file with definitions of range, precision, and limits of the data types of decimal arithmetic.

Although library routines in the quadruple and octuple extended types in decimal and nondecimal bases are available on all platforms, the extended types may be mapped to a type of the highest available precision, and therefore may not offer the expected increase in precision.

The key reference for the definitions, properties, and relations of many of the mathematical functions provided by this library is the book

M. Abramowitz & I. A. Stegun Handbook of Mathematical Functions U. S. Department of Commerce, Washington, DC, USA (1964).

DOCUMENTATION

In addition to the conventional manual pages listed in the next section, a book entitled The mathcw Portable Elementary Function Library, is in development.

SEE ALSO

acos(3CW), acosdeg(3CW), acosh(3CW), acosp(3CW), acospi(3CW), adx(3CW), adxp(3CW), agm(3CW), annuity(3CW), asin(3CW), asindeg(3CW), asinh(3CW), asinp(3CW), asinpi(3CW), atan(3CW), atan2(3CW), atan2deg(3CW), atan2p(3CW), atan2pi(3CW), atandeg(3CW), atanh(3CW), atanp(3CW), atanpi(3CW), bernum(3CW)), bernum(3CW), beta(3CW), betam1(3CW), betnm1(3CW), betnm1(3CW) betnum(3CW), bi0(3CW), bi1(3CW), bin(3CW), binom(3CW), bis0(3CW), bis1(3CW), bisn(3CW), bk0(3CW), bk1(3CW), bkn(3CW), bks0(3CW), bks1(3CW), bksn(3CW), cabs(3CW), cacos(3CW), cacosh(3CW), cadd(3CW), carg(3CW), casin(3CW), casinh(3CW), catan(3CW), catanh(3CW), cbrt(3CW), ccbrt(3CW), ccopy(3CW), ccos(3CW), ccosh(3CW), cdiv(3CW), ceil(3CW), cexp(3CW), cexpm1(3CW), chisq(3CW), cimag(3CW), cipow(3CW), clog(3CW), clog1p(3CW), clp2(3CW), cmul(3CW), cneg(3CW), compound(3CW), conj(3CW), copysign(3CW), cos(3CW), cosdeg(3CW), cosh(3CW) cosh(3CW), cosp(3CW) cosp(3CW), cospi(3CW), cotan(3CW), cotandeg(3CW), cotanp(3CW), cotanpi(3CW), cpow(3CW), cproj(3CW), creal(3CW), cset(3CW), csin(3CW), csinh(3CW), csqrt(3CW), csub(3CW), ctan(3CW), ctanh(3CW), ctocx(3CW), cvtia(3CW), cvtib(3CW), cvtid(3CW), cvtig(3CW), cvtih(3CW), cvtinf(3CW), cvtio(3CW), cvtnan(3CW), cvtob(3CW), cvtod(3CW), cvtog(3CW), cvtoh(3CW), cvtoi(3CW), cvton(3CW), cvtoo(3CW) cvtoo(3CW), cxabs(3CW), cxacos(3CW), cxacosh(3CW), cxadd(3CW), cxarg(3CW), cxasin(3CW), cxasinh(3CW), cxatan(3CW), cxatanh(3CW), cxcbrt(3CW), cxconj(3CW), cxcopy(3CW), cxcos(3CW), cxcosh(3CW), cxdiv(3CW), cxexp(3CW), cxexpm1(3CW), cximag(3CW), cxipow(3CW), cxlog(3CW), cxlog1p(3CW), cxmul(3CW), cxneg(3CW), cxpow(3CW), cxproj(3CW), cxreal(3CW), cxset(3CW), cxsin(3CW), cxsinh(3CW), cxsqrt(3CW), cxsub(3CW), cxtan(3CW), cxtanh(3CW), cxtoc(3CW), dfabs(3CW), dfact(3CW), dfadd(3CW), dfdiv(3CW), dfmul(3CW), dfneg(3CW), dfsqrt(3CW), dfsub(3CW), eljag(3CW), eljam(3CW), eljcd(3CW), eljcn(3CW), eljcs(3CW), eljdc(3CW), eljdn(3CW), eljds(3CW), eljnc(3CW), eljnd(3CW), eljns(3CW), eljsc(3CW), eljsd(3CW), eljsn(3CW), eljt(3CW), eljt1(3CW), eljt2(3CW), eljt3(3CW), eljt4(3CW), eljz(3CW), elk(3CW), elkm1(3CW), elldi(3CW), elle(3CW), ellec(3CW), ellei(3CW), ellfi(3CW), ellk(3CW), ellkc(3CW), ellpi(3CW), ellrc(3CW), ellrd(3CW), ellre(3CW), ellrf(3CW), ellrg(3CW), ellrh(3CW), ellrj(3CW), ellrk(3CW), ellrl(3CW), ellrm(3CW), elq(3CW), elq1p(3CW), elqc(3CW), elqc1p(3CW), ercw(3CW), ercw_r(3CW), ereduce(3CW) ereduce(3CW), erf(3CW), erfc(3CW), eriduce(3CW) eriduce(3CW), eulnum(3CW)), eulnum(3CW), exp(3CW), exp10(3CW), exp10m1(3CW), exp16(3CW), exp16m1(3CW), exp2(3CW), exp2m1(3CW), exp8(3CW), exp8m1(3CW), expm1(3CW), fabs(3CW), fact(3CW), fdim(3CW), feclearexcept(3CW), fegetenv(3CW), fegetexceptflag(3CW), fegetprec(3CW), fegetround(3CW), feholdexcept(3CW), feraiseexcept(3CW), fesetenv(3CW), fesetexceptflag(3CW), fesetprec(3CW), fesetround(3CW), fetestexcept(3CW), feupdateenv(3CW), fibnum(3CW), floor(3CW), flp2(3CW), fma(3CW), fmax(3CW), fmin(3CW), fmod(3CW), fmul(3CW), fpclassify(3CW), fprintf(3CW), frexp(3CW) frexp(3CW), frexph(3CW), frexpo(3CW), fscanf(3CW), gami(3CW), gamib(3CW), gamic(3CW), gscw(3CW), hypot(3CW), ichisq(3CW), ierf(3CW), ierfc(3CW), ilog2(3CW), ilogb(3CW), incw_r(3CW), infty(3CW) infty(3CW), intxp(3CW), iphi(3CW), iphic(3CW), ipow(3CW), is_abs_safe(3CW), is_add_safe(3CW), is_dec_bid(3CW), is_dec_dpd(3CW), is_div_safe(3CW), is_mul_safe(3CW), is_neg_safe(3CW), is_rem_safe(3CW), is_sub_safe(3CW), iscinf(3CW), iscnan(3CW), iscxinf(3CW), iscxnan(3CW), isfinite(3CW), isgreater(3CW), isgreaterequal(3CW), isinf(3CW), isless(3CW), islessequal(3CW), islessgreater(3CW), isnan(3CW) isnan(3CW), isnormal(3CW), isqnan(3CW), issnan(3CW), issubnormal(3CW), isunordered(3CW), j0(3CW), j1(3CW), jn(3CW), ldexp(3CW) ldexp(3CW), ldexph(3CW), ldexpo(3CW), lgamma(3CW), lgamma_r(3CW), llmscw(3CW), llrancw(3CW), llrancw_r(3CW), llrincw(3CW), llrincw_r(3CW), llrint(3CW), llround(3CW), lmscw(3CW), log(3CW), log10(3CW), log101p(3CW), log16(3CW), log161p(3CW), log1p(3CW), log2(3CW), log21p(3CW), log8(3CW), log81p(3CW), logb(3CW), logbfact(3CW) lrancw(3CW), lrancw_r(3CW), lrcw(3CW), lrcw_r(3CW), lrincw(3CW), lrincw_r(3CW), lrint(3CW), lround(3CW), mchep(3CW), mcheps(3CW), modf(3CW), mscw(3CW), nan(3CW), nearbyint(3CW), nextafter(3CW), nexttoward(3CW), nlz(3CW), normalize(3CW), nrcw(3CW), nrcw_r(3CW), ntz(3CW), pabs(3CW), pacos(3CW), pacosh(3CW), padd(3CW), pasin(3CW), pasinh(3CW), patan(3CW), patan2(3CW), patanh(3CW), pcbrt(3CW), pcmp(3CW), pcon(3CW), pcopy(3CW), pcopysign(3CW), pcos(3CW), pcosh(3CW), pcotan(3CW), pdiv(3CW), pdot(3CW), peps(3CW), peval(3CW), pexp(3CW) pexp(3CW), pexp10(3CW), pexp16(3CW), pexp2(3CW), pexp8(3CW), pexpm1(3CW), pfdim(3CW), pfmax(3CW), pfmin(3CW), pfrexp(3CW), pfrexph(3CW), phi(3CW), phic(3CW), phigh(3CW), phypot(3CW), pierf(3CW), pierfc(3CW), pilogb(3CW), pin(3CW), pinfty(3CW), pipow(3CW), pisinf(3CW), pisnan(3CW), pisqnan(3CW), pissnan(3CW), pldexp(3CW), pldexph(3CW), plog(3CW), plog101p(3CW), plog1p(3CW), plow(3CW), pmul(3CW), pmul2(3CW), pneg(3CW), pop(3CW), pout(3CW), pow(3CW), pprosum(3CW), pqnan(3CW), printf(3CW) printf(3CW)), printf(3CW), pscalbln(3CW), pscalbn(3CW), pset(3CW) pset(3CW), psi(3CW), psignbit(3CW), psiln(3CW), psin(3CW), psinh(3CW), psnan(3CW), psplit(3CW), psqrt(3CW), psub(3CW), psum(3CW), psum2(3CW) psum2(3CW), ptan(3CW), ptanh(3CW), qert(3CW), qnan(3CW), quantize(3CW), randcw(3CW), remainder(3CW), remquo(3CW), rint(3CW), round(3CW), rsqrt(3CW), samequantum(3CW), sbi0(3CW), sbi1(3CW), sbin(3CW), sbis0(3CW), sbis1(3CW), sbisn(3CW), sbj0(3CW), sbj1(3CW), sbjn(3CW), sbk0(3CW), sbk1(3CW), sbkn(3CW), sbks0(3CW), sbks1(3CW), sbksn(3CW), sby0(3CW), sby1(3CW), sbyn(3CW), scalbln(3CW), scalbn(3CW) scalbn(3CW), scalbnl(3CW), scanf(3CW), sccw(3CW), second(3CW), setxp(3CW), signbit(3CW), sin(3CW), sincos(3CW), sincosp(3CW), sincospi(3CW), sindeg(3CW), sinh(3CW), sinhcosh(3CW) sinhcosh(3CW), sinp(3CW), sinpi(3CW), snan(3CW), snprintf(3CW), sprintf(3CW), sqrt(3CW), srancw(3CW), sscanf(3CW), sscw(3CW), store(3CW), strlcat(3CW), strlcpy(3CW), strtol(3CW), strtoll(3CW), strton(3CW), strtoul(3CW), strtoull(3CW), tan(3CW), tandeg(3CW), tanh(3CW), tanp(3CW), tanpi(3CW), tgamma(3CW), trunc(3CW), ulpk(3CW), ulpmh(3CW), urcw(3CW), urcw1(3CW), urcw1_r(3CW), urcw2(3CW), urcw2_r(3CW), urcw3(3CW), urcw3_r(3CW), urcw4(3CW), urcw4_r(3CW), urcw_r(3CW), vagm(3CW), vbi(3CW) vbi(3CW), vbis(3CW), vbj(3CW), vbk(3CW) vbk(3CW), vbks(3CW), vby(3CW), vercw(3CW), vercw_r(3CW), vfprintf(3CW), vfscanf(3CW), vllrancw(3CW), vllrancw_r(3CW), vllrincw(3CW), vllrincw_r(3CW), vlrancw(3CW), vlrancw_r(3CW), vlrcw(3CW), vlrcw_r(3CW), vlrincw(3CW), vlrincw_r(3CW), vnrcw(3CW), vnrcw_r(3CW), vprintf(3CW), vsbi(3CW), vsbis(3CW), vsbj(3CW), vsbk(3CW), vsbks(3CW), vsby(3CW), vscanf(3CW), vsnprintf(3CW), vsprintf(3CW), vurcw(3CW), vurcw1(3CW), vurcw1_r(3CW), vurcw2(3CW), vurcw2_r(3CW), vurcw3(3CW), vurcw3_r(3CW), vurcw4(3CW), vurcw4_r(3CW), vurcw_r(3CW), y0(3CW), y1(3CW), yn(3CW), zeta(3CW)) zeta(3CW), zetam1(3CW), zetnm1(3CW), zetnum(3CW).