为什么我运行C程序版的gp算法出现这么多错误呢?
这是C程序版GP算法#include "mex.h"
#include "math.h"
#include<stdio.h>
/*****************************************************************
*data:the time series
*r: the r series
*N: the length of the time series
*delay : the delay of the time series
*rlen: the length of r series
*ln_C: the correlation dimention series
******************************************************************/
void G_P(double data[], double r[], int N, int m,
int rlen, int delay, double ln_C[],double ln_r[])
{
double distance;
double max=0;
int cr=0;
int i,j,k,l;
double Cr=0;
int M=N-(m-1)*delay;
for (l=0; l<rlen; l++)
{
for (i=0; i<M-1; i++)
{
for (j=i+1; j<M; j++)
{
for (k=0; k<m; k++)
{
distance = fabs(data-data);
if (distance>max)
max = distance;
}
if (r>=max)
cr++;
max = 0;
}
}
Cr = cr*2.0/(M*(M-1));
cr = 0;
ln_C = log(Cr);
ln_r = log(r);
}
}
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
double *data;
double *r;
int m;
int delay;
double *ln_C;
double *ln_r;
int datalen,rlen;
if (nrhs!=4)
mexErrMsgTxt("Four inputs required!");
else if (nlhs>2)
mexErrMsgTxt("Too many output arguments!");
datalen = mxGetN(prhs);
rlen = mxGetN(prhs);
m = mxGetScalar(prhs);
delay = mxGetScalar(prhs);
//define the two output arguments
plhs = mxCreateDoubleMatrix(1,rlen,mxREAL);
plhs = mxCreateDoubleMatrix(1,rlen,mxREAL);
data = mxGetPr(prhs);
r = mxGetPr(prhs);
ln_C = mxGetPr(plhs);
ln_r = mxGetPr(plhs);
G_P(data,r,datalen,m,rlen,delay,ln_C,ln_r);
}
这是错误提示:
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Linking...
Cpp1.obj : error LNK2001: unresolved external symbol _mxGetPr
Cpp1.obj : error LNK2001: unresolved external symbol _mxCreateDoubleMatrix
Cpp1.obj : error LNK2001: unresolved external symbol _mxGetScalar
Cpp1.obj : error LNK2001: unresolved external symbol _mxGetN
Cpp1.obj : error LNK2001: unresolved external symbol _mexErrMsgTxt
LIBCD.lib(crt0.obj) : error LNK2001: unresolved external symbol _main
Debug/Cpp1.exe : fatal error LNK1120: 6 unresolved externals
Error executing link.exe.
Cpp1.exe - 7 error(s), 0 warning(s)
各个们,这是什么原因啊?帮帮我,谢谢了 int M 这一行分开两行,int M;然后M=。。。,并且将int M放到double distance的上面或者下面,看看行不行?
回复 沙发 胡晓宇 的帖子
不好意思,这个程序是在matlab调用下进行的,int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]这几个参数分别是输出参数的个数,输出参数的mxarray数组,输入参数的个数,输入参数的mxarray数组。只是我不知道参数的mxarray数组的输入,因为data,m,delay ,r的数组的维数是不相同的,所以一直在郁闷中,感觉我自己的理解是错误的,不知道你能帮我解决下嘛?谢谢!
页:
[1]