// tsncom04.cc // Nick Macks (macks@fnal.gov), Summer 2002 // CovMatrices: CovMatrixX addition #include "CovMatrices/CovMatrix5.h" #include "CovMatrices/CovMatrix6.h" using namespace std; using CovMatrices::CovMatrix5; using CovMatrices::CovMatrix6; // Function declarations void Identification(); void GetDimension(int&); void Describe(const int&); void BuildMatrix(CovMatrix5&, CovMatrix6&, const int&); void Show(CovMatrix5&, CovMatrix6&, const int&); void GetCalcs(int&); void GetRuns(int&); void Calculate(CovMatrix5&, CovMatrix5&, CovMatrix6&, CovMatrix6&, const int&, 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(5-6): "; cin >> dimension; while ( (dimension < 5) || (dimension > 6) ) { cout << "Enter 5 or 6: "; cin >> dimension; } } // Describe how the matrices were defined void Describe(const int& dimension) { cout << "Matrices were defined 'CovMatrix" << dimension << "'\n"; } // Build the matrix void BuildMatrix(CovMatrix5& matrix5, CovMatrix6& matrix6, const int& dimension) { if (dimension == 5) { for (int i=0; i j) matrix5(i,j) = 2 + i*2 + j*(dimension*2); } } } else if (dimension == 6) { for (int i=0; i j) matrix6(i,j) = 2 + i*2 + j*(dimension*2); } } } } // Show the matrix void Show(CovMatrix5& matrix5, CovMatrix6& matrix6, const int& dimension) { if (dimension == 5) cout << "Using matrix =\n" << matrix5 << "\n"; else if (dimension == 6) cout << "Using matrix =\n" << matrix6 << "\n"; } // Get the number of calculations void GetCalcs(int& N) { cout << "How many additions? "; cin >> N; } // Get the number of runs void GetRuns(int& run) { cout << "How many runs? "; cin >> run; cout << "\n"; } // Add the matrices void Calculate(CovMatrix5& matrix51, CovMatrix5& matrix52, CovMatrix6& matrix61, CovMatrix6& matrix62, const int& dimension, const int& N, const int& runs) { // Define a counter int counter = 0; // Define two matrices to hold the result // and initialize them to zeros CovMatrix5 sum5; CovMatrix6 sum6; if (dimension == 5) { // Loop "run" times for (int r=0; r