// tsncom38.cc // Nick Macks (macks@fnal.gov), Summer 2002 // CovMatrices: VectorX * VectorX multiplication // vector form like in RowVector*ColumnVector #include #include "CovMatrices/Vector2.h" #include "CovMatrices/Vector3.h" #include "CovMatrices/Vector4.h" #include "CovMatrices/Vector5.h" #include "CovMatrices/Vector6.h" using namespace std; using CovMatrices::Vector2; using CovMatrices::Vector3; using CovMatrices::Vector4; using CovMatrices::Vector5; using CovMatrices::Vector6; // Function declarations void Identification(); void GetDimension(int&); void Describe(const int&); void BuildVector(vector&); void BuildVector2(Vector2&); void BuildVector3(Vector3&); void BuildVector4(Vector4&); void BuildVector5(Vector5&); void BuildVector6(Vector6&); void Show(const vector&, const vector&); void Show2(const Vector2&, const Vector2&); void Show3(const Vector3&, const Vector3&); void Show4(const Vector4&, const Vector4&); void Show5(const Vector5&, const Vector5&); void Show6(const Vector6&, const Vector6&); void GetCalcs(int&); void GetRuns(int&); void Calculate(vector&, vector&, const int&, const int&); void Calculate2(Vector2&, Vector2&, const int&, const int&); void Calculate3(Vector3&, Vector3&, const int&, const int&); void Calculate4(Vector4&, Vector4&, const int&, const int&); void Calculate5(Vector5&, Vector5&, const int&, const int&); void Calculate6(Vector6&, Vector6&, const int&, const int&); // Package ID void Identification() { cout << "Using CovMatrices\n"; } // Ask for the desired dimension void GetDimension(int& dimension) { cout << "Enter the desired dimension(1-6): "; cin >> dimension; while ( (dimension < 1) || (dimension > 6) ) { cout << "Enter an integer between 1 and 6: "; cin >> dimension; } } // Describe how the vectors were defined void Describe(const int& dimension) { if (dimension == 1) cout << "Vectors were defined 'vector'\n"; else cout << "Vectors were defined 'Vector" << dimension << "'\n"; } // Build a 1-dimensional Vector void BuildVector(vector& vector) { vector.push_back(2); } // Build a 2-dimensional Vector void BuildVector2(Vector2& vector2) { for (int i=0; i<2; ++i) { vector2[i] = 2 + 2*i; } } // Build a 3-dimensional Vector void BuildVector3(Vector3& vector3) { for (int i=0; i<3; ++i) { vector3[i] = 2 + 2*i; } } // Build a 4-dimensional Vector void BuildVector4(Vector4& vector4) { for (int i=0; i<4; ++i) { vector4[i] = 2 + 2*i; } } // Build a 5-dimensional Vector void BuildVector5(Vector5& vector5) { for (int i=0; i<5; ++i) { vector5[i] = 2 + 2*i; } } // Build a 6-dimensional Vector void BuildVector6(Vector6& vector6) { for (int i=0; i<6; ++i) { vector6[i] = 2 + 2*i; } } // Show the 1-dimensional vectors void Show(const vector& vector1, const vector& vector2) { cout << "Using vector =\n" << vector1[0] << "\n"; cout << "Using vector =\n" << vector2[0] << "\n"; } // Show the 2-dimensional vectors void Show2(const Vector2& vector1, const Vector2& vector2) { cout << "Using vector =\n" << vector1 << "\n"; cout << "Using vector =\n" << vector2 << "\n"; } // Show the 3-dimensional vectors void Show3(const Vector3& vector1, const Vector3& vector2) { cout << "Using vector =\n" << vector1 << "\n"; cout << "Using vector =\n" << vector2 << "\n"; } // Show the 4-dimensional vectors void Show4(const Vector4& vector1, const Vector4& vector2) { cout << "Using vector =\n" << vector1 << "\n"; cout << "Using vector =\n" << vector2 << "\n"; } // Show the 5-dimensional vectors void Show5(const Vector5& vector1, const Vector5& vector2) { cout << "Using vector =\n" << vector1 << "\n"; cout << "Using vector =\n" << vector2 << "\n"; } // Show the 6-dimensional vectors void Show6(const Vector6& vector1, const Vector6& vector2) { cout << "Using vector =\n" << vector1 << "\n"; cout << "Using vector =\n" << vector2 << "\n"; } // Get the number of calculations void GetCalcs(int& N) { cout << "How many multiplications? "; cin >> N; } // Get the number of runs void GetRuns(int& run) { cout << "How many runs? "; cin >> run; cout << "\n"; } // Multiply the 1-dimensional vectors void Calculate(vector& vector1, vector& vector2, const int& N, const int& runs) { // Define a counter int counter = 0; // Define a vector of doubles to hold the result vector product; // and assign 0 to its first element product.push_back(0.); // Loop "run" times for (int r=0; r