锘??xml version="1.0" encoding="utf-8" standalone="yes"?>青青草原综合久久大伊人精品,国产精品免费福利久久,亚洲成色www久久网站夜月http://www.shnenglu.com/newplan/archive/2008/05/07/49127.html灞辨硥寮歡灞辨硥寮歡Wed, 07 May 2008 07:05:00 GMThttp://www.shnenglu.com/newplan/archive/2008/05/07/49127.htmlhttp://www.shnenglu.com/newplan/comments/49127.htmlhttp://www.shnenglu.com/newplan/archive/2008/05/07/49127.html#Feedback0http://www.shnenglu.com/newplan/comments/commentRss/49127.htmlhttp://www.shnenglu.com/newplan/services/trackbacks/49127.html/*
Romberg Algorithm 
寮鍙戣?newplan
寮鍙戞棩鏈?
08.05.07 
*/


/*=======================================*/
/*INCLUDES*/ 
#include           
<cstdlib>
#include           
<iostream>
#include           
<cmath>
/*=======================================*/
/*MACROS  USED IN THIS FILE*/
#define            MAX       
20   
#define            PRECISION 
0.000008
/*=======================================*/
/*DECLARE NAMES IN STL NAMESAPCE */
using  std::cout;
using  std::endl;

/*=======================================*/
/*CLASS FUNC (FUNCTION OBJECT): THE ORIGINAL FUNCTION WE WANT TO INTEGRAL*/
class  func{
       
public:
              func(
double x=1.0):exp(x){}
              
double operator()(const double& dnum)const{return pow(dnum,exp);}
       
private:
              
double exp;
       };
/*=======================================*/
/*CLASS ECHELONFUNC (FUNCTION OBJECT)姊艦娉曠殑閫掓帹鍏紡*/
class  echelonFunc{
       
public:
              echelonFunc(
double begining,double ending,func & myfunc);
              
double operator()();
       
private:
               
double    h;
               
int       n;
               
double    T;
               func      myfunc;
               
double    begining;
               
double    ending ;
     };
/*=======================================*/
echelonFunc::echelonFunc(
double begining,double ending,func & myfunc)
              {
               this
->begining=begining;
               this
->ending=ending;
               this
->h=ending-begining;
               this
->n=0;
               this
->T=0;
               this
->myfunc=myfunc;//FUCNTION 
              }
/*------------------------------*/
/* INCREASE FUNCTION 閫掓帹鍑芥暟*/
double echelonFunc::operator()()
              {   
if(this->n==0)
                  {
                   this
->T=h*0.5*(myfunc(this->begining)+myfunc(this->ending));
                   this
->n=1;
                   return this
->T;
                  }
                  
double len=0.5*h;
                  
double sum=0;
                  
int k=0;
                  
for(k=0;k<this->n;k++)
                      {
                       sum
+=myfunc(len);
                       
len=len+h;
                      }
                  this
->T=0.5*this->T+0.5*h*sum;
                  this
->h/=2;
                  this
->n*=2;
                  return this
->T;
              }
/*=======================================*/
/*THE MAIN CLASS IN THIS PROGRAM*/ 
class  Romberg{
       
public:
              Romberg(
double begining,double ending,double exp);
              ~Romberg();
       
private:
              void RombergCPU();
/*THE MOST IMPORTANT FUNCTION IN THIS PROGRAM*/
              echelonFunc 
*echol; 
              
double T[MAX][MAX];/*STO THE ROMBERG TABLE*/       
       };
/*------------------------------*/
Romberg::Romberg(
double begining ,double ending ,double paraexp)
{
    func     myfunc(paraexp);
    echol 
=  new echelonFunc(begining,ending,myfunc);
    RombergCPU();
}
/*------------------------------*/
Romberg::~Romberg()
{
     delete echol;
}
/*------------------------------*/
void Romberg::RombergCPU()
{   clock_t Start; 
//TIME STARAT
    clock_t 
End;   //TIME END
    
double *p[MAX];//WE USE THIS POINTER ARRAY TO ACCELERATE ALGOTITHM
    
double **q;
    
int i,j;
    Start 
= clock();//TIME START FROM HERE
    
for(i = 0,q = p; q < p+MAX; q++,i++)
        
*q= &T[i][0];
    
double a,b,pows; 
    cout
<<"-----------------------Romberg Algorithm---------------------"<<endl;
    
*p[0]=(*echol)();
    cout
<<"  "<<*p[0]<<endl;
    p[
0]++;
    
do{
       
*p[0]=(*echol)();
        cout
<<"  "<<*p[0];
        p[
0]++;
        
for(i=1;;i++)
                  {
                    pows
=pow(4.0,double(i));
                    a
=pows/(pows-1);
                    b
=1/(pows-1);
                    
*p[i]=a*(*(p[i-1]-1))-b*(*(p[i-1]-2));//ROMBERG ALGORITHM
                    cout
<<"  "<<*p[i];
                    
if(p[i]==&T[i][0])
                      {
                      p[i]
++
                      break;
                      } 
                     p[i]
++;
                   }
                   cout
<<endl;//fabs(T[i][0]-T[i-1][0])
       }
while(fabs(T[i][0]-T[i-1][0])>PRECISION);
    
    
End = clock();//TIME END HERE
    
    cout
<<"-------------------------------------------------------------"<<
    endl
<<"  TIME SPEND:"<<(double)(End-Start)/CLOCKS_PER_SEC<<endl; 

/*=======================================*/
/*MAIN FUNCTION*/
int main(int argc, char *argv[])
{  
   Romberg  romberg(
0,1,1.5);//ROMBERG API :BEGIN(0END(1EXP(1.5)
   system(
"PAUSE");
   return EXIT_SUCCESS;
}


灞辨硥寮歡 2008-05-07 15:05 鍙戣〃璇勮
]]>
亚洲人成无码网站久久99热国产| 久久水蜜桃亚洲av无码精品麻豆| 日本久久久久久中文字幕| 精品精品国产自在久久高清| 欧美精品一区二区精品久久 | 丰满少妇人妻久久久久久| 久久国产精品-久久精品| 久久亚洲国产成人精品无码区| 久久99这里只有精品国产| 91久久精一区二区三区大全| 久久精品国产亚洲精品| 久久综合给合久久狠狠狠97色| 国产成人精品久久亚洲| 亚洲人成精品久久久久| 久久93精品国产91久久综合| 欧洲人妻丰满av无码久久不卡 | 伊人久久免费视频| 一级A毛片免费观看久久精品| 亚洲国产成人久久精品影视| 亚洲精品高清国产一线久久| 看全色黄大色大片免费久久久| 久久久亚洲欧洲日产国码二区| 免费精品国产日韩热久久| 久久亚洲国产中v天仙www| 久久久亚洲欧洲日产国码是AV| 中文字幕亚洲综合久久2| 久久精品99久久香蕉国产色戒| 欧美日韩精品久久免费| 三级片免费观看久久| 久久成人18免费网站| 精品久久综合1区2区3区激情| 亚洲欧美精品伊人久久| 久久美女人爽女人爽| 青青草原综合久久大伊人精品| 亚洲国产精品18久久久久久| 狠狠色丁香久久婷婷综合| 久久久一本精品99久久精品88| 久久人人青草97香蕉| 亚洲伊人久久大香线蕉综合图片| 久久乐国产综合亚洲精品| 精品人妻伦九区久久AAA片69|