AlVin  1.0
A C++ implementation of the Vinberg's algorithm for Q, Q( sqrt(d) ) and Q( cos(2 pi / 7) )
alvin.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2014, 2015, 2016
3 Rafael Guglielmetti, rafael.guglielmetti@unifr.ch
4 */
5 
6 /*
7 This file is part of AlVin.
8 
9 CoxIter is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as
11 published by the Free Software Foundation, either version 3 of the
12 License, or (at your option) any later version.
13 
14 CoxIter is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with AlVin. If not, see <http://www.gnu.org/licenses/>.
21 */
22 
31 #ifndef ALVIN_H
32 #define ALVIN_H
33 
34 #include <vector>
35 #include <iterator>
36 #include <iostream>
37 #include <cmath>
38 #include <algorithm>
39 
40 #include <map>
41 #include <memory>
42 
43 #include "CoxIter/coxiter.h"
44 #include "CoxIter/lib/math_tools.h"
45 
46 #include "algebraicinteger.h"
47 #include "alvinfractions.h"
48 
49 using namespace std;
50 using namespace MathTools;
51 
52 class AlVin
53 {
54  protected:
55  vector< AlgebraicInteger* > aiQF;
56  unsigned int iDimension;
57 
59  bool bDebug;
60  bool bWriteInfo;
62 
64 
65  vector< unsigned int > iQBlocksSize;
66  vector< unsigned int > iComponentLessThan;
67 
68  vector< vector< AlgebraicInteger* > > aiVectors;
69  unsigned int iVectorsCount;
70  unsigned int iVectorsCount_second;
71 
72  vector< vector< AlgebraicInteger* > > aiVectors_candidates;
73 
74  vector< vector< unsigned int > > iCoxeterMatrix;
75 
76  vector< AlgebraicInteger* > iBilinearProducts;
77 
78  AlVinFractions *vf;
79 
80  string strOuputMathematicalFormat;
81 
83 
84  private:
85  CoxIter* ptrCI;
86 
87  public:
94  AlVin( const string& strOuputMathematicalFormat, const bool& bWriteInfo, const bool& bDebug );
95 
96  virtual ~AlVin();
97 
101  virtual bool PreRun() = 0;
102 
109  bool Run( unsigned int iMinVectors = 0, unsigned int iMaxVectors = 0, bool bLastCheckFV = true );
110 
114  AlgebraicInteger* aiBilinearProduct( const vector< AlgebraicInteger* >& v1, const vector< AlgebraicInteger* >& v2 );
115 
119  void print_iQF() const;
120 
124  void print_vectors() const;
125 
129  vector< vector< unsigned int > > get_iCoxeterMatrix() const;
130 
134  unsigned int get_iDimension() const;
135 
139  string get_strFinalInformation() const;
140 
144  string get_strCoxeterMatrix() const;
145 
149  virtual string get_strField() const = 0;
150 
156  string get_strQF( const string& strSeparator = ", " ) const;
157 
161  string get_strAlgebraicIntegerType() const;
162 
166  vector< vector< AlgebraicInteger* > > get_aiVectors() const;
167 
171  unsigned int get_iVectorsCount() const;
172 
176  vector< AlgebraicInteger* > get_aiQF() const;
177 
181  vector< AlgebraicInteger* > get_aiPossibleNorm2() const;
182 
186  const vector< AlgebraicInteger* >* get_ptraiPossibleNorm2() const;
187 
191  CoxIter* get_ptrCI() const;
192 
193  // ---------------------------------------------------
194  // Setters
195 
199  void set_iCreateImage( const int& iValue );
200 
204  void set_bComputeInvariantsPolyhedron( const bool& bValue );
205 
206  protected:
207  void initializations();
208 
209  void print_initialInformation() const;
210  virtual void print_initialInformationChild() const;
211  void print_finallInformation() const;
212 
213  private:
214  virtual void findPossibleNorms2() = 0;
215  virtual void findVector( AlgebraicInteger* aiX0, AlgebraicInteger* aiNorm2 ) = 0;
216 
217  void findFirstVectors();
218 
219  void addVector( const vector< AlgebraicInteger* >& aiVect );
220  virtual int addVector_iFindWeight( AlgebraicInteger* aiNumerator, AlgebraicInteger* aiDenominator ) = 0;
221 
222  void printFoundVector( vector< AlgebraicInteger* > aiV, const unsigned int& iIndex, const bool& bFirst = false ) const;
223 
224  virtual void addVectorChild( const vector< AlgebraicInteger* >& aiVector ) = 0;
225 };
226 
227 inline AlgebraicInteger* AlVin::aiBilinearProduct( const vector< AlgebraicInteger* >& v1, const vector< AlgebraicInteger* >& v2 )
228 {
229  AlgebraicInteger* aiProduct( aiQF[0]->copy() );
230  AlgebraicInteger* aiTemp( aiQF[0]->copy() );
231 
232  aiProduct->opp();
233  aiProduct->multiplyBy( v1[0] );
234  aiProduct->multiplyBy( v2[0] );
235 
236  for( unsigned int j( 1 ); j <= iDimension; j++ )
237  {
238  aiTemp->set( aiQF[j] );
239  aiTemp->multiplyBy( v1[j] );
240  aiTemp->multiplyBy( v2[j] );
241  aiProduct->add( aiTemp );
242  }
243 
244  delete aiTemp;
245 
246  return aiProduct;
247 }
248 
249 #endif // ALVIN_H
bool bComputeInvariantsPolyhedron
If yes, we compute the invariants of the final polyhedron.
Definition: alvin.h:58
unsigned int iVectorsCount
Number of vectors found.
Definition: alvin.h:69
virtual void add(const AlgebraicInteger *ai)=0
Performs the addition of *this by the parameter.
AlgebraicInteger * aiBilinearProduct(const vector< AlgebraicInteger * > &v1, const vector< AlgebraicInteger * > &v2)
Compute the product between two vectors.
Definition: alvin.h:227
vector< vector< AlgebraicInteger * > > aiVectors
The vectors.
Definition: alvin.h:68
Main class for AlVin.
Definition: alvin.h:52
virtual void multiplyBy(const int &n)=0
Performs the multiplication of *this by the parameter.
virtual void opp()=0
Computes the opp.
vector< unsigned int > iComponentLessThan
The entry [ i ] = j means x_i <= x_j, [ i ] = 0 means no information for x_i.
Definition: alvin.h:66
vector< unsigned int > iQBlocksSize
Sizes of blocks of coefficients.
Definition: alvin.h:65
unsigned int iVectorsCount_second
Number of vectors found (second batch)
Definition: alvin.h:70
unsigned int iDimension
Dimension of the space.
Definition: alvin.h:56
Parent class for rational, quadratic and rc7 integers.
Definition: algebraicinteger.h:43
bool bWriteInfo
If we want to write informations (false if AlVin is used "as a plugin")
Definition: alvin.h:60
int iCreateImage
-1: not specified (i.e. yes if possible and if the number of vectors is <= 25), 0: no...
Definition: alvin.h:61
string strAlgebraicIntegerType
RationalInteger, QuadraticInteger.
Definition: alvin.h:63
string strFinalInformation
Final information that will be displayed.
Definition: alvin.h:82
virtual void set(const int &n)=0
Assign an integer to the algebraic integer.
vector< vector< AlgebraicInteger * > > aiVectors_candidates
Vectors which are compatiable with the previous.
Definition: alvin.h:72
vector< AlgebraicInteger * > iBilinearProducts
To control during findVector_simple that the vector has negative product with the preceding ones...
Definition: alvin.h:76
bool bDebug
If true, more information are displayed.
Definition: alvin.h:59
This class represents a set of possible fractions x_0^2 / (e,e) We generate series of the type: (x0 +...
Definition: alvinfractions.h:46