Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
witness_set.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//bertini2/nag_datatypes/witness_set.hpp is free software: you can redistribute it and/or modify
4//it under the terms of the GNU General Public License as published by
5//the Free Software Foundation, either version 3 of the License, or
6//(at your option) any later version.
7//
8//bertini2/nag_datatypes/witness_set.hpp is distributed in the hope that it will be useful,
9//but WITHOUT ANY WARRANTY; without even the implied warranty of
10//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11//GNU General Public License for more details.
12//
13//You should have received a copy of the GNU General Public License
14//along with bertini2/nag_datatypes/witness_set.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) 2017 by Bertini2 Development Team
17//
18// See <http://www.gnu.org/licenses/> for a copy of the license,
19// as well as COPYING. Bertini2 is provided with permitted
20// additional terms in the b2/licenses/ directory.
21
22
28
29
30#pragma once
31
32#include <deque>
34#include "bertini2/nag_datatypes/common/policies.hpp"
37
38
39namespace bertini {
40
41 namespace nag_datatype {
42
43 template <typename T>
44 using PointCont = std::deque<T>;
45
46 using IndexT = typename PointCont<int>::size_type;
47
73 template<typename NumT, typename SystemT = System, template<typename> class ObjManagementP = policy::Copy >
75 {
76 using PointP = ObjManagementP<Vec<NumT>>;
77 using SliceP = ObjManagementP<LinearSlice>;
78 using SystemP = ObjManagementP<SystemT>;
79
80 using PointContT = PointCont<typename PointP::HeldT>;
81
82 PointContT points_;
83 typename SliceP::HeldT slice_;
84 typename SystemP::HeldT system_;
85
86
87public:
94
100 WitnessSet(PointContT const& pts, typename SliceP::HeldT const& slc, typename SystemP::HeldT const& sys) :
101 points_(pts),
102 slice_(slc),
103 system_(sys)
104 {}
105
106
112 inline
113 auto Degree() const
114 {
115 return GetPoints().size();
116 }
117
118
122 inline
123 auto Dimension() const
124 {
125 return GetSlice().Dimension();
126 }
127
128
132 inline
133 void AddPoint(typename PointP::HeldT const& p)
134 {
135 points_.push_back(p);
136 }
137
138
142 void SetPoints(PointContT const& pts)
143 {
144 points_ = pts;
145 }
146
147
151 inline
152 const PointContT& GetPoints() const
153 {
154 return points_;
155 }
156
160 const Vec<NumT>& GetPoint(IndexT ind) const
161 {
162 if (ind > Degree())
163 {
164 std::stringstream ss;
165 ss << "asking for point of index " << ind << ", outside range [0,"<<Degree()-1 << "].";
166 throw std::runtime_error(ss.str());
167 }
168
169 return PointP::AtGet(points_[ind]);
170 }
171
172
176 const Vec<NumT>& operator[](IndexT ind) const
177 {
178 return PointP::AtGet(points_[ind]);
179 }
180
181
182
183
184
190 void SetSystem(typename SystemP::HeldT const& sys)
191 {
192 system_ = sys;
193 }
194
195
199 inline
200 const SystemT& GetSystem() const
201 {
202 return SystemP::AtGet(system_);
203 }
204
205
211 void SetSlice(typename SliceP::HeldT const& s)
212 {
213 slice_ = s;
214 }
215
219 const LinearSlice & GetSlice() const
220 {
221 return SliceP::AtGet(slice_);
222 }
223
227 bool IsConsistent() const
228 {
229 return (GetSystem().NumVariables() - GetSystem().NumNaturalFunctions()) == GetSlice().Dimension();
230 }
231
232
233 };
234 }
235}
236
237
Slice an affine or projective space with a LinearSlice today!
Definition slice.hpp:59
unsigned Dimension() const
Get the dimension of the slice.
Definition slice.hpp:188
const SystemT & GetSystem() const
Gets a (const reference to) the system for the witness set.
Definition witness_set.hpp:200
const Vec< NumT > & operator[](IndexT ind) const
Non-range-checked accessor to get points from witness set.
Definition witness_set.hpp:176
void SetSlice(typename SliceP::HeldT const &s)
Sets the slice for the witness set.
Definition witness_set.hpp:211
WitnessSet(PointContT const &pts, typename SliceP::HeldT const &slc, typename SystemP::HeldT const &sys)
Construct a witness set from points, slice, and system.
Definition witness_set.hpp:100
const PointContT & GetPoints() const
Get (a const reference to) the set of points for the witness set.
Definition witness_set.hpp:152
WitnessSet()
The default constructor.
Definition witness_set.hpp:93
const LinearSlice & GetSlice() const
Definition witness_set.hpp:219
bool IsConsistent() const
Check whether the witness set makes sense, in terms of system size, number of variables,...
Definition witness_set.hpp:227
auto Degree() const
Get the degree of the witness set.
Definition witness_set.hpp:113
void SetSystem(typename SystemP::HeldT const &sys)
Definition witness_set.hpp:190
void SetPoints(PointContT const &pts)
Sets the set of points for the witness set.
Definition witness_set.hpp:142
const Vec< NumT > & GetPoint(IndexT ind) const
Range-checked version of point getter for witness set.
Definition witness_set.hpp:160
auto Dimension() const
Query the dimension of the witness set. Fundamentally, this is the dimension of the slice.
Definition witness_set.hpp:123
void AddPoint(typename PointP::HeldT const &p)
Adds a point to the witness set.
Definition witness_set.hpp:133
Bertini extensions of the Eigen linear algebra library.
Provides the bertini::LinearSlice class.
Provides the bertini::System class.