00001 //----------------------------------------------------------------------------- 00002 // 00003 // Module: Vectors.h 00004 // 00005 // Author: Feng Xie -- xief@mcmaster.ca 00006 // 00007 // Discription: Vectors/Covectors. 00008 // 00009 // Note: 1) Vectors are obtained by repeated composition of circuits. 00010 // 2) Since vectors are symmetric by negation, only the positve 00011 // half is stored. 00012 // 3) Vectors are stored in set for fast lookup. 00013 // 00014 // Change log: 00015 // 09-06-23 Created. 00016 // 00017 //----------------------------------------------------------------------------- 00018 00019 #ifndef OMC_VECTORS_H 00020 #define OMC_VECTORS_H 00021 00022 #include "Circuits.h" 00023 #include <iostream> 00024 #include <set> 00025 00026 namespace omc 00027 { 00028 class Vectors { 00029 public: 00030 Vectors (const Circuits &); // constructor 00031 Vectors (const Vectors &); // copy constructor 00032 00033 ~Vectors () {}; // destructor 00034 00035 size_t getRank () const; // get the rank of the OM 00036 size_t getNumElements () const; // get the number of elements of the OM 00037 size_t getNumVectors () const; // get the number of vectors 00038 00039 void relabel (index_t, index_t); // relabeling 00040 void relabel (const Permutation &); 00041 00042 void reorient (size_t); // reorientation 00043 void reorient (const Combination &); 00044 00045 bool operator== (const Vectors & C) const; // operator == 00046 00047 //bool verify () const; 00048 00049 // Iterators. 00050 typedef std::set<SignedSet>::iterator vector_iterator; 00051 vector_iterator vector_begin (); 00052 vector_iterator vector_end (); 00053 00054 typedef std::set<SignedSet>::reverse_iterator reverse_vector_iterator; 00055 reverse_vector_iterator vector_rbegin (); 00056 reverse_vector_iterator vector_rend (); 00057 00058 protected: 00059 Circuits m_circuits; // the underlying circuits 00060 00061 std::set <SignedSet> m_Vector; // set of vectors 00062 00063 void generate_vectors (); // generate vectors from circuits 00064 00065 }; // class Vectors 00066 00067 // Output stream overloading. 00068 std::ostream & operator<< (std::ostream &, Vectors &); 00069 00070 00072 inline Vectors::Vectors (const Circuits & C) 00073 : m_circuits (C) 00074 { 00075 generate_vectors (); 00076 } 00077 00079 inline Vectors::Vectors (const Vectors & V) 00080 : m_circuits (V.m_circuits) 00081 { 00082 generate_vectors (); 00083 } 00084 00086 inline size_t Vectors::getRank () const { 00087 return m_circuits.getRank (); 00088 } 00089 00091 inline size_t Vectors::getNumElements () const { 00092 return m_circuits.getNumElements (); 00093 } 00094 00096 inline size_t Vectors::getNumVectors () const { 00097 return m_Vector.size (); 00098 } 00099 00101 inline void Vectors::relabel (index_t i, index_t j) { 00102 m_circuits.relabel (i, j); 00103 generate_vectors (); 00104 } 00105 00107 inline void Vectors::relabel (const Permutation & perm) { 00108 m_circuits.relabel (perm); 00109 generate_vectors (); 00110 } 00111 00113 inline void Vectors::reorient (size_t i) { 00114 m_circuits.reorient (i); 00115 generate_vectors (); 00116 } 00117 00119 inline void Vectors::reorient (const Combination & comb) { 00120 m_circuits.reorient (comb); 00121 generate_vectors (); 00122 } 00123 00125 inline bool Vectors::operator== (const Vectors & V) const { 00126 return (m_circuits == V.m_circuits) ? true : false; 00127 } 00128 00130 inline Vectors::vector_iterator Vectors::vector_begin () { 00131 return m_Vector.begin (); 00132 } 00133 00135 inline Vectors::vector_iterator Vectors::vector_end () { 00136 return m_Vector.end (); 00137 } 00138 00140 inline Vectors::reverse_vector_iterator Vectors::vector_rbegin () { 00141 return m_Vector.rbegin (); 00142 } 00143 00145 inline Vectors::reverse_vector_iterator Vectors::vector_rend () { 00146 return m_Vector.rend (); 00147 } 00148 00149 }; // namespace omc 00150 00151 #endif // OMC_VECTORS_H