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

📄 xavevar.cpp

📁 这是C++数值算法(第二版)的源代码,其中包含了目前一些比较常用的数值计算的算法.
💻 CPP
字号:
#include <iostream>
#include <iomanip>
#include "nr.h"
using namespace std;

// Driver for routine avevar

int main(void)
{
        const int NPTS=10000;
        const DP EPS=0.1;
        int i,j,idum=(-5);
        DP ave,shift,vrnce;
        Vec_DP data(NPTS);

        // generate gaussian distributed data
        cout << endl << setw(9) << "shift" << setw(12) << "average";
        cout << setw(13) << "variance" << endl;
        cout << fixed << setprecision(2);
        for (i=0;i<11;i++) {
          shift=i*EPS;
          for (j=0;j<NPTS;j++)
            data[j]=shift+(i+1)*NR::gasdev(idum);
          NR::avevar(data,ave,vrnce);
          cout << setw(8) << shift << setw(12) << ave;
          cout << setw(13) << vrnce << endl;
        }
        return 0;
}

⌨️ 快捷键说明

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