diff --git a/pyext/GIntegral.i b/pyext/GIntegral.i new file mode 100644 index 0000000..a0fa895 --- /dev/null +++ b/pyext/GIntegral.i @@ -0,0 +1,77 @@ +/*************************************************************************** + * GIntegral.hpp - Integration class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010-2011 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program 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. * + * * + * This program 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 this program. If not, see . * + * * + ***************************************************************************/ +/** + * @file GIntegral.hpp + * @brief Integration class Python interface definition + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GIntegral.hpp" +#include "GTools.hpp" +%} + + +/***********************************************************************//** + * @class GIntegral + * + * @brief Integration class Python interface defintion. + * + * This class allows to perform integration using various methods. The + * integrand is implemented by a derived class of GIntegrand. + ***************************************************************************/ +class GIntegral { +public: + + // Constructors and destructors + explicit GIntegral(void); + explicit GIntegral(GIntegrand* integrand); + GIntegral(const GIntegral& integral); + virtual ~GIntegral(void); + + // Methods + void clear(void); + GIntegral* clone(void) const; + void max_iter(const int& max_iter) { m_max_iter=max_iter; } + void eps(const double& eps) { m_eps=eps; } + void silent(const bool& silent) { m_silent=silent; } + const int& iter(void) const { return m_iter; } + const int& max_iter(void) const { return m_max_iter; } + const double& eps(void) const { return m_eps; } + const bool& silent(void) const { return m_silent; } + void integrand(GIntegrand* integrand) { m_integrand=integrand; } + const GIntegrand* integrand(void) const { return m_integrand; } + double romb(double a, double b, int k = 5); + double trapzd(double a, double b, int n = 1, double result = 0.0); +}; + + +/***********************************************************************//** + * @brief GIntegral class extension + ***************************************************************************/ +%extend GIntegral { + char *__str__() { + return tochar(self->print()); + } + GIntegral copy() { + return (*self); + } +}; diff --git a/pyext/GIntegrand.i b/pyext/GIntegrand.i new file mode 100644 index 0000000..8ed96eb --- /dev/null +++ b/pyext/GIntegrand.i @@ -0,0 +1,66 @@ +/*************************************************************************** + * GIntegrand.hpp - Integrand function abstract base class * + * ----------------------------------------------------------------------- * + * copyright (C) 2010 by Jurgen Knodlseder * + * ----------------------------------------------------------------------- * + * * + * This program 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. * + * * + * This program 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 this program. If not, see . * + * * + ***************************************************************************/ +/** + * @file GIntegrand.hpp + * @brief Integrand abstract virtual base class Python interface definition. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GIntegrand.hpp" +#include "GTools.hpp" +%} + + +/***********************************************************************//** + * @class GIntegrand + * + * @brief Integrand class Python interface defintion. + * + * This class implements the abstract interface for the integration kernel + * function. It has no members. The only pure virtual method that has to + * be implemented by the derived class is the eval() method that provides + * function evaluation at a given value x, e.g. y=eval(x). + ***************************************************************************/ +class GIntegrand { +public: + + // Constructors and destructors + GIntegrand(void); + GIntegrand(const GIntegrand& arg); + virtual ~GIntegrand(void); + + // Methods + virtual double eval(double x) = 0; + +protected: + // Protected methods + void init_members(void); + void copy_members(const GIntegrand& arg); + void free_members(void); +}; + + +/***********************************************************************//** + * @brief GIntegrand class extension + ***************************************************************************/ +//%extend GIntegrand { +//};