Main Page | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

augmentedalgebras.H

00001 #ifndef _AUGMENTEDALGEBRAS_H_
00002 #define _AUGMENTEDALGEBRAS_H_
00003 
00004 #include "affinealgebras.H"
00005 using namespace std;
00006 
00008 
00012 template <class K>
00013 class AugmentedAlgebra : public AffineAlgebra<K> {
00014 public:
00016 
00022   map<long, K> epsilon;
00023 
00024   Polynomial<K> new_variable(const string& name, const K& aug){
00025     Polynomial<K> ans;    
00026 
00027     ans= AffineAlgebra<K>::new_variable(name);
00028     epsilon[this->var_in_use]= aug;
00029 
00030     return ans;
00031   }
00032  
00033   virtual void swap_variables_order(long i, long j,list< Polynomial<K> >& polys){
00034     K dummy;
00035 
00036     AffineAlgebra<K>::swap_variables_order(i,j,polys);
00037     dummy= epsilon[i];
00038     epsilon[i]= epsilon[j];
00039     epsilon[j]= dummy;
00040   }
00041 
00042   // code below is the same as for affinealgebra !!
00043   // however, since we redefine a method with the
00044   // same name (but different arguments), the
00045   // compiler would be confused if we did not rewrite
00046   // this one as well.
00047   virtual void swap_variables_order(long i, long j){
00048     list< Polynomial<K> > empty_list;
00049     
00050     this->swap_variables_order(i,j,empty_list);
00051   }
00052 
00053 
00054 
00055 
00056   virtual void kill_top_variable(const Polynomial<K>& replacement,list< Polynomial<K> >& polys){
00057     AffineAlgebra<K>::kill_top_variable(replacement,polys);
00058     epsilon.erase(this->var_in_use + 1);
00059   }
00060 
00061 
00062   virtual void kill_top_variable(const Polynomial<K>& replacement){
00063     list< Polynomial<K> > empty_list;
00064 
00065     this->kill_top_variable(replacement,empty_list);
00066   }
00067 
00068 
00069 
00070   friend ostream& operator<<(ostream& os, const AugmentedAlgebra<K>& R){
00071     typename map<long, string>::const_iterator it_gen;
00072     typename map<long, K>::const_iterator it_aug;
00073     typename list< Polynomial<K> >::const_iterator it_rel;
00074 
00075     os << "generators:" << endl;
00076     for(it_gen= R.names.begin(), it_aug= R.epsilon.begin(); 
00077         it_gen!= R.names.end(); 
00078         it_gen++, it_aug++)
00079       os << it_gen->second << " whose augmentation is "
00080          << it_aug->second << endl;
00081     
00082     os << endl << "relations:" << endl;
00083     for(it_rel=R.relations.generators.begin(); 
00084         it_rel!= R.relations.generators.end(); it_rel++)
00085       os << *it_rel << endl;
00086 
00087     return os;
00088   }
00089   
00091   friend ofstream& operator<<(ofstream& file, AugmentedAlgebra<K>& A){
00092     
00093     // write the underlying affine algebra
00094     AffineAlgebra<K> *ptr;
00095     ptr= &A;
00096     file << *ptr;
00097     // write the augmentations
00098     for(long i=1; i <= A.var_in_use; i++)
00099       file << A.epsilon[i] << " ";
00100     
00101     return file;
00102   }
00103   
00104   friend void operator>>(ifstream& file, AugmentedAlgebra<K>& A){
00105     
00106     //read the underlying affine algebra
00107     AffineAlgebra<K> *ptr;
00108     ptr= &A;
00109     file >> *ptr;
00110     //read the degrees
00111     long deg;
00112     for(long i=1; i<= A.var_in_use; i++){
00113       file >> deg;
00114       A.epsilon[i]=deg;
00115     }
00116   }
00117   
00118   
00119 
00120 
00121 };
00122 
00123 
00124 
00125 
00126 
00127 #endif

Generated on Wed Jun 18 17:22:39 2008 for Pierre Guillot by  doxygen 1.3.9.1