diff --git a/pyext/GCTAObservation.i b/pyext/GCTAObservation.i new file mode 100644 index 0000000..19dceea --- /dev/null +++ b/pyext/GCTAObservation.i @@ -0,0 +1,59 @@ +/*************************************************************************** + * GCTAObservation.i - CTA Observation class SWIG interface * + * ----------------------------------------------------------------------- * + * 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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GCTAObservation.i + * @brief GCTAObservation class SWIG interface. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GCTAObservation.hpp" +%} + + +/***********************************************************************//** + * @class GCTAObservation + * + * @brief Interface class for CTA observations. + ***************************************************************************/ +class GCTAObservation : public GObservation { +public: + // Constructors and destructors + GCTAObservation(void); + GCTAObservation(const GCTAObservation& obs); + virtual ~GCTAObservation(void); + + // Methods + void response(const std::string& irfname, std::string caldb = ""); + void load_unbinned(const std::string& filename); + void load_binned(const std::string& filename); +}; + + +/***********************************************************************//** + * @brief GCTAObservation class extension + ***************************************************************************/ +%extend GCTAObservation { + char *__str__() { + static char str_buffer[10001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 10001); + str_buffer[10000] = '\0'; + return str_buffer; + } + GCTAObservation copy() { + return (*self); + } +}; diff --git a/pyext/GModel.i b/pyext/GModel.i new file mode 100644 index 0000000..5a78479 --- /dev/null +++ b/pyext/GModel.i @@ -0,0 +1,77 @@ +/*************************************************************************** + * GModel.i - Model class SWIG interface * + * ----------------------------------------------------------------------- * + * copyright (C) 2009-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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GModel.i + * @brief GModel class SWIG interface. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GModel.hpp" +%} + + +/***********************************************************************//** + * @class GModel + * + * @brief GModel class SWIG interface defintion. + ***************************************************************************/ +class GModel { +public: + // Constructors and destructors + GModel(void); + GModel(const GModelSpatial& spatial, const GModelSpectral& spectral); + GModel(const GModel& model); + ~GModel(void); + + // Methods + GModelPar* par(int index) const; + double value(const GSkyDir& srcDir, const GEnergy& srcEng, + const GTime& srcTime); + GVector gradients(const GSkyDir& srcDir, const GEnergy& srcEng, + const GTime& srcTime); + double eval(const GInstDir& obsDir, const GEnergy& obsEng, + const GTime& obsTime, const GResponse& rsp, + const GPointing& pnt); + double eval_gradients(const GInstDir& obsDir, const GEnergy& obsEng, + const GTime& obsTime, const GResponse& rsp, + const GPointing& pnt); + bool isvalid(const std::string& name); + + // Inline methods + std::string name(void) const { return m_name; } + void name(const std::string& name) { m_name=name; return; } + int npars(void) const { return m_npars; } + const GModelSpatial* spatial(void) const { return m_spatial; } + const GModelSpectral* spectral(void) const { return m_spectral; } + const GModelTemporal* temporal(void) const { return m_temporal; } +}; + + +/***********************************************************************//** + * @brief GModel class extension + ***************************************************************************/ +%extend GModel { + char *__str__() { + static char str_buffer[10001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 10001); + str_buffer[10000] = '\0'; + return str_buffer; + } + GModel copy() { + return (*self); + } +}; diff --git a/pyext/GModelPar.i b/pyext/GModelPar.i new file mode 100644 index 0000000..12bf133 --- /dev/null +++ b/pyext/GModelPar.i @@ -0,0 +1,85 @@ +/*************************************************************************** + * GModelPar.i - Model parameter class SWIG interface * + * ----------------------------------------------------------------------- * + * copyright (C) 2009-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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GModelPar.i + * @brief GModelPar class SWIG interface. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GModelPar.hpp" +%} + + +/***********************************************************************//** + * @class GModelPar + * + * @brief GModelPar class SWIG interface defintion. + ***************************************************************************/ +class GModelPar { +public: + // Constructors and destructors + GModelPar(void); + GModelPar(const GModelPar& par); + ~GModelPar(); + + // Methods + std::string name(void) const { return m_name; } + std::string unit(void) const { return m_unit; } + double real_value(void) const { return m_value*m_scale; } + double real_error(void) const { return m_error*m_scale; } + double real_min(void) const { return m_min*m_scale; } + double real_max(void) const { return m_max*m_scale; } + double value(void) const { return m_value; } + double error(void) const { return m_error; } + double gradient(void) const { return m_gradient; } + double min(void) const { return m_min; } + double max(void) const { return m_max; } + double scale(void) const { return m_scale; } + bool isfree(void) const { return m_free; } + bool hasmin(void) const { return m_hasmin; } + bool hasmax(void) const { return m_hasmax; } + void name(const std::string& name) { m_name=name; return; } + void unit(const std::string& unit) { m_unit=unit; return; } + void value(const double& value); + void error(const double& error) { m_error=error; return; } + void gradient(const double& gradient) { m_gradient=gradient; return; } + void min(const double& min); + void max(const double& max); + void scale(const double& scale) { m_scale=scale; return; } + void range(const double& min, const double& max); + void remove_min(void) { m_hasmin=false; return; } + void remove_max(void) { m_hasmax=false; return; } + void remove_range(void) { m_hasmin=false; m_hasmax=false; return; } + void free(void) { m_free=true; return; } + void fix(void) { m_free=false; return; } +}; + + +/***********************************************************************//** + * @brief GModelPar class extension + ***************************************************************************/ +%extend GModelPar { + char *__str__() { + static char str_buffer[1001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 1001); + str_buffer[1000] = '\0'; + return str_buffer; + } + GModelPar copy() { + return (*self); + } +}; diff --git a/pyext/GModelSpatial.i b/pyext/GModelSpatial.i new file mode 100644 index 0000000..2340816 --- /dev/null +++ b/pyext/GModelSpatial.i @@ -0,0 +1,42 @@ +/*************************************************************************** + * GModelSpatial.i - Spatial model class SWIG interface * + * ----------------------------------------------------------------------- * + * copyright (C) 2009-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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GModelSpatial.i + * @brief GModelSpatial class SWIG interface. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GModelSpatial.hpp" +%} + + +/***********************************************************************//** + * @class GModelSpatial + * + * @brief Abstract SWIG interface definition for the spatial model class. + ***************************************************************************/ +class GModelSpatial { +public: + // Constructors and destructors + explicit GModelSpatial(void); + GModelSpatial(const GModelSpatial& model); + virtual ~GModelSpatial(); + + // Virtual methods + virtual int npars(void) const = 0; + virtual GModelPar* par(int index) const = 0; + virtual double eval(const GSkyDir& srcDir) = 0; + virtual double eval_gradients(const GSkyDir& srcDir) = 0; + virtual bool isptsource(void) const { return false; } +}; diff --git a/pyext/GModelSpatialPtsrc.i b/pyext/GModelSpatialPtsrc.i new file mode 100644 index 0000000..01b95c0 --- /dev/null +++ b/pyext/GModelSpatialPtsrc.i @@ -0,0 +1,64 @@ +/*************************************************************************** + * GModelSpatialPtsrc.i - Spatial point source model class SWIG interface* + * ----------------------------------------------------------------------- * + * copyright (C) 2009-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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GModelSpatialPtsrc.i + * @brief GModelSpatialPtsrc class SWIG interface. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GModelSpatialPtsrc.hpp" +%} + + +/***********************************************************************//** + * @class GModelSpatialPtsrc + * + * @brief Point source model interface definition. + ***************************************************************************/ +class GModelSpatialPtsrc : public GModelSpatial { +public: + // Constructors and destructors + explicit GModelSpatialPtsrc(void); + explicit GModelSpatialPtsrc(const GSkyDir& dir); + GModelSpatialPtsrc(const GModelSpatialPtsrc& model); + ~GModelSpatialPtsrc(void); + + // Methods + int npars(void) const { return m_npars; } + GModelPar* par(int index) const; + double eval(const GSkyDir& srcDir); + double eval_gradients(const GSkyDir& srcDir); + bool isptsource(void) const { return true; } + double ra(void) const { return m_ra.real_value(); } + double dec(void) const { return m_dec.real_value(); } +}; + + +/***********************************************************************//** + * @brief GModelSpatialPtsrc class extension + ***************************************************************************/ +%extend GModelSpatialPtsrc { + char *__str__() { + static char str_buffer[1001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 1001); + str_buffer[1000] = '\0'; + return str_buffer; + } + GModelSpatialPtsrc copy() { + return (*self); + } +}; diff --git a/pyext/GModelSpectral.i b/pyext/GModelSpectral.i new file mode 100644 index 0000000..3d8e01f --- /dev/null +++ b/pyext/GModelSpectral.i @@ -0,0 +1,41 @@ +/*************************************************************************** + * GModelSpectral.i - Spectral model class SWIG interface * + * ----------------------------------------------------------------------- * + * copyright (C) 2009-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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GModelSpectral.i + * @brief GModelSpectral class SWIG interface. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GModelSpectral.hpp" +%} + + +/***********************************************************************//** + * @class GModelSpectral + * + * @brief Abstract SWIG interface definition for the spectral model class. + ***************************************************************************/ +class GModelSpectral { +public: + // Constructors and destructors + GModelSpectral(void); + GModelSpectral(const GModelSpectral& model); + virtual ~GModelSpectral(); + + // Virtual methods + virtual int npars(void) const = 0; + virtual GModelPar* par(int index) const = 0; + virtual double eval(const GEnergy& srcEng) = 0; + virtual double eval_gradients(const GEnergy& srcEng) = 0; +}; diff --git a/pyext/GModelSpectralPlaw.i b/pyext/GModelSpectralPlaw.i new file mode 100644 index 0000000..885ba09 --- /dev/null +++ b/pyext/GModelSpectralPlaw.i @@ -0,0 +1,68 @@ +/*************************************************************************** + * GModelSpectralPlaw.i - Spectral power law model class SWIG interface * + * ----------------------------------------------------------------------- * + * copyright (C) 2009-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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GModelSpectralPlaw.i + * @brief GModelSpectralPlaw class SWIG interface. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GModelSpectralPlaw.hpp" +%} + + +/***********************************************************************//** + * @class GModelSpectralPlaw + * + * @brief Powerlaw SWIG interface definition. + ***************************************************************************/ +class GModelSpectralPlaw : public GModelSpectral { +public: + // Constructors and destructors + GModelSpectralPlaw(void); + explicit GModelSpectralPlaw(const double& norm, const double& index); + GModelSpectralPlaw(const GModelSpectralPlaw& model); + virtual ~GModelSpectralPlaw(void); + + // Methods + int npars(void) const { return m_npars; } + GModelPar* par(int index) const; + GModelPar* par_norm(void) { return &m_norm; } + GModelPar* par_index(void) { return &m_index; } + GModelPar* par_pivot(void) { return &m_pivot; } + double eval(const GEnergy& srcEng); + double eval_gradients(const GEnergy& srcEng); + void autoscale(void); + double norm(void) const { return m_norm.real_value(); } + double index(void) const { return m_index.real_value(); } + double pivot(void) const { return m_pivot.real_value(); } +}; + + +/***********************************************************************//** + * @brief GModelSpectralPlaw class extension + ***************************************************************************/ +%extend GModelSpectralPlaw { + char *__str__() { + static char str_buffer[1001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 1001); + str_buffer[1000] = '\0'; + return str_buffer; + } + GModelSpectralPlaw copy() { + return (*self); + } +}; diff --git a/pyext/GModelTemporal.i b/pyext/GModelTemporal.i new file mode 100644 index 0000000..0943327 --- /dev/null +++ b/pyext/GModelTemporal.i @@ -0,0 +1,41 @@ +/*************************************************************************** + * GModelTemporal.i - Temporal model class SWIG interface * + * ----------------------------------------------------------------------- * + * copyright (C) 2009-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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GModelTemporal.i + * @brief GModelTemporal class SWIG interface. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GModelTemporal.hpp" +%} + + +/***********************************************************************//** + * @class GModelTemporal + * + * @brief Abstract SWIG interface definition for the temporal model class. + ***************************************************************************/ +class GModelTemporal { +public: + // Constructors and destructors + GModelTemporal(void); + GModelTemporal(const GModelTemporal& model); + virtual ~GModelTemporal(void); + + // Virtual methods + virtual int npars(void) const = 0; + virtual GModelPar* par(int index) const = 0; + virtual double eval(const GTime& srcTime) = 0; + virtual double eval_gradients(const GTime& srcTime) = 0; +}; diff --git a/pyext/GModelTemporalConst.i b/pyext/GModelTemporalConst.i new file mode 100644 index 0000000..a771482 --- /dev/null +++ b/pyext/GModelTemporalConst.i @@ -0,0 +1,60 @@ +/*************************************************************************** + * GModelTemporalConst.i - Temporal constant model class SWIG interface * + * ----------------------------------------------------------------------- * + * copyright (C) 2009-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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GModelTemporalConst.i + * @brief GModelTemporalConst class SWIG interface. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GModelTemporalConst.hpp" +%} + + +/***********************************************************************//** + * @class GModelTemporalConst + * + * @brief SWIG interface definition for the constant model class. + ***************************************************************************/ +class GModelTemporalConst : public GModelTemporal { +public: + // Constructors and destructors + GModelTemporalConst(void); + GModelTemporalConst(const GModelTemporalConst& model); + virtual ~GModelTemporalConst(void); + + // Methods + int npars(void) const { return m_npars; } + GModelPar* par(int index) const; + double eval(const GTime& srcTime); + double eval_gradients(const GTime& srcTime); +}; + + +/***********************************************************************//** + * @brief GModelTemporalConst class extension + ***************************************************************************/ +%extend GModelTemporalConst { + char *__str__() { + static char str_buffer[1001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 1001); + str_buffer[1000] = '\0'; + return str_buffer; + } + GModelTemporalConst copy() { + return (*self); + } +}; diff --git a/pyext/GModels.i b/pyext/GModels.i new file mode 100644 index 0000000..a5d9084 --- /dev/null +++ b/pyext/GModels.i @@ -0,0 +1,71 @@ +/*************************************************************************** + * GModels.i - Model container class SWIG interface * + * ----------------------------------------------------------------------- * + * copyright (C) 2009-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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GModels.i + * @brief GModels class SWIG interface. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GModels.hpp" +%} + + +/***********************************************************************//** + * @class GModels + * + * @brief GModels class SWIG interface defintion. + ***************************************************************************/ +class GModels : public GOptimizerPars { +public: + // Constructors and destructors + GModels(void); + GModels(const GModels& models); + ~GModels(void); + + // Methods + void append(const GModel& model); + double eval(const GInstDir& obsDir, const GEnergy& obsEng, + const GTime& obsTime, const GResponse& rsp, + const GPointing& pnt); + double eval_gradients(const GInstDir& obsDir, const GEnergy& obsEng, + const GTime& obsTime, const GResponse& rsp, + const GPointing& pnt); + int size(void) const { return m_elements; } +}; + + +/***********************************************************************//** + * @brief GModels class extension + ***************************************************************************/ +%extend GModels { + char *__str__() { + static char str_buffer[10001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 10001); + str_buffer[10000] = '\0'; + return str_buffer; + } + GModel* __getitem__(int index) { + if (index >= 0 && index < self->size()) + return (*self)(index); + else + throw GException::out_of_range("__getitem__(int)", index, + self->size()); + } + GModels copy() { + return (*self); + } +}; diff --git a/pyext/GOptimizer.i b/pyext/GOptimizer.i new file mode 100644 index 0000000..8ccdb46 --- /dev/null +++ b/pyext/GOptimizer.i @@ -0,0 +1,39 @@ +/*************************************************************************** + * GOptimizer.i - Optimizer class SWIG interface * + * ----------------------------------------------------------------------- * + * copyright (C) 2009-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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GOptimizer.i + * @brief GOptimizer class SWIG interface. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GOptimizer.hpp" +%} + + +/***********************************************************************//** + * @class GOptimizer + * + * @brief GOptimizer class SWIG interface defintion. + ***************************************************************************/ +class GOptimizer { +public: + // Constructors and destructors + GOptimizer(); + GOptimizer(const GOptimizer& opt); + virtual ~GOptimizer(); + + // Operators (we need those to make the class abstract!!!) + virtual GOptimizerPars& operator() (GOptimizerFunction& fct, GOptimizerPars& p) = 0; + virtual GModels& operator() (GOptimizerFunction& fct, GModels& m) = 0; +}; diff --git a/pyext/GOptimizerLM.i b/pyext/GOptimizerLM.i new file mode 100644 index 0000000..f5eab3e --- /dev/null +++ b/pyext/GOptimizerLM.i @@ -0,0 +1,77 @@ +/*************************************************************************** + * GOptimizerLM.i - Levenberg Marquardt optimizer class SWIG interface * + * ----------------------------------------------------------------------- * + * copyright (C) 2009-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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GOptimizerLM.i + * @brief GOptimizerLM class SWIG interface. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GOptimizerLM.hpp" +%} + + +/***********************************************************************//** + * @class GOptimizerLM + * + * @brief GOptimizerLM class SWIG interface defintion. + ***************************************************************************/ +class GOptimizerLM : public GOptimizer { +public: + + // Constructors and destructors + GOptimizerLM(void); + GOptimizerLM(const GOptimizerLM& opt); + virtual ~GOptimizerLM(void); + + // Operators (we need those to make the class not abstract!!!) + GOptimizerPars& operator() (GOptimizerFunction& fct, GOptimizerPars& p); + GModels& operator() (GOptimizerFunction& fct, GModels& m); + + // Methods + void max_iter(const int& n) { m_max_iter=n; return; } + void max_stalls(const int& n) { m_max_stall=n; return; } + void lambda_start(const double& val) { m_lambda_start=val; return; } + void lambda_inc(const double& val) { m_lambda_inc=val; return; } + void lambda_dec(const double& val) { m_lambda_dec=val; return; } + void eps(const double& eps) { m_eps=eps; return; } + int max_iter(void) const { return m_max_iter; } + int max_stalls(void) const { return m_max_stall; } + int status(void) const { return m_status; } + int iter(void) const { return m_iter; } + double lambda_start(void) const { return m_lambda_start; } + double lambda_inc(void) const { return m_lambda_inc; } + double lambda_dec(void) const { return m_lambda_dec; } + //double lambda(void) const { return m_lambda; } + double eps(void) const { return m_eps; } + double value(void) const { return m_value; } +}; + + +/***********************************************************************//** + * @brief GOptimizerLM class extension + ***************************************************************************/ +%extend GOptimizerLM { + char *__str__() { + static char str_buffer[10001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 10001); + str_buffer[10000] = '\0'; + return str_buffer; + } + GOptimizerLM copy() { + return (*self); + } +}; diff --git a/pyext/GOptimizerPars.i b/pyext/GOptimizerPars.i new file mode 100644 index 0000000..b93313a --- /dev/null +++ b/pyext/GOptimizerPars.i @@ -0,0 +1,59 @@ +/*************************************************************************** + * GOptimizerPars.i - Parameter container class SWIG interface * + * ----------------------------------------------------------------------- * + * copyright (C) 2009-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 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ +/** + * @file GOptimizerPars.i + * @brief GOptimizerPars class SWIG interface. + * @author J. Knodlseder + */ +%{ +/* Put headers and other declarations here that are needed for compilation */ +#include "GOptimizerPars.hpp" +%} + + +/***********************************************************************//** + * @class GOptimizerPars + * + * @brief GOptimizerPars container class SWIG interface defintion. + ***************************************************************************/ +class GOptimizerPars { +public: + // Constructors and destructors + GOptimizerPars(void); + GOptimizerPars(const GOptimizerPars& pars); + ~GOptimizerPars(); + + // Methods + int npars(void) const { return m_npars; } + int nfree(void) const; + GModelPar* par(int index) const; +}; + + +/***********************************************************************//** + * @brief GOptimizerPars class extension + ***************************************************************************/ +%extend GOptimizerPars { + char *__str__() { + static char str_buffer[10001]; + std::ostringstream buffer; + buffer << *self; + std::string str = buffer.str(); + strncpy(str_buffer, (char*)str.c_str(), 10001); + str_buffer[10000] = '\0'; + return str_buffer; + } + GOptimizerPars copy() { + return (*self); + } +};