//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 .
//
// Copyright(C) 2016-2018 by Bertini2 Development Team
//
// See 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
#include
#include "python_common.hpp"
namespace bertini{
namespace python{
using namespace bertini;
template using Vec = Eigen::Matrix;
template using Mat = Eigen::Matrix;
using dbl = std::complex;
using mpfr = bertini::mpfr_complex;
void ExportAllSystems();
// some useful subfunctions used in ExportAllSystems
void ExportSystem();
void ExportStartSystems();
void ExportStartSystemBase();
void ExportTotalDegree();
/**
System class
*/
template
class SystemVisitor: public def_visitor >
{
friend class def_visitor_access;
public:
template
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 const&);
using fn_and_name = void (bertini::System::*)(std::shared_ptr const&, std::string const&);
static fn_and_name AddFnAndName()
{
return &System::AddFunction;
};
static void AddJustFn(bertini::System& self, std::shared_ptr const& f) { return self.AddFunction(f);}
void (bertini::System::*sysAddFunc1)(std::shared_ptr const&) = &bertini::System::AddFunction;
// void (bertini::System::*sysAddFunc2)(std::shared_ptr const&, std::string const&) = &bertini::System::AddFunction;
// Vec (System::*sysEval1)(const Vec &) = &System::template Eval;
// Vec (System::*sysEval1)(const Vec &) = &System::template Eval;
std::vector (bertini::System::*sysDeg1)() const = &bertini::System::Degrees;
std::vector (bertini::System::*sysDeg2)(VariableGroup const&) const = &bertini::System::Degrees;
// Eval functions
template
using Eval0_ptr = Vec (SystemBaseT::*)() const;
template
static Eval0_ptr return_Eval0_ptr()
{
return &SystemBaseT::template Eval;
};
// 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
static
Vec eval_wrap_1(SystemBaseT const& self, Eigen::Ref< Vec> x){
return self.template Eval(x);
}
template
using Eval1_ptr = Vec (SystemBaseT::*)(const Vec&) const;
template
static Eval1_ptr return_Eval1_ptr()
{
return &SystemBaseT::template Eval;
};
template
using Eval2_ptr = Vec (SystemBaseT::*)(const Vec&, const T &) const;
template
static Eval2_ptr return_Eval2_ptr()
{
return &SystemBaseT::template Eval;
};
// Jacobian Eval functions
template
using Jac0_ptr = Mat (SystemBaseT::*)() const;
template
static Jac0_ptr return_Jac0_ptr()
{
return &SystemBaseT::template Jacobian;
};
template
using Jac1_ptr = Mat (SystemBaseT::*)(const Vec&) const;
template
static Jac1_ptr return_Jac1_ptr()
{
return &SystemBaseT::template Jacobian;
};
template
using Jac2_ptr = Mat (SystemBaseT::*)(const Vec&, const T &) const;
template
static Jac2_ptr return_Jac2_ptr()
{
return &SystemBaseT::template Jacobian;
};
static
void rescale_wrap_inplace_mpfr(SystemBaseT const& self, Eigen::Ref> x){
Vec result(x);
self.RescalePointToFitPatchInPlace(result);
x = result;}
};
/**
StartSystem class
*/
template
class StartSystemVisitor: public def_visitor >
{
friend class def_visitor_access;
public:
template
void visit(PyClass& cl) const;
private:
template
using GenStart_ptr = Vec (SystemBaseT::*)(unsigned long long) const;
template
static GenStart_ptr return_GenStart_ptr()
{
return &SystemBaseT::template StartPoint;
};
};
}
}
#endif