ANSI C vs. Non-ANSI C and IMSL.h in the IMSL C Numerical Library



All of the examples in this documentation conform to ANSI C. If you are not using ANSI C, you will need to modify your examples in functions that are declared or in those arrays that are initialized as type float.

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 following pro gram contains arrays that are initialized as type float and also a user-defined function:


  1. #include <imsls.h>

  2. float           fcn(int, float[], int, float[]);
  3. 4
  4. main()
  5. {
  6.      int         n_observations = 3,
  7.                  n_parameters = 1,
  8.                  n_independent = 1;
  9.     float       *theta_hat;
  10.     float       x[3] = {1.0, 2.0, 3.0};
  11.     float       y[3] = {2.0, 4.0, 3.0};
  12.                      /* Evaluate the integral */
  13.     theta_hat = imsls_f_nonlinear_regression(fcn, n_parameters,
  14.                 n_observations, n_independent, x, y, 0);
  15.                      /* Print the result and the exact answer */
  16.     imsls_f_write_matrix("estimated coefficient", 1, 1, theta_hat, 0);
  17. }
  18. float fcn(int n_independent, float x[], int n_parameters,
  19.            float theta[])
  20. {
  21.     return exp(theta[0]*x[0]);
  22. }
    If using non-ANSI C, you will need to modify lines 3, 11, 12, and on as follows:
    3  float          fcn(); /* Function is not prototyped */
         .
         .
         .
    11    static float       x[3] = {1.0, 2.0, 3.0};
    12    static float       y[3] = {2.0, 4.0, 3.0};
         .
         .
         .
    19  float fcn(n_independent, x, n_parameters,
    20            theta)     /*Declaration of variable names*/
    20a int n_independent;
    20b float x[];
    20c int n_parameters;
    20d float theta[];       /*Type definitions of variables*/
Both the imsl.h and the imsls.h file MATH: imsl.h

The included 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). STAT: imsls.h

The included file <imsls.h> is used in all the examples in this manual. This file contains prototypes for all IMSL-defined functions: the structures, Imsls_f_regression, Imsls_d_regression, Imsls_f_poly_regression, Imsls_d_poly_regression, Imsls_f_arma and Imsls_d_arma; and the enu-merated data types, Imsls_arma_method, Imsls_permute, Imsls_dummy_method, Imsls_write_options, Imsls_page_options and Imsls_error.


Company Products & Services Solutions Success Stories Support Downloads Email this page
© Copyright 2008 Visual Numerics, Inc. All Rights Reserved Legal Privacy