#define _CheckBounds #include #include #include #include #include using namespace std; #include "ToString.cpp" #include "Timer.cpp" #include "Vector.cpp" #include "Matrix.cpp" #include "PrintOp.cpp" /* Loop has wrong order */ void Prod1(Vector &y, const Matrix &A, const Vector &x); void Prod1(Vector &y, const Matrix &A, const Vector &x) { int m = A.Rows(); int n = A.Cols(); for(int i=0; i &y, const Matrix &A, const Vector &x); void Prod2(Vector &y, const Matrix &A, const Vector &x) { int m = A.Rows(); int n = A.Cols(); for(int i=0; i &y, const Matrix &A, const Vector &x); void Prod3(Vector &y, const Matrix &A, const Vector &x) { int m = A.Rows(); int n = A.Cols(); for(int i=0; i &y, const Matrix &A, const Vector &x); void Prod4(Vector &y, const Matrix &A, const Vector &x) { int m = A.Rows(); int n = A.Cols(); double *y1 = y.Begin(); const double *A1 = A.Begin(); for(int i=0; i &y, const Matrix &A, const Vector &x); void Prod5(Vector &y, const Matrix &A, const Vector &x) { int m = A.Rows(); int n = A.Cols(); double *y1 = y.Begin(); const double *A1 = A.Begin(); for(int i=0; i x(n,3.0); Matrix A(m,n,0.001); Vector y1(m); Vector y2(m); Vector y3(m); Vector y4(m); Vector y5(m); Vector y6(m); Timer tm1; tm1.PrintLevel = 0; tm1.Start(); Prod1(y1,A,x); cout << "Cpu Time Used, Prod1: " << tm1.Stop() << "\n"; cout << "y1(0): " << y1(0) << "\n"; Timer tm2; tm2.PrintLevel = 0; tm2.Start(); Prod2(y2,A,x); cout << "Cpu Time Used, Prod2: " << tm2.Stop() << "\n"; cout << "y2(0): " << y2(0) << "\n"; Timer tm3; tm3.PrintLevel = 0; tm3.Start(); Prod3(y3,A,x); cout << "Cpu Time Used, Prod3: " << tm3.Stop() << "\n"; cout << "y3(0): " << y3(0) << "\n"; Timer tm4; tm4.PrintLevel = 0; tm4.Start(); Prod4(y4,A,x); cout << "Cpu Time Used, Prod4: " << tm4.Stop() << "\n"; cout << "y4(0): " << y4(0) << "\n"; Timer tm5; tm5.PrintLevel = 0; tm5.Start(); Prod5(y5,A,x); cout << "Cpu Time Used, Prod5: " << tm5.Stop() << "\n"; cout << "y5(0): " << y5(0) << "\n"; cout << "End"; return 0; }