OPENF4
Library for Gröebner basis computations over finite fields.
 All Classes Namespaces Files Functions Variables Friends Pages
avl-monomial.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015 Antoine Joux, Vanessa Vitse and Titouan Coladon
3  *
4  * This file is part of openf4.
5  *
6  * openf4 is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * openf4 is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with openf4. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
26 #ifndef OPENF4_AVL_MONOMIAL_H
27 #define OPENF4_AVL_MONOMIAL_H
28 
30 #include "global.h"
31 #include <iostream>
32 #include <cassert>
33 #include <iomanip>
34 #include <unordered_set>
36 #include "dynamic-array.h"
37 
41 namespace F4
42 {
48  {
49  public:
50 
51  /* Constructor */
52 
57 
58  /* Attributes */
59 
61  bool _lt;
62  signed char _bf;
66  };
67 
72  void printNode(NodeAvlMonomial * p, int indent=0);
73 
74 
80  {
81  public:
82 
83  /* Constructor */
84 
88  AvlMonomial();
89 
90 
91  /* Miscellaneous */
92 
97  void printAvlMonomial(std::ostream & stream) const;
98 
102  void reset();
103 
108  size_t size() const;
109 
114  void setLT(int numMon);
115 
116 
117  /* Insertion */
118 
127  int insert(int numMon, bool lt);
128 
129 
130  /* Search */
131 
137 
144 
145  private:
147  unordered_set<int> _umon;
148  unordered_set<int> _lt;
152  };
153 
154 
155  /* External operators */
156 
161  template <typename dataType>
162  std::ostream & operator<<(std::ostream & stream, AvlMonomial const & avlMonomial);
163 }
164 
166 #include "../src/avl-monomial.inl"
169 #endif // OPENF4_AVL_MONOMIAL_H
DynamicArray< NodeAvlMonomial > _array
Definition: avl-monomial.h:146
int insert(int numMon, bool lt)
If numMon is already in the AVL, update its lt flag, otherwise insert a new node. ...
NodeAvlMonomial * findNextBiggest(NodeAvlMonomial *node)
Find the next biggest NodeAvlMonomial after node.
Represent an avl of pair (number of a monomial, is leading monomial).
Definition: avl-monomial.h:79
Declaration of class DynamicArray.
void printNode(NodeAvlPolynomial *p, int indent=0)
Print the AVL of root p.
NodeAvlMonomial * _right
Definition: avl-monomial.h:65
unordered_set< int > _lt
Definition: avl-monomial.h:148
void printAvlMonomial(std::ostream &stream) const
Print the AVL.
NodeAvlMonomial * _left
Definition: avl-monomial.h:64
NodeAvlMonomial _node
Definition: avl-monomial.h:151
Wrapper for config.h in order to avoid multiple definitions.
Represent a dynamic array whose the width is fixed, the memory is allocated by blocs.
Definition: dynamic-array.h:45
void setLT(int numMon)
Add numMon to the unordered set _lt.
NodeAvlMonomial()
Constructor.
Represent a node of the AVL of monomials.
Definition: avl-monomial.h:47
unordered_set< int > _umon
Definition: avl-monomial.h:147
NodeAvlMonomial * _parent
Definition: avl-monomial.h:63
size_t size() const
Get the number of element in the AVL.
void reset()
Reset the AVL for a new usage, memory is not clear.
NodeAvlMonomial * _it
Definition: avl-monomial.h:149
NodeAvlMonomial * _root
Definition: avl-monomial.h:150
AvlMonomial()
Constructor.
NodeAvlMonomial * findBiggest()
Find the biggest NodeAvlMonomial of the AVL.
std::ostream & operator<<(std::ostream &stream, Term< Element > const &term)
Overload the operator <<.