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

📄 fdmmain2.cc

📁 C++ source code for book-C++ and Object Oriented Numeric computing for scientists and engineers
💻 CC
字号:
// file fdmmain2.cc


/* *****  to compile
   g++ matvec.cc fdmmain2.cc
 */

#include "fdm.h"
#include "fdm.cc"
#include "fdmfndef2.cc"

complex<double> exact(double x, double y) {
  return exp((0, x+y));
}

int main() {
  double a = 0, b = 1, c = 0, d = 1;    // domain
  int nx = 50, ny = 50;                 // number of nodes

  fdm<double, complex<double> > pb(a, b, c, d, nx, ny);
  cout << "residual in solving linear system (two norm) = " 
       << pb.BandSolve() << '\n';

  double er = 0, er2 = 0;
  for (int j=0; j < ny; j++) {
    for (int i=0; i < nx; i++) {
      complex<double> exvu = exact(a+i*pb.hx, c+j*pb.hy);
      er = max(er, abs(pb.v[i + nx*j] - exvu));
      er2 = max(er2,abs(exvu));
    }
  }
  cout << "relative FDM true error(max norm)= " << er/er2;
} // end fdmmain2()

⌨️ 快捷键说明

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