#ifndef BIVECTOR_H #define BIVECTOR_H // Definitions for generalized BiVector class // $Id: BiVector.h,v 1.13 2002/10/22 17:07:58 sachs Exp $ // David Sachs - Fermilab - April 2002 // A BiVector is a 2xn (or nx2) matrix, which is implemented // as a pair of vectors #include #include #include namespace CovMatrices { class CovMatrix; // BiVector Class class BiVector { private: int n; // order of BiVector std::vector v0; std::vector v1; public: friend class CovMatrix; // *** Constructors *** // Construct Empty or zero BiVector (Default Constructor) explicit inline BiVector(int m = 0) : n(m), v0(m), v1(m) {} // Copy Constructor (Uses Compiler generated version) // Construct from 2 Vectors BiVector(const std::vector&, const std::vector&); // Construct from Vector containing all 2*n elements explicit BiVector(const std::vector&); // Destructor (Uses Compiler generated version) // Assignment functions // Copy Assignment (Uses Compiler generated version) // Assign from Vector containing all 2*n elements BiVector& operator=(const std::vector&); // Get order int size() const {return n;} // returns order // Set order without specific element initialization void resize(int); // Subscripting (any nonzero value is treated as 1) std::vector& operator[] (int i) { return (i ? v1 : v0); } const std::vector& operator[] (int i) const { return (i ? v1 : v0); } // Dump BiVector to vector void dump(std::vector&) const; // Print BiVector void put(std::ostream&) const; // Static function to display a vector // This function is provided for BiVector and CovMatrix classes // because vector does not have output operator defined static void printv( std::ostream&, const std::vector& ); // friend functions friend BiVector operator* (const CovMatrix&, const BiVector&); friend BiVector operator* (const BiVector&, const CovMatrix&); }; // Declarations of non-member functions inline std::ostream& operator<<(std::ostream& o, const BiVector& B) { B.put(o); return o; } } // namespace CovMatrices #endif