Initializes the IMSL C Stat Library.
#include <imsls.h>
int imsls_initialize (int reason)
int reason
(Input)
The reason why the call is being made.
The module is being loaded. | |
2 |
The current process is creating a new thread. |
3 |
A thread is exiting. |
4 |
The module is being unloaded. |
If the initialization succeeds a nonzero value is returned. If there is an error, zero is returned.
This function is used to initialize the IMSL C Stat Library. It is not always required, but is always allowed.
This function is only required on Windows and only if the static version of the IMSL C Stat Library is being used. It initializes the library for thread-safe usage.
If the IMSL library is linked into an EXE file, the library should be initialized by calling imsls_initialize before any other IMSL C Stat Library calls are made.
If the IMSL library is linked into a DLL file, the DLL must contain the DllMain callback function, which must call the function imsls_initialize. The function DllMain is an entry point into a DLL. Windows calls this function when it starts or terminates a process or a thread. It is also called when the DLL is loaded or unloaded using the LoadLibrary and FreeLibrary functions defined by Windows.
In this example, the IMSL C Stat Library is initialized within an application. Often this is not required, but may be required if the static library version of the IMSL C Stat Library is linked into a Windows EXE. Even if not required, the initialization call is always allowed.
#include <imsl.h>
#include <stdio.h>
int main()
{
float y;
imsls_initialize(1);
y = imsls_f_normal_cdf(0.5);
printf("normal_cdf(0.5) = %g\n", y);
}
normal_cdf(0.5) = 0.69462
If the static library version of the IMSL Stat Library is linked into a Windows DLL, the DLL must define the callback function DllMain. The function DllMain must in turn call imsls_initialize.
The following shows a simple implementation of DllMain. If the DLL requires additional initialization code, it can be added to DllMain.
#include <windows.h>
#include <stdio.h>
#include <imsl.h>
BOOL WINAPI DllMain(HINSTANCE hinstDLL,
DWORD fdwReason, LPVOID lpvReserved)
{
return imsls_initialize(fdwReason);
}