// tsncom18.cc // Nick Macks (macks@fnal.gov), Summer 2002 // CovMatrices: CovMatrixX determinant calculation #include "CovMatrices/CovMatrix5.h" #include "CovMatrices/CovMatrix6.h" using namespace std; using CovMatrices::CovMatrix5; using CovMatrices::CovMatrix6; // Function declarations void Identification(); void GetDimension(); void Describe(const int&); void BuildMatrix(CovMatrix5&, CovMatrix6&, const int&); void Show(const CovMatrix5&, const CovMatrix6&, const int&); void GetCalcs(int&); void GetRuns(int&); void Calculate(CovMatrix5&, 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 matrix was defined void Describe(const int& dimension) { cout << "Matrix was 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(const CovMatrix5& matrix5, const 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 times to calculate the determinant void GetCalcs(int& N) { cout << "How many determinant calculations? "; cin >> N; } // Get the number of runs void GetRuns(int& run) { cout << "How many runs? "; cin >> run; cout << "\n"; } // Calculate the determinant of the matrix void Determinant(CovMatrix5& matrix5, CovMatrix6& matrix6, const int& dimension, const int& N, const int& runs) { // Define two doubles to hold the value of the determinant double determinant5 = 0.; double determinant6 = 0.; // Define a counter int counter = 0; if (dimension == 5) { // Loop "run" times for (int r=0; r