Why can I not compile the project in Virtual C++ 2010?

Post here if you have a question about LAPACK or ScaLAPACK algorithm or data format

Why can I not compile the project in Virtual C++ 2010?

Postby marshors » Fri Jun 01, 2012 3:03 am

I am new user.

I have tried the real number case and sucessed.

the code is
--------------------
#include <stdio.h>
#include <complex.h>
extern void dgesv_(int *N, int *NRHS, double *A, int *LDA, int * IPIV, double *B, int *LDB, int * INFO);



#define D 5

#define DB 3

int main()

{

FILE *out;

double CA[D][D], A[D*D],

CB[D][DB], B[D*DB] ;

int N, NRHS, IPIV[D], INFO;

int i, j;

N = D;

NRHS = 3;

CA[0][0]=6.80, CA[0][1]=-6.05, CA[0][2]=-0.45, CA[0][3]=8.32, CA[0][4]=-9.67;

CA[1][0]=-2.11, CA[1][1]=-3.30, CA[1][2]= 2.58, CA[1][3]=2.71, CA[1][4]=-5.14;

CA[2][0]=5.66, CA[2][1]=5.36, CA[2][2]=-2.70, CA[2][3]=4.35, CA[2][4]=-7.26;

CA[3][0]=5.97, CA[3][1]=-4.44, CA[3][2]= 0.27, CA[3][3]=-7.17, CA[3][4]=6.08;

CA[4][0]=8.23, CA[4][1]=1.08, CA[4][2]= 9.04, CA[4][3]= 2.14, CA[4][4]=-6.87;

CB[0][0]=4.02, CB[0][1]=-1.56, CB[0][2]=9.81;

CB[1][0]=6.19, CB[1][1]=4.00, CB[1][2]=-4.09;

CB[2][0]=-8.22, CB[2][1]=-8.67, CB[2][2]=-4.57;

CB[3][0]=-7.57, CB[3][1]=1.75, CB[3][2]=-8.61;

CB[4][0]=-3.03, CB[4][1]=2.86, CB[4][2]=8.99;

for(i=0; i< D; i++)

for(j=0;j<D; j++)

A[i + D*j] = CA[i][j];

for(i=0; i<D; i++)

for(j=0;j<NRHS; j++)

B[i+D*j] = CB[i][j];

dgesv_(&N, &NRHS, A, &N, IPIV, B, &N, &INFO);

out = stderr;

fprintf(out, "INFO: %d\n", INFO);

fprintf(out, "A:\n");

for(i=0;i<D; i++)

{

for(j=0;j<D; j++)

fprintf(out, "%g\t", A[i+D*j]);

fprintf(out, "\n");

}

fprintf(out, "B:\n");

for(i=0;i<D; i++)

{

for(j=0;j<NRHS; j++)

fprintf(out, "%g\t", B[i+D*j]);

fprintf(out, "\n");

}

return 0;

}
---------------------------------------------------

however,
when i try to compute the complex type

the VC shows the error massage

complx.obj : error LNK2019: undecoded external notation "void __cdecl zgesv_(int *,int *,class std::complex<double> *,int *,int *,class std::complex<double> *,int *,int *)" (?zgesv_@@YAXPAH0PAV?$complex@N@std@@00100@Z)

the code is
------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <complex>

using namespace std;

extern void zgesv_(int *H, int *NRHS, complex <double> *A, int *LDA, int *IPIV, complex <double> *B, int *LDB, int *INFO);

#define N 4
#define NRHS 2
#define LDA N
#define LDB NRHS

int main()
{ int n = N, nrhs = NRHS, lda = LDA, ldb = LDB, info;
int ipiv[N];
complex <double> a[LDA*N];
complex <double> b[LDA*N];

a[0] = complex <double> ( 1.23, -5.50);
a[1] = complex <double> ( 7.91, -5.38);
a[2] = complex <double> (-9.80, -4.86);
a[3] = complex <double> (-7.32, 7.57);
a[4] = complex <double> (-2.14, -1.12);
a[5] = complex <double> (-9.92, -0.79);
a[6] = complex <double> (-9.18, -1.12);
a[7] = complex <double> ( 1.37, 0.43);
a[8] = complex <double> (-4.30, -7.10);
a[9] = complex <double> (-6.47, 2.52);
a[10] = complex <double> (-6.51, -2.67);
a[11] = complex <double> (-5.86, 7.38);
a[12] = complex <double> ( 1.27, 7.29);
a[13] = complex <double> ( 8.90, 6.92);
a[14] = complex <double> (-8.82, 1.25);
a[15] = complex <double> ( 5.41, 5.37);


b[0] = complex <double> ( 8.33, -7.32);
b[1] = complex <double> (-6.11, -3.81);
b[2] = complex <double> (-6.18, -4.80);
b[3] = complex <double> ( 0.14, -7.71);
b[4] = complex <double> (-5.71, -2.80);
b[5] = complex <double> ( 1.41, 3.40);
b[6] = complex <double> (-1.60, 3.08);
b[7] = complex <double> ( 8.54, -4.05);

zgesv_(&n, &nrhs, a, &lda, ipiv, b, &ldb, &info);

printf("A is /n");

int i,j;
for (i=0;i<4;i++)
{for (j=i*4;j<i*4+4;j++)
printf("%f+%f *i ",real(a[j]),imag(a[j]));
printf("/n");
}
}
marshors
 
Posts: 1
Joined: Fri Jun 01, 2012 2:43 am

Re: Why can I not compile the project in Virtual C++ 2010?

Postby admin » Fri Jun 01, 2012 8:59 am

Did you try to use LAPACKE? the new C Standard API for LAPACK
See http://icl.cs.utk.edu/lapack-for-windows/lapack/ for more info.
Julie
admin
Site Admin
 
Posts: 501
Joined: Wed Dec 08, 2004 7:07 pm


Return to Algorithm / Data

Who is online

Users browsing this forum: No registered users and 1 guest