Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
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) 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// silviana amethyst, university of wisconsin eau claire
24
32
33#pragma once
34
37#include "bertini2/common/config.hpp"
38
39// these next two blobs solve a problem of private-ness.
40// see https://stackoverflow.com/questions/4112075/trouble-overriding-save-construct-data-when-serializing-a-pointer-to-a-class-wit
41
42// forward declare the User start system
43namespace bertini{ namespace start_system{
44 class User;
45}}
46
47// forward declare the function, so we can friend it below.
48namespace boost { namespace serialization {
49template<class Archive>
50inline void save_construct_data(Archive & ar, const bertini::start_system::User * t, const unsigned int file_version);
51}}
52// end nonsense for friends. so lonely, but c++ friends don't solve the irl problem at all.
53
54namespace bertini
55{
56 namespace start_system{
57
58
64 class User : public StartSystem
65 {
66 public:
67 User() = delete; // deleted because requires a reference to a System to construct
68 virtual ~User() = default;
69
73 User(System const& s, SampCont<dbl> const& solns);
74 User(System const& s, SampCont<mpfr_complex> 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<dbl> GenerateStartPoint(dbl,unsigned long long index) const override;
95
101 Vec<mpfr_complex> GenerateStartPoint(mpfr_complex,unsigned long long index) const override;
102
103
104 friend class boost::serialization::access;
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<dbl>, SampCont<mpfr_complex>> solns_;
114 bool solns_in_dbl_;
115 };
116 }
117}
118
119namespace boost { namespace serialization {
120template<class Archive>
121inline void save_construct_data(
122 Archive & ar, const bertini::start_system::User * t, const unsigned int file_version
123){
124 // save data required to construct instance
125 ar << t->user_system_;
126 ar << t->solns_in_dbl_;
127
128 ar << std::get<0>(t->solns_);
129 ar << std::get<1>(t->solns_);
130
131}
132
133template<class Archive>
134inline void load_construct_data(
135 Archive & ar, bertini::start_system::User * t, const unsigned int file_version
136){
137 // retrieve data from archive required to construct new instance
138 bertini::System sys;
139 ar >> sys;
140
141 bool solns_in_dbl;
142 ar >> solns_in_dbl;
143
144 if (solns_in_dbl)
145 {
146 bertini::SampCont<bertini::dbl> solns;
147 ar >> solns;
148 ::new(t)bertini::start_system::User(sys, solns);
149 }
150 else
151 {
152 bertini::SampCont<bertini::mpfr_complex> solns;
153 ar >> solns;
154 ::new(t)bertini::start_system::User(sys, solns);
155 }
156}
157}}
The fundamental polynomial system class for Bertini2.
Definition system/system.hpp:99
System()
The default constructor for a system.
Definition system/system.hpp:111
Abstract base class for other start systems.
Definition start_base.hpp:49
The user-provided start system for Numerical Algebraic Geometry.
Definition user.hpp:65
unsigned long long NumStartPoints() const override
Definition user.cpp:47
Defines generic start system type.
utilities for start system code.