[問題] VC++ 2008中 C3867 函式呼叫遺漏引數清單
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++ 2008
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
newt.cpp
問題(Question):
我在form1的設計中想使用 NR::newt(fg2,check, fkfun);
這個在.cpp檔中可compiler過的
但拿到form.h中使用就變成有下面的錯誤
error C3867: 'FindRoot::Form1::fkfun': 函式呼叫遺漏引數清單,請用
'&FindRoot::Form1::fkfun' 建立成員的指標
有沒有人知道如何改呢?感謝
餵入的資料(Input):
預期的正確結果(Expected Output):
錯誤結果(Wrong Output):
程式碼(Code):(請善用置底文網頁, 記得排版)
void fkfun(Vec_I_DP &a,Vec_O_DP &f)
{
f[0]=5+a[0]-2*a[1];
f[1]=5*a[0]+a[1]-3;
}
private: System::Void button1_Click(System::Object^ sender,
System::EventArgs^ e) {
float at,bt,ct;
Vec_DP fg2(2),fr2(2);
bool check;
fg2[0]=0;
fg2[1]=0;
NR::newt(fg2,check, fkfun);
fkfun(fg2,fr2);
at = fg2[0];
bt = fg2[1];
ct = bt;
}
補充說明(Supplement):
void NR::newt(Vec_IO_DP &x, bool &check, void vecfunc(Vec_I_DP &, Vec_O_DP &))
{
const int MAXITS=300;
const DP TOLF=1.0e-6,TOLMIN=1.0e-12,STPMX=100.0;
const DP TOLX=numeric_limits<DP>::epsilon();
int i,j,its;
DP d,den,f,fold,stpmax,sum,temp,test;
int n=x.size();
Vec_INT indx(n);
Vec_DP g(n),p(n),xold(n);
Mat_DP fjac(n,n);
fvec_p=new Vec_DP(n);
nrfuncv=vecfunc;
Vec_DP &fvec=*fvec_p;
f=fmin(x);
test=0.0;
for (i=0;i<n;i++)
if (fabs(fvec[i]) > test) test=fabs(fvec[i]);
if (test < 0.01*TOLF) {
check=false;
delete fvec_p;
return;
}
sum=0.0;
for (i=0;i<n;i++) sum += SQR(x[i]);
stpmax=STPMX*MAX(sqrt(sum),DP(n));
for (its=0;its<MAXITS;its++) {
fdjac(x,fvec,fjac,vecfunc);
for (i=0;i<n;i++) {
sum=0.0;
for (j=0;j<n;j++) sum += fjac[j][i]*fvec[j];
g[i]=sum;
}
for (i=0;i<n;i++) xold[i]=x[i];
fold=f;
for (i=0;i<n;i++) p[i] = -fvec[i];
ludcmp(fjac,indx,d);
lubksb(fjac,indx,p);
lnsrch(xold,fold,g,p,x,f,stpmax,check,fmin);
test=0.0;
for (i=0;i<n;i++)
if (fabs(fvec[i]) > test) test=fabs(fvec[i]);
if (test < TOLF) {
check=false;
delete fvec_p;
return;
}
if (check) {
test=0.0;
den=MAX(f,0.5*n);
for (i=0;i<n;i++) {
temp=fabs(g[i])*MAX(fabs(x[i]),1.0)/den;
if (temp > test) test=temp;
}
check=(test < TOLMIN);
delete fvec_p;
return;
}
test=0.0;
for (i=0;i<n;i++) {
temp=(fabs(x[i]-xold[i]))/MAX(fabs(x[i]),1.0);
if (temp > test) test=temp;
}
if (test < TOLX) {
delete fvec_p;
return;
}
}
nrerror("MAXITS exceeded in newt");
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.123.124.127
→
07/20 12:48, , 1F
07/20 12:48, 1F
→
07/20 12:59, , 2F
07/20 12:59, 2F
→
07/20 13:06, , 3F
07/20 13:06, 3F
→
07/20 13:08, , 4F
07/20 13:08, 4F
→
07/20 13:48, , 5F
07/20 13:48, 5F
→
07/20 13:53, , 6F
07/20 13:53, 6F
→
07/20 20:35, , 7F
07/20 20:35, 7F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章