Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

/magnus/back_end/NilpotentGroup/include/NilpotentCollector.h

Go to the documentation of this file.
00001 // Copyright (C) 1994 The New York Group Theory Cooperative
00002 // See magnus/doc/COPYRIGHT for the full notice.
00003 //
00004 // Contents: Definition of classes NilpotentCollector
00005 //
00006 //
00007 // Principal Author: Eugene Paderin
00008 //
00009 // Status: In progress
00010 //
00011 // Revision History:
00012 //
00013 // Special Notes:
00014 //
00015 
00016 #ifndef _NILPOTENT_COLLECTOR_H_
00017 #define _NILPOTENT_COLLECTOR_H_
00018 
00019 #include "BasicCommutators.h"
00020 
00021 
00022 class NGCollectorRep;
00023 
00024 
00025 //===========================================================================
00026 //===================== class NilpotentCollector ============================
00027 //===========================================================================
00028 
00029 
00030 class NilpotentCollector
00031 {
00032 
00033 public:
00034 
00035   enum Type { STANDARD = 0, TO_THE_LEFT = 0, FROM_THE_LEFT = 1,
00036               FROM_THE_RIGHT = 2, POLYNOMIAL = 3
00037   };  // to be extended
00038 
00039   //------------------------------------------------------------------------
00040   //   Constructors and initializers
00041   //------------------------------------------------------------------------
00042 
00043   NilpotentCollector(int numgen, int nilclass, bool initialize = true);
00044   // creates collector for free nilpotent group 
00045   // Flag initialize shows whether the initialization should be
00046   // performed immediately or delayed
00047 
00048   NilpotentCollector(const BasicCommutators& bc);
00049   //To create collector using given BC
00050   
00051   //copy constructor, destructor and assignment operator provided by compiler
00052 
00053   virtual void initialize() const;    // Logical const!
00054   // initializes uninitialized object
00055 
00056   //------------------------------------------------------------------------
00057   //   Factories
00058   //------------------------------------------------------------------------
00059 
00060   static NilpotentCollector * make(int numgen, int nilclass,
00061                                    NilpotentCollector::Type colType,
00062                                    bool initialize = true);
00063   // makes a collector of given type
00064 
00065 
00066   virtual NilpotentCollector * clone() const = 0;
00067   // method to clone the object
00068 
00069 
00070   //------------------------------------------------------------------------
00071   //   Accessors
00072   //------------------------------------------------------------------------
00073 
00074   const BasicCommutators& commutators() const {
00075     return BC;
00076   }
00077   // access to the basic commutators
00078 
00079   virtual NilpotentCollector::Type type() const = 0;
00080   // the collector type
00081 
00082   virtual bool isInitialized() const {
00083     return BC.isInitialized();
00084   }
00085   // true iff the object is initialized
00086 
00087 
00088   //------------------------------------------------------------------------
00089   //   Common problems related with the collecting process
00090   //------------------------------------------------------------------------
00091 
00092   virtual void collectingProcess( PolyWord& pw ) const = 0;
00093   // collects the given PolyWord. The result is stored in the same PolyWord.
00094 
00095   virtual PolyWord collect(const Word& w) const;
00096   // collects the word
00097   // Input word is given in generators of the nilpotent group.
00098   // The output is a PolyWord in generators of Malcev basis.
00099 
00100   virtual PolyWord collect(const PolyWord& pw) const;
00101   // collects the PolyWord
00102   // The output is a PolyWord in generators of Malcev basis.
00103 
00104   virtual bool collectLetter(PolyWord& w, Generator c) const;
00105   // collects one letter
00106   // Returns true if the letter presents in the word after collection,
00107   // and false if the letter was eliminated or not found
00108 
00109   virtual PolyWord multiply(const PolyWord& pw1, const PolyWord& pw2) const;
00110   // returns collected product of two words
00111 
00112   virtual PolyWord raiseToPower(const PolyWord& pw, int power) const;
00113   // returns a collected power of the word
00114 
00115   virtual PolyWord inverse(const PolyWord& pw) const;
00116   // returns collected inverse of the word
00117 
00118   virtual int weightOf(const Word& w) const;
00119   // returns the weight of the word (the weight of the first letter
00120   // in the word's collected form)
00121   // (nilClass+1) means word is trivial
00122   
00123   virtual int weightOf(const PolyWord& w) const;
00124   // returns the weight of the word (the weight of the first letter)
00125   
00126   //------------------------------------------------------------------------
00127   //   IPC tools
00128   //------------------------------------------------------------------------
00129 
00130   virtual ostream& writeIPC(ostream& s) const;
00131   virtual istream& readIPC(istream& s) const;  //Logical const!
00132   // IPC tools
00133 
00134   //------------------------------------------------------------------------
00135   //   Data
00136   //------------------------------------------------------------------------
00137 
00138 protected:
00139 
00140   BasicCommutators BC;
00141 
00142 };
00143 
00144 
00145 //===========================================================================
00146 //============================ class NGCollector ============================
00147 //===========================================================================
00148 
00149 
00150 // This is a wrapper for NilpotentCollector family of classes.
00151 // To be redesigned to use standard form for shared representations
00152 
00153 class NGCollector {
00154 
00155 public:
00156 
00157 
00158   //------------------------------------------------------------------------
00159   //   Constructors and initializers
00160   //------------------------------------------------------------------------
00161 
00162   NGCollector(int numgen, int nilclass, 
00163               NilpotentCollector::Type collType = NilpotentCollector::STANDARD,
00164               bool initialize = true)
00165     : NC( NilpotentCollector::make(numgen, nilclass, collType, initialize ) )
00166   { }
00167   // Creates a collector of given type
00168   
00169 
00170   //NGCollector(const BasicCommutators& bc, Type collType = STANDARD);
00171   // Creates a collector using existing set of commutators
00172   
00173   NGCollector(const NGCollector & ngc)
00174     : NC( ngc.NC->clone() )
00175   { }
00176   // The copy constructor
00177 
00178 
00179   ~NGCollector() {
00180     delete NC;
00181   }
00182   //The destructor
00183 
00184 
00185   NGCollector & operator = (const NGCollector& ngc) {
00186     delete NC;
00187     NC = ngc.NC->clone();
00188   }
00189   //The assignment operator
00190 
00191 
00192   void initialize() const {    // Logical const!
00193     NC->initialize();
00194   }
00195   // initializes uninitialized object
00196 
00197 
00198   //------------------------------------------------------------------------
00199   //   Accessors
00200   //------------------------------------------------------------------------
00201 
00202   const BasicCommutators& commutators() const {
00203     return NC->commutators();
00204   }
00205   // access to the basic commutators
00206 
00207   NilpotentCollector::Type type() const {
00208     return NC->type();
00209   }
00210   // the collector type
00211 
00212   bool isInitialized() const {
00213     return NC->isInitialized();
00214   }
00215   // true iff the object is initialized
00216 
00217   //------------------------------------------------------------------------
00218   //   Common problems related with the collecting process
00219   //------------------------------------------------------------------------
00220 
00221   void collectingProcess( PolyWord& pw ) const {
00222     NC->collectingProcess(pw);
00223   }
00224   // collects the given PolyWord. The result is stored in the same PolyWord.
00225 
00226   PolyWord collect(const Word& w) const {
00227     return NC->collect(w);
00228   }
00229   // collects the word
00230   // Input word is given in generators of the nilpotent group.
00231   // The output is a PolyWord in generators of Malcev basis.
00232 
00233   PolyWord collect(const PolyWord& pw) const {
00234     return NC->collect(pw);
00235   }
00236   // collects the PolyWord
00237   // The output is a PolyWord in generators of Malcev basis.
00238 
00239   bool collectLetter(PolyWord& w, Generator c) const {
00240     return NC->collectLetter(w,c);
00241   }
00242   // collects one letter
00243   // Returns true if the letter presents in the word after collection,
00244   // and false if the letter was eliminated or not found
00245 
00246 
00247   PolyWord multiply(const PolyWord& pw1, const PolyWord& pw2) const {
00248     return NC->multiply(pw1, pw2);
00249   }
00250   // returns a collected product of two words
00251 
00252   PolyWord raiseToPower(const PolyWord& pw, int power) const {
00253     return NC->raiseToPower(pw, power);
00254   }
00255   // returns a collected power of the word
00256 
00257   virtual PolyWord inverse(const PolyWord& pw) const {
00258     return NC->inverse(pw);
00259   }
00260   // returns collected inverse of the word
00261 
00262   int weightOf(const Word& w) const {
00263     return NC->weightOf(w);
00264   }
00265   // returns the weight of the word (the weight of the first letter
00266   // in the word's collected form)
00267   // (nilClass+1) means word is trivial
00268   
00269   int weightOf(const PolyWord& w) const {
00270     return NC->weightOf(w);
00271   }
00272   // returns the weight of the word (the weight of the first letter)
00273   
00274   //------------------------------------------------------------------------
00275   //   IPC tools
00276   //------------------------------------------------------------------------
00277 
00278   ostream& writeIPC(ostream& s) const;
00279 
00280   istream& readIPC(istream& s) const;  //Logical const!
00281 
00282 
00283   //------------------------------------------------------------------------
00284   //   Data
00285   //------------------------------------------------------------------------
00286 
00287 
00288 private:
00289 
00290   NilpotentCollector * NC;
00291 
00292 };
00293 
00294 
00295 //====================================================================
00296 //====================== free functions ==============================
00297 //====================================================================
00298 
00299 inline ostream& operator < ( ostream& ostr, const NGCollector& NGC ) {
00300   return NGC.writeIPC(ostr);
00301 }
00302 
00303 inline istream& operator > ( istream& istr, const NGCollector& NGC) {
00304   return NGC.readIPC(istr);
00305 }
00306 
00307 
00308 #endif
00309 
00310 

Generated at Tue Jun 19 09:49:37 2001 for Magnus Classes by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001