00001 // 00002 // FGLMStrategy.h 00003 // PolyBoRi 00004 // 00005 // Created by Michael Brickenstein on 2008-11-13. 00006 // Copyright 2008 The PolyBoRi Team 00007 // 00008 00009 #ifndef fglm_header 00010 #define fglm_header 00011 00012 #include <polybori/BoolePolyRing.h> 00013 #include "groebner_alg.h" 00014 00015 extern "C" { 00016 #include <m4ri/m4ri.h> 00017 } 00018 00019 BEGIN_NAMESPACE_PBORIGB 00020 00021 typedef std::vector<Polynomial> poly_vec; 00022 00023 class FGLMStrategy{ 00024 00025 00028 FGLMStrategy(const FGLMStrategy& rhs); 00029 00031 FGLMStrategy& operator=(const FGLMStrategy& rhs); 00032 00033 public: 00034 typedef BoolePolyRing ring_with_ordering_type; 00035 00036 FGLMStrategy(const ring_with_ordering_type& from_ring, const ring_with_ordering_type& to_ring, const PolynomialVector& gb); 00037 00038 PolynomialVector main(); 00039 void analyzeGB(const ReductionStrategy& gb); 00040 void setupMultiplicationTables(); 00041 void setupStandardMonomialsFromTables(); 00042 void writeRowToVariableDivisors(mzd_t* row, Monomial lm); 00043 void testMultiplicationTables(); 00044 void transposeMultiplicationTables(); 00045 void writeTailToRow(MonomialSet tail, mzd_t* row); 00046 Polynomial rowToPoly(mzd_t* row); 00047 //allocates a window, free it with mzd_free_window 00048 void findVectorInMultTables(mzd_t* dst, Monomial m); 00049 mzd_t* multiplicationTableForVariable(const Variable& v){ 00050 return multiplicationTables[ring2Index[v.index()]]; 00051 } 00052 ~FGLMStrategy(){ 00053 for(std::size_t i=0;i<multiplicationTables.size();i++){ 00054 mzd_free(multiplicationTables[i]); 00055 } 00056 } 00057 typedef std::vector<idx_type> IndexVector; 00058 00059 00060 private: 00061 bool prot; 00062 Monomial vars; 00063 size_t varietySize; 00064 typedef std::vector<Monomial> MonomialVector; 00065 typedef std::vector<mzd_t*> MatrixVector; 00066 typedef std::vector<Variable> VariableVector; 00067 00068 00069 MonomialSet standardMonomialsFrom; 00070 MonomialVector standardMonomialsFromVector; 00071 MonomialSet leadingTermsFrom; 00072 MonomialSet varsSet; 00073 VariableVector varsVector; 00074 00075 ReductionStrategy gbFrom; //reduced gb 00076 MonomialSet edgesUnitedVerticesFrom; 00077 ring_with_ordering_type from; 00078 ring_with_ordering_type to; 00079 00080 //indices in multiplicationTables correspond to reverse standard BooleSet iteration of standardMonomialsFrom 00081 00082 IndexVector ring2Index; 00083 IndexVector index2Ring; 00084 IndexVector rowStartingWithIndex; 00085 MonomialSet::size_type nVariables; 00086 bool transposed; 00087 std::vector<IndexVector> tableXRowYIsMonomialFromWithIndex; 00088 lm2Index_map_type standardMonomialsFrom2Index; 00089 lm2Index_map_type monomial2MultiplicationMatrix; 00090 lm2Index_map_type monomial2MultiplicationMatrixRowIndex; 00091 MatrixVector multiplicationTables; 00092 00093 bool canAddThisElementLaterToGB(Polynomial p); 00094 PolynomialVector addTheseLater; 00095 IndexVector rowIsStandardMonomialToWithIndex; 00096 Exponent::idx_map_type standardExponentsFrom2Index; 00097 Polynomial reducedNormalFormInFromRing(Polynomial f); 00098 IndexVector rowVectorIsLinearCombinationOfRows(mzd_t* mat, mzd_t* v); 00099 }; 00100 END_NAMESPACE_PBORIGB 00101 #endif 00102