CLAPACK Frequently Asked Questions (FAQ)

lapack@cs.utk.edu

Many thanks to the netlib_maintainers@netlib.org from whose FAQ list I have patterned this list for CLAPACK.

Table of Contents

1.1) What is CLAPACK?
1.2) Are there legal restrictions on the use of CLAPACK software?
1.3) How do I reference CLAPACK in a scientific publication?
1.4) How can I unpack clapack.tgz?
1.5) How do I install CLAPACK?
1.6) How was CLAPACK created?
1.7) Installation difficulties?
1.8) How do I link my C program with CLAPACK?
1.9) Can I see an example program calling CLAPACK?
1.10) Installing CLAPACK on Windows NT?
1.11) Question not addressed in this FAQ?

1) CLAPACK

1.1) What is CLAPACK?

The CLAPACK library was built using a Fortran to C conversion utility called f2c. The entire Fortran 77 LAPACK library is run through f2c to obtain C code, and then modified to improve readability. CLAPACK's goal is to provide LAPACK for someone who does not have access to a Fortran compiler.

For further details, please refer to the clapack/readme.maintain file on netlib.

1.2) Are there legal restrictions on the use of CLAPACK software?

CLAPACK is a freely-available software package. It is available from netlib via anonymous ftp and the World Wide Web. Thus, it can be included in commercial software packages (and has been). We only ask that proper credit be given to the authors. Namely, we ask that you cite the LAPACK Users' Guide, Third Edition.

@BOOK{laug,
      AUTHOR = {Anderson, E. and Bai, Z. and Bischof, C. and
                Blackford, S. and Demmel, J. and Dongarra, J. and
                Du Croz, J. and Greenbaum, A. and Hammarling, S. and
                McKenney, A. and Sorensen, D.},
      TITLE = {{LAPACK} Users' Guide},
      EDITION = {Third},
      PUBLISHER = {Society for Industrial and Applied Mathematics},
      YEAR = {1999},
      ADDRESS = {Philadelphia, PA},
      ISBN = {0-89871-447-8 (paperback)} }

Like all software, it is copyrighted. It is not trademarked, but we do ask the following:

If you modify the source for these routines we ask that you change the name of the routine and comment the changes made to the original.

We will gladly answer any questions regarding the software. If a modification is done, however, it is the responsibility of the person who modified the routine to provide support.

1.3) How do I reference CLAPACK in a scientific publication?

We ask that you cite the LAPACK Users' Guide, Third Edition.

@BOOK{laug,
      AUTHOR = {Anderson, E. and Bai, Z. and Bischof, C. and
                Blackford, S. and Demmel, J. and Dongarra, J. and
                Du Croz, J. and Greenbaum, A. and Hammarling, S. and
                McKenney, A. and Sorensen, D.},
      TITLE = {{LAPACK} Users' Guide},
      EDITION = {Third},
      PUBLISHER = {Society for Industrial and Applied Mathematics},
      YEAR = {1999},
      ADDRESS = {Philadelphia, PA},
      ISBN = {0-89871-447-8 (paperback)} }

1.4) How can I unpack clapack.tgz?

   gunzip clapack.tgz
   tar xvf clapack.tar

The compression program gzip (and gunzip) is Gnu software. If it is not already available on your machine, you can download it via anonymous ftp:

   ncftp prep.ai.mit.edu
   cd pub/gnu/
   get gzip-1.2.4.tar

1.5) How do I install CLAPACK?

For complete details on the installation of CLAPACK, please refer to the clapack/readme.install file on netlib.

1.6) How was CLAPACK created?

As previously stated, the CLAPACK library was built using a Fortran to C conversion utility called f2c. The entire Fortran 77 LAPACK library is run through f2c to obtain C code, and then modified to improve readability. CLAPACK's goal is to provide LAPACK for someone who does not have access to a Fortran compiler.

It is important to note that this f2c conversion was run on a machine that appends an underscore to differentiate C and Fortran 77 namespaces. If your machine does not append an underscore to differentiate namespaces, then CLAPACK will not work on your machine.

For complete details on the creation of CLAPACK, please refer to the clapack/readme.maintain file on netlib.

1.7) Installation difficulties?

The following is a list of commonly encountered installation difficulties.

  1. Compiling F2CLIBS/libI77/ under non-standard UNIX I/O?

     
        If you get error messages about references to cf->_ptr
        and cf->_base when compiling wrtfmt.c and wsfe.c or to
        stderr->_flag when compiling err.c, then insert the line
     
        #define NON_UNIX_STDIO
       
        at the beginning of F2CLIBS/libI77/fio.h, and recompile everything 
        (or at least those modules that contain NON_UNIX_STDIO).
    
  2. Testing program runs forever and generates large amount of output?

        If the testing program runs forever, and generates large amount of
        output, it is probably due to a faulty "sprintf" on your system.
    
        If your system's sprintf does not work the way ANSI C
        specifies -- specifically, if it does not return the
        number of characters transmitted -- then insert the line
     
        #define USE_STRLEN
     
        at the end of F2CLIBS/libI77/fmt.h. This is necessary with at least 
        some versions of Sun and DEC software.
    
  3. Your system lacks onexit()?

       If your system lacks onexit() and you are not using an ANSI C 
       compiler, then you should add -DNO_ONEXIT to CFLAGS in 
       F2CLIBS/libF77/makefile, e.g., by changing the "CFLAGS =" line to
     
            CFLAGS = -O -DNO_ONEXIT
     
       On at least some Sun systems, it is more appropriate to change the
       "CFLAGS =" line to
     
            CFLAGS = -O -Donexit=on_exit
     
       Refer to F2CLIBS/libF77/README and F2CLIBS/libF77/makefile for details.
    
  4. Inconsistent type declaration in rawio.h?

       On at least some Sun systems, the following type declaration in 
       F2CLIBS/libI77/rawio.h: 
     
            extern FILE *fdopen(int, char*);
     
       is not consistent with the one defined in stdio.h. In this case
       you should comment out this line before compiling this directory.
    

1.8) How do I link my C program with CLAPACK?

I always refer users who have questions about how to link to CLAPACK to the makefiles in the CLAPACK/TESTING or CLAPACK/TIMING subdirectories. For example, you will see in the CLAPACK/TESTING/LIN/Makefile the following line:

 
../xlintsts : $(ALINTST) $(SLINTST) $(SCLNTST)
        $(LOADER) $(LOADOPTS)  $(ALINTST) $(SCLNTST) $(SLINTST) \
        ../../$(TMGLIB) ../../$(LAPACKLIB) $(BLASLIB) $(F2CLIB) -lm -lc \
        -o $@
where TMGLIB and LAPACKLIB are built in the distribution, BLASLIB is the optimized BLAS library on your machine, and F2CLIB is libF77.a and libI77.a.

If you downloaded an individual CLAPACK routine with dependencies and wish to link your C main program with it, you must have -lF77 and possibly -lI77 available on your machine, or you will need to download clapack/f2clibs.tar.gz and build and link to it as well.

1.9) Can I see an example program calling CLAPACK?

/* Start of Listing */

#include "f2c.h"
#include "stdio.h"
#include "clapack.h"

#define SIZE 4

void MAIN_(){}
void MAIN__(){}
void _MAIN_(){}

main( )
{
     char JOBU;
     char JOBVT;

     int i;
    
     integer M = SIZE;
     integer N = SIZE;
    
     integer LDA = M;
     integer LDU = M;
     integer LDVT = N;
     integer LWORK;
     integer INFO;
   
     integer mn = min( M, N );
    
     integer MN = max( M, N );
     
     double a[SIZE*SIZE] = { 16.0, 5.0, 9.0 , 4.0, 2.0, 11.0, 7.0 , 14.0, 3.0, 10.0, 6.0, 15.0, 13.0, 8.0, 12.0, 1.0};
     double s[SIZE];
     double wk[201];
     double uu[SIZE*SIZE];
     double vt[SIZE*SIZE];
     
       JOBU = 'A';
     
       JOBVT = 'A';
     
    LWORK =  201;
    
/* Subroutine int dgesvd_(char *jobu, char *jobvt, integer *m, integer *n, 
        doublereal *a, integer *lda, doublereal *s, doublereal *u, integer *
        ldu, doublereal *vt, integer *ldvt, doublereal *work, integer *lwork, 
        integer *info)
*/

    dgesvd_( &JOBU, &JOBVT, &M, &N, a, &LDA, s, uu, 
          &LDU, vt, &LDVT, wk, &LWORK, &INFO);
          
    printf("\n INFO=%d", INFO );          

    for ( i= 0; i< SIZE; i++ ) {
        printf("\n s[ %d ] = %f", i, s[ i ] );
    }

    return 0;
}     

/* End of Listing */

1.10) Installing CLAPACK on Windows NT?

Refer to http://www.netlib.org/clapack/CLAw32.zip and http://www.netlib.org/clapack/readme.claw32 for further details.


Here are a few hints that we received from a user who installed CLAPACK under Windows NT and the Microsoft Visual C++ compiler.

As for timing, I simply replaced the calls to "times" in second.c and
dsecnd.c with calls to "clock" (which is declared in Microsoft's time.h).
Source files are attached below. I have no idea how accurate the resulting
timings are; the numbers look reasonable. I'll run the timing benchmarks and
send you the results as soon as I get a chance. 

Microsoft's math.h defines a struct "complex" which obviously conflicts with
the one in f2c.h; I added the following 3 lines to f2c.h to disable
compilation of the offending code in math.h:
 
        #ifdef _WIN32 
        #define _COMPLEX_DEFINED 
        #endif
 
Here are second.c and dsecnd.c:

#include "f2c.h"
/* #include  */
#include 
#include 

#ifndef CLK_TCK
#define CLK_TCK 60
#endif

doublereal second_()
{
    /*  struct tms rusage;

        times(&rusage);
        return (doublereal)(rusage.tms_utime) / CLK_TCK */

    clock_t rusage;

    rusage = clock();
    return (doublereal)(rusage) / CLOCKS_PER_SEC;

} /* second_ */



#include "f2c.h"
/* #include  */
#include 
#include 

#ifndef CLK_TCK
#define CLK_TCK 60
#endif

doublereal dsecnd_()
{
    /*  struct tms rusage;

        times(&rusage);
        return (doublereal)(rusage.tms_utime) / CLK_TCK; */

    clock_t rusage;

    rusage = clock();
    return (doublereal)(rusage) / CLOCKS_PER_SEC;

} /* dsecnd_ */

1.11) Question not addressed in this FAQ?

If your question was not addressed in this FAQ, have you consulted the LAPACK FAQ?

If you question is still unanswered, please feel free to contact us at the mailing alias

lapack@cs.utk.edu
.

lapack@cs.utk.edu