IMSL C Math Library
initialize_error_handler
Initializes the IMSL C Math Library error handling system.
Synopsis
#include  <imsl.h>
int  imsl_initialize_error_handler ()
Return Value
If the initialization succeeds, zero is returned. If there is an error, a nonzero value is returned.
Description
This function is used to initialize the IMSL C Math Library error handling system for the current thread. It is not required, but is always allowed.
Use of this function is advised if the possibility of low heap memory exists when calling the IMSL C Math Library for the first time in the current thread. A successful return from imsl_initialize_error_handler confirms that IMSL C Math Library error handling system has been initialized and is operational. The effects of calling imsl_initialize_error_handler are limited to the calling thread only.
If imsl_initialize_error_handler is not called and initialization of the error handling system fails, an error message is printed to stderr, and execution is stopped.
Example
In this example, the IMSL C Math Library error handler is initialized prior to calling multiple other IMSL C Math Library functions. Often this is not required, but is advised if the possibility of low heap memory exists. Even if not required, the initialization call is always allowed.
The computations performed in this example are based on Example 1 for imsl_f_spline_least_squares.
 
#include <imsl.h>
#include <stdio.h>
#include <math.h>
 
#define NDATA   90
/* Define function */
#define F(x)    (float)(1.+ sin(x)+7.*sin(3.0*x))
 
int main()
{
  int status;    
  int                 i, spline_space_dim = 12;
  float               fdata[NDATA], xdata[NDATA], *random;
  Imsl_f_spline       *sp;
 
  /* Initialize the IMSL C Math Library error handler. */
  status = imsl_initialize_error_handler();
 
  /*
   * Verify successful error handler initialization before
   * continuing.
   */
  if (status == 0) {
    /* Generate random numbers */
    imsl_random_seed_set(123457);
    random = imsl_f_random_uniform(NDATA, 0);
    /* Set up data */
    for (i = 0;  i < NDATA;  i++) {
      xdata[i] = 6.*(float)i /((float)(NDATA-1));
      fdata[i] = F(xdata[i]) + 2.*(random[i]-.5);
    }
    sp = imsl_f_spline_least_squares(NDATA, xdata, fdata,
      spline_space_dim, 0);
    printf("       x         error  \n");
    for(i = 0;  i < 10;  i++) {
      float x, error;
      x = 6.*i/9.;
      error = F(x) - imsl_f_spline_value(x, sp, 0);
      printf("%10.3f  %10.3f\n", x, error);
    }
  } else {
    printf("Unable to initialize IMSL C Math Library error handler.\n");
  }
}