LAPACK Archives

[Lapack] Clapack and ATLAS

Dear Ankit

Below is your program with LAPACKE, the new C LAPACK Standard Interface
CLAPACK is no longer maintained.

Here is the way to link it with the Reference BLAS
 gcc -o prog.exe  prog.c -L/opt/mylib/ -llapacke -llapack -lrefblas -lgfortran

and here is the way to link it with ATLAS
gcc -o prog.exe  prog.c -L/Users/julie/opt/mylib/ -llapacke -llapack  -lf77blas 
-lcblas -latlas -lgfortran

LAPACK and LAPACKE have been generated with the latest LAPACK release available 
at http://www.netlib.org/lapack/lapack.tgz

Best,
Julie

#include "stdio.h"
#include "lapacke.h"

#define min(a,b) ((a)>(b)?(b):(a))

#define SIZE 4


int main( void )
{
     char JOBU;
     char JOBVT;

     int i;
    
     int M = SIZE;
     int N = SIZE;
    
     int LDA = M;
     int LDU = M;
     int LDVT = N;
     int LWORK;
     int INFO;
        
     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 superb[min(M,N)-1];
     double uu[SIZE*SIZE];
     double vt[SIZE*SIZE];
     
       JOBU = 'A';
     
       JOBVT = 'A';
     
    LWORK =  201;
 /*
 lapack_int LAPACKE_dgesvd( int matrix_order, char jobu, char jobvt,
                           lapack_int m, lapack_int n, double* a,
                           lapack_int lda, double* s, double* u, lapack_int ldu,
                           double* vt, lapack_int ldvt, double* superb );
*/   
    INFO= LAPACKE_dgesvd( LAPACK_ROW_MAJOR, JOBU, JOBVT, M, N, a, LDA, s, uu, 
          LDU, vt, LDVT, superb);
          
    printf("INFO=%d\n", INFO );          

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

    return 0;
}     

/* End of Listing */

On Feb 10, 2012, at 1:24 PM, ankit jain wrote:

do you know whats wrong?....
I really appreciate your help....

On Fri, Feb 10, 2012 at 4:04 PM, ankit jain 
<ankitjain.me.iitk@Domain.Removed> wrote:
sorry... the output is:
dgesvd.o:
0000000000000000 T dgesvd_


On Fri, Feb 10, 2012 at 4:03 PM, ankit jain 
<ankitjain.me.iitk@Domain.Removed> wrote:
ankit at ubuntu:/usr/local/lib$ ls
lapack_LINUX.a  libgslcblas.a         libgsl.so.0       python2.7
libatlas.a      libgslcblas.la        libgsl.so.0.16.0  site_ruby
libcblas.a      libgslcblas.so        libI77.a          tmglib_LINUX.a
libcblaswr.a    libgslcblas.so.0      liblapack.a       vmd
libF77.a        libgslcblas.so.0.0.0  libptcblas.a
libf77blas.a    libgsl.la             libptf77blas.a
libgsl.a        libgsl.so             pkgconfig
ankit at ubuntu:/usr/local/lib$ nm lapack_Linux.a |  grep -i dgesvd
nm: 'lapack_Linux.a': No such file
ankit at ubuntu:/usr/local/lib$

On Fri, Feb 10, 2012 at 3:56 PM, julie langou <julie@Domain.Removed> wrote:
Could you give me the output of
nm lapack_Linux.a |  grep -i dgesvd

Again, LAPACKE is way easier to use.
Thanks
Julie

On Feb 10, 2012, at 12:52 PM, ankit jain wrote:

I added extern while declaring the libraries but still i am getting some 
error.
It reads like:
g++ test.cpp -L lapack_Linux.a -lf77blas -lcblas -lF77 -lI77 -lm
test.cpp: In function ?int main()?:
test.cpp:54:31: warning: format ?%d? expects argument of type ?int?, but 
argument 2 has type ?integer {aka long int}? [-Wformat]
/tmp/ccvExfJj.o: In function `main':
test.cpp:(.text+0x20a): undefined reference to `dgesvd_'
collect2: ld returned 1 exit status


and the program i am trying to compile is:
/* Start of Listing */
extern "C"{
#include "clapack/f2c.h"
#include "stdio.h"
#include "clapack/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 */







On Fri, Feb 10, 2012 at 3:40 PM, ankit jain 
<ankitjain.me.iitk@Domain.Removed> wrote:
Thanks for your quick response...
I tried to do as you said....
I copied a code from the first link mentioned by you, and complied using the 
mentioned libraries..but I get this error:

g++ test.cpp -L lapack_Linux.a -lf77blas -lcblas -lF77 -lI77 -lm
test.cpp: In function ?int main()?:
test.cpp:54:31: warning: format ?%d? expects argument of type ?int?, but 
argument 2 has type ?integer {aka long int}? [-Wformat]
/tmp/ccEeoJZc.o: In function `main':
test.cpp:(.text+0x20a): undefined reference to `dgesvd_(char*, char*, long*, 
long*, double*, long*, double*, double*, long*, double*, long*, double*, 
long*, long*)'
collect2: ld returned 1 exit status


Can you please tell whats wrong?....
And again thank a lot for helping me...

On Fri, Feb 10, 2012 at 9:21 AM, julie langou <julie@Domain.Removed> wrote:
Dear Ankit,
Just google clapack example, there is plenty.
http://www.netlib.org/clapack/faq.html#1.9
http://theochem.mercer.edu/clapack/

to compile you need just the CLAPACK library and BLAS library,
On your machine, it should be lapack_LINUX.a  -lf77blas -lcblas -latlas 
-lg2c -lm
See http://math-atlas.sourceforge.net/errata.html#LINK to link with ALTAS

Also we CLAPACK has now been replaced by the new C Standard Interface to 
LAPACK: LAPACKE
LAPACKE is included in the latest LAPACK release available at 
http://www.netlib.org/lapack
Sincerely,
Julie
On Feb 9, 2012, at 5:28 PM, ankit jain wrote:

Hi,
I installed CLAPACK using BLAS from ATLAS on my ubuntu system.
I am having difficulty in compiling my c++ program which uses clapack. If 
possible, could you send me a sample program with all header files and gcc 
command to be used for compilation (I mean linking libraries.)....

Thank You,
Ankit Jain

I have following libraries:
lapack_LINUX.a
libatlas.a
licblas.a
libcblaswr.a
libf77blas.a
libF77.a
libI77.a
liblapack.a
libptcblas.a
libptf77blas.a
tmglib_LINUX.a _______________________________________________
Lapack mailing list
Lapack@Domain.Removed
http://lists.eecs.utk.edu/mailman/listinfo/lapack








-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
http://lists.eecs.utk.edu/mailman/private/lapack/attachments/20120210/836d39f5/attachment.html
 

<Prev in Thread] Current Thread [Next in Thread>


For additional information you may use the LAPACK/ScaLAPACK Forum.
Or one of the mailing lists, or