Initializes the IMSL C Math Library.
#include <imsl.h>
int imsl_initialize (int reason)
int reason
(Input)
The reason why the call is being made.
|
1 |
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 Math 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 Math 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 imsl_initialize before any other IMSL C Math 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 imsl_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 Math Library is initialized within an application. Often this is not required, but may be required if the static library version of the IMSL C Math Library is linked into a Windows EXE. Even if not required, the initialization call is always allowed.
#include <imsl.h>
int main()
{
float y;
imsl_initialize(1);
y = imsl_f_gamma(3.5);
printf("gamma(3.5) = %g\n", y);
}
gamma(3.5) = 3.32335
If the static library version of the IMSL Math Library is linked into a Windows DLL, the DLL must define the callback function DllMain. The function DllMain must in turn call imsl_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 imsl_initialize(fdwReason);
}