Bertini 2 - C++ Core
Software for Numerical Algebraic Geometry
Loading...
Searching...
No Matches
switches_zerodim.hpp
Go to the documentation of this file.
1//This file is part of Bertini 2.
2//
3//bertini2/blackbox/switches_zerodim.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/blackbox/switches_zerodim.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/blackbox/switches_zerodim.hpp. If not, see <http://www.gnu.org/licenses/>.
15//
16// Copyright(C) 2017-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// silviana amethyst, university of wisconsin-eau claire
23
29
30
31
32#pragma once
33
34
35#include "bertini2/system.hpp"
37#include "bertini2/endgames.hpp"
38
40
41
42namespace bertini{
43namespace blackbox{
44
45
46
47struct ZeroDimRT
48{
49 type::Start start = type::Start::TotalDegree;
50 type::Tracker tracker = type::Tracker::Adaptive;
51 type::Endgame endgame = type::Endgame::Cauchy;
52};
53
54
55template <typename StartType, typename TrackerType, typename EndgameType, template<typename,typename> class SystemManagementPol, typename ... ConstTs>
56std::unique_ptr<algorithm::AnyZeroDim> ZeroDimSpecifyComplete(ConstTs const& ...ts)
57{
58 return std::make_unique<
59 algorithm::ZeroDim<
60 TrackerType,
61 EndgameType,
62 System,
63 StartType,
64 SystemManagementPol>
65 >(ts...);
66}
67
68template <typename StartType, typename TrackerType, typename EndgameType, typename ... ConstTs>
69std::unique_ptr<algorithm::AnyZeroDim> ZeroDimSpecifyShouldClone(std::true_type, ConstTs const& ...ts)
70{
71 return ZeroDimSpecifyComplete<StartType, TrackerType,
72 typename endgame::EndgameSelector<TrackerType>::Cauchy, policy::CloneGiven>(ts...);
73}
74
75template <typename StartType, typename TrackerType, typename EndgameType, typename ... ConstTs>
76std::unique_ptr<algorithm::AnyZeroDim> ZeroDimSpecifyShouldClone(std::false_type, ConstTs const& ...ts)
77{
78 return ZeroDimSpecifyComplete<StartType, TrackerType,
79 typename endgame::EndgameSelector<TrackerType>::Cauchy, policy::RefToGiven>(ts...);
80}
81
82
83template <typename StartType, typename TrackerType, typename ... ConstTs>
84std::unique_ptr<algorithm::AnyZeroDim> ZeroDimSpecifyEndgame(ZeroDimRT const& rt, ConstTs const& ...ts)
85{
86
87 switch (rt.endgame)
88 {
89 case type::Endgame::PowerSeries:
90 return ZeroDimSpecifyShouldClone<StartType, TrackerType,
91 typename endgame::EndgameSelector<TrackerType>::PSEG>(typename StorageSelector<StartType>::ShouldClone(), ts...);
92
93 case type::Endgame::Cauchy:
94 return ZeroDimSpecifyShouldClone<StartType, TrackerType,
95 typename endgame::EndgameSelector<TrackerType>::Cauchy>(typename StorageSelector<StartType>::ShouldClone(), ts...);
96 }
97}
98
99template <typename StartType, typename ... ConstTs>
100std::unique_ptr<algorithm::AnyZeroDim> ZeroDimSpecifyTracker(ZeroDimRT const& rt, ConstTs const& ...ts)
101{
102 switch (rt.tracker)
103 {
104 case type::Tracker::FixedDouble:
105 return ZeroDimSpecifyEndgame<StartType, tracking::DoublePrecisionTracker>(rt, ts...);
106 case type::Tracker::FixedMultiple:
107 return ZeroDimSpecifyEndgame<StartType, tracking::MultiplePrecisionTracker>(rt, ts...);
108 case type::Tracker::Adaptive:
109 return ZeroDimSpecifyEndgame<StartType, tracking::AMPTracker>(rt, ts...);
110 }
111}
112
113template <typename ... ConstTs>
114std::unique_ptr<algorithm::AnyZeroDim> ZeroDimSpecifyStart(ZeroDimRT const& rt, ConstTs const& ...ts)
115{
116 switch (rt.start)
117 {
118 case type::Start::TotalDegree:
119 return ZeroDimSpecifyTracker<start_system::TotalDegree>(rt, ts...);
120 case type::Start::MHom:
121 return ZeroDimSpecifyTracker<start_system::MHomogeneous>(rt, ts...);
122 case type::Start::User:
123 throw std::runtime_error("trying to use generic zero dim with user homotopy. use the specific UserBlaBla instead");
124 }
125}
126
127template <typename ... ConstTs>
128std::unique_ptr<algorithm::AnyZeroDim> MakeZeroDim(ZeroDimRT const& rt, ConstTs const& ...ts)
129{
130 return ZeroDimSpecifyStart(rt, ts...);
131}
132
133
134} //ns blackbox
135} //ns bertini
Configs for the blackbox whatnot.
Collects the various header files which define the Bertini2 endgames.
Collects the various header files which define the Bertini2 systems.
Provides the algorithm for computing all zero-dimensional solutions for an algberaic system.