please help me out on lapack with C language

Post here if you have a question about linking your program with LAPACK or ScaLAPACK library

please help me out on lapack with C language

Postby ruoshan » Tue Mar 08, 2011 9:11 am

I am using Debian,and It has the lapack installed.
as far as I know,the lapack package is compiled for fortran.But why can I still use it in C code.
here is my C code:
=============tt.c====================
#include <stdio.h>
//#include "clapack.h"
void dgtsv_(const long *Np, const long *NRHSp, double *DL,
double *D, double *DU, double *B, const long *LDBp,
long *INFOp);
double l[] = {
-1, -2, -1, -1
};
double d[] = {
2, 2, 3, 3, 1
};
double u[] = {
-1, -1, -1, -2
};
double x[] = {
1, 2, 3, 2, 1
};
static long
dgtsv(long N, long NRHS, double *DL, double *D, double *DU, double *B,
long LDB){
//extern void dgtsv_(const long *Np, const long *NRHSp, double *DL,
//double *D, double *DU, double *B, const long *LDBp,
//long *INFOp);
long info;
dgtsv_(&N, &NRHS, DL, D, DU, B, &LDB, &info);
return info;
}

int
main()
{
int i, info;
info = dgtsv(5, 1, l, d, u, x, 5);
if (info != 0) fprintf(stderr, "failure with error %d\n", info);
for (i=0; i<5; ++i) printf("%5.1f\n", x[i]);
return 0;
}
================================================
And I compile it like this: gcc -llapack tt.c
It successes. Why?
ruoshan
 
Posts: 2
Joined: Mon Mar 07, 2011 8:35 am

Re: please help me out on lapack with C language

Postby admin » Tue May 31, 2011 5:37 am

Please take a look here: http://icl.cs.utk.edu/lapack-forum/viewtopic.php?f=2&t=2455
It should get you you started.
I strongly advice to go with the LAPACKE Interface.
Julie
admin
Site Admin
 
Posts: 499
Joined: Wed Dec 08, 2004 7:07 pm


Return to Linking Problem

Who is online

Users browsing this forum: No registered users and 1 guest