Bertini 2 d882924 (2026-10-06 19:56 UTC)
Numerical algebraic geometry library (C++ core)
Loading...
Searching...
No Matches
user.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//bertini2/system/start/user.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/system/start/user.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/system/start/user.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) 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
29
30#pragma once
31
35
36// these next two blobs solve a problem of private-ness.
37// see https://stackoverflow.com/questions/4112075/trouble-overriding-save-construct-data-when-serializing-a-pointer-to-a-class-wit
38
39// forward declare the User start system
40namespace bertini{ namespace start_system{
41 class User;
42}}
43
44// forward declare the function, so we can friend it below.
45namespace boost { namespace serialization {
47template<class Archive>
48inline void save_construct_data(Archive & ar, const bertini::start_system::User * t, const unsigned int file_version);
50}}
51// end nonsense for friends. so lonely, but c++ friends don't solve the irl problem at all.
52
53namespace bertini
54{
55 namespace start_system{
56
57
63 class User : public StartSystem
64 {
65 public:
66 User() = delete; // deleted because requires a reference to a System to construct
67 virtual ~User() = default;
68
72 User(System const& s, SampCont<complex_dbl> const& solns);
74 User(System const& s, SampCont<complex_mp> const& solns);
75
76
77
81 unsigned long long NumStartPoints() const override;
82
83 User& operator*=(Nd const& n) = delete;
84
85 User& operator+=(System const& sys) = delete;
86
87 private:
88
94 Vec<complex_dbl> GenerateStartPoint(complex_dbl,unsigned long long index) const override;
95
101 Vec<complex_mp> GenerateStartPoint(complex_mp,unsigned long long index) const override;
102
103
105 template<class Archive> friend void boost::serialization::save_construct_data(Archive & ar, const User * t, const unsigned int file_version);
106
107 template <typename Archive>
108 void serialize(Archive& ar, const unsigned /*version*/) {
109 ar & boost::serialization::base_object<StartSystem>(*this);
110 }
111
112 const bertini::System& user_system_;
113 std::tuple<SampCont<complex_dbl>, SampCont<complex_mp>> solns_;
114 bool solns_in_dbl_;
115 };
116 }
117}
118
119namespace boost { namespace serialization {
121template<class Archive>
122inline void save_construct_data(
123 Archive & ar, const bertini::start_system::User * t, const unsigned int /*file_version*/
124){
125 // save data required to construct instance
126 ar << t->user_system_;
127 ar << t->solns_in_dbl_;
128
129 ar << std::get<0>(t->solns_);
130 ar << std::get<1>(t->solns_);
131
132}
133
134template<class Archive>
135inline void load_construct_data(
136 Archive & ar, bertini::start_system::User * t, const unsigned int /*file_version*/
137){
138 // retrieve data from archive required to construct new instance
139 bertini::System sys;
140 ar >> sys;
141
142 bool solns_in_dbl;
143 ar >> solns_in_dbl;
144
145 if (solns_in_dbl)
146 {
148 ar >> solns;
149 ::new(t)bertini::start_system::User(sys, solns);
150 }
151 else
152 {
154 ar >> solns;
155 ::new(t)bertini::start_system::User(sys, solns);
156 }
157}
159}}
The fundamental polynomial system class for Bertini2.
Definition system.hpp:106
System()
The default constructor for a system.
Definition system.hpp:117
std::shared_ptr< node::Node > Nd
Shorthand for a shared pointer to a generic expression-tree node.
Definition system.hpp:112
Abstract base class for other start systems.
Definition start_base.hpp:83
The user-provided start system for Numerical Algebraic Geometry.
Definition user.hpp:64
User & operator*=(Nd const &n)=delete
unsigned long long NumStartPoints() const override
Get the number of start points for this start system.
User & operator+=(System const &sys)=delete
friend void boost::serialization::save_construct_data(Archive &ar, const User *t, const unsigned int file_version)
virtual ~User()=default
User(System const &s, SampCont< complex_dbl > const &solns)
Constructor for making a user-provided start system from another.
friend class boost::serialization::access
Definition user.hpp:104
User(System const &s, SampCont< complex_mp > const &solns)
Construct a user-provided start system from a system and its multiprecision solutions.
Definition zero_dim_solve.hpp:68
Definition algorithm_builder.hpp:36
std::complex< double > complex_dbl
The double-precision complex number type.
Definition double_extensions.hpp:47
Eigen::Matrix< NumT, Eigen::Dynamic, 1 > Vec
A dynamically-sized column vector of NumT.
Definition eigen_extensions.hpp:296
std::deque< Vec< T > > SampCont
Definition config.hpp:33
bmp::number< mpc_complex_backend< 0 >, bmp::et_on > complex_mp
The arbitrary-precision complex number type.
Definition mpfr_complex.hpp:58
Definition mpfr_complex.hpp:191
Definition forbid_mixed_arithmetic.hpp:27
Defines generic start system type.
utilities for start system code.