#include #include "MatrixT.h" #include #include using namespace std; using namespace chrono; const int ROWS{500}; const int SAME{300}; const int COLS{700}; #ifdef USE_DYNAMIC_MATRIX using MatrixT = MatrixDT; string NAME="Dynamic Matrix"; #else using MatrixT = MatrixVT; string NAME="Vector Matrix"; #endif ostream & operator << (ostream & s, const MatrixT & m) { for(size_t r = 0; r < m.Rows(); ++r) { for(size_t c = 0; c < m.Cols(); ++c) { s << m[r,c] << " "; } s << endl; } return s; } int main() { double totalTime = 0; cout << "Using matrix " << NAME << endl; cout << "Multiplying " << ROWS << "X" << SAME << " by " << SAME << "X" << COLS << endl; for(int i = 0; i < 10; ++i) { auto start = high_resolution_clock::now(); MatrixT a{ROWS, SAME}; MatrixT b{SAME, COLS}; MakeRandomMatrix(a); MakeRandomMatrix(b); MatrixT c = a * b; auto end = high_resolution_clock::now(); cout << "Time: " << duration(end - start).count() << " seconds\n"; totalTime += duration(end - start).count(); } cout << " Average Time " << totalTime/ 10 << " seconds" << endl; return 0; }