Add files

This commit is contained in:
2025-01-14 01:15:48 +01:00
commit 2f9fcec55b
406 changed files with 87154 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
//This file is part of Bertini 2.
//
//bertini_python.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//bertini_python.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with bertini_python.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2016-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// James Collins
// West Texas A&M University
// Spring 2016
//
// silviana amethyst
// University of Wisconsin - Eau Claire
// Spring 2018
//
//
// python/bertini_python.hpp: the main header file for the python interface for bertini.
#pragma once
#ifndef BERTINI_PYTHON_HPP
#define BERTINI_PYTHON_HPP
#include "python_common.hpp"
#include "containers_export.hpp"
#include "mpfr_export.hpp"
#include "random_export.hpp"
#include "eigenpy_interaction.hpp"
#include "function_tree_export.hpp"
#include "system_export.hpp"
#include "parser_export.hpp"
#include "tracker_export.hpp"
#include "tracker_observers.hpp"
#include "endgame_export.hpp"
#include "tracker_observers.hpp"
#include "endgame_observers.hpp"
#include "detail.hpp"
#include "logging.hpp"
#include "zero_dim_export.hpp"
#endif

View File

@@ -0,0 +1,214 @@
//This file is part of Bertini 2.
//
//python/containers_export.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/containers_export.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/containers_export.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2016-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// James Collins
// West Texas A&M University
// Spring 2016
//
// silviana amethyst
// UWEC
// Spring 2018
//
// python/containers_export.hpp: Exports all needed containers from Bertini 2.0 to python.
#pragma once
#ifndef BERTINI_PYTHON_CONTAINERS_EXPORT_HPP
#define BERTINI_PYTHON_CONTAINERS_EXPORT_HPP
#include <deque>
#include "python_common.hpp"
#include <bertini2/nag_algorithms/zero_dim_solve.hpp>
#include <bertini2/function_tree.hpp>
#include <boost/python/stl_iterator.hpp>
namespace bertini{ namespace python{
template< typename T>
inline std::ostream& operator<<(std::ostream & out, const std::vector<T> & t)
{
out << "[";
for (int ii = 0; ii < t.size(); ++ii)
{
out << t[ii];
if (ii!=t.size()-1)
{
out << ", ";
}
}
out << "]";
return out;
}
template< typename T>
inline std::ostream& operator<<(std::ostream & out, const std::deque<T> & t)
{
out << "[";
for (int ii = 0; ii < t.size(); ++ii)
{
out << t[ii];
if (ii!=t.size()-1)
{
out << ", ";
}
}
out << "]";
return out;
}
/**
Adds functionality to iterable types
*/
template<typename ContT>
class ListVisitor: public def_visitor<ListVisitor<ContT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
static std::string __str__(const object& obj)
{
std::ostringstream oss;
const ContT& self=extract<ContT>(obj)();
std::stringstream ss;
ss << "[";
for (int ii = 0; ii < self.size(); ++ii)
{
ss << self[ii];
if (ii!=self.size()-1)
{
ss << ", ";
}
}
ss << "]";
return ss.str();
};
static std::string __repr__(const object& obj)
{
return __str__(obj);
// std::ostringstream oss;
// const ContT& self=extract<ContT>(obj)();
// std::stringstream ss;
// ss << self.str(0,std::ios::scientific);
// return ss.str();
};
};// ListVisitor class
// This block of code lets us construct a container in C++ from a list of things in Python.
// i found this problem difficult.
//
// fortunately, there were a number of questions and answers of varying quality about it, and the below
// worked readily.
//
// derived from https://stackoverflow.com/questions/56290774/boost-python-exposing-c-class-with-constructor-taking-a-stdlist
template<typename ContT>
std::shared_ptr<ContT> create_MyClass(boost::python::list const& l)
{
using ContainedT = typename ContT::value_type;
ContT temp{ boost::python::stl_input_iterator<ContainedT>(l)
, boost::python::stl_input_iterator<ContainedT>() };
return std::make_shared<ContT>(temp);
}
template<typename ContT>
struct std_list_to_python
{
static PyObject* convert(ContT const& l)
{
boost::python::list result;
for (auto const& value : l) {
result.append(value);
}
return boost::python::incref(result.ptr());
}
};
template<typename ContT>
struct pylist_converter
{
using ContainedT = typename ContT::value_type;
static void* convertible(PyObject* object)
{
if (!PyList_Check(object)) {
return nullptr;
}
int sz = PySequence_Size(object);
for (int i = 0; i < sz; ++i) {
if (!(PyList_GetItem(object, i))) { // silviana sez: i removed a string checking call here.
return nullptr;
}
}
return object;
}
static void construct(PyObject* object, boost::python::converter::rvalue_from_python_stage1_data* data)
{
typedef boost::python::converter::rvalue_from_python_storage<ContT> storage_type;
void* storage = reinterpret_cast<storage_type*>(data)->storage.bytes;
data->convertible = new (storage) ContT();
ContT* l = (ContT*)(storage);
int sz = PySequence_Size(object);
for (int i = 0; i < sz; ++i) {
l->push_back(boost::python::extract<ContainedT>(PyList_GetItem(object, i)));
}
}
};
void ExportContainers();
}} // namespaces
#endif

39
python/include/detail.hpp Normal file
View File

@@ -0,0 +1,39 @@
//This file is part of Bertini 2.
//
//python/detail.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/detail.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/detail.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2017-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// silviana amethyst
// UWEC
// Fall 2017, Spring 2018
//
//
// python/detail.hpp: source file for exposing b2 c++ details to python
#pragma once
#include "generic_observer.hpp"
namespace bertini{
namespace python{
void ExportDetails();
}} // namespaces

View File

@@ -0,0 +1,158 @@
#pragma once
#ifndef BERTINI_PYTHON_EIGENPY_INTERACTION_HPP
#define BERTINI_PYTHON_EIGENPY_INTERACTION_HPP
#include "python_common.hpp"
#include <eigenpy/eigenpy.hpp>
#include <eigenpy/user-type.hpp>
#include <eigenpy/ufunc.hpp>
// this code derived from
// https://github.com/stack-of-tasks/eigenpy/issues/365
// where I asked about using custom types, and @jcarpent responded with a discussion
// of an application of this in Pinnochio, a library for rigid body dynamics.
namespace eigenpy
{
namespace internal
{
// template specialization for real numbers
template <>
struct getitem<bertini::mpfr_float>
{
using NumT = bertini::mpfr_float;
static PyObject* run(void* data, void* /* arr */) {
NumT & mpfr_scalar = *static_cast<NumT*>(data);
auto & backend = mpfr_scalar.backend();
if(backend.data()[0]._mpfr_d == 0) // If the mpfr_scalar is not initialized, we have to init it.
{
mpfr_scalar = NumT(0);
}
boost::python::object m(boost::ref(mpfr_scalar));
Py_INCREF(m.ptr());
return m.ptr();
}
};
// a template specialization for complex numbers
template <>
struct getitem<bertini::mpfr_complex>
{
using NumT = bertini::mpfr_complex;
static PyObject* run(void* data, void* /* arr */) {
NumT & mpfr_scalar = *static_cast<NumT*>(data);
auto & backend = mpfr_scalar.backend();
if(backend.data()[0].re->_mpfr_d == 0) // If the mpfr_scalar is not initialized, we have to init it.
{
mpfr_scalar = NumT(0);
}
boost::python::object m(boost::ref(mpfr_scalar));
Py_INCREF(m.ptr());
return m.ptr();
}
};
} // namespace internal
// i lifted this from EigenPy and adapted it, basically removing the calls for the comparitors.
template <typename Scalar>
void registerUfunct_without_comparitors(){
const int type_code = Register::getTypeCode<Scalar>();
PyObject *numpy_str;
#if PY_MAJOR_VERSION >= 3
numpy_str = PyUnicode_FromString("numpy");
#else
numpy_str = PyString_FromString("numpy");
#endif
PyObject *numpy;
numpy = PyImport_Import(numpy_str);
Py_DECREF(numpy_str);
import_ufunc();
// Matrix multiply
{
int types[3] = {type_code, type_code, type_code};
std::stringstream ss;
ss << "return result of multiplying two matrices of ";
ss << bp::type_info(typeid(Scalar)).name();
PyUFuncObject *ufunc =
(PyUFuncObject *)PyObject_GetAttrString(numpy, "matmul");
if (!ufunc) {
std::stringstream ss;
ss << "Impossible to define matrix_multiply for given type "
<< bp::type_info(typeid(Scalar)).name() << std::endl;
eigenpy::Exception(ss.str());
}
if (PyUFunc_RegisterLoopForType((PyUFuncObject *)ufunc, type_code,
&internal::gufunc_matrix_multiply<Scalar>,
types, 0) < 0) {
std::stringstream ss;
ss << "Impossible to register matrix_multiply for given type "
<< bp::type_info(typeid(Scalar)).name() << std::endl;
eigenpy::Exception(ss.str());
}
Py_DECREF(ufunc);
}
// Binary operators
EIGENPY_REGISTER_BINARY_UFUNC(add, type_code, Scalar, Scalar, Scalar);
EIGENPY_REGISTER_BINARY_UFUNC(subtract, type_code, Scalar, Scalar, Scalar);
EIGENPY_REGISTER_BINARY_UFUNC(multiply, type_code, Scalar, Scalar, Scalar);
EIGENPY_REGISTER_BINARY_UFUNC(divide, type_code, Scalar, Scalar, Scalar);
// Comparison operators
EIGENPY_REGISTER_BINARY_UFUNC(equal, type_code, Scalar, Scalar, bool);
EIGENPY_REGISTER_BINARY_UFUNC(not_equal, type_code, Scalar, Scalar, bool);
//these are commented out because the comparisons are NOT defined for complex types!!
// EIGENPY_REGISTER_BINARY_UFUNC(greater, type_code, Scalar, Scalar, bool);
// EIGENPY_REGISTER_BINARY_UFUNC(less, type_code, Scalar, Scalar, bool);
// EIGENPY_REGISTER_BINARY_UFUNC(greater_equal, type_code, Scalar, Scalar, bool);
// EIGENPY_REGISTER_BINARY_UFUNC(less_equal, type_code, Scalar, Scalar, bool);
// Unary operators
EIGENPY_REGISTER_UNARY_UFUNC(negative, type_code, Scalar, Scalar);
Py_DECREF(numpy);
}
} // namespace eigenpy
namespace bertini{
namespace python{
void EnableEigenPy();
}} // namespaces
#endif // include guard

View File

@@ -0,0 +1,162 @@
//This file is part of Bertini 2.
//
//python/endgame_export.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/endgame_export.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/endgame_export.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2016-2024 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// silviana amethyst
// University of Notre Dame
// Summer 2016, Summer 2023, Fall 2024
//
//
// python/endgame_export.hpp: Header file for exposing endgames to python.
#pragma once
#include "python_common.hpp"
#include <bertini2/endgames.hpp>
namespace bertini{
namespace python{
using namespace bertini::tracking;
/**
Abstract Endgame class
*/
template<typename EndgameT>
class EndgameBaseVisitor: public def_visitor<EndgameBaseVisitor<EndgameT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
using BCT = typename TrackerTraits<typename EndgameT::TrackerType>::BaseComplexType;
using BRT = typename TrackerTraits<typename EndgameT::TrackerType>::BaseRealType;
using BaseEGT = typename EndgameT::BaseEGT;
static
SuccessCode WrapRunDefaultTime(EndgameT & self, BCT const& t, const Eigen::Ref<const Vec<BCT>> s){
return self.Run(t, s);
}
static
SuccessCode WrapRunCustomTime(EndgameT & self, BCT const& t, const Eigen::Ref<const Vec<BCT>> s, BCT const& u){
return self.Run(t, s, u);
}
using unsigned_of_void = unsigned (BaseEGT::*)() const;
static unsigned_of_void GetCycleNumberFn()
{
return &BaseEGT::CycleNumber;
};
template <typename T>
static
Vec<T> return_final_approximation(EndgameT const& self)
{
return self.template FinalApproximation<T>();
}
};// EndgameVisitor class
/**
Particulars for the PowerSeries endgame.
*/
template<typename PowerSeriesT>
class PowerSeriesVisitor: public def_visitor<PowerSeriesVisitor<PowerSeriesT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
using BCT = typename TrackerTraits<typename PowerSeriesT::TrackerType>::BaseComplexType;
using BRT = typename TrackerTraits<typename PowerSeriesT::TrackerType>::BaseRealType;
};// CauchyVisitor class
/**
Particulars for the Cauchy endgame.
*/
template<typename CauchyT>
class CauchyVisitor: public def_visitor<CauchyVisitor<CauchyT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
using BCT = typename TrackerTraits<typename CauchyT::TrackerType>::BaseComplexType;
using BRT = typename TrackerTraits<typename CauchyT::TrackerType>::BaseRealType;
};// CauchyVisitor class
// now prototypes for expose functions defined in the .cpp files for the python bindings.
/**
The main function for exporting the bound endgames to Python.
This should be the only function called from the main function defining the module, and should call all those functions exposing particular endgames.
*/
void ExportEndgames();
/**
export the power series endgame incarnations
*/
void ExportAMPPSEG();
void ExportFDPSEG();
void ExportFMPSEG();
/**
export the cauchy endgame incarnations
*/
void ExportAMPCauchyEG();
void ExportFDCauchyEG();
void ExportFMCauchyEG();
}}// re: namespaces

View File

@@ -0,0 +1,62 @@
//This file is part of Bertini 2.
//
//python/endgame_observers.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/endgame_observers.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/endgame_observers.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2017-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// silviana amethyst
// UWEC
// Fall 2017, Spring 2018
//
//
// python/endgame_observers.hpp: source file for exposing endgame observers to python.
#pragma once
#include "python_common.hpp"
#include "endgame_export.hpp"
#include <bertini2/endgames/observers.hpp>
namespace bertini{
namespace python{
void ExportEndgameObservers();
using namespace bertini::endgame;
template<typename ObsT>
struct EndgameObserverVisitor: public def_visitor<EndgameObserverVisitor<ObsT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const{
}
};
}} // namespaces

View File

@@ -0,0 +1,96 @@
//This file is part of Bertini 2.
//
//python/function_tree.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/function_tree.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/function_tree.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2016-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// James Collins
// West Texas A&M University
// Spring 2016
//
//
// python/function_tree.hpp: Header file for all node types.
#pragma once
#ifndef BERTINI_PYTHON_FUNCTION_TREE_HPP
#define BERTINI_PYTHON_FUNCTION_TREE_HPP
#include "python_common.hpp"
#include <bertini2/function_tree.hpp>
#include "node_export.hpp"
#include "symbol_export.hpp"
#include "operator_export.hpp"
#include "root_export.hpp"
namespace bertini{
namespace python{
using namespace bertini::node;
using Node = Node;
using Nodeptr = std::shared_ptr<Node>;
void SetupFunctionTree()
{
// Tell Python that pointers to derived Nodes can be used as Node pointers when passed to methods
implicitly_convertible<std::shared_ptr<Float>, Nodeptr>();
implicitly_convertible<std::shared_ptr<special_number::Pi>, Nodeptr>();
implicitly_convertible<std::shared_ptr<special_number::E>, Nodeptr>();
implicitly_convertible<std::shared_ptr<Integer>, Nodeptr>();
implicitly_convertible<std::shared_ptr<Rational>, Nodeptr>();
implicitly_convertible<std::shared_ptr<Variable>, Nodeptr>();
implicitly_convertible<std::shared_ptr<Differential>, Nodeptr>();
implicitly_convertible<std::shared_ptr<SumOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<MultOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<PowerOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<NegateOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<IntegerPowerOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<SqrtOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<ExpOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<LogOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<TrigOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<SinOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<CosOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<TanOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<ArcSinOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<ArcCosOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<ArcTanOperator>, Nodeptr>();
implicitly_convertible<std::shared_ptr<Function>, Nodeptr>();
implicitly_convertible<std::shared_ptr<Jacobian>, Nodeptr>();
}
}
}
#endif

View File

@@ -0,0 +1,69 @@
//This file is part of Bertini 2.
//
//python/generic_observable.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/generic_observable.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/generic_observable.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2017-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// silviana amethyst
// UWEC
// Fall 2017, Spring 2018
//
//
// python/generic_observable.hpp: source file for exposing trackers to python.
#pragma once
#include "python_common.hpp"
#include <bertini2/detail/observable.hpp>
namespace bertini{
namespace python{
template <typename ObsT>
class ObservableVisitor : public def_visitor<ObservableVisitor<ObsT>>
{
friend class def_visitor_access;
static void AddObserver(object& obj, object& obs)
{
ObsT& self=extract<ObsT&>(obj)();
AnyObserver& observer=extract<AnyObserver&>(obs)();
self.AddObserver(observer);
};
static void RemoveObserver(object& obj, object& obs)
{
ObsT& self=extract<ObsT&>(obj)();
AnyObserver& observer=extract<AnyObserver&>(obs)();
self.RemoveObserver(observer);
};
public:
template<class PyClass>
void visit(PyClass& cl) const{
cl
.def("add_observer", &ObservableVisitor::AddObserver)
.def("remove_observer", &ObservableVisitor::RemoveObserver)
;
}
};
}} // namespaces

View File

@@ -0,0 +1,49 @@
//This file is part of Bertini 2.
//
//python/generic_observer.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/generic_observer.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/generic_observer.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2017-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// silviana amethyst
// UWEC
// Fall 2017, Spring 2018
//
//
// python/generic_observer.hpp: source file for exposing trackers to python.
#pragma once
#include "python_common.hpp"
#include <bertini2/detail/observer.hpp>
namespace bertini{
namespace python{
// Wrapper struct to allow derived classes to overide methods in python
template<typename ObsT>
struct ObserverWrapper : ObsT, wrapper<ObsT>
{
void Observe(AnyEvent const& e) { this->get_override("Observe")(e);}
}; // re: ObserverWrapper
void ExportObserver();
}} // namespaces

View File

@@ -0,0 +1,43 @@
//This file is part of Bertini 2.
//
//python/include/logging.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/include/logging.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/include/logging.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// silviana amethyst
// UWEC
// Spring 2018
//
//
// python/include/logging.hpp: header file for exposing logging to python.
#pragma once
#include "python_common.hpp"
#include <bertini2/logging.hpp>
namespace bertini{ namespace python{
void ExportLogging();
}} // namespaces

View File

@@ -0,0 +1,353 @@
//This file is part of Bertini 2.
//
//python/mpfr_export.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/mpfr_export.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/mpfr_export.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2016-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
//
// individual authors of this file include:
//
// silviana amethyst
// University of Wisconsin - Eau Claire
// Fall 2017, Spring 2018
//
// James Collins
// West Texas A&M University
// Spring 2016
//
//
// python/mpfr_export.hpp: Header file for exposing all multiprecision data types, those from boost and bertini::complex.
#pragma once
#ifndef BERTINI_PYTHON_MPFR_EXPORT_HPP
#define BERTINI_PYTHON_MPFR_EXPORT_HPP
#include "python_common.hpp"
#include "eigenpy_interaction.hpp"
namespace bertini{
namespace python{
using namespace boost::python;
void ExportMpfr();
/**
\brief Exposes precision
*/
template<typename T>
class PrecisionVisitor: public def_visitor<PrecisionVisitor<T>>
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
unsigned (T::*get_prec)() const= &T::precision; // return type needs to be PrecT
void (T::*set_prec)(unsigned) = &T::precision;
};
/**
\brief Exposes str, repr, and precision
*/
template<typename T>
class RealStrVisitor: public def_visitor<RealStrVisitor<T>>
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
static std::string __str__(const object& obj)
{
std::ostringstream oss;
const T& self=extract<T>(obj)();
std::stringstream ss;
ss << self;
return ss.str();
};
static std::string __repr__(const object& obj)
{
std::ostringstream oss;
const T& self=extract<T>(obj)();
std::stringstream ss;
ss << self.str(0,std::ios::scientific);
return ss.str();
};
};
/**
\brief Exposes == and != for homogeneous comparison
*/
template<typename T>
class EqualitySelfVisitor: public def_visitor<EqualitySelfVisitor<T>>
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
};
/**
\brief Exposes == and != for inhomogeneous comparison
*/
template<typename T, typename S>
class EqualityVisitor: public def_visitor<EqualityVisitor<T,S>>
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
};
/**
\brief Exposes +, - and *
*/
template<typename T, typename S>
class RingVisitor: public def_visitor<RingVisitor<T, S> >
{
static_assert(!std::is_same<T,S>::value, "RingVisitor is to define T-S operations. for T-T operations, use RingSelfVisitor");
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
static T __add__(const T& a, const S& b){ return a+b; };
static T __radd__(const T& b, const S& a){ return a+b; };
static T __iadd__(T& a, const S& b){ a+=b; return a; };
static T __sub__(const T& a, const S& b){ return a-b; };
static T __rsub__(const T& b, const S& a){ return a-b; };
static T __isub__(T& a, const S& b){ a-=b; return a; };
static T __mul__(const T& a, const S& b){ return a*b; };
static T __rmul__(const T& b, const S& a){ return a*b; };
static T __imul__(T& a, const S& b){ a*=b; return a; };
}; // RingVisitor
/**
\brief Exposes +, - and *
*/
template<typename T>
class RingSelfVisitor: public def_visitor<RingSelfVisitor<T> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
static T __add__(const T& a, const T& b){ return a+b; };
static T __iadd__(T& a, const T& b){ a+=b; return a; };
static T __sub__(const T& a, const T& b){ return a-b; };
static T __isub__(T& a, const T& b){ a-=b; return a; };
static T __mul__(const T& a, const T& b){ return a*b; };
static T __imul__(T& a, const T& b){ a*=b; return a; };
static T __neg__(const T& a){ return -a; };
}; // RingSelfVisitor
/**
\brief Exposes +, - and *
*/
template<typename T>
class RealFreeVisitor: public def_visitor<RealFreeVisitor<T> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
static T __abs__(T const& x){ return abs(x);}
}; // RingSelfVisitor
/**
\brief Exposes +,-,*,/
*/
template<typename T, typename S>
class FieldVisitor: public def_visitor<FieldVisitor<T, S> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
static T __div__(const T& a, const S& b){ return a/b; };
static T __rdiv__(const T& b, const S& a){ return a/b; };
static T __idiv__(T& a, const S& b){ a/=b; return a; };
}; // FieldVisitor
template<typename T>
class FieldSelfVisitor: public def_visitor<FieldSelfVisitor<T> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
static T div(const T& a, const T& b){ return a/b; };
static T idiv(T& a, const T& b){ a/=b; return a; };
}; // FieldSelfVisitor
template<typename T, typename S>
class PowVisitor: public def_visitor<PowVisitor<T,S>>
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
static T __pow__(const T& a, const S& b){using std::pow; using boost::multiprecision::pow; return pow(a,b); };
};
template<typename T, typename S>
class GreatLessVisitor: public def_visitor<GreatLessVisitor<T,S>>
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
};
template<typename T>
class GreatLessSelfVisitor: public def_visitor<GreatLessSelfVisitor<T>>
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
};
template<typename T>
class TranscendentalVisitor: public def_visitor<TranscendentalVisitor<T>>
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
static T __log__(T const& x){ return log(x);}
static T __exp__(T const& x){ return exp(x);}
static T __sqrt__(T const& x){ return sqrt(x);}
static T __sin__(T const& x){ return sin(x);}
static T __cos__(T const& x){ return cos(x);}
static T __tan__(T const& x){ return tan(x);}
static T __asin__(T const& x){ return asin(x);}
static T __acos__(T const& x){ return acos(x);}
static T __atan__(T const& x){ return atan(x);}
static T __sinh__(T const& x){ return sinh(x);}
static T __cosh__(T const& x){ return cosh(x);}
static T __tanh__(T const& x){ return tanh(x);}
static T __asinh__(T const& x){ return asinh(x);}
static T __acosh__(T const& x){ return acosh(x);}
static T __atanh__(T const& x){ return atanh(x);}
};
/**
\brief Exposes complex-specific things
*/
template<typename T>
class ComplexVisitor: public def_visitor<ComplexVisitor<T>>
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
using RealT = typename NumTraits<T>::Real;
private:
static void set_real(T &c, mpfr_float const& r) { c.real(r);}
static RealT get_real(T const&c) { return c.real();}
static void set_imag(T &c, RealT const& r) { c.imag(r);}
static RealT get_imag(T const&c) { return c.imag();}
static RealT __abs__(T const& x){ return abs(x);}
static T conj(T const& x){ return conj(x);}
static std::string __str__(const object& obj)
{
std::ostringstream oss;
const T& self=extract<T>(obj)();
std::stringstream ss;
ss << self;
return ss.str();
}
static std::string __repr__(const object& obj)
{
std::ostringstream oss;
const T& self=extract<T>(obj)();
std::stringstream ss;
ss << "(" << real(self).str(0,std::ios::scientific) << ", " << imag(self).str(0,std::ios::scientific) << ")";
return ss.str();
}
};
}
}
#endif

View File

@@ -0,0 +1,267 @@
//This file is part of Bertini 2.
//
//python/node_export.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/node_export.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/node_export.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2016-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// James Collins
// West Texas A&M University
// Spring 2016
//
// silviana amethyst
// UWEC
// Spring 2018
//
// python/node_export.hpp: Header file for exposing Node class to python.
#pragma once
#ifndef BERTINI_PYTHON_NODE_EXPORT_HPP
#define BERTINI_PYTHON_NODE_EXPORT_HPP
#include <bertini2/function_tree.hpp>
#include <bertini2/function_tree/node.hpp>
#include "python_common.hpp"
namespace bertini{
namespace python{
using namespace bertini::node;
using Nodeptr = std::shared_ptr<Node>;
void ExportNode();
template<typename NodeBaseT>
class NodeVisitor: public def_visitor<NodeVisitor<NodeBaseT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
static unsigned GetPrecision(NodeBaseT const& self) {return self.precision();}
static void SetPrecision(NodeBaseT & self, unsigned p){self.precision(p);}
static Nodeptr Diff0(NodeBaseT& self) { return self.Differentiate();}
Nodeptr (NodeBaseT::*Diff1)(std::shared_ptr<Variable> const&) const= &NodeBaseT::Differentiate;
static int Deg0(NodeBaseT& self) { return self.Degree();}
int (NodeBaseT::*Deg1)(std::shared_ptr<Variable> const&) const= &NodeBaseT::Degree;
int (NodeBaseT::*Deg2)(VariableGroup const&) const = &NodeBaseT::Degree;
static bool IsHom0(NodeBaseT& self) { return self.IsHomogeneous();}
bool (NodeBaseT::*IsHom1)(std::shared_ptr<Variable> const&) const= &NodeBaseT::IsHomogeneous;
bool (NodeBaseT::*IsHom2)(VariableGroup const& vars) const= &NodeBaseT::IsHomogeneous;
static bool IsPoly0(NodeBaseT& self) { return self.IsPolynomial();}
bool (NodeBaseT::*IsPoly1)(std::shared_ptr<Variable> const&) const= &NodeBaseT::IsPolynomial;
bool (NodeBaseT::*IsPoly2)(VariableGroup const& vars) const= &NodeBaseT::IsPolynomial;
// Can't create member function pointer to Eval with zero arguments because implementation
// uses default arguments
template <typename T>
static T Eval0(NodeBaseT& self) { return self.template Eval<T>();}
// Use templating to return member function pointer to Eval<T>
template <typename T>
using Eval1_ptr = T (NodeBaseT::*)(std::shared_ptr<Variable> const&) const;
template <typename T>
static Eval1_ptr<T> return_Eval1_ptr()
{
return &NodeBaseT::template Eval<T>;
};
// Addition operators
Nodeptr(*addNodeNode)(Nodeptr, const Nodeptr&) = &(operator+);
Nodeptr(*addNodeMpfr)(Nodeptr, const mpfr_complex&) = &(operator+);
static Nodeptr raddNodeMpfr(Nodeptr y, const mpfr_complex & x)
{
return x+y;
}
Nodeptr(*addNodeRat)(Nodeptr, const bertini::mpq_rational&) = &(operator+);
static Nodeptr raddNodeRat(Nodeptr y, const bertini::mpq_rational& x)
{ return x+y; }
static Nodeptr raddNodeInt(Nodeptr y, const int & x)
{
return x+y;
}
Nodeptr(*addNodeInt)(Nodeptr, int) = &(operator+);
static Nodeptr iaddNodeNode(Nodeptr lhs, const Nodeptr & rhs)
{
return lhs += rhs;
}
// static Nodeptr iaddNodeDouble(Nodeptr lhs, double rhs)
// {
// return lhs += rhs;
// }
static SumOperator iaddSumNode(SumOperator lhs, const Nodeptr & rhs)
{
return lhs += rhs;
}
// Subtraction operators
Nodeptr(*subNodeNode)(Nodeptr, const Nodeptr&) = &(operator-);
Nodeptr(*subNodeMpfr)(Nodeptr, mpfr_complex) = &(operator-);
Nodeptr(*subNodeInt)(Nodeptr, int) = &(operator-);
static Nodeptr isubNodeNode(Nodeptr lhs, const Nodeptr & rhs)
{
return lhs -= rhs;
}
static SumOperator isubSumNode(SumOperator lhs, const Nodeptr & rhs)
{
return lhs -= rhs;
}
static Nodeptr rsubNodeMpfr(Nodeptr y, const mpfr_complex & x)
{
return x-y;
}
Nodeptr(*subNodeRat)(Nodeptr, const bertini::mpq_rational&) = &(operator-);
static Nodeptr rsubNodeRat(Nodeptr y, const bertini::mpq_rational& x)
{ return x-y; }
static Nodeptr rsubNodeInt(Nodeptr y, const int & x)
{
return x-y;
}
// Negate operator
Nodeptr(*negNode)(const Nodeptr &) = &(operator-);
// Multiplication operators
Nodeptr(*multNodeNode)(Nodeptr, const Nodeptr&) = &(operator*);
Nodeptr(*multNodeMpfr)(Nodeptr, mpfr_complex) = &(operator*);
Nodeptr(*multNodeRat)(Nodeptr, const mpq_rational&) = &(operator*);
Nodeptr(*multNodeInt)(Nodeptr, int) = &(operator*);
static Nodeptr imultNodeNode(Nodeptr lhs, const Nodeptr & rhs)
{
return lhs *= rhs;
}
Nodeptr(*imultMultNode)(std::shared_ptr<node::MultOperator> &, const Nodeptr &) = &(operator*=);
static Nodeptr rmultNodeMpfr(Nodeptr y, const mpfr_complex & x)
{
return x*y;
}
static Nodeptr rmultNodeRat(Nodeptr y, const mpq_rational & x)
{
return x*y;
}
static Nodeptr rmultNodeInt(Nodeptr y, const int & x)
{
return x*y;
}
// Division operators
Nodeptr(*divNodeNode)(Nodeptr, const Nodeptr&) = &(operator/);
Nodeptr(*divNodeRat)(Nodeptr, const mpq_rational&) = &(operator/);
Nodeptr(*divNodeMpfr)(Nodeptr, mpfr_complex) = &(operator/);
Nodeptr(*divNodeInt)(Nodeptr, int) = &(operator/);
static Nodeptr idivNodeNode(Nodeptr lhs, const Nodeptr & rhs)
{
return lhs /= rhs;
}
Nodeptr(*idivMultNode)(std::shared_ptr<node::MultOperator> &, const Nodeptr &) = &(operator/=);
static Nodeptr rdivNodeMpfr(Nodeptr y, const mpfr_complex & x)
{
return x/y;
}
static Nodeptr rdivNodeRat(Nodeptr y, const mpq_rational & x)
{
return x/y;
}
static Nodeptr rdivNodeInt(Nodeptr y, const int & x)
{
return x/y;
}
// Power operators
Nodeptr(*powNodeNode)(const Nodeptr &, const Nodeptr&) = &pow;
Nodeptr(*powNodeMpfr)(const Nodeptr&, mpfr_complex) = &pow;
Nodeptr(*powNodeRat)(const Nodeptr&, const mpq_rational&) = &pow;
Nodeptr(*powNodeInt)( Nodeptr const&, int) = &pow;
// Transcendental operators
Nodeptr(*expNodeNode)(const Nodeptr &) = &exp;
Nodeptr(*logNodeNode)(const Nodeptr &) = &log;
Nodeptr(*sinNodeNode)(const Nodeptr &) = &sin;
Nodeptr(*asinNodeNode)(const Nodeptr &) = &asin;
Nodeptr(*cosNodeNode)(const Nodeptr &) = &cos;
Nodeptr(*acosNodeNode)(const Nodeptr &) = &acos;
Nodeptr(*tanNodeNode)(const Nodeptr &) = &tan;
Nodeptr(*atanNodeNode)(const Nodeptr &) = &atan;
};
}
}
#endif

View File

@@ -0,0 +1,164 @@
//This file is part of Bertini 2.
//
//python/operator_export.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/operator_export.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/operator_export.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2016-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// James Collins
// West Texas A&M University
// Spring 2016
//
// silviana amethyst
// UWEC
// Spring 2018
//
//
// python/operator_export.hpp: Header file for exposing operator nodes to python.
#pragma once
#ifndef BERTINI_PYTHON_OPERATOR_EXPORT_HPP
#define BERTINI_PYTHON_OPERATOR_EXPORT_HPP
#include <bertini2/function_tree/operators/operator.hpp>
#include <bertini2/function_tree/operators/arithmetic.hpp>
#include <bertini2/function_tree/operators/trig.hpp>
#include "python_common.hpp"
namespace bertini{
namespace python{
using namespace boost::python;
using namespace bertini::node;
using Node = Node;
using Nodeptr = std::shared_ptr<Node>;
void ExportOperators();
/**
UnaryOperator class(abstract)
*/
template<typename NodeBaseT>
class UnaryOpVisitor: public def_visitor<UnaryOpVisitor<NodeBaseT> >
{
public:
template<class PyClass>
void visit(PyClass& cl) const;
};
/** NaryOperator class(abstract)
*/
template<typename NodeBaseT>
class NaryOpVisitor: public def_visitor<NaryOpVisitor<NodeBaseT> >
{
public:
template<class PyClass>
void visit(PyClass& cl) const;
};
/**
SumOperator and MultOperator classes
*/
template<typename NodeBaseT>
class SumMultOpVisitor: public def_visitor<SumMultOpVisitor<NodeBaseT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
void (NodeBaseT::*AddOperand2)(std::shared_ptr<Node> child, bool) = &NodeBaseT::AddOperand;
};
/**
PowerOperator class
*/
template<typename NodeBaseT>
class PowerOpVisitor: public def_visitor<PowerOpVisitor<NodeBaseT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
};
/**
IntegerPowerOperator class
*/
template<typename NodeBaseT>
class IntPowOpVisitor: public def_visitor<IntPowOpVisitor<NodeBaseT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
std::string (NodeBaseT::*getexp)() const = &NodeBaseT::exponent;
void (NodeBaseT::*setexp)(const std::string &) = &NodeBaseT::set_exponent;
};
} //re: namespace python
}//re: namespace bertini
#endif

View File

@@ -0,0 +1,72 @@
//This file is part of Bertini 2.
//
//python/include/parser_export.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/include/parser_export.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/include/parser_export.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2016-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// James Collins
// West Texas A&M University
// Spring 2016
//
// silviana amethyst
// University of Wisconsin - Eau Claire
// Spring 2018
//
// python/include/parser_export.hpp: Header file for exposing a method for parsing an input file to a system to python.
#pragma once
#ifndef BERTINI_PYTHON_PARSER_EXPORT_HPP
#define BERTINI_PYTHON_PARSER_EXPORT_HPP
#include <boost/spirit/include/qi.hpp>
#include <bertini2/io/parsing/function_parsers.hpp>
#include <bertini2/io/parsing/system_parsers.hpp>
#include "python_common.hpp"
namespace bertini{
namespace python{
using namespace bertini;
///////////// Parser Exposure /////////////////////
template <typename ResultT, typename ParserT>
ResultT Parser(std::string str)
{
ResultT res;
std::string::const_iterator iter = str.begin();
std::string::const_iterator end = str.end();
ParserT P;
phrase_parse(iter, end, P, boost::spirit::ascii::space, res);
return res;
};
void ExportParsers();
}
}
#endif

View File

@@ -0,0 +1,65 @@
//This file is part of Bertini 2.
//
//python/python_common.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/python_common.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/python_common.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2016-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// James Collins
// West Texas A&M University
// Spring 2016
//
//
// python/python_common.hpp: A common header file for all python exposure files
#pragma once
#ifndef BERTINI_PYTHON_COMMON_HPP
#define BERTINI_PYTHON_COMMON_HPP
#include <boost/python.hpp>
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <boost/python/args.hpp>
#include <boost/python/class.hpp>
#include <boost/python/overloads.hpp>
#include <boost/python/return_internal_reference.hpp>
#include <boost/python/register_ptr_to_python.hpp>
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
#include <boost/python/wrapper.hpp>
#include <boost/python/operators.hpp>
#include <boost/operators.hpp>
#include <sstream>
#include <bertini2/mpfr_complex.hpp>
#include <bertini2/mpfr_extensions.hpp>
#include <bertini2/eigen_extensions.hpp>
using namespace boost::python;
using mpfr_float = bertini::mpfr_float;
using mpfr_complex = bertini::mpfr_complex;
#endif

View File

@@ -0,0 +1,48 @@
//This file is part of Bertini 2.
//
//python/random_export.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/random_export.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/random_export.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2023 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// silviana amethyst, summer 2023
//
//
// python/random_export.hpp: Header file for exposing root nodes to python.
#pragma once
#ifndef BERTINI_PYTHON_RANDOM_EXPORT_HPP
#define BERTINI_PYTHON_RANDOM_EXPORT_HPP
#include "python_common.hpp"
namespace bertini{
namespace python{
using namespace boost::python;
void ExportRandom();
}} // namespaces
#endif // include guard

View File

@@ -0,0 +1,92 @@
//This file is part of Bertini 2.
//
//python/root_export.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/root_export.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/root_export.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2016-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// James Collins
// West Texas A&M University
// Spring 2016
//
//
// python/root_export.hpp: Header file for exposing root nodes to python.
#pragma once
#ifndef BERTINI_PYTHON_ROOT_EXPORT_HPP
#define BERTINI_PYTHON_ROOT_EXPORT_HPP
#include <bertini2/function_tree/roots/function.hpp>
#include <bertini2/function_tree/roots/jacobian.hpp>
#include "python_common.hpp"
namespace bertini{
namespace python{
using namespace boost::python;
using namespace bertini::node;
using Node = Node;
using Nodeptr = std::shared_ptr<Node>;
void ExportRoots();
/**
Function class
*/
template<typename NodeBaseT>
class HandleVisitor: public def_visitor<HandleVisitor<NodeBaseT> >
{
public:
template<class PyClass>
void visit(PyClass& cl) const;
};
/**
Function class
*/
template<typename NodeBaseT>
class FunctionVisitor: public def_visitor<FunctionVisitor<NodeBaseT> >
{
public:
template<class PyClass>
void visit(PyClass& cl) const;
};
/**
Jacobian class
*/
template<typename NodeBaseT>
class JacobianVisitor: public def_visitor<JacobianVisitor<NodeBaseT> >
{
public:
template<class PyClass>
void visit(PyClass& cl) const;
};
}
}
#endif

View File

@@ -0,0 +1,146 @@
//This file is part of Bertini 2.
//
//python/symbol_export.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/symbol_export.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/symbol_export.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2016-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// James Collins
// West Texas A&M University
// Spring 2016
//
//
// python/symbol_export.hpp: Header file for exposing symbol nodes to python.
#pragma once
#ifndef BERTINI_PYTHON_SYMBOLS_EXPORT_HPP
#define BERTINI_PYTHON_SYMBOLS_EXPORT_HPP
#include <bertini2/function_tree/symbols/symbol.hpp>
#include <bertini2/function_tree/symbols/number.hpp>
#include <bertini2/function_tree/symbols/special_number.hpp>
#include <bertini2/function_tree/symbols/variable.hpp>
#include <bertini2/function_tree/symbols/differential.hpp>
#include "python_common.hpp"
namespace bertini{
namespace python{
using namespace bertini::node;
// the main function for exporting symbols into python.
void ExportSymbols();
/**
NamedSymbol class(abstract)
*/
template<typename NodeBaseT>
class NamedSymbolVisitor: public def_visitor<NamedSymbolVisitor<NodeBaseT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
std::string (NodeBaseT::*getname)() const = &NodeBaseT::name;
void (NodeBaseT::*setname)(const std::string &) = &NodeBaseT::name;
};
/**
Integer class
*/
template<typename NodeBaseT>
class IntegerVisitor: public def_visitor<IntegerVisitor<NodeBaseT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
};
/**
Rational class
*/
template<typename NodeBaseT>
class RationalVisitor: public def_visitor<RationalVisitor<NodeBaseT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
};
/**
Variable class
*/
template<typename NodeBaseT>
class VariableVisitor: public def_visitor<VariableVisitor<NodeBaseT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
};
/**
Differential class
*/
template<typename NodeBaseT>
class DifferentialVisitor: public def_visitor<DifferentialVisitor<NodeBaseT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
};
}//namespace python
} // namespace bertini
#endif

View File

@@ -0,0 +1,218 @@
//This file is part of Bertini 2.
//
//python/system_export.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/system_export.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/system_export.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2016-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// James Collins
// West Texas A&M University
// Spring 2016
//
// silviana amethyst
// UWEC
// Spring 2018
//
//
// python/system_export.hpp: Header file for exposing systems to python, including start systems.
#pragma once
#ifndef BERTINI_PYTHON_SYSTEM_EXPORT_HPP
#define BERTINI_PYTHON_SYSTEM_EXPORT_HPP
#include <bertini2/system/system.hpp>
#include <bertini2/system/start_systems.hpp>
#include "python_common.hpp"
namespace bertini{
namespace python{
using namespace bertini;
template<typename T> using Vec = Eigen::Matrix<T, Eigen::Dynamic, 1>;
template<typename T> using Mat = Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>;
using dbl = std::complex<double>;
using mpfr = bertini::mpfr_complex;
void ExportAllSystems();
// some useful subfunctions used in ExportAllSystems
void ExportSystem();
void ExportStartSystems();
void ExportStartSystemBase();
void ExportTotalDegree();
/**
System class
*/
template<typename SystemBaseT>
class SystemVisitor: public def_visitor<SystemVisitor<SystemBaseT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
// precision functions
void (bertini::System::*set_prec_)(unsigned) const = &bertini::System::precision;
unsigned (bertini::System::*get_prec_)(void) const = &bertini::System::precision;
// using just_fn = void (bertini::System::*)(std::shared_ptr<node::Node> const&);
using fn_and_name = void (bertini::System::*)(std::shared_ptr<node::Node> const&, std::string const&);
static fn_and_name AddFnAndName()
{
return &System::AddFunction;
};
static void AddJustFn(bertini::System& self, std::shared_ptr<node::Node> const& f) { return self.AddFunction(f);}
void (bertini::System::*sysAddFunc1)(std::shared_ptr<node::Function> const&) = &bertini::System::AddFunction;
// void (bertini::System::*sysAddFunc2)(std::shared_ptr<node::Node> const&, std::string const&) = &bertini::System::AddFunction;
// Vec<dbl> (System::*sysEval1)(const Vec<dbl> &) = &System::template Eval<dbl>;
// Vec<dbl> (System::*sysEval1)(const Vec<dbl> &) = &System::template Eval<dbl>;
std::vector<int> (bertini::System::*sysDeg1)() const = &bertini::System::Degrees;
std::vector<int> (bertini::System::*sysDeg2)(VariableGroup const&) const = &bertini::System::Degrees;
// Eval functions
template <typename T>
using Eval0_ptr = Vec<T> (SystemBaseT::*)() const;
template <typename T>
static Eval0_ptr<T> return_Eval0_ptr()
{
return &SystemBaseT::template Eval<T>;
};
// evaluate at arguments passed in, return a vector
// in case you wondered how it's done, this is how you enable wrapping of in-place using a Ref.
// this ended up being unnecessary, lol. but i kept it because it might be useful
// for future reference.
template<typename T>
static
Vec<T> eval_wrap_1(SystemBaseT const& self, Eigen::Ref< Vec<T>> x){
return self.template Eval<T>(x);
}
template <typename T>
using Eval1_ptr = Vec<T> (SystemBaseT::*)(const Vec<T>&) const;
template <typename T>
static Eval1_ptr<T> return_Eval1_ptr()
{
return &SystemBaseT::template Eval<T>;
};
template <typename T>
using Eval2_ptr = Vec<T> (SystemBaseT::*)(const Vec<T>&, const T &) const;
template <typename T>
static Eval2_ptr<T> return_Eval2_ptr()
{
return &SystemBaseT::template Eval<T>;
};
// Jacobian Eval functions
template <typename T>
using Jac0_ptr = Mat<T> (SystemBaseT::*)() const;
template <typename T>
static Jac0_ptr<T> return_Jac0_ptr()
{
return &SystemBaseT::template Jacobian<T>;
};
template <typename T>
using Jac1_ptr = Mat<T> (SystemBaseT::*)(const Vec<T>&) const;
template <typename T>
static Jac1_ptr<T> return_Jac1_ptr()
{
return &SystemBaseT::template Jacobian<T>;
};
template <typename T>
using Jac2_ptr = Mat<T> (SystemBaseT::*)(const Vec<T>&, const T &) const;
template <typename T>
static Jac2_ptr<T> return_Jac2_ptr()
{
return &SystemBaseT::template Jacobian<T>;
};
static
void rescale_wrap_inplace_mpfr(SystemBaseT const& self, Eigen::Ref<Vec<mpfr>> x){
Vec<mpfr> result(x);
self.RescalePointToFitPatchInPlace(result);
x = result;}
};
/**
StartSystem class
*/
template<typename SystemBaseT>
class StartSystemVisitor: public def_visitor<StartSystemVisitor<SystemBaseT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
template <typename T>
using GenStart_ptr = Vec<T> (SystemBaseT::*)(unsigned long long) const;
template <typename T>
static GenStart_ptr<T> return_GenStart_ptr()
{
return &SystemBaseT::template StartPoint<T>;
};
};
}
}
#endif

View File

@@ -0,0 +1,245 @@
//This file is part of Bertini 2.
//
//python/tracker.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/tracker.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/tracker.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2016-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// silviana amethyst
// University of Notre Dame
// Summer 2016, Spring 2018
//
// James Collins
// West Texas A&M University
// Summer 2016
//
//
//
// python/tracker.hpp: Header file for exposing trackers to python.
#pragma once
#include "python_common.hpp"
#include "generic_observable.hpp"
#include <bertini2/trackers/tracker.hpp>
namespace bertini{
namespace python{
using namespace bertini::tracking;
/**
Abstract Tracker class
*/
template<typename TrackerT>
class TrackerVisitor: public def_visitor<TrackerVisitor<TrackerT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
using CT = typename TrackerTraits<TrackerT>::BaseComplexType;
using RT = typename TrackerTraits<TrackerT>::BaseRealType;
// resolve overloads for getting and setting predictor method.
void (TrackerT::*set_predictor_)(Predictor)= &TrackerT::SetPredictor;
Predictor (TrackerT::*get_predictor_)(void) const = &TrackerT::GetPredictor;
static
SuccessCode track_path_wrap(TrackerT const& self, Eigen::Ref<Vec<CT>> result, CT const& start_time, CT const& end_time, Vec<CT> const& start_point)
{
Vec<CT> temp_result(self.GetSystem().NumVariables());
auto code = self.TrackPath(temp_result, start_time, end_time, start_point);
result = temp_result;
return code;
}
};// TrackerVisitor class
/**
AMP Tracker class
*/
template<typename TrackerT>
class AMPTrackerVisitor: public def_visitor<AMPTrackerVisitor<TrackerT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
// resolve overloads for refining a point.
template <typename T>
using Refine3_ptr = SuccessCode (TrackerT::*)(Vec<T>&, Vec<T> const&, T const&) const;
template <typename T>
static Refine3_ptr<T> return_Refine3_ptr()
{
return &TrackerT::template Refine<T>;
};
template <typename ComplexT>
using Refine4_ptr = SuccessCode (TrackerT::*)(Vec<ComplexT>&, Vec<ComplexT> const&, ComplexT const&, double const&, unsigned) const;
template <typename ComplexT>
static Refine4_ptr<ComplexT> return_Refine4_ptr()
{
return &TrackerT::template Refine<ComplexT>;
};
};// AMPTrackerVisitor class
/**
Fixed Double Tracker class
*/
template<typename TrackerT>
class FixedDoubleTrackerVisitor: public def_visitor<FixedDoubleTrackerVisitor<TrackerT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
// resolve overloads for refining a point.
template <typename T>
using Refine3_ptr = SuccessCode (TrackerT::*)(Vec<T>&, Vec<T> const&, T const&) const;
template <typename T>
static Refine3_ptr<T> return_Refine3_ptr()
{
return &TrackerT::template Refine<T>;
};
template <typename ComplexT>
using Refine4_ptr = SuccessCode (TrackerT::*)(Vec<ComplexT>&, Vec<ComplexT> const&, ComplexT const&, double const&, unsigned) const;
template <typename ComplexT>
static Refine4_ptr<ComplexT> return_Refine4_ptr()
{
return &TrackerT::template Refine<ComplexT>;
};
};// FixedDoubleTrackerVisitor class
/**
Fixed Multiple Tracker class
*/
template<typename TrackerT>
class FixedMultipleTrackerVisitor: public def_visitor<FixedMultipleTrackerVisitor<TrackerT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
// resolve overloads for refining a point.
template <typename T>
using Refine3_ptr = SuccessCode (TrackerT::*)(Vec<T>&, Vec<T> const&, T const&) const;
template <typename T>
static Refine3_ptr<T> return_Refine3_ptr()
{
return &TrackerT::template Refine<T>;
};
template <typename ComplexT>
using Refine4_ptr = SuccessCode (TrackerT::*)(Vec<ComplexT>&, Vec<ComplexT> const&, ComplexT const&, double const&, unsigned) const;
template <typename ComplexT>
static Refine4_ptr<ComplexT> return_Refine4_ptr()
{
return &TrackerT::template Refine<ComplexT>;
};
};// FixedMultipleTrackerVisitor class
/**
Stepping struct
*/
template<typename T>
class SteppingVisitor: public def_visitor<SteppingVisitor<T> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
};// SteppingVisitor class
// template<typename NumT>
// class TolerancesVisitor: public def_visitor<TolerancesVisitor<NumT> >
// {
// friend class def_visitor_access;
// public:
// template<class PyClass>
// void visit(PyClass& cl) const
// {
// cl
// .def_readwrite("newton_before_endgame", &Tolerances<NumT>::newton_before_endgame)
// .def_readwrite("newton_during_endgame", &Tolerances<NumT>::newton_during_endgame)
// .def_readwrite("final_tolerance", &Tolerances<NumT>::final_tolerance)
// .def_readwrite("final_tolerance_multiplier", &Tolerances<NumT>::final_tolerance_multiplier)
// .def_readwrite("path_truncation_threshold", &Tolerances<NumT>::path_truncation_threshold)
// .def_readwrite("final_tolerance_times_final_tolerance_multiplier", &Tolerances<NumT>::final_tolerance_times_final_tolerance_multiplier)
// ;
// }
// };
// now prototypes for expose functions defined in the .cpp files for the python bindings.
void ExportTrackers();
void ExportAMPTracker();
void ExportFixedTrackers();
void ExportFixedDoubleTracker();
void ExportFixedMultipleTracker();
void ExportConfigSettings();
}}// re: namespaces

View File

@@ -0,0 +1,62 @@
//This file is part of Bertini 2.
//
//python/tracker_observers.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/tracker_observers.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/tracker_observers.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2017-2018 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// silviana amethyst
// UWEC
// Fall 2017, Spring 2018
//
//
// python/tracker_observers.hpp: source file for exposing trackers to python.
#pragma once
#include "python_common.hpp"
#include <bertini2/trackers/observers.hpp>
#include <bertini2/trackers/amp_tracker.hpp>
#include <bertini2/trackers/fixed_precision_tracker.hpp>
namespace bertini{
namespace python{
void ExportTrackerObservers();
using namespace bertini::tracking;
template<typename ObsT>
struct TrackingObserverVisitor: public def_visitor<TrackingObserverVisitor<ObsT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const{
}
};
}} // namespaces

View File

@@ -0,0 +1,111 @@
//This file is part of Bertini 2.
//
//python/zero_dim_export.hpp is free software: you can redistribute it and/or modify
//it under the terms of the GNU General Public License as published by
//the Free Software Foundation, either version 3 of the License, or
//(at your option) any later version.
//
//python/zero_dim_export.hpp is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//GNU General Public License for more details.
//
//You should have received a copy of the GNU General Public License
//along with python/zero_dim_export.hpp. If not, see <http://www.gnu.org/licenses/>.
//
// Copyright(C) 2023 by Bertini2 Development Team
//
// See <http://www.gnu.org/licenses/> for a copy of the license,
// as well as COPYING. Bertini2 is provided with permitted
// additional terms in the b2/licenses/ directory.
// individual authors of this file include:
//
// silviana amethyst
// University of Wisconsin-Eau Claire
// 2023
//
//
// python/zero_dim_export.hpp: Header file for exposing the zero dim solve algorithm to Python
#ifndef BERTINI2_PYBERTINI_NAG_ALGORITHMS_ZERO_DIM
#define BERTINI2_PYBERTINI_NAG_ALGORITHMS_ZERO_DIM
#pragma once
#include "python_common.hpp"
#include <bertini2/endgames.hpp>
#include <bertini2/nag_algorithms/zero_dim_solve.hpp>
namespace bertini{
namespace python{
using namespace bertini;
void ExportZeroDim();
// some sub-functions to help
void ExportZDAlgorithms();
void ExportZDConfigs();
void ExposeZDMetaData();
template<typename AlgoT>
class ZDVisitor: public def_visitor<ZDVisitor<AlgoT> >
{
friend class def_visitor_access;
public:
template<class PyClass>
void visit(PyClass& cl) const;
private:
using MutableTrackerGetter = typename AlgoT::TrackerT& (AlgoT::*)();
static MutableTrackerGetter GetTrackerMutable()
{
return &AlgoT::GetTracker;
};
using MutableEndgameGetter = typename AlgoT::EndgameT& (AlgoT::*)();
static MutableEndgameGetter GetEndgameMutable()
{
return &AlgoT::GetEndgame;
};
// pattern:
// returned type. name. argument types.
// typename AlgoT::TrackerT& (*GetTrackerMutable)() = &AlgoT::GetTracker;
};
}} // namespaces
#endif // the include guards