Macaulay2 Engine
Loading...
Searching...
No Matches
tset.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright (C) 2006-2011 by Mikhail V. Zinin *
3 * mzinin@gmail.com *
4 * *
5 * You may redistribute this file under the terms of the GNU General *
6 * Public License as published by the Free Software Foundation, either *
7 * version 2 of the License, or any later version. *
8 *****************************************************************************/
9
10#ifndef BIBASIS_TSET_HPP
11#define BIBASIS_TSET_HPP
12
40
41#include <list>
42#include <algorithm>
43#include "janettree.hpp"
44
45namespace BIBasis
46{
47 template <typename MonomType>
48 class TSet
49 {
50 private:
51 std::list<Triple<MonomType>*> TripleList;
53
54 public:
55 typedef typename std::list<Triple<MonomType>*>::iterator Iterator;
56 typedef typename std::list<Triple<MonomType>*>::const_iterator ConstIterator;
57
58 TSet();
59 ~TSet();
60
62 ConstIterator Begin() const;
63 Iterator End();
64 ConstIterator End() const;
65
66 void Clear();
68 void PushBack(Triple<MonomType>* newTriple);
69 std::size_t Size() const;
70
71 const Triple<MonomType>* Find(const MonomType& monom) const;
72 Triple<MonomType>* Back() const;
73
74 void CollectNonMultiProlongations(Iterator& iterator, std::list<Triple<MonomType>*>& set);
75 };
76
77 template <typename MonomType>
79 : TripleList()
80 , JTree()
81 {
82 }
83
84 template <typename MonomType>
86 {
87 Clear();
88 }
89
90 template <typename MonomType>
92 {
93 return TripleList.begin();
94 }
95
96 template <typename MonomType>
98 {
99 return TripleList.begin();
100 }
101
102 template <typename MonomType>
104 {
105 return TripleList.end();
106 }
107
108 template <typename MonomType>
110 {
111 return TripleList.end();
112 }
113
114 template <typename MonomType>
116 {
117 JTree.Clear();
118
119 Iterator it = TripleList.begin();
120 while (it != TripleList.end())
121 {
122 delete *it;
123 ++it;
124 }
125 TripleList.clear();
126 }
127
128 template <typename MonomType>
130 {
131 JTree.Delete(*it);
132 return TripleList.erase(it);
133 }
134
135 template <typename MonomType>
137 {
138 TripleList.push_back(newTriple);
139 JTree.Insert(newTriple);
140 }
141
142 template <typename MonomType>
143 std::size_t TSet<MonomType>::Size() const
144 {
145 return TripleList.size();
146 }
147
148 template <typename MonomType>
149 const Triple<MonomType>* TSet<MonomType>::Find(const MonomType& monom) const
150 {
151 return JTree.Find(monom);
152 }
153
154 template <typename MonomType>
156 {
157 return TripleList.back();
158 }
159
160 template <typename MonomType>
162 {
163 if (iterator == TripleList.end() || !(*iterator))
164 {
165 return;
166 }
167
168 typename MonomType::Integer firstMultiVar = (**iterator).GetPolynomLm().FirstMultiVar();
169 for (typename MonomType::Integer var = 0; var < firstMultiVar; ++var)
170 {
171 if (!(**iterator).TestNmp(var))
172 {
173 Polynom<MonomType>* tmpPolynom = new Polynom<MonomType>(*(**iterator).GetPolynom());
174 (*tmpPolynom) *= var;
175
176 (**iterator).SetNmp(var);
177
178 if (!tmpPolynom->IsZero())
179 {
180 set.push_back(new Triple<MonomType>(tmpPolynom
181 , (**iterator).GetAncestor()
182 , (**iterator).GetNmp()
183 , (*iterator)
184 , var)
185 );
186 }
187 delete tmpPolynom;
188 }
189 }
190 }
191}
192
193#endif // BIBASIS_TSET_HPP
bool IsZero() const
Definition polynom.hpp:157
std::size_t Size() const
Definition tset.hpp:143
Iterator Begin()
Definition tset.hpp:91
std::list< Triple< MonomType > * >::const_iterator ConstIterator
Definition tset.hpp:56
Triple< MonomType > * Back() const
Definition tset.hpp:155
std::list< Triple< MonomType > * > TripleList
Definition tset.hpp:51
void Clear()
Definition tset.hpp:115
void CollectNonMultiProlongations(Iterator &iterator, std::list< Triple< MonomType > * > &set)
Definition tset.hpp:161
JanetTree< MonomType > JTree
Definition tset.hpp:52
std::list< Triple< MonomType > * >::iterator Iterator
Definition tset.hpp:55
Iterator End()
Definition tset.hpp:103
void PushBack(Triple< MonomType > *newTriple)
Definition tset.hpp:136
const Triple< MonomType > * Find(const MonomType &monom) const
Definition tset.hpp:149
Iterator Erase(Iterator it)
Definition tset.hpp:129
BIBasis::JanetTree<MonomType> — the involutive-division index for boolean Gröbner bases.