#include #include #include typedef void (*MatrixAction) (double*, double*, int n); double SCALE = 1; /**************************** Some Usefull One-Liners *******************/ // y = alpha*x (x,y - vectors, alpha - scalar) inline void vector_copy(double *y, double *x, int n, double alpha = 1.0) { for(int i=0; i> SCALE; int CHEB = 0; std::cout << "Enter 1 for Chebyshev Acceleration or 0" "for the standard Richardson iteration: "; std::cin >> CHEB; if (CHEB) { double *c = new double[n]; c[0]=-SCALE*4; c[1]=0; c[2]=SCALE*4; c[3]=-SCALE*4; double *x = new double[n]; x[0]=0; x[1]=0; x[2]=0; x[3]=0; std::cout << "******* Chebyshev Acceleration " " of the Richardson Method ******" << std::endl; iter = solveCheb(myMatrix, c, x, n, 1-6*SCALE, 1-2*SCALE); delete c; delete x; } else { double *c = new double[n]; c[0]=-SCALE*4; c[1]=0; c[2]=SCALE*4; c[3]=-SCALE*4; double *x = new double[n]; x[0]=0; x[1]=0; x[2]=0; x[3]=0; double *temp = new double[n]; std::cout << "******* The Standard Version of " " the Richardson Method ******" << std::endl; std::cout << "Enter the number of iterations: "; std::cin >> iter; for (int i=0; i