IMSL C Stat Library
initialize_error_handler
Initializes the IMSL C Stat Library error handling system.
Synopsis
#include  <imsls.h>
int imsls_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 Stat 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 IMSL C Stat Library for the first time in the current thread. A successful return from imsls_initialize_error_handler confirms that the IMSL C Stat Library error handling system has been initialized and is operational. The effects of calling imsls_initialize_error_handler are limited to the calling thread only.
If imsls_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 Stat Library error handler is initialized prior to calling multiple other IMSL C Stat 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 imsls_f_regression_prediction.
 
#include <imsls.h>
#include <stdio.h>
 
int main()
{
#define INTERCEPT 1
#define N_INDEPENDENT 4
#define N_OBSERVATIONS 13
#define N_COEFFICIENTS (INTERCEPT + N_INDEPENDENT)
#define N_DEPENDENT 1
 
int status;
float *y_hat, *coefficients;
Imsls_f_regression *regression_info;
float x[][N_INDEPENDENT] = {
7.0, 26.0, 6.0, 60.0,
1.0, 29.0, 15.0, 52.0,
11.0, 56.0, 8.0, 20.0,
11.0, 31.0, 8.0, 47.0,
7.0, 52.0, 6.0, 33.0,
11.0, 55.0, 9.0, 22.0,
3.0, 71.0, 17.0, 6.0,
1.0, 31.0, 22.0, 44.0,
2.0, 54.0, 18.0, 22.0,
21.0, 47.0, 4.0, 26.0,
1.0, 40.0, 23.0, 34.0,
11.0, 66.0, 9.0, 12.0,
10.0, 68.0, 8.0, 12.0};
float y[] = {78.5, 74.3, 104.3, 87.6, 95.9, 109.2,
102.7, 72.5, 93.1, 115.9, 83.8, 113.3, 109.4};
 
/* Initialize the IMSL C Math Library error handler. */
status = imsls_initialize_error_handler();
 
/*
* Verify successful error handler initialization before
* continuing.
*/
if (status == 0) {
 
/* Fit the regression model */
coefficients = imsls_f_regression(N_OBSERVATIONS, N_INDEPENDENT,
(float *)x, y,
IMSLS_REGRESSION_INFO, &regression_info,
0);
 
/* Generate case statistics */
y_hat = imsls_f_regression_prediction(regression_info,
N_OBSERVATIONS, (float*)x, 0);
 
/* Print results */
imsls_f_write_matrix("Predicted Responses", 1, N_OBSERVATIONS,
y_hat, 0);
 
} else {
printf("Unable to initialize IMSL C Math Library error handler.\n");
}
}
Output
 
Predicted Responses
1 2 3 4 5 6
78.5 72.8 106.0 89.3 95.6 105.3
 
7 8 9 10 11 12
104.1 75.7 91.7 115.6 81.8 112.3
 
13
111.7