Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

/home/r0/dav/atlas.dir/atlas3/sources/interface/blockmode.cpp

Go to the documentation of this file.
00001 /*
00002   This is blockmode.cpp
00003 
00004   Copyright (C) 2007 Marc van Leeuwen
00005   part of the Atlas of Reductive Lie Groups
00006 
00007   See file main.cpp for full copyright notice
00008 */
00009 
00010 #include <iostream>
00011 #include <fstream>
00012 
00013 #include "blockmode.h"
00014 
00015 #include "complexredgp.h"
00016 #include "complexredgp_io.h"
00017 #include "error.h"
00018 #include "helpmode.h"
00019 #include "interactive.h"
00020 #include "io.h"
00021 #include "ioutils.h"
00022 #include "basic_io.h"
00023 #include "filekl.h"
00024 #include "realredgp.h"
00025 #include "realredgp_io.h"
00026 #include "cartanset.h"
00027 #include "kgb.h"
00028 #include "kgb_io.h"
00029 #include "blocks.h"
00030 #include "block_io.h"
00031 #include "kl.h"
00032 #include "kl_io.h"
00033 #include "wgraph.h"
00034 #include "wgraph_io.h"
00035 #include "special.h"
00036 #include "test.h"
00037 
00038 /****************************************************************************
00039 
00040   This file contains the commands defined in the "block" mode of the program.
00041   This means that a real form and a dual real form have been chosen.
00042 
00043 *****************************************************************************/
00044 
00045 namespace atlas {
00046 
00047 namespace {
00048 
00049   using namespace blockmode;
00050 
00051   void block_mode_entry() throw(commands::EntryError);
00052   void block_mode_exit();
00053 
00054   // functions for the predefined commands
00055 
00056   void type_f();
00057   void realform_f();
00058   void small_kgb_f();
00059   void small_dual_kgb_f();
00060 template<bool small>
00061   void block_f();
00062 template<bool small>
00063   void dual_block_f();
00064   void dual_map_f();
00065   void blockd_f();
00066   void blockorder_f();
00067   void blocku_f();
00068   void blockwrite_f();
00069   void blockstabilizer_f();
00070   void klbasis_f();
00071   void kllist_f();
00072   void primkl_f();
00073   void klwrite_f();
00074   void wgraph_f();
00075   void wcells_f();
00076 
00077 
00078   // local variables
00079 
00080   complexredgp::ComplexReductiveGroup* dual_G_C_pointer=NULL;
00081   realredgp::RealReductiveGroup* dual_G_R_pointer=NULL;
00082   blocks::Block* block_pointer=NULL;
00083   klsupport::KLSupport* kls_pointer=NULL;
00084   kl::KLContext* klc_pointer=NULL;
00085   wgraph::WGraph* WGr_pointer=NULL;
00086 }
00087 
00088 /*****************************************************************************
00089 
00090         Chapter I -- Functions declared in blockmode.h
00091 
00092 ******************************************************************************/
00093 
00094 namespace blockmode {
00095 
00096 // Returns a |CommandMode| object that is constructed on first call.
00097 commands::CommandMode& blockMode()
00098 {
00099   static commands::CommandMode block_mode
00100     ("block: ",block_mode_entry,block_mode_exit);
00101   if (block_mode.empty()) // true upon first call
00102   {
00103     // add the commands from the real mode
00104     commands::addCommands(block_mode,realmode::realMode());
00105 
00106     // add commands for this mode
00107     // the "type" command should be redefined here because it needs to exit
00108     // the block and real modes
00109     block_mode.add("type",type_f); // override
00110     block_mode.add("realform",realform_f); // this one too
00111     block_mode.add("smallkgb",small_kgb_f);
00112     block_mode.add("smalldualkgb",small_dual_kgb_f);
00113     block_mode.add("block",block_f<false>);
00114     block_mode.add("smallblock",block_f<true>);
00115     block_mode.add("dualblock",dual_block_f<false>);
00116     block_mode.add("smalldualblock",dual_block_f<true>);
00117     block_mode.add("dualmap",dual_map_f);
00118     block_mode.add("blockd",blockd_f);
00119     block_mode.add("blocku",blocku_f);
00120     block_mode.add("blockorder",blockorder_f);
00121     block_mode.add("blockwrite",blockwrite_f);
00122     block_mode.add("blockstabilizer",blockstabilizer_f);
00123     block_mode.add("klbasis",klbasis_f);
00124     block_mode.add("kllist",kllist_f);
00125     block_mode.add("primkl",primkl_f);
00126     block_mode.add("klwrite",klwrite_f);
00127     block_mode.add("wcells",wcells_f);
00128     block_mode.add("wgraph",wgraph_f);
00129 
00130     // add special commands
00131     special::addSpecialCommands(block_mode,BlockmodeTag());
00132 
00133     // add test commands
00134     test::addTestCommands(block_mode,BlockmodeTag());
00135   }
00136   return block_mode;
00137 }
00138 
00139 complexredgp::ComplexReductiveGroup& currentDualComplexGroup()
00140 {
00141   return *dual_G_C_pointer;
00142 }
00143 
00144 realredgp::RealReductiveGroup& currentDualRealGroup()
00145 {
00146   return *dual_G_R_pointer;
00147 }
00148 
00149 realform::RealForm currentDualRealForm()
00150 {
00151   return dual_G_R_pointer->realForm();
00152 }
00153 
00154 blocks::Block& currentBlock()
00155 {
00156   if (block_pointer==NULL)
00157   {
00158     block_pointer=new
00159       blocks::Block(mainmode::currentComplexGroup(),
00160                     realmode::currentRealGroup().realForm(),
00161                     dual_G_R_pointer->realForm());
00162   }
00163   return *block_pointer;
00164 }
00165 
00166 kl::KLContext& currentKL()
00167 {
00168   if (klc_pointer==NULL)
00169   {
00170     kls_pointer=new klsupport::KLSupport(currentBlock());
00171     kls_pointer->fill();
00172     klc_pointer=new kl::KLContext(*kls_pointer);
00173     klc_pointer->fill();
00174   }
00175   return *klc_pointer;
00176 }
00177 
00178 wgraph::WGraph& currentWGraph()
00179 {
00180   if (WGr_pointer==NULL)
00181   {
00182     const kl::KLContext& c=currentKL();
00183     WGr_pointer=new wgraph::WGraph(c.rank());
00184     kl::wGraph(*WGr_pointer,c);
00185   }
00186   return *WGr_pointer;
00187 }
00188 
00189 } // namespace blockmode
00190 
00191 /****************************************************************************
00192 
00193         Chapter II -- The block mode |CommandMode|
00194 
00195   One instance of |CommandMode| for the block mode is created at the
00196   first call of |blockMode()|; further calls just return a reference to it.
00197 
00198 *****************************************************************************/
00199 
00200 namespace {
00201 
00202 /*
00203   Synopsis: attempts to set a real form interactively. In case of failure,
00204   throws an InputError and returns.
00205 */
00206 void block_mode_entry() throw(commands::EntryError)
00207 {
00208   try
00209   {
00210     realredgp::RealReductiveGroup& G_R = realmode::currentRealGroup();
00211     G_R.fillCartan();
00212 
00213     complexredgp::ComplexReductiveGroup& G_C = G_R.complexGroup();
00214     const realredgp_io::Interface& G_RI = realmode::currentRealInterface();
00215     const complexredgp_io::Interface& G_I = G_RI.complexInterface();
00216 
00217     // get dual real form
00218     realform::RealForm drf;
00219 
00220     interactive::getInteractive
00221       (drf,G_I,G_C.dualRealFormLabels(G_R.mostSplit()),tags::DualTag());
00222 
00223     dual_G_C_pointer=new
00224       complexredgp::ComplexReductiveGroup(G_C,tags::DualTag());
00225     dual_G_R_pointer=new realredgp::RealReductiveGroup(*dual_G_C_pointer,drf);
00226     dual_G_R_pointer->fillCartan(); // this will be needed in all cases
00227   }
00228   catch(error::InputError& e)
00229   {
00230     block_mode_exit(); // clean up
00231     e("no dual real form set");
00232     throw commands::EntryError();
00233   }
00234 }
00235 
00236 
00237 /*
00238   Synopsis: destroys any local data, resoring NULL pointers
00239 */
00240 void block_mode_exit()
00241 {
00242   delete dual_G_C_pointer; dual_G_C_pointer=NULL;
00243   delete dual_G_R_pointer; dual_G_R_pointer=NULL;
00244   delete block_pointer; block_pointer=NULL;
00245   delete kls_pointer; kls_pointer=NULL;
00246   delete klc_pointer; klc_pointer=NULL;
00247   delete WGr_pointer; WGr_pointer=NULL;
00248 }
00249 
00250 } // namespace
00251 
00252 /*****************************************************************************
00253 
00254         Chapter III --- Functions for the predefined commands
00255 
00256   This section contains the definitions of the functions associated to the
00257   various commands defined in this mode.
00258 
00259 ******************************************************************************/
00260 
00261 namespace {
00262 
00263 /*
00264   Synopsis: resets the type of the complex group.
00265 
00266   In case of success, the real forms are invalidated, and therefore we
00267   should exit real mode; in case of failure, we don't need to.
00268 */
00269 void type_f()
00270 {
00271   try {
00272     complexredgp::ComplexReductiveGroup* G;
00273     complexredgp_io::Interface* I;
00274 
00275     interactive::getInteractive(G,I);
00276     mainmode::replaceComplexGroup(G,I);
00277     commands::exitMode(); // upon success pop block mode, destroying dual group
00278     commands::exitMode(); // and pop real mode, destroying real group
00279   }
00280   catch (error::InputError& e) {
00281     e("complex group and real form not changed");
00282   }
00283 }
00284 
00285 
00286 /*
00287   Synopsis: resets the type, effectively re-entering the real mode. If the
00288   construction of the new type fails, the current block remains in force.
00289 */
00290 void realform_f()
00291 {
00292   try {
00293     realredgp::RealReductiveGroup& G_R=realmode::currentRealGroup();
00294     interactive::getInteractive(G_R,mainmode::currentComplexInterface());
00295 
00296     realredgp_io::Interface RI(G_R,mainmode::currentComplexInterface());
00297     realmode::currentRealInterface().swap(RI);
00298 
00299     commands::exitMode(); // upon success pop block mode, destroying dual group
00300   }
00301   catch (error::InputError& e) {
00302     e("real form not changed");
00303   }
00304   catch (error::InnerClassError& e) {
00305     e("that real form is not in the current inner class\n"
00306       "real form not changed");
00307   }
00308 }
00309 
00310 // Print the kgb table, only the necessary part for one block
00311 void small_kgb_f()
00312 {
00313   realredgp::RealReductiveGroup& G_R = realmode::currentRealGroup();
00314   realredgp::RealReductiveGroup& dGR = currentDualRealGroup();
00315 
00316   bitmap::BitMap common=blocks::common_Cartans(G_R,dGR);
00317 
00318   std::cout << "relevant Cartan classes: ";
00319   basic_io::seqPrint(std::cout,common.begin(),common.end(),",","{","}\n");
00320 
00321   std::cout
00322     << "partial kgb size: "
00323     << mainmode::currentComplexGroup().cartanClasses().KGB_size
00324         (realmode::currentRealForm(),common)
00325     << std::endl;
00326 
00327   ioutils::OutputFile file;
00328   kgb::KGB kgb(G_R,common);
00329   kgb_io::printKGB(file,kgb);
00330 }
00331 
00332 void small_dual_kgb_f()
00333 {
00334   realredgp::RealReductiveGroup& G_R = realmode::currentRealGroup();
00335   realredgp::RealReductiveGroup& dGR = currentDualRealGroup();
00336   complexredgp::ComplexReductiveGroup& dGC = currentDualComplexGroup();
00337 
00338   bitmap::BitMap common=blocks::common_Cartans(dGR,G_R);
00339 
00340   std::cout << "relevant Cartan classes for dual group: ";
00341   basic_io::seqPrint(std::cout,common.begin(),common.end(),",","{","}\n");
00342 
00343   std::cout << "partial kgb size: " <<
00344     dGC.cartanClasses().KGB_size(currentDualRealForm(),common) << std::endl;
00345   ioutils::OutputFile file;
00346 
00347   kgb::KGB kgb(dGR,common);
00348   kgb_io::printKGB(file,kgb);
00349 }
00350 
00351 // Print the current block
00352 template<bool small>
00353 void block_f()
00354 {
00355   ioutils::OutputFile file;
00356   if (small) // must unfortunatly regenerate the block here
00357   {
00358     block_io::printBlock
00359       (file,blocks::Block(mainmode::currentComplexGroup(),
00360                           realmode::currentRealForm(),
00361                           currentDualRealForm(),
00362                           true));
00363   }
00364   else
00365     block_io::printBlock(file,currentBlock());
00366 }
00367 
00368 // Print the dual block of the current block
00369 template<bool small>
00370 void dual_block_f()
00371 {
00372   complexredgp::ComplexReductiveGroup& dG = currentDualComplexGroup();
00373 
00374   blocks::Block block(dG,currentDualRealForm(),realmode::currentRealForm(),
00375                       small);
00376 
00377   ioutils::OutputFile file;
00378   block_io::printBlock(file,block);
00379 }
00380 
00381 // Print the correspondence of the current block with its dual block
00382 void dual_map_f()
00383 {
00384   const blocks::Block& block = currentBlock();
00385   blocks::Block dual_block(currentDualComplexGroup(),
00386                            currentDualRealForm(),
00387                            realmode::currentRealForm());
00388 
00389   std::vector<blocks::BlockElt> v=blocks::dual_map(block,dual_block);
00390 
00391   std::ostringstream s("");
00392   basic_io::seqPrint(s,v.begin(),v.end(),", ","[","]\n");
00393   ioutils::OutputFile file;
00394   foldLine(file,s.str()," ");
00395 }
00396 
00397 // Print the current block with involutions in involution-reduced form
00398 void blockd_f()
00399 {
00400   ioutils::OutputFile file;
00401   block_io::printBlockD(file,currentBlock());
00402 }
00403 
00404 // Print the unitary elements of the block.
00405 void blocku_f()
00406 {
00407   ioutils::OutputFile file;
00408   block_io::printBlockU(file,currentBlock());
00409 }
00410 
00411 
00412 // Print the Hasse diagram for the Bruhat order on the current block
00413 void blockorder_f()
00414 {
00415   blocks::Block& block = currentBlock();
00416   std::cout << "block size: " << block.size() << std::endl;
00417   ioutils::OutputFile file;
00418   kgb_io::printBruhatOrder(file,block.bruhatOrder());
00419 }
00420 
00421 // Writes a binary file containing descent sets and ascent sets for block
00422 void blockwrite_f()
00423 {
00424   std::ofstream block_out; // binary output files
00425   if (interactive::open_binary_file
00426       (block_out,"File name for block output: "))
00427   {
00428     filekl::write_block_file(currentBlock(),block_out);
00429     std::cout<< "Binary file written.\n" << std::endl;
00430   }
00431   else
00432     std::cout << "No file written.\n";
00433 }
00434 
00435 /*
00436   Synopsis: prints out information about the stabilizer of a representation
00437   under the cross action
00438 */
00439 void blockstabilizer_f()
00440 {
00441   realredgp::RealReductiveGroup& G_R = realmode::currentRealGroup();
00442   realredgp::RealReductiveGroup& dGR = currentDualRealGroup();
00443 
00444   bitmap::BitMap common=blocks::common_Cartans(G_R,dGR);
00445 
00446   // get Cartan class; abort if unvalid
00447   size_t cn;
00448   interactive::getCartanClass(cn,common,commands::currentLine());
00449 
00450   ioutils::OutputFile file;
00451   realredgp_io::printBlockStabilizer
00452     (file,realmode::currentRealGroup(),cn,currentDualRealForm());
00453 }
00454 
00455 /* For each element $y$ in the block, outputs the list of non-zero K-L
00456    polynomials $P_{x,y}$.
00457 
00458    This is what is required to write down the K-L basis element $c_y$.
00459 */
00460 void klbasis_f()
00461 {
00462   kl::KLContext& klc = currentKL();
00463 
00464   ioutils::OutputFile file;
00465   file << "Full list of non-zero Kazhdan-Lusztig-Vogan polynomials:"
00466        << std::endl << std::endl;
00467   kl_io::printAllKL(file,klc);
00468 }
00469 
00470 
00471 // Print the list of all distinct Kazhdan-Lusztig-Vogan polynomials
00472 void kllist_f()
00473 {
00474   const kl::KLContext& klc = currentKL();
00475 
00476   ioutils::OutputFile file;
00477   kl_io::printKLList(file,klc);
00478 }
00479 
00480 /*
00481   Print out the list of all K-L polynomials for primitive pairs.
00482 
00483   Explanation: x is primitive w.r.t. y, if any descent for y is also a
00484   descent for x, or a type II imaginary ascent. Ths means that none of
00485   the easy recursion formulas applies to P_{x,y}.
00486 */
00487 
00488 void primkl_f()
00489 {
00490   kl::KLContext& klc = currentKL();
00491 
00492   ioutils::OutputFile file;
00493   file << "Kazhdan-Lusztig-Vogan polynomials for primitive pairs:"
00494        << std::endl << std::endl;
00495   kl_io::printPrimitiveKL(file,klc);
00496 }
00497 
00498 // Write the results of the KL computations to a pair of binary files
00499 void klwrite_f()
00500 {
00501   std::ofstream matrix_out, coefficient_out; // binary output files
00502   interactive::open_binary_file(matrix_out,"File name for matrix output: ");
00503   interactive::open_binary_file
00504     (coefficient_out,"File name for polynomial output: ");
00505 
00506   const kl::KLContext& klc = currentKL();
00507 
00508   if (matrix_out.is_open())
00509   {
00510     std::cout << "Writing matrix entries... " << std::flush;
00511     filekl::write_matrix_file(klc,matrix_out);
00512     std::cout << "Done." << std::endl;
00513   }
00514   if (coefficient_out.is_open())
00515   {
00516     std::cout << "Writing polynomial coefficients... " << std::flush;
00517     filekl::write_KL_store(klc.polStore(),coefficient_out);
00518     std::cout << "Done." << std::endl;
00519   }
00520 }
00521 
00522 // Print the W-graph corresponding to a block.
00523 void wgraph_f()
00524 {
00525   wgraph::WGraph& wg = currentWGraph();
00526   ioutils::OutputFile file; wgraph_io::printWGraph(file,wg);
00527 }
00528 
00529 // Print the cells of the W-graph of the block.
00530 void wcells_f()
00531 {
00532   wgraph::WGraph& wg = currentWGraph();
00533   wgraph::DecomposedWGraph dg(wg);
00534 
00535   ioutils::OutputFile file; wgraph_io::printWDecomposition(file,dg);
00536 }
00537 
00538 
00539 
00540 
00541 } // namespace
00542 
00543 
00544 
00545 
00546 //      Chapter IV ---    H E L P    F U N C T I O N S
00547 
00548 
00549 // Install help functions for block functions into help mode
00550 
00551 namespace {
00552 
00553   const char* block_tag = "prints all the representations in a block";
00554   const char* dual_block_tag = "prints a block for the dual group";
00555   const char* dual_map_tag = "prints a map from block to its dual block";
00556   const char* blockd_tag =
00557    "prints all representations in the block, alternative format";
00558   const char* blocku_tag =
00559    "prints the unitary representations in the block at rho";
00560   const char* blockorder_tag =
00561    "shows Hasse diagram of the Bruhat order on the blocks";
00562   const char* blockwrite_tag = "writes the block information to disk";
00563   const char* blockstabilizer_tag = "print the real Weyl group for the block";
00564   const char* klbasis_tag = "prints the KL basis for the Hecke module";
00565   const char* kllist_tag = "prints the list of distinct KL polynomials";
00566   const char* klprim_tag = "prints the KL polynomials for primitive pairs";
00567   const char* klwrite_tag = "writes the KL polynomials to disk";
00568   const char* wgraph_tag = "prints the W-graph for the block";
00569   const char* wcells_tag = "prints the Kazhdan-Lusztig cells for the block";
00570 
00571 void block_h()
00572 {
00573   io::printFile(std::cerr,"block.help",io::MESSAGE_DIR);
00574 }
00575 
00576 void blockd_h()
00577 {
00578   io::printFile(std::cerr,"blockd.help",io::MESSAGE_DIR);
00579 }
00580 
00581 void blocku_h()
00582 {
00583   io::printFile(std::cerr,"blocku.help",io::MESSAGE_DIR);
00584 }
00585 
00586 void blockorder_h()
00587 {
00588   io::printFile(std::cerr,"blockorder.help",io::MESSAGE_DIR);
00589 }
00590 
00591 void blockwrite_h()
00592 {
00593   io::printFile(std::cerr,"blockwrite.help",io::MESSAGE_DIR);
00594 }
00595 void klbasis_h()
00596 {
00597   io::printFile(std::cerr,"klbasis.help",io::MESSAGE_DIR);
00598 }
00599 
00600 void kllist_h()
00601 {
00602   io::printFile(std::cerr,"kllist.help",io::MESSAGE_DIR);
00603 }
00604 
00605 void primkl_h()
00606 {
00607   io::printFile(std::cerr,"primkl.help",io::MESSAGE_DIR);
00608 }
00609 
00610 void klwrite_h()
00611 {
00612   io::printFile(std::cerr,"klwrite.help",io::MESSAGE_DIR);
00613 }
00614 
00615 void wcells_h()
00616 {
00617   io::printFile(std::cerr,"wcells.help",io::MESSAGE_DIR);
00618 }
00619 
00620 void wgraph_h()
00621 {
00622   io::printFile(std::cerr,"wgraph.help",io::MESSAGE_DIR);
00623 }
00624 
00625 } // namespace
00626 
00627 namespace blockmode {
00628 
00629 void addBlockHelp(commands::CommandMode& mode, commands::TagDict& tagDict)
00630 
00631 {
00632   using commands::insertTag;
00633 
00634   //  mode.add("components",helpmode::nohelp_h);
00635   mode.add("block",block_h);
00636   mode.add("blockd",blockd_h);
00637   mode.add("blocku",blocku_h);
00638   mode.add("blockorder",blockorder_h);
00639   mode.add("blockwrite",blockwrite_h);
00640   mode.add("blockstabilizer",helpmode::nohelp_h);
00641   mode.add("klwrite",klwrite_h);
00642   mode.add("kllist",kllist_h);
00643   mode.add("primkl",primkl_h);
00644   mode.add("klbasis",klbasis_h);
00645   mode.add("wcells",wcells_h);
00646   mode.add("wgraph",wgraph_h);
00647 
00648   // insertTag(tagDict,"components",components_tag);
00649   insertTag(tagDict,"block",block_tag);
00650   insertTag(tagDict,"blockd",blockd_tag);
00651   insertTag(tagDict,"blocku",blocku_tag);
00652   insertTag(tagDict,"blockorder",blockorder_tag);
00653   insertTag(tagDict,"blockwrite",blockwrite_tag);
00654   insertTag(tagDict,"blockstabilizer",blockstabilizer_tag);
00655   insertTag(tagDict,"klbasis",klbasis_tag);
00656   insertTag(tagDict,"kllist",kllist_tag);
00657   insertTag(tagDict,"primkl",klprim_tag);
00658   insertTag(tagDict,"klwrite",klwrite_tag);
00659   insertTag(tagDict,"wcells",wcells_tag);
00660   insertTag(tagDict,"wgraph",wgraph_tag);
00661 }
00662 
00663 } // namespace blockmode
00664 
00665 } // namespace atlas

Generated on Wed Mar 26 16:49:34 2008 for atlas by  doxygen 1.3.9.1