请求高手帮忙看看这个程序那里不对!

DECEL27 2012-01-09 10:15:35
/* Used for prediction from a time series based on the reconstruction of
phase space.(一阶局域法) */
#include<iostream.h>
#include<math.h>
#include<fstream.h>

#define N 8000
#define e 2.7182818281828
#define L 40 //代表需要寻找的邻域的点数,一般选取L>Dim+1即可。
#define Dim 5 //Dimention of the reconstructed phase space.

double y[N];
double Tau=5;
//*****************************************************************************************
double Cal_Lenth(int p1,int p2,int dim,int tau) //Calculate the distance between p1 and p2
{ //dim is the dimension of reconstruction,
double Lenth=0.0; //tau is the the time delay in the reconstruction.
for(int i=0;i<=dim-1;i++)
{
int t=i*tau;
Lenth=Lenth+(y[p1+t]-y[p2+t])*(y[p1+t]-y[p2+t]);
}
return Lenth=sqrt(Lenth);
}

//******************************************************************************************

void main()
{
int i=0;
ifstream fin; //Read from the data source file.
fin.open("the source.txt",ios::in|ios::nocreate);
while(!fin.eof())
{
fin>>y[i];
i++;
}
int n=i-1;
if (n>N) cout<<"Not enogh space for time series."<<endl;
cout<<"The totle number of data: N="<<n<<endl;
cout<<"There is ("<<n-(Dim-1)*Tau<<") points in the reconstructed phase space."<<endl;
cout<<"The last point(center point) is: (";
for(i=Dim;i=1;i--) {cout<<y[n-(i-1)*Tau];}
cout<<")."<<endl;
fin.close();

int Npoint[L],Cpoint=n-(Dim-1)*Tau;
double Nlenth[L],P[L]; //Nlenth[]为各近邻点到中心点的距离,P[]为各点的权值。
for(i=0;i<L;i++) {Nlenth[i]=1000;}
for(i=0;i<n-(Dim-1)*Tau;i++) //Find nearest neighbors (Npoint[Dim]) to the last data point.
{
double D=Cal_Lenth(Cpoint,i,Dim,Tau);
for(int j=0;j<L;j++)
{
int Flag=0;
if(D<=Nlenth[j])
{
for(k=L-1;k>j;k--) {Nlenth[k]=Nlenth[k-1];Npoint[k]=Npoint[k-1];}
Nlenth[j]=D;
Npoint[j]=i;
Flag=1;
}
if(Flag==1) break;
}
}
//******************the L nearest points have been found.************************

double Temp=0; //计算各点的权值,保存到P[]中。
for(i=0;i<L;i++)
{
P[i]=Nlenth[0]-Nlenth[i];
P[i]=pow(e,P[i]);
Temp=Temp+P[i];
}
for(i=0;i<L;i++) {P[i]=P[i]/Temp;}

}
...全文
68 回复 打赏 收藏 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
代码下载链接: https://pan.quark.cn/s/a4b39357ea24 用户账户控制(UAC)白名单的配置 Windows7环境中 UAC(User Account Control,用户帐户控制)是由微软在Windows Vista版本中推出的一项旨在增强系统安全性的创新技术,该技术强制要求用户在执行可能干扰计算机正常运作的操作或进行更改会波及其他用户设置的变动前,必须提供相应的权限或管理员密码进行验证。通过对这些操作启动前进行授权确认,UAC能够有效阻止恶意软件及间谍软件在未获授权的状态下于计算机内进行安装或实施修改。 自从Vista版本问世以来,微软便开始推行这一全新的安全机制,可视为对系统安全防护的显著提升。尽管UAC确实能够在一定程度上对某些非法程序起到防御作用,但与此同时,这一功能也给众多用户带来了诸多不便。 因此,许多用户开始探寻是否存在类似于白名单的功能,以便将那些值得信赖的程序直接赋予运行权限。事实上,这类功能确实存在,不过微软并未将其作为标准配置提供。 网络上关于此问题的绝大多数建议都是建议禁用UAC,这种说法显然缺乏针对性,因为若用户希望禁用此功能,本就不会提出相关疑问。 通过运用微软官方发布的Microsoft Application Compatibility Toolkit 5.6版本,可以将信任的程序纳入系统白名单范畴。 获取Application Compatibility Toolkit 安装程序成功后会出现三个可执行文件 以管理员身份启动Compatibility Administrator 在Custom DataBases部分创建新的数据库,并添加一个Application Fix(在下方空白处点击右键,选择...

1,979

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 其他语言讨论
社区管理员
  • 其他语言社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧