#include #include #include "nr.h" using namespace std; // Driver for routine jacobi int main(void) { const int NMAT=3; DP a_d[3*3]= {1.0,2.0,3.0, 2.0,2.0,3.0, 3.0,3.0,3.0}; DP b_d[5*5]= {-2.0,-1.0,0.0,1.0,2.0, -1.0,-1.0,0.0,1.0,2.0, 0.0,0.0,0.0,1.0,2.0, 1.0,1.0,1.0,1.0,2.0, 2.0,2.0,2.0,2.0,2.0}; DP c_d[10*10]= {5.0,4.3,3.0,2.0,1.0,0.0,-1.0,-2.0,-3.0,-4.0, 4.3,5.1,4.0,3.0,2.0,1.0,0.0,-1.0,-2.0,-3.0, 3.0,4.0,5.0,4.0,3.0,2.0,1.0,0.0,-1.0,-2.0, 2.0,3.0,4.0,5.0,4.0,3.0,2.0,1.0,0.0,-1.0, 1.0,2.0,3.0,4.0,5.0,4.0,3.0,2.0,1.0,0.0, 0.0,1.0,2.0,3.0,4.0,5.0,4.0,3.0,2.0,1.0, -1.0,0.0,1.0,2.0,3.0,4.0,5.0,4.0,3.0,2.0, -2.0,-1.0,0.0,1.0,2.0,3.0,4.0,5.0,4.0,3.0, -3.0,-2.0,-1.0,0.0,1.0,2.0,3.0,4.0,5.0,4.0, -4.0,-3.0,-2.0,-1.0,0.0,1.0,2.0,3.0,4.0,5.0}; int i,j,k,l,kk,ll,nrot; int num[3]={3,5,10}; Mat_DP a(a_d,3,3),b(b_d,5,5),c(c_d,10,10); Mat_DP e[3]={a,b,c}; cout << fixed << setprecision(6); for (i=0;i l) { kk=l; ll=k; } else { kk=k; ll=l; } r[l] += (e[i][ll][kk]*v[k][j]); } } cout << "vector number " << (j+1) << endl; cout << setw(11) << "vector" << setw(14) << "mtrx*vec."; cout << setw(10) << "ratio" << endl; for (l=0;l