The C Numerical Library (CNL) is essentially the IMSL Fortran Numerical Library (FNL) converted from Fortran 77 subprograms to C procedures.
Each C program that uses a CNL procedure should begin with
#include <math.h>
#include <imsl.h>
These will provide access to the basic C math functions and the IMSL header file and its CNL prototype statements.
All CNL procedure names begin with imsl_ followed by a type letter:
This document illustrates use of the CNL imsl_d_beta procedure to evaluate the beta function of two double variables. The "correct" answer to 30 digits was obtained from Mathematica and is printed exactly for comparison with the CNL value. In this example, the imsl_d_beta function calculates the correct answer to 16 digits, which is what one expects from a double precision function. (The sample C program prints 18 digits as requested, without complaint from the compiler or CNL. However, all digits beyond the 16th should be considered random noise.)
The output from a sample terminal session is shown below, followed by a discussion of the steps. The cttshell alias and environment variables used below are available if you have made the suggested UNIX configuration changes described in Getting Started with CTT: Setting Up Your UNIX Account.
setenv commands in setup files | |
---|---|
CTT_DIR | /opt/vni/CTT5.0 |
LDLIBS | "$LINK_CNL_PERF" |
<100>% cttshell <1>% touch betaTest.c <2>% make betaTest cc -mp -fsingle -DANSI -I/opt/vni/CTT3.0/include -o betaTest betaTest.c -R/opt/vni/CTT5.0/lib/lib.solaris -L/opt/vni/CTT5.0/lib/lib.solaris -limslcmathsup_perf -limslcmath -limslcstat -xlic_lib=sunperf -lm -lsocket -lnsl -lmtsk <3>% betaTest The beta function using the imsl_d_beta procedure is beta = 0.147252692087097320 The beta function (to 30 digits) using Mathematica is beta = 0.147252692087097336727624375866 <4>% exit <101>%
#include#include void main() { double a,b; a=1.2; b=4.5; printf("The beta function using the imsl_d_beta procedure is\n"); printf(" beta = %20.18f\n",imsl_d_beta(a,b)); printf("The beta function (to 30 digits) using Mathematica is\n"); printf(" beta = 0.147252692087097336727624375866\n"); }