主题:[讨论]积分函数
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <dir.h>
#include <io.h>
#include <math.h>
#include <iostream.h>
#include <bcd.h>
#include <complex.h>
complex i;
#define i complex(0.,1.)
#define h 0.001
#define pi 3.1415926
double beta=1.0;
double wc,w1c;
complex x1;
double t;
complex (*f)();
complex lags(x1)
[color=FF0000]{[/color] [color=FF00FF]运行时老是说这边declaration syntax error[/color]
int k;
f=x1;
static double b[5]={0.26355990, 1.41340290, 3.59642600, 7.08580990, 12.64080000};
static double c[5]={0.6790941054, 1.638487956, 2.769426772, 4.315944000, 7.104896230};
complex g=0.0;
for( k=0;k<=4;k++)
{
xx=b[k];
g=g+c[k]*(*f)(xx);
}
return (g);
}
// -----------------------------------------------
void main()
{
//参数设置--------------
wc=100.0*beta;
w1c=0.0*beta;
//----------------------
FILE *fp1;
if((fp1=fopen("entropy.dat","wt"))==NULL)
{
printf("can not open file\n");
exit(0);
}
complex lagsf(double);
for(t=0.0000001;t<=50.0;)
{
complex At; //////////////////
At=exp(i*beta*(4.330959e+01)*t)/(1.0+pow(beta,1.5)/2.0/pow((sqrt(wc)+pow(-i*(i*beta*(4.330959e+01))-w1c,0.5)),2.0)/pow(-i*(i*beta*(4.330959e+01))-w1c,0.5))+[color=FF00FF]exp(i*w1c*t)/pi*lags(lagsf);[/color] [color=FF0000]此外调用积分函数[/color]
double Pu; // the upper-level population
Pu=norm(At);
//entropy------------------------------------------------------------
//-------------------------------------------------------------------
fprintf(fp1,"%e\t%e\n",t,Pu);
t=t+h;
}
}
complex lagsf(x) //被积函数f1(x)
{ double x;
complex y;
y=pow(i*x*beta*beta*beta,0.5)*(wc-i*x)*exp(-x*t)/(pow((i*w1c-x)*(wc-i*x)-i*pow(beta*beta*beta*wc,0.5),2.0)+i*beta*beta*beta*x);
return y;
}
请各位大侠帮忙看一下,主要是那边调用积分函数有问题,望高手指点下,看我编的求积分函数是否有问题,谢谢
#include <stdlib.h>
#include <string.h>
#include <dir.h>
#include <io.h>
#include <math.h>
#include <iostream.h>
#include <bcd.h>
#include <complex.h>
complex i;
#define i complex(0.,1.)
#define h 0.001
#define pi 3.1415926
double beta=1.0;
double wc,w1c;
complex x1;
double t;
complex (*f)();
complex lags(x1)
[color=FF0000]{[/color] [color=FF00FF]运行时老是说这边declaration syntax error[/color]
int k;
f=x1;
static double b[5]={0.26355990, 1.41340290, 3.59642600, 7.08580990, 12.64080000};
static double c[5]={0.6790941054, 1.638487956, 2.769426772, 4.315944000, 7.104896230};
complex g=0.0;
for( k=0;k<=4;k++)
{
xx=b[k];
g=g+c[k]*(*f)(xx);
}
return (g);
}
// -----------------------------------------------
void main()
{
//参数设置--------------
wc=100.0*beta;
w1c=0.0*beta;
//----------------------
FILE *fp1;
if((fp1=fopen("entropy.dat","wt"))==NULL)
{
printf("can not open file\n");
exit(0);
}
complex lagsf(double);
for(t=0.0000001;t<=50.0;)
{
complex At; //////////////////
At=exp(i*beta*(4.330959e+01)*t)/(1.0+pow(beta,1.5)/2.0/pow((sqrt(wc)+pow(-i*(i*beta*(4.330959e+01))-w1c,0.5)),2.0)/pow(-i*(i*beta*(4.330959e+01))-w1c,0.5))+[color=FF00FF]exp(i*w1c*t)/pi*lags(lagsf);[/color] [color=FF0000]此外调用积分函数[/color]
double Pu; // the upper-level population
Pu=norm(At);
//entropy------------------------------------------------------------
//-------------------------------------------------------------------
fprintf(fp1,"%e\t%e\n",t,Pu);
t=t+h;
}
}
complex lagsf(x) //被积函数f1(x)
{ double x;
complex y;
y=pow(i*x*beta*beta*beta,0.5)*(wc-i*x)*exp(-x*t)/(pow((i*w1c-x)*(wc-i*x)-i*pow(beta*beta*beta*wc,0.5),2.0)+i*beta*beta*beta*x);
return y;
}
请各位大侠帮忙看一下,主要是那边调用积分函数有问题,望高手指点下,看我编的求积分函数是否有问题,谢谢