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

📄 xsprstp.cpp

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

// Driver for routine sprstp

int main(void)
{
        const int NP=5,NMAX=2*NP*NP+1;
        int i,j;
        const DP a_d[NP*NP]=
          {3.0,0.0,1.0,0.0,0.0,
          0.0,4.0,0.0,0.0,0.0,
          0.0,7.0,5.0,9.0,0.0,
          0.0,0.0,0.0,0.0,2.0,
          0.0,0.0,0.0,6.0,5.0};
        Vec_INT ija(NMAX),ijat(NMAX);
        Vec_DP sa(NMAX),sat(NMAX);
        Mat_DP at(NP,NP),a(a_d,NP,NP);

        NR::sprsin(a,0.5,sa,ija);
        NR::sprstp(sa,ija,sat,ijat);
        for (i=0;i<NP;i++)
          for (j=0;j<NP;j++) at[i][j]=0.0;
        for (i=0;i<NP;i++) {
          at[i][i]=sat[i];
          for (j=ijat[i];j<ijat[i+1];j++) at[i][ijat[j]]=sat[j];
        }
        cout << fixed << setprecision(2);
        cout << "Original Matrix" << endl;
        for (i=0;i<NP;i++) {
          for (j=0;j<NP;j++) cout << setw(6) << a[i][j];
          cout << endl;
        }
        cout << endl << "Transpose" << endl;
        for (i=0;i<NP;i++) {
          for (j=0;j<NP;j++) cout << setw(6) << at[i][j];
          cout << endl;
        }
        return 0;
}

⌨️ 快捷键说明

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