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

repring.cpp

00001 #include "repring.H"
00002 #include "my_gmp.H"
00003 using namespace std;
00004 
00005 // methods for (complex) representation rings *******************************
00006 //***************************************************************************
00007 
00008 RepresentationRing::RepresentationRing(){
00009 
00010   base_field= "complex";
00011 }
00012 
00013 
00014 // as usual, we need to rewrite the following
00015 Polynomial<QQ> RepresentationRing::new_variable(const string& name, 
00016                                                 const QQ& aug, 
00017                                                 long index){
00018   Polynomial<QQ> ans;
00019 
00020   ans= AugmentedAlgebra<QQ>::new_variable(name, aug);
00021   schur_indices[this->var_in_use]= index;
00022 
00023   return ans;
00024 }
00025 
00026 void RepresentationRing::swap_variables_order(long i, long j,
00027                                               list< Polynomial<QQ> >& polys){
00028   Tuple< Polynomial<QQ> > dummy;
00029   long a, b;
00030 
00031   AugmentedAlgebra<QQ>::swap_variables_order(i,j,polys);
00032   dummy.steal(lambda_operations[i]);
00033   lambda_operations[i].steal(lambda_operations[j]);
00034   lambda_operations[j].steal(dummy);
00035 
00036   // now parse through the polynomials in
00037   // the lambda operations and swap
00038   for(a=1; a<= var_in_use; a++)
00039     for(b= 2; b<= epsilon[a]; b++)
00040       lambda_operations[a][b].swap_variables(i, j);
00041   // deal with the schur indices
00042  long dummy_s;
00043 
00044   dummy_s= schur_indices[i];
00045   schur_indices[i]= schur_indices[j];
00046   schur_indices[j]= dummy_s;
00047 
00048 }
00049 
00050 
00051 void RepresentationRing::swap_variables_order(long i, long j){
00052   list< Polynomial<QQ> > empty_list;
00053   
00054   this->swap_variables_order(i,j,empty_list);
00055 }
00056 
00057 void RepresentationRing::kill_top_variable(const Polynomial<QQ>& replacement,
00058                                            list< Polynomial<QQ> >& polys){
00059   long i, j;  
00060 
00061 
00062   AugmentedAlgebra<QQ>::kill_top_variable(replacement,polys);
00063   schur_indices.erase(this->var_in_use + 1);
00064   lambda_operations.erase(this->var_in_use + 1);
00065   // now we need to make the substitutions in the lambda-operations
00066   for(i=1; i<= var_in_use; i++)
00067     for(j= 2; j<= epsilon[i]; j++)
00068       lambda_operations[i][j].substitute_variable(var_in_use + 1, replacement);
00069 }
00070 
00071 void RepresentationRing::kill_top_variable(const Polynomial<QQ>& replacement){
00072   list< Polynomial<QQ> > empty_list;
00073   
00074   this->kill_top_variable(replacement,empty_list);
00075 }
00076 
00077 // ok! now the interesting new methods
00078 
00079 long RepresentationRing::read_variables(ifstream& thefile, Tuple< Polynomial<QQ> >& thevars){
00080   long n, i, index;  
00081   string buf;
00082   ostringstream autoname;
00083 
00084   /* careful!  GAP produces n representations, the first one being the
00085    trivial one (normally...). So the others are numbered 2, 3, ...,
00086    n. (Lists in GAP start from 1, not 0.) However the name of variable
00087    #i is r_{i-1} ie the names are r_1, r_2, ..., r_{n-1}.
00088    */
00089 
00090   thefile >> n;
00091   thevars.resize(n+1);
00092   thevars[1]=one(); // drop thevars[0]...
00093   for(i=2; i <= n; i++){
00094     thefile >> index;
00095     thefile >> buf; //reads the degree of the rep
00096     autoname.str("");
00097     autoname << "r_" << i-1;
00098     thevars[i]= new_variable(autoname.str(),QQ(buf), index);
00099   }
00100 
00101   return n;
00102 
00103 
00104 }
00105 
00106 bool RepresentationRing::read_from_GAP_file(const string& name){
00107   ifstream in_file(name.c_str());
00108   long n,i,j,k,nb_relations, current_relation,var, dim;
00109   string buf;
00110   Tuple< Polynomial<QQ> > vars;
00111   Polynomial<QQ> rel;
00112   //list < Polynomial<QQ> > structure_constants;
00113   list< Polynomial<QQ> >::iterator it,itprime; 
00114   // bool grobner_done;
00115 
00116   if( in_file.fail() ){
00117     cout << "Unable to read from file " << string(name) << endl;
00118     return false;
00119   }
00120 
00121   // read the varibles
00122   // *****************
00123   n= this->read_variables(in_file,vars);
00124 
00125 
00126   // read the relations
00127   // ******************
00128 
00129   relations.generators.clear();
00130 
00131   nb_relations= 0;
00132   for(i= 2; i<= n; i++)
00133     for(j= i; j<= n; j++){
00134       rel= vars[i] * vars[j] * (-1);
00135       for(k=1; k<= n; k++){
00136         in_file >> buf;
00137         rel+= vars[k] * QQ(buf);
00138       }
00139       relations.generators.push_back(rel);
00140       nb_relations++;
00141       //      add_relation(rel);
00142     }
00143 
00144   // read the lambda operations
00145   // **************************
00146 
00147   for(i= 1; i< n; i++){
00148     dim= ZZtolong(epsilon[i]);// dim of the rep
00149     lambda_operations[i].resize(dim+1);
00150     for(j=2; j <= dim; j++){
00151       rel.sets_to_zero();
00152       for(k= 1; k<= n; k++){
00153         in_file >> buf;  
00154         rel+= vars[k] * QQ(buf);
00155       }
00156       lambda_operations[i][j]= rel;
00157     }
00158   }
00159 
00160   // now we cut down the relations and variables
00161   // *******************************************
00162 
00163   //  grobner_done= false;
00164 
00165   if(verbose){
00166     cout << "Original presentation:" << endl << endl;
00167     cout << var_in_use << " variables, "
00168          << nb_relations << " relations" << endl << endl;
00169   }
00170 
00172   //  cout << *((RealRepresentationRing *) this) << endl;
00174   /*
00175     nb_relations= 0;
00176     current_relation= 1;
00177   
00178   for(it= structure_constants.begin(); 
00179    it!= structure_constants.end();){
00180       
00181       if( (var= it->has_lonely_variable(rel)) > 0 ){
00182      if(verbose)
00183        cout << "relation " << current_relation
00184          << " yields a variable redundancy: $"
00185          << vars[var+1] << " = " << rel 
00186          << "$" << endl << endl;
00187          it= structure_constants.erase(it);
00188          kill_variable(var, rel, structure_constants);
00189          grobner_done= false;
00190          }
00191          else{
00192          
00193          if( !grobner_done ){
00194          find_grobner_basis();
00195          grobner_done= true;
00196          }
00197          rel= reduced_form( *it );
00198          if( !rel.is_zero() ){
00199          nb_relations++;
00200          if(very_verbose)
00201          cout << "adding relation " << current_relation
00202            << " (total " << nb_relations << " relations added): "
00203                 << "$" << rel << "$" << endl << endl;
00204                 add_relation(rel);
00205                 grobner_done= false;
00206                 it++;
00207          }
00208          else{
00209          if(very_verbose)
00210          cout << "relation " << current_relation << " redundant"
00211          << endl << endl;
00212          it= structure_constants.erase(it);
00213          }
00214          }
00215          current_relation++;
00216          }
00217          //cut_down_variables();
00218          if(verbose)
00219          cout << "{\\bf Final presentation: }" 
00220          << var_in_use << " variables kept, " << endl
00221          << nb_relations << " relations kept" 
00222          << endl << endl;
00223          
00224          // having selected the non-redudant structure constants,
00225          // and replaced the redundant variables by their expression
00226          // in terms of the others, we can take the structure
00227          // constants as generators for the ideal of relations,
00228          // rather than the current generators which may only be
00229          // generators over QQ.
00230          
00231          relations.generators= structure_constants;
00232   */
00233    return true;
00234 }
00235 
00236 
00237 ostream& operator<<(ostream& os, const RepresentationRing& R){
00238 
00239   map< long, Tuple< Polynomial<QQ> > >::const_iterator it_lambda;
00240   map<long, string>::const_iterator it_gen;
00241   map<long, QQ>::const_iterator it_aug;
00242   list< Polynomial<QQ> >::const_iterator it_rel;
00243   map<long, long>::const_iterator it_schur;
00244   long j;
00245     
00246   os << "generators:" << endl << endl;
00247   for(  it_gen= R.names.begin(), 
00248           it_aug= R.epsilon.begin(), 
00249           it_schur= R.schur_indices.begin(); 
00250         it_gen!= R.names.end(); 
00251         it_gen++, it_aug++, it_schur++){
00252     
00253     os << "$" << it_gen->second << "$";
00254     switch(it_schur->second){
00255     case 1:
00256       cout << " of real type";
00257       break;
00258     case 2:
00259       cout << " of complex type";
00260       break;
00261     case 4:
00262       cout << " of quaternion type";
00263       break;
00264     }
00265     cout << ", its " << R.base_field
00266          << " dimension is "
00267          << it_aug->second << endl << endl;    
00268   }  
00269 
00270   os << "relations:" << endl << endl;
00271   for(it_rel=R.relations.generators.begin(); 
00272       it_rel!= R.relations.generators.end(); it_rel++)
00273     os << "$" << *it_rel << "$" << endl << endl;
00274 
00275   os << endl << "lambda operations:" << endl << endl;
00276   for(it_lambda= R.lambda_operations.begin(), it_gen= R.names.begin();
00277       it_lambda != R.lambda_operations.end();
00278       it_lambda++, it_gen++)
00279 
00280     for(j=2; j< it_lambda->second.size(); j++)
00281       cout << "$\\lambda^" << j << "("
00282            << it_gen->second << ") = "
00283            << it_lambda->second[j] << "$"
00284            << endl << endl;
00285 
00286   
00287   return os;
00288 
00289 }
00290 
00291 
00292 
00293 
00294 
00295 // methods for real representation rings *************************************
00296 // ***************************************************************************
00297 
00298 RealRepresentationRing::RealRepresentationRing(){
00299 
00300   base_field= "real";
00301 }
00302 
00303 
00304 
00305 long RealRepresentationRing::read_variables(ifstream& thefile, Tuple< Polynomial<QQ> >& thevars){
00306   long n, i, buf2, added;  
00307   string buf1;
00308   ostringstream autoname, autoname2;
00309 
00310   /* careful!  GAP produces n representations, the first one being the
00311    trivial one (normally...). So the others are numbered 2, 3, ...,
00312    n. (Lists in GAP start from 1, not 0.) However the name of variable
00313    #i is r_{i-1} ie the names are r_1, r_2, ..., r_{n-1}.
00314    */
00315 
00316   added= 1;
00317   thefile >> n;
00318   thevars.resize(n+1);
00319   thevars[1]=one(); // drop thevars[0]...
00320   for(i=2; i <= n; i++){
00321     thefile >> buf2; //reads the schur index
00322     thefile >> buf1; //reads the degree of the rep
00323 
00324     autoname.str(""); 
00325     autoname << "r_" << i-1;
00326 
00327 
00328     if( buf2 > 0 ){ // buf2==0 means this is the complex conjugate
00329       added++;      // of some rep already added
00330       thevars[added]= new_variable(autoname.str(), QQ(buf1), buf2);
00331     }
00332     else{  // we register the conjugacy
00333       autoname2.str("");
00334       autoname2 << "r_" << ZZ(buf1)-1;// in this case buf1 gives the conjugate
00335       conjugates[autoname.str()]= autoname2.str(); //not the degree
00336     }
00337     
00338   }
00339 
00340   return added;
00341 }
00342 
00343 /*
00344   ostream& operator<<(ostream& os, const RealRepresentationRing& R){
00345   
00346   map< long, Tuple< Polynomial<QQ> > >::const_iterator it_lambda;
00347   map<long, string>::const_iterator it_gen;
00348   map<long, QQ>::const_iterator it_aug;
00349   list< Polynomial<QQ> >::const_iterator it_rel;
00350   map<long, long>::const_iterator it_schur;
00351   long j;
00352   
00353   os << "generators:" << endl << endl;
00354   for(  it_gen= R.names.begin(), 
00355   it_aug= R.epsilon.begin(), 
00356   it_schur= R.schur_indices.begin(); 
00357   it_gen!= R.names.end(); 
00358   it_gen++, it_aug++, it_schur++){
00359   
00360   os << "$" << it_gen->second << "$";
00361   switch(it_schur->second){
00362   case 1:
00363   cout << " of real type";
00364   break;
00365   case 2:
00366   cout << " of complex type";
00367   break;
00368   case 4:
00369   cout << " of quaternion type";
00370   break;
00371   }
00372   cout << ", its real dimension is "
00373   << it_aug->second << endl << endl;    
00374   }  
00375   
00376   os << "relations:" << endl << endl;
00377   for(it_rel=R.relations.generators.begin(); 
00378   it_rel!= R.relations.generators.end(); it_rel++)
00379   os << "$" << *it_rel << "$" << endl << endl;
00380   
00381   os << endl << "lambda operations:" << endl << endl;
00382   for(it_lambda= R.lambda_operations.begin(), it_gen= R.names.begin();
00383   it_lambda != R.lambda_operations.end();
00384   it_lambda++, it_gen++)
00385   
00386   for(j=2; j< it_lambda->second.size(); j++)
00387   cout << "$\\lambda^" << j << "("
00388   << it_gen->second << ") = "
00389   << it_lambda->second[j] << "$"
00390   << endl << endl;
00391   
00392   
00393   return os;
00394   
00395   }*/
00396 
00397 
00398 

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