// tsncom37.cc // Nick Macks (macks@fnal.gov), Summer 2002 // CLHEP: HepVector*HepVector multiplication // vector form like in RowVector*ColumnVector // (In order to perform vector*vector in CLHEP we have to transpose // one of the two vectors. Here we transpose the first vector. // However, when we transpose a HepVector we get back a HepMatrix. // Thus, we end up performing matrix*vector and not vector*vector.) #include "CLHEP/Matrix/Vector.h" #include "CLHEP/Matrix/Matrix.h" using namespace std; // Function declarations void Identification(); void GetDimension(int&); void Describe(const int&); void BuildVectors(HepVector&, HepVector&, const int&); void Show(const HepVector&, const HepVector&); void GetCalcs(int&); void GetRuns(int&); void Calculate(HepVector&, HepVector&, const int&, const int&); // Package ID void Identification() { cout << "Using CLHEP\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 two vectors were defined void Describe(const int& dimension) { cout << "Vectors were defined 'HepVector (" << dimension << ")'\n"; } // Build the two vectors void BuildVectors(HepVector& vector1, HepVector& vector2, const int& dimension) { for (int i=0; i> N; } // Get the number of runs void GetRuns(int& run) { cout << "How many runs? "; cin >> run; cout << "\n"; } // Multiply the two vectors void Calculate(HepVector& vector1, HepVector& vector2, const int& N, const int& runs) { // Define a counter int counter = 0; // Define a HepMatrix to hold the inverted vector HepMatrix vector1_inverted; // Invert the second vector vector1_inverted = vector1.T(); // Define a vector to hold the result HepVector product(1); // Loop "run" times for (int r=0; r