00001 #include "repring.H"
00002 #include "my_gmp.H"
00003 using namespace std;
00004
00005
00006
00007
00008 RepresentationRing::RepresentationRing(){
00009
00010 base_field= "complex";
00011 }
00012
00013
00014
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
00037
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
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
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
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
00085
00086
00087
00088
00089
00090 thefile >> n;
00091 thevars.resize(n+1);
00092 thevars[1]=one();
00093 for(i=2; i <= n; i++){
00094 thefile >> index;
00095 thefile >> buf;
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
00113 list< Polynomial<QQ> >::iterator it,itprime;
00114
00115
00116 if( in_file.fail() ){
00117 cout << "Unable to read from file " << string(name) << endl;
00118 return false;
00119 }
00120
00121
00122
00123 n= this->read_variables(in_file,vars);
00124
00125
00126
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
00142 }
00143
00144
00145
00146
00147 for(i= 1; i< n; i++){
00148 dim= ZZtolong(epsilon[i]);
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
00161
00162
00163
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
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
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
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
00311
00312
00313
00314
00315
00316 added= 1;
00317 thefile >> n;
00318 thevars.resize(n+1);
00319 thevars[1]=one();
00320 for(i=2; i <= n; i++){
00321 thefile >> buf2;
00322 thefile >> buf1;
00323
00324 autoname.str("");
00325 autoname << "r_" << i-1;
00326
00327
00328 if( buf2 > 0 ){
00329 added++;
00330 thevars[added]= new_variable(autoname.str(), QQ(buf1), buf2);
00331 }
00332 else{
00333 autoname2.str("");
00334 autoname2 << "r_" << ZZ(buf1)-1;
00335 conjugates[autoname.str()]= autoname2.str();
00336 }
00337
00338 }
00339
00340 return added;
00341 }
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398