#include "band.h" #include int main(){ bandMatrix A(4,1); vector x(4,0.0), y(4,0.0); int i,j; for( i=0; i<4; i++) A(i,i) = 4.0+0.1*i; for( i=0; i<3; i++){ A(i,i+1) = -1-0.2*i; A(i+1,i) = -1-0.3*i; } cout << "The matrix A is \n" << A; for( i=0; i<4; i++) x[i] = 1+i; y = A*x; cout << "The answers should be \n" << x; cout << "The rhs is \n" << y; cout << "The answers are \n" << solve(A,y); bandMatrix B(4,2); for( i=0; i<4; i++) B(i,i) = 4.0+0.1*i; for( i=0; i<3; i++){ B(i,i+1) = -1-0.2*i; B(i+1,i) = -1-0.3*i; } for( i=0; i<2; i++){ B(i,i+2) = -0.1-0.02*i; B(i+2,i) = -0.1-0.03*i; } cout << "The matrix B is \n" << B; for( i=0; i<4; i++) x[i] = 1+i; y = B*x; cout << "The answers should be \n" << x; cout << "The rhs is \n" << y; cout << "The answers are \n" << solve(B,y); bandMatrix C(4,3); for( i=0; i<4; i++) C(i,i) = 4.0+0.1*i; for( i=0; i<3; i++){ C(i,i+1) = -1-0.2*i; C(i+1,i) = -1-0.3*i; } for( i=0; i<2; i++){ C(i,i+2) = -0.1-0.02*i; C(i+2,i) = -0.1-0.03*i; } C(0,3) = 0.04; C(3,0) = 0.05; cout << "The matrix C is \n" << C; for( i=0; i<4; i++) x[i] = 1+i; y = C*x; cout << "The answers should be \n" << x; cout << "The rhs is \n" << y; cout << "The answers are \n" << solve(C,y); }