1 // xsplit.h: Declaration of class form_finder
2 //////////////////////////////////////////////////////////////////////////
3 //
4 // Copyright 1990-2012 John Cremona
5 //                     Marcus Mo     (parallel code)
6 //
7 // This file is part of the eclib package.
8 //
9 // eclib is free software; you can redistribute it and/or modify it
10 // under the terms of the GNU General Public License as published by the
11 // Free Software Foundation; either version 2 of the License, or (at your
12 // option) any later version.
13 //
14 // eclib is distributed in the hope that it will be useful, but WITHOUT
15 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17 // for more details.
18 //
19 // You should have received a copy of the GNU General Public License
20 // along with eclib; if not, write to the Free Software Foundation,
21 // Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #if     !defined(_ECLIB_XSPLIT_H)
26 #define _ECLIB_XSPLIT_H      1       //flags that this file has been included
27 
28 // Disable multithreading
29 // #undef ECLIB_MULTITHREAD
30 
31 #ifdef ECLIB_MULTITHREAD
32 #include <boost/thread/mutex.hpp>
33 #endif
34 
35 #include <eclib/xsplit_data.h>
36 #include <eclib/splitbase.h>
37 #ifdef ECLIB_MULTITHREAD
38 #include <eclib/threadpool.h>
39 #endif
40 
41 // flags set on construction:
42 
43 // dual:  use dual bases throughout (the usual case)
44 // plusflag: if 1 then targetdim=1 and conjmat not used
45 //           if 0 then targetdim=2 and conjmat is used
46 
47 // bigmats: if 1 then uses opmat() to get operators on ambient space,
48 // does its own restriction to the current subspace; if 0 then uses
49 // opmat_restricted() to get operators restricted to current space
50 // directly -- ONLY possible when dual=1
51 
52 class form_finder {
53   public:
54     form_finder(splitter_base* hh, int plus, int maxd, int mind=0,
55                 int dualflag=1, int bigmatsflag=0, int v=0);
56     ~form_finder(void);
57 
58     void find();
59     void find(ff_data &data);
60     void recover(vector< vector<long> > eigs);
61     void splitoff(const vector<long>& eigs);
62     void store(vec bp, vec bm, vector<long> eigs);
63 
getbasis(ff_data & data)64     vec  getbasis( ff_data &data ) const {return data.bplus_;}
getbasisplus(ff_data & data)65     vec  getbasisplus( ff_data &data ) const {return data.bplus_;}
getbasisminus(ff_data & data)66     vec  getbasisminus( ff_data &data ) const {return data.bminus_;}
67 
68     friend class ff_data;
69 
70   protected:
71     splitter_base* h;
72 
73     int            plusflag, dual, bigmats, verbose, targetdim;
74     int            gnfcount;                  // Global newform counter
75     long           maxdepth, mindepth, dimen;
76     SCALAR         denom1;
77     vector< vector<long> > gaplist;           // Vector to hold all (sub)eiglists
78     vector<vec>    gbplus, gbminus;           // Vector to hold all bplus/bminus
79 
80     ff_data* root;                            // Always points to root data node
81 
82     void make_opmat(long i, ff_data &data);   // Puts it in the_opmat
83     void make_submat(ff_data &data);
84     smat make_nested_submat(long ip, ff_data &data);
85     void go_down(ff_data &data, long eig, int last=0);
86     void go_up( ff_data &data );
87     void make_basis(ff_data &data);
88     vec make_basis1(ff_data &data);  // current space has dim. 1
89     vec make_basis2(ff_data &data, const vec& v);  // current space has dim. >1 and
90                                                    // relative basis vector v
91 
92 #ifdef ECLIB_MULTITHREAD
93     threadpool   pool;                        // Job queue
94     boost::mutex store_lock;                  // Lock for store() function
95 #endif
96 };
97 
98 vec  getbasis1(const ssubspace* s);       // Assuming dim(s)=1, get basis vector
99 vec  lift(const vec& v);                  // Lift basis vector
100 
101 #endif
102