IMSL Products: CNL Tips
1. CNL 2.0 - Compiling under Windows with Borland 4.5
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: Windows 3.1
PROBLEM DESCRIPTION
Using Borland 4.5, Windows, and WIN32s, the user can compile and link our
examples from the command line but cannot run the resulting executables. The
screen either just blinks or a GPF occurs.
SOLUTION
In order to use the C libraries under Borland 4.5 under Windows, the user
must use WIN32s. The user can compile and link the examples that come with
the libraries from either the command prompt or from the work bench. They
will not, however, run from the command prompt because the examples produce
console applications and WIN32s does not recognize the console. Calls to the
WIN API must be made in the code and the resulting executable must be run
from Windows. We have several examples that show the user how to do this.
2. CNL - Calling C libraries from FORTRAN
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL
Architecture/OS version: All
PROBLEM DESCRIPTION
A user wants to call the C Numerical Libraries from FORTRAN.
SOLUTION
There is no easy way to do this and there are many reasons for NOT trying it.
1) It is very difficult to do. It is much easier to call FORTRAN from C.
2) If the user has access to the FORTRAN libraries, they provide more
coverage than the C libraries. The latest version of the C Libraries only
provides 85% of the routines of the FORTRAN libraries. 3) Because of the
complexity of the problems that can arise from trying to call C routines from
FORTRAN, there is no technical documents available. If the user insist on
trying, he must pass every C argument by reference.
3. CNL - Random number from a general discrete distribution
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL
Architecture/OS version: All
PROBLEM DESCRIPTION
There is no comparable routine in the C libraries that will perform what
RNGDA does (random numbers from a general discrete distribution).
SOLUTION
The user can, however, obtain a random number from a general discrete
distribution by using the values that you are passing through the parameters
NMASS and PROBS. You have to assign intervals of probability where the first
interval is 0 to PROBS(1), the second interval is PROBS(1) to
PROBS(1)+PROBS(2), the third interval is PROBS(1)+PROBS(2) to
PROBS(2)+PROBS(3), and so on up to PROBS(n-1)+PROBS(n). Then just generate a
uniform random number using the C routine random_uniform and select the
interval that it falls in. Return the index of the interval it falls into.
This will provide the random discrete deviates
4. CNL - how to represent the FORTRAN "complex" variable type in C.
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: FNL, CNL
Architecture/OS version: All
PROBLEM DESCRIPTION
Complex, and double complex data types are not defined in C, but they are
defined in FORTRAN.
SOLUTION
Complex, and double complex data types are not defined in C.
However, they are frequently used in the IMSL Libraries. To get around this
problem, an equivalent structure can easily be defined as follows :
/* type definition of ( single ) complex data type */
typedef struct
{float r, i;} complex;
/* type definition of ( double ) complex data type */
typedef struct
{double r, i;} double_complex;
5. CNL - normality_test (Shapiro_Wilk W test) is limited to 2000 samples
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL
Architecture/OS version: All
PROBLEM DESCRIPTION
In the routine normality_test, the Shapiro_Wilk W test is limited to 2000
samples.
SOLUTION
The code is from 1982. A newer algorithm exists that might take care of this
limitation, but has not yet been implemented. See Royston (1992), Journal of
Statistical Computations and Simulations, #2, pg 117 and #42 pg 79.
Alternatively, use the Lilliefors Test. It is not as powerful as the
Shapiro-Wilk W Test, but there is no limit on the number of input samples.
6. CNL - bivariate_normal_cdf returns incorrect results
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: Windows 95, Solaris
PROBLEM DESCRIPTION
The function bivariate_normal_cdf is returning incorrect results. Both the
single and double precision versions have returned incorrect results on
Windows 95, VC++ 4.0 and Sun Solaris. On the HP, the double precision version
returned correct results, while the single precision version did not.
SOLUTION
This is caused by a bug in the code. Some variables are not being properly
initialized.
7. CNL 2.0 - SGI C compiling linking limitations
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: SGI / IRIX 6.0
PROBLEM DESCRIPTION
SGI C compiling and linking limitations : IRIX 6.0 coupled with the IRIX
Developer's Option 6.0 can support compilation and linking of 32-bit ELF
binaries to IRIX 5.2 libraries.
SOLUTION
IRIX 6.0 coupled with the IRIX Developer's Option 6.0 can support compilation
and linking of 32-bit ELF binaries to IRIX 5.2 libraries. The binaries
supplied with this media were generated on an IRIX 5.2 system. To use these
binaries on an IRIX 6.x system, you must compile and link your application
using the -mips2 and -32 compiler/linker options. Note that you cannot mix
32-bit and 64-bit object code in an application.
8. CNL 2.0 - mat_mul_rect_coordinate(): example 1
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: All
PROBLEM DESCRIPTION
Example 1 for imsl_f_mat_mul_rect_coordinate as written in the doc and
online help for CNL 2.0 is incorrect. There is a missing argument after
IMSL_A_MATRIX. The line should be:
IMSL_A_MATRIX, n, n, nz, a
SOLUTION
change
IMSL_A_MATRIX, n, nz, a
to
IMSL_A_MATRIX, n, n, nz, a
9. CNL - VC++ 4.0 / debug assertion failure on free
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL
Architecture/OS version: Windows 95/NT
PROBLEM DESCRIPTION
The error message " debug assertion failure" occurs when trying to delete or
free memory allocated within one of our C functions, such as with
Imsls_d_regression for IMSLS_REGRESSION_INFO, using CNL 2.0 on Win95 and NT
under VC++ 4.0.
SOLUTION
Since these functions are using malloc to allocate space, free should be used
to deallocate the space. However, this error occurs only in debug mode and
occurs when the /MLd option is used to compile. The /MLd option is a default
of debug under workbench compilation.Our docs specify using the /MD option.
The solution is to compile and run in release mode or to compile under debug
mode using /MD rather than /MLd. If using the workbench, set this under
Build/ Settings. Under "Settings For", select Debug. Then under C/C++ in the
Project Options box, change MLd to MD, and hit OK.
10. CNL - Documentation / min_con_nonlin IMSL_GRADIENT optional argument
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL
Architecture/OS version: All
PROBLEM DESCRIPTION
The documentation for min_con_nonlin states that the g argument of the
optional argument IMSL_GRADIENT grad function is an output argument.
SOLUTION
This is a misprint. It is an input argument.
11. CNL 2.0 - VC++ examples not working with single precision
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: Windows 95/NT
PROBLEM DESCRIPTION
The CNL example programs are not giving the correct results under Visual C
++ 4.0, Windows NT or 95, with single precision.
SOLUTION
The compiler switch -DANSI is required for single precision functions.
12. CNL - Unresolved dependencies, rename.h
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL
Architecture/OS version: All
PROBLEM DESCRIPTION
Getting 2 unresolved dependencies, rename.h and renames.h
SOLUTION
These are references to include files for PV-WAVE advantage. If the user is
complaining about this, all they need to do is create a blank dummy include
file, rename.h.
13. CNL - VC++ / linking to MFC application / unresolved external __imp__xxx
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL
Architecture/OS version: Windows
PROBLEM DESCRIPTION
When linking an MFC application with the CNL static libraries under Visual
C++ 4.0, you get an unresolved external symbol on __imp__function.
SOLUTION
This error message is documented in the VC++ help under LNK2001. It says:
When compiling with the /MD option, a reference to "func" in your source
becomes a reference "__imp__func" in the object since all the run-time is now
held within a DLL. If you try to link with the static libraries LIBC.LIB or
LIBCMT.LIB, you will get an unresolved external on __imp__func. If you try to
link with MSVCxx.LIB when compiling without the /MD option you will not
always get an unresolved external, but you will likely have other problems.
Solution: link with the dynamic (dll) libraries or create a console
application.
14. CNL - Results from regression differ between Win NT and HP
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL
Architecture/OS version: Windows NT
PROBLEM DESCRIPTION
The results of certain data run through the imsls_d_regression function
differ between Win NT and HP. Specifically, with the test data, the Win NT
platform gave a RANK_DEFICIENT error message whereas the same data run on the
HP gave a solution.
SOLUTION
Try regression_stepwise as a possible workaround.
15. CNL - documentation errors in error_options
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL
Architecture/OS version: All
PROBLEM DESCRIPTION
For CMATH, the documentation for error_options states that the name of the
function to be used is imsls_error_options and also all the options as
starting with IMSLS. Also, the document seems to indicate that
IMSL_WARNING_IMMEDIATE and IMSL_FATAL_IMMEDIATE could be used as a severity
level when they cannot.
SOLUTION
Use imsl_error_options , with options starting with IMSL instead of IMSLS,
when using the math functions.
16. CNL - Computing Null space of a matrix using the SVD routine.
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL
Architecture/OS version: All
PROBLEM DESCRIPTION
User wants to compute the 'base of the null space' as done in Numerical
recipes.
SOLUTION
the value is equal to (n-rank).
17. CNL - Signal trapping using too much CPU time
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL
Architecture/OS version: All
PROBLEM DESCRIPTION
User's code is using way too much CPU time in signal trapping.
SOLUTION
The following program shows how to use an undocumented feature that turns off
the signal trapping. This is only available in version 2.0 of CNL, not 1.02.
#include
18. CNL 2.0 - documentation of nonlin_least_squares optional arguments
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: Any
PROBLEM DESCRIPTION
The documentation of nonlin_least_squares optional arguments XSCALE,
GRAD_TOL, and STEP_TOL needs enhancement.
SOLUTION
The XSCALE argument can affect the stepsize. The documentation should
state that the expressions shown under GRAD_TOL and STEP_TOL must be
greater than these tolerances.
19. CNL 2.0 - Sun OS / unresolved symbol nint
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: Sun / Sun OS
PROBLEM DESCRIPTION
When linking with the shared libraries under Sun OS, customer gets
unresolved symbol "nint".
SOLUTION
You must include the "-lm" switch when you link. This switch is included
in the symbol $LINK_CNL. See the installation guide for the recommended
link command using LINK_CNL. "nint" is located in /usr/lib/libm.a.
20. CNL 2.0 - imsl_c_div does not report function name to error handler
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: Any
PROBLEM DESCRIPTION
A divide by zero in function imsl_c_div reported the following error:
*** TERMINAL Error from . Complex division by zero.
SOLUTION
The function imsl_c_div is not correctly passing its function name to
the error handler. A change request has been filed.
21. CNL 2.0 - ode_adams_gear example 2
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: Any
PROBLEM DESCRIPTION
There is an error in example 2 for function ode_adams_gear.
The first include statement should read:
#include
Also, it should be noted that the output for example 2 will vary
for different types of machines, and may not match the output shown
in the documentation.
SOLUTION
A change request has been filed.
22. CNL 2.0 - Technical Letter 6314 locating error message files
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: Windows 95 or NT, Visual C++ 4.0
PROBLEM DESCRIPTION
Technical Letter 6314
The IMSL C Numerical Libraries Version 2.0 for Microsoft Visual C++ 4.0
has an error in the installation process. The installation neglects to
define two environment variables that are needed for the C Numerical
Libraries to find the error message files. Without these variables set,
if an error needs to be printed out during a run of the IMSL C Numerical
Libraries code, an error message will be displayed noting that the error
message file cannot be opened.
SOLUTION
To rectify this situation, first determine the top level directory in
which the C Numerical Libraries were installed on your system. The
default location is "C:\IMSLNT\CNL", however the installation script
gives the installer an option to change this to another directory.
The phrase "" in the following instructions refers
to this top level directory.
Windows NT:
1. Click on "Control Panel"
2. Click on "System"
3. Click on "Variable" at the bottom.
4. Type in
IMSLERRPATH
5. Click on "Value"
6. Type in
\LIB\. Click on "Set" to the right
8. Click on "Variable" again
9. Type in
IMSLSERRPATH
10. Click on "Value"
11. Type in
\LIB\. Click on "Set" to the right
13. Look in the "User Environmental Variables for Administrator"
window and make sure the IMSLERRPATH and IMSLSERRPATH environment
variables are corrrectly defined.
14. Click "OK"
Windows 95:
1. Edit the file
\CNLENV.BAT
2. Add these two lines to the end of the file:
SET IMSLERRPATH=%IMSLNT_CNL%\LIB\
SET IMSLSERRPATH=%IMSLNT_CNL%\LIB\
According to instructions in the installation guide, the file
AUTOEXEC.BAT in the top level directory for your system disk was
to be modified so that it calls \CNLENV.BAT.
Assuming this has been done for your system, reboot the system.
4. When the system comes back up, check the environment variables
IMSLERRPATH and IMSLSERRPATH to make sure they are set to the
values in step 2.
23. CNL 2.0 - using MAX_FCN optional argument with bounded_least_squares
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: any
PROBLEM DESCRIPTION
Passing the optional argument IMSL_MAX_FCN, maximum number of function
evaluations, to bounded_least_squares does not seem to control
the number of function calls accurately. The actual number of function
evaluations is higher than the number requested in the optional argument.
SOLUTION
Bounded_least_squares is calling the user supplied function
to compute the gradient but is not counting these extra calls. This is
why it appears that the function is being called more times than
the number specified by IMSL_MAX_FCN. A change request has been filed.
One workaround would be for the user to supply the jacobian function.
24. CNL 2.0 - imsl_f_lin_sol_gen_min_residual example not working
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: all
PROBLEM DESCRIPTION
Example 1 routine from CNL routine, imsl_f_lin_sol_gen_min_residual,
is returning error messages that state that there is an error with
argument number 7 and argument number 8.
SOLUTION
The error is not being generated correctly. It really is a
documentation problem with the matrix multiplication routine in the
user function. There is a 1 parameter missing. It should be:
imsl_f_mat_mul_rect_coordinate ("A*x",
IMSL_A_MATRIX, n, n, nz, a,
IMSL_X_VECTOR, n, p,
IMSL_RETURN_USER_VECTOR, z,
0);
An extra "n" has been added as the fourth coordinate.
25. CNL 2.0 - min_con_gen_lin changes input "a" matrix
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: all
PROBLEM DESCRIPTION
Function min_con_gen_lin is altering the input matrix "a".
In other words, after a call to min_con_gen_lin, "a" does not
contain the same values that were input.
SOLUTION
min_con_gen_lin is taking the transpose of matrix "a" and
storing it back in "a". This is an error that will be corrected
in the next release of CNL. A change request has been filed.
26. CNL 2.0 - will CNL run on HP 800 series machines
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: HP 800
PROBLEM DESCRIPTION
Will CNL 2.0 run on an HP 800 series machine? The installation
script ipt_install will not run on an 800 series machine.
SOLUTION
CNL 2.0 should run on an HP 800 series with 1.1 chip. It will
not be compatible with machines running the 1.0 chip. Check the
model number of the machine with the "uname -a" command and
then check for which chip the machine uses by looking at
/usr/lib/sched.models.
The customer should have either the IPT 1.2 or CTT 1.1 tape for
HPUX 10.01. The installation script on these tapes does not check
for machine type.
It is possible to install from the IPT 2.0 tape if the machine has
the 1.1 chip, but it is recommended that the HPUX 10.01 tape be
used if possible. The IPT 2.0 tape is intended for use on HPUX 9.05
only. You can edit the ipt/bin/arch shell script to force the machine
architecture to hps700 (by setting MACH=7 under the HP-UX case) so
that ipt_install will run.
27. CNL 2.0 - Example 2 for regressors_for_glm does not work as documented.
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version:
PROBLEM DESCRIPTION
Example 2 for regressors_for_glm does not work as documented.
SOLUTION
In example 2, the statement
float anova[15], *reg;
should read
float anova[15], *regressors;
A change request has been filed.
28. CNL 2.0 - How to call CNL from Visual Basic 5.0
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: Windows NT/95
PROBLEM DESCRIPTION
Errors occur when trying to call CNL from Visual Basic 5.0,
especially "Bad DLL calling convention".
SOLUTION
An intermediate library must be used to accept the calls from
Visual Basic 5.0 and to make the proper calls to the CNL libraries.
The problem is the data types between VB5 and CNL (and most other C
libraries) are incompatible. The solution is to build an intermediate
C library that can be called from VB5. The intermediate library moves
the data into "safe" arrays that can be safely passed to CNL routines.
The same is true when the data is passed back. A ZIP file, VB5_IMSL.ZIP,
contains both an example VB5 program and an intermediate C library to
translate the calls to CNL. Source code for both is also included.
The user should unzip the file the files into the same path, D:\VB5_IMSL,
that was used during the compilation. Otherwise, hard-coded values will
have to be changed. This file can located on the Network Neighborhood
on Hou-fs1 in PostComm\VB5_IMSL or contact Technical Support.
The Visual Basic compiler is not a supported platform, but we can provide
tips for doing this. The ZIP file contains a full working example of
how to call CNL from Visual Basic 5.0. Make sure you have added the
MSFLEXGRID to your project. Basically, you have to write an intermediate
DLL in C that translates the call from Visual Basic to our CNL library.
It also accepts the results and sends them back to the Visual Basic
calling program. To use the program, just run it in the VB5 environment,
click on "Upload data" to load the raw data and click "Perform Regression"
to make the call the CNL routine and get the results. The ZIP file
contains the Visual Basic source code and the C source code for the
intermediate DLL that is written in C. There is also a small
readme.txt file that you should read.
This is a very simple example that loads a small data set from a
text file into a grid, performs a linear regression and then dumps
the results into 2 other grids. This program shows how to set up
the intermediate DLL.
There are two points to be aware of concerning this program.
There is very little if any error checking. We know what the results
should be and we know the data is good. Error checking is not
the point of this example program. Also, we have not passed any
optional arguments to the intermediate IMSL.DLL. You will need to
figure out some mechanism for passing optional arguments from VB5
to the intermediate DLL and then onto CNL.
29. CNL 2.0 - Bug in IMSLS_X_INDICES option in regression routine
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version:
PROBLEM DESCRIPTION
Example 3 in the regression documentation illustrates the problem.
The example code compiles but the executable produces a segmentation fault.
SOLUTION
The code will work if it is rewritten without using the IMSLS_X_INDICES option.
Alternate version of regression example 3:
/home/sointenty/jmccormi/test_files/regression_ex3_alt.c.
A bug report has been filed.
30. CNL 2.0 - Write CNL output to MFC MessageBox
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: Windows NT/95
PROBLEM DESCRIPTION
This sample program writes CNL output to a MessageBox.
The example also shows how to create a more general MessageBox.
SOLUTION
Create a console application with MSDEV. Include cmath.lib.
Use default compiler switches.
#include
#include
#include
void main(void)
{
char *message_text;
char *caption_text;
int a[]={1,2,3,4,5}; /* sample data*/
char *b; /* pointer to output from write_matrix */
imsl_i_write_matrix("Sample Data\n",1,5,(int *)a,
IMSL_RETURN_STRING,&b,
IMSL_NO_COL_LABELS,
0);
printf("\n\n%s\n\n",b);
caption_text="IMSL Data";
MessageBox(NULL,b,caption_text,MB_OK);
caption_text="Message Caption";
message_text="This is an OK message.";
MessageBox(NULL,message_text,caption_text,MB_OK);
/* Other MessageBox types include: MB_ICONSTOP, MB_ICONINFORMATION */
}
31. CNL 2.0 - MSVC++ DLLs and LIB files needed
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: Windows NT / 95
PROBLEM DESCRIPTION
What MSVC++ DLLs and LIB files are needed for the CNL 2.0 library?
SOLUTION
Customer should look in our Makefile in the examples directory.
It refers to NTWIN32.MAK which may in turn refer to WIN32.MAK.
Inside WIN32.MAK near the bottom are the 6 base MS libs that are
needed by our product.
32. CNL 2.0 - 64 bit product does not run on SGI O2 with IRIX 6.3
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: SGI O2 / IRIX 6.3
PROBLEM DESCRIPTION
Customer has problems running 64 bit version of CNL on SGI O2
running IRIX 6.3 with SGI Mipspro C compiler.
SOLUTION
The SGI O2 running IRIX 6.3 is actually a 32 bit system. We do not have a
32 bit version of this library for the SGI Mipspro C compiler.
Upgrading to IRIX 6.4 would make this a 64 bit system. The other
alternative is for the customer to obtain the source code and build the library.
33. CNL 2.0 - use of active parameter in min_con_nonlin
-
PRODUCT/PLATFORM INFORMATION
Product/Version #: CNL 2.0
Architecture/OS version: all
PROBLEM DESCRIPTION
How is the active parameter in the user supplied function of
min_con_nonlin used?
SOLUTION
The active parameter of the user supplied function, fcn, is
used to determine which constraints the function needs to have
evaluated each time it is called. The function may not need to
have all constraints evaluated for each call, so using this
parameter could save computation time in some cases. When
active[n] is true or equal to 1, function fcn needs to have
constraint n evaluated.
Active[0] to active[meq] show whether or not the equality
constraints need to be evaluated, and active[meq+1] to active[m]
show whether or not the inequality constraints need to be evaluated.
Also, see example 1 for an example of how this parameter is used
inside the function.