⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 model.cc

📁 一个统计模块的C++源程序!应该能用到的!
💻 CC
字号:
#include "model.h"

model::model() { }

model::~model() { }


realmat model::e(INTEGER t)
{
  realmat et(1,1);
  REAL    a,b,yta,yt,xt;
  INTEGER i;

  i=t+2;
  
  yt = (nds[i]/pop[i])/(nds[i-1]/pop[i-1]);
  xt = (1.0+nyse[i])*(dflat[i-1]/dflat[i]);

  a=s.theta[1];
  b=s.theta[2];

  yta = pow(yt,a);

  et[1] = b * yta * xt - 1.0;

  return et;
}

realmat model::dele(INTEGER t) 
{
  realmat derqt(1,2);

  REAL    a,b,yta,yt,xt;
  INTEGER i;

  i=t+2;
  
  yt = (nds[i]/pop[i])/(nds[i-1]/pop[i-1]);
  xt = (1.0+nyse[i])*(dflat[i-1]/dflat[i]);

  a=s.theta[1];
  b=s.theta[2];

  yta = pow(yt,a);

  derqt.elem(1,1) = b * log(yt) * yta * xt;

  derqt.elem(1,2) = yta*xt;

  return derqt;

}


int model::initialize()
{
  INTEGER i;
  double tmp;

#ifdef  GNU_GPP_COMPILER
#ifdef  USE_ATT_STYLE_IO_WITH_GNU

  filebuf cdata_buf;
  if (cdata_buf.open("hansen.dat",input) ==0) {
    cerr << "Error, model::model, Cannot open hansen.dat.\n";
    exit(1);
  }
  istream cdata(&cdata_buf);

#endif

#ifdef  USE_GNU_STYLE_IO_WITH_GNU

  istream cdata("hansen.dat",io_readonly,a_useonly);
  if ( !cdata ) {
    cerr << "Error, model::model, Cannot open hansen.dat.\n";
    exit(1);
  }

#endif

#endif

#ifdef  TURBO_CPP_COMPILER

  ifstream cdata("hansen.dat");
  if (!cdata) {
    cerr << "Error, model::model, Cannot open hansen.dat.\n";
    exit(1);
  }

#endif


  for (i=1; i<=240; i++) {
    cdata >> tmp; nds[i]=(REAL)tmp;
    cdata >> tmp; pop[i]=(REAL)tmp;
    cdata >> tmp; nyse[i]=(REAL)tmp;
    cdata >> tmp; dflat[i]=(REAL)tmp;
  }

  return 1;
}

realmat model::Z(INTEGER t)
{
  INTEGER i;

  i=t+2;

  realmat z(3,1);

  z[1]=1.0;
  z[2]=(nds[i-1]/pop[i-1])/(nds[i-2]/pop[i-2]);
  z[3]=(1.0+nyse[i-1])*(dflat[i-2]/dflat[i-1]);

  return z;
}

int model::terminate() { return 0; }





⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -