Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
operator.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//operator.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//operator.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 operator.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) 2015 - 2021 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// individual authors of this file include:
23// James Collins
24// West Texas A&M University
25// Spring, Summer 2015
26//
27// silviana amethyst, university of wisconsin-eau claire
28//
29// Created by Collins, James B. on 4/30/15.
30//
31//
32// operator.hpp: Declares the class Operator.
33
40
41#ifndef BERTINI_OPERATOR_HPP
42#define BERTINI_OPERATOR_HPP
43
45
46#include <vector>
47
48
49namespace bertini {
50namespace node{
51
57 class Operator : public virtual Node
58 {
59
60 public:
61
62 virtual ~Operator() = default;
63
64 private:
65
66 friend class boost::serialization::access;
67
68 template <typename Archive>
69 void serialize(Archive& ar, const unsigned version) {
70 ar & boost::serialization::base_object<Node>(*this);
71 }
72 };
73
74
75
83 class UnaryOperator : public virtual Operator
84 {
85 public:
86
87 UnaryOperator(const std::shared_ptr<Node> & n) : operand_(n)
88 {}
89
90
91
92 virtual ~UnaryOperator() = default;
93
94
95 void Reset() const override;
96
97
98 void SetOperand(std::shared_ptr<Node> n);
99
100
101
102 //Return the only child for the unary operator
103 std::shared_ptr<Node> Operand() const;
104
105
106
110 int Degree(std::shared_ptr<Variable> const& v = nullptr) const override;
111
112
113 int Degree(VariableGroup const& vars) const override;
114
115
119 std::vector<int> MultiDegree(VariableGroup const& vars) const override;
120
121
122 void Homogenize(VariableGroup const& vars, std::shared_ptr<Variable> const& homvar) override;
123
124
125 bool IsHomogeneous(std::shared_ptr<Variable> const& v = nullptr) const override;
126
127
131 bool IsHomogeneous(VariableGroup const& vars) const override;
132
133
134
140 void precision(unsigned int prec) const override;
141
142
143
144 protected:
145 //Stores the single child of the unary operator
146 std::shared_ptr<Node> operand_;
147 UnaryOperator(){}
148 private:
149 friend class boost::serialization::access;
150
151 template <typename Archive>
152 void serialize(Archive& ar, const unsigned version) {
153 ar & boost::serialization::base_object<Operator>(*this);
154 ar & operand_;
155 }
156 };
157
158
159
160
168 class NaryOperator : public virtual Operator
169 {
170 public:
171
172 virtual ~NaryOperator() = default;
173
174
175 void Reset() const override;
176
177 // Add an operand onto the container for this operator
178 virtual void AddOperand(std::shared_ptr<Node> n);
179
180
181 size_t NumOperands() const;
182
183 inline auto const& Operands() const{
184 return operands_;
185 }
186
187
188 std::shared_ptr<Node> FirstOperand() const;
189
195 void precision(unsigned int prec) const override;
196
197
198
199 protected:
200
201 //Stores all children for this operator node.
202 //This is an NaryOperator and can have any number of children.
203 std::vector< std::shared_ptr<Node> > operands_;
204
205 // constructor is protected to help prevent instantiating empty operators
206 NaryOperator(){}
207
208 private:
209
210 virtual void PrecisionChangeSpecific(unsigned prec) const;
211
212
213 friend class boost::serialization::access;
214
215 template <typename Archive>
216 void serialize(Archive& ar, const unsigned version) {
217 ar & boost::serialization::base_object<Operator>(*this);
218 ar & operands_;
219 }
220
221 };
222
223
224} // re: namespace node
225} // re: namespace bertini
226
227
228#endif
void Reset() const override
Definition operator.cpp:138
void precision(unsigned int prec) const override
Definition operator.cpp:175
Abstract Node type from which all Operators inherit.
Definition operator.hpp:58
void precision(unsigned int prec) const override
Definition operator.cpp:122
void Homogenize(VariableGroup const &vars, std::shared_ptr< Variable > const &homvar) override
Definition operator.cpp:85
bool IsHomogeneous(std::shared_ptr< Variable > const &v=nullptr) const override
Definition operator.cpp:91
void Reset() const override
Definition operator.cpp:33
std::vector< int > MultiDegree(VariableGroup const &vars) const override
Definition operator.cpp:74
int Degree(std::shared_ptr< Variable > const &v=nullptr) const override
Definition operator.cpp:53
Defines the abstract Node base class.