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

📄 xsplie2.cpp

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

// Driver for routine splie2

int main(void)
{
        const int M=10,N=10;
        int i,j;
        DP x1x2;
        Vec_DP x1(N),x2(N);
        Mat_DP y(M,N),y2(M,N);

        for (i=0;i<M;i++) x1[i]=0.2*(i+1);
        for (i=0;i<N;i++) x2[i]=0.2*(i+1);
        for (i=0;i<M;i++)
          for (j=0;j<N;j++) {
            x1x2=x1[i]*x2[j];
            y[i][j]=x1x2*x1x2;
          }
        NR::splie2(x1,x2,y,y2);
        cout << endl << "second derivatives from SPLIE2" << endl;
        cout << "natural spline assumed" << endl;
        cout << fixed << setprecision(6);
        for (i=0;i<5;i++) {
          for (j=0;j<5;j++) cout << setw(12) << y2[i][j];
          cout << endl;
        }
        cout << endl << "actual second derivatives" << endl;
        for (i=0;i<5;i++) {
          for (j=0;j<5;j++) cout << setw(12) << 2.0*x1[i]*x1[i];
          cout << endl;
        }
        return 0;
}

⌨️ 快捷键说明

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