Introduction

Getting Started

To use any of the IMSL C Math Library functions, you first must write a program in C to call the function. Each function conforms to established conventions in programming and documentation. We give first priority in development to efficient algorithms, clear documentation, and accurate results. The uniform design of the functions makes it easy to use more than one function in a given application. Also, you will find that the design consistency enables you to apply your experience with one IMSL C Math Library function to all other IMSL functions that you use.

ANSI C vs. Non-ANSI C

All of the examples in this user’s manual conform to ANSI C. If you are not using ANSI C, you will need to modify your examples in which functions are declared or in which arrays are initialized as the type float.

The following is an ANSI C program in which a function is declared. The program estimates the value of the following:

1 #include <math.h>
2 #include <imsl.h>
3
4 float           fcn(float x);
5
6 main()
7 {
8     float       q, exact;
9                      /* evaluate the integral */
10    q = imsl_f_int_fcn_sing (fcn, 0.0, 1.0, 0);
11                     /* print the result and the exact answer */
12    exact = -4.0;

13    printf("integral  = %10.3f\nexact     = %10.3f\n", q, exact);
14 }
15
16 float fcn(float x)
17 {
18    return log(x)/sqrt(x);
19 }

If using non-ANSI C, you would need to modify lines 4 and 16 as follows:

4   float          fcn(); /* function is not prototyped */
     .
     .
     .
16  float fcn(x)          /*Only variable of function defined here */
16a float x;             /* Type of variable declared here */

Non-ANSI C does not allow for automatic aggregate initialization, and thus, all auto arrays that are initialized as type float in ANSI C must be initialized as type static float in non-ANSI C. The next program contains arrays that are initialized as type float.

1 #include <imsl.h>
2
3 main()
4 {
5     int          n = 3;
6     float        *x;
7     float        a[] = {1.0, 3.0, 3.0,
8                         1.0, 3.0, 4.0,
9                         1.0, 4.0, 3.0};
10
11    float        b[] = {1.0, 4.0, -1.0};
12                           /* Solve Ax = b for x */
13    x = imsl_f_lin_sol_gen (n, a, b, 0);
14                           /* Print x */
15    imsl_f_write_matrix ("Solution, x, of Ax = b", 1, 3, x, 0);
16 }

If using non-ANSI C, you would need to modify lines 7 and 11 as follows:

7     static float       a[] = {1.0, 3.0, 3.0,
         .
         .
         .
11    static float       b[] = {1.0, 4.0, -1.0};

The imsl.h File

The include file <imsl.h> is used in all of the examples in this manual. This file contains prototypes for all IMSL-defined functions; the spline structures, Imsl_f_ppoly, Imsl_d_ppoly, Imsl_f_spline, and Imsl_d_spline; enumerated data types, Imsl_quad, Imsl_write_options, Imsl_page_options, Imsl_ode, and Imsl_error; and the IMSL-defined data types f_complex (which is the type float complex) and d_complex (which is the type double complex).


Visual Numerics, Inc.
Visual Numerics - Developers of IMSL and PV-WAVE
http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260