Commit e4f1f907df5326a2ce9d99d9cb4c07183d5c58fa

Authored by knodlseder
1 parent d5afa149

initial version

pyext/GCTAObservation.i 0 โ†’ 100644
  1 +/***************************************************************************
  2 + * GCTAObservation.i - CTA Observation class SWIG interface *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GCTAObservation.i
  15 + * @brief GCTAObservation class SWIG interface.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GCTAObservation.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GCTAObservation
  26 + *
  27 + * @brief Interface class for CTA observations.
  28 + ***************************************************************************/
  29 +class GCTAObservation : public GObservation {
  30 +public:
  31 + // Constructors and destructors
  32 + GCTAObservation(void);
  33 + GCTAObservation(const GCTAObservation& obs);
  34 + virtual ~GCTAObservation(void);
  35 +
  36 + // Methods
  37 + void response(const std::string& irfname, std::string caldb = "");
  38 + void load_unbinned(const std::string& filename);
  39 + void load_binned(const std::string& filename);
  40 +};
  41 +
  42 +
  43 +/***********************************************************************//**
  44 + * @brief GCTAObservation class extension
  45 + ***************************************************************************/
  46 +%extend GCTAObservation {
  47 + char *__str__() {
  48 + static char str_buffer[10001];
  49 + std::ostringstream buffer;
  50 + buffer << *self;
  51 + std::string str = buffer.str();
  52 + strncpy(str_buffer, (char*)str.c_str(), 10001);
  53 + str_buffer[10000] = '\0';
  54 + return str_buffer;
  55 + }
  56 + GCTAObservation copy() {
  57 + return (*self);
  58 + }
  59 +};
... ...
pyext/GModel.i 0 โ†’ 100644
  1 +/***************************************************************************
  2 + * GModel.i - Model class SWIG interface *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2009-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GModel.i
  15 + * @brief GModel class SWIG interface.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GModel.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GModel
  26 + *
  27 + * @brief GModel class SWIG interface defintion.
  28 + ***************************************************************************/
  29 +class GModel {
  30 +public:
  31 + // Constructors and destructors
  32 + GModel(void);
  33 + GModel(const GModelSpatial& spatial, const GModelSpectral& spectral);
  34 + GModel(const GModel& model);
  35 + ~GModel(void);
  36 +
  37 + // Methods
  38 + GModelPar* par(int index) const;
  39 + double value(const GSkyDir& srcDir, const GEnergy& srcEng,
  40 + const GTime& srcTime);
  41 + GVector gradients(const GSkyDir& srcDir, const GEnergy& srcEng,
  42 + const GTime& srcTime);
  43 + double eval(const GInstDir& obsDir, const GEnergy& obsEng,
  44 + const GTime& obsTime, const GResponse& rsp,
  45 + const GPointing& pnt);
  46 + double eval_gradients(const GInstDir& obsDir, const GEnergy& obsEng,
  47 + const GTime& obsTime, const GResponse& rsp,
  48 + const GPointing& pnt);
  49 + bool isvalid(const std::string& name);
  50 +
  51 + // Inline methods
  52 + std::string name(void) const { return m_name; }
  53 + void name(const std::string& name) { m_name=name; return; }
  54 + int npars(void) const { return m_npars; }
  55 + const GModelSpatial* spatial(void) const { return m_spatial; }
  56 + const GModelSpectral* spectral(void) const { return m_spectral; }
  57 + const GModelTemporal* temporal(void) const { return m_temporal; }
  58 +};
  59 +
  60 +
  61 +/***********************************************************************//**
  62 + * @brief GModel class extension
  63 + ***************************************************************************/
  64 +%extend GModel {
  65 + char *__str__() {
  66 + static char str_buffer[10001];
  67 + std::ostringstream buffer;
  68 + buffer << *self;
  69 + std::string str = buffer.str();
  70 + strncpy(str_buffer, (char*)str.c_str(), 10001);
  71 + str_buffer[10000] = '\0';
  72 + return str_buffer;
  73 + }
  74 + GModel copy() {
  75 + return (*self);
  76 + }
  77 +};
... ...
pyext/GModelPar.i 0 โ†’ 100644
  1 +/***************************************************************************
  2 + * GModelPar.i - Model parameter class SWIG interface *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2009-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GModelPar.i
  15 + * @brief GModelPar class SWIG interface.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GModelPar.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GModelPar
  26 + *
  27 + * @brief GModelPar class SWIG interface defintion.
  28 + ***************************************************************************/
  29 +class GModelPar {
  30 +public:
  31 + // Constructors and destructors
  32 + GModelPar(void);
  33 + GModelPar(const GModelPar& par);
  34 + ~GModelPar();
  35 +
  36 + // Methods
  37 + std::string name(void) const { return m_name; }
  38 + std::string unit(void) const { return m_unit; }
  39 + double real_value(void) const { return m_value*m_scale; }
  40 + double real_error(void) const { return m_error*m_scale; }
  41 + double real_min(void) const { return m_min*m_scale; }
  42 + double real_max(void) const { return m_max*m_scale; }
  43 + double value(void) const { return m_value; }
  44 + double error(void) const { return m_error; }
  45 + double gradient(void) const { return m_gradient; }
  46 + double min(void) const { return m_min; }
  47 + double max(void) const { return m_max; }
  48 + double scale(void) const { return m_scale; }
  49 + bool isfree(void) const { return m_free; }
  50 + bool hasmin(void) const { return m_hasmin; }
  51 + bool hasmax(void) const { return m_hasmax; }
  52 + void name(const std::string& name) { m_name=name; return; }
  53 + void unit(const std::string& unit) { m_unit=unit; return; }
  54 + void value(const double& value);
  55 + void error(const double& error) { m_error=error; return; }
  56 + void gradient(const double& gradient) { m_gradient=gradient; return; }
  57 + void min(const double& min);
  58 + void max(const double& max);
  59 + void scale(const double& scale) { m_scale=scale; return; }
  60 + void range(const double& min, const double& max);
  61 + void remove_min(void) { m_hasmin=false; return; }
  62 + void remove_max(void) { m_hasmax=false; return; }
  63 + void remove_range(void) { m_hasmin=false; m_hasmax=false; return; }
  64 + void free(void) { m_free=true; return; }
  65 + void fix(void) { m_free=false; return; }
  66 +};
  67 +
  68 +
  69 +/***********************************************************************//**
  70 + * @brief GModelPar class extension
  71 + ***************************************************************************/
  72 +%extend GModelPar {
  73 + char *__str__() {
  74 + static char str_buffer[1001];
  75 + std::ostringstream buffer;
  76 + buffer << *self;
  77 + std::string str = buffer.str();
  78 + strncpy(str_buffer, (char*)str.c_str(), 1001);
  79 + str_buffer[1000] = '\0';
  80 + return str_buffer;
  81 + }
  82 + GModelPar copy() {
  83 + return (*self);
  84 + }
  85 +};
... ...
pyext/GModelSpatial.i 0 โ†’ 100644
  1 +/***************************************************************************
  2 + * GModelSpatial.i - Spatial model class SWIG interface *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2009-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GModelSpatial.i
  15 + * @brief GModelSpatial class SWIG interface.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GModelSpatial.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GModelSpatial
  26 + *
  27 + * @brief Abstract SWIG interface definition for the spatial model class.
  28 + ***************************************************************************/
  29 +class GModelSpatial {
  30 +public:
  31 + // Constructors and destructors
  32 + explicit GModelSpatial(void);
  33 + GModelSpatial(const GModelSpatial& model);
  34 + virtual ~GModelSpatial();
  35 +
  36 + // Virtual methods
  37 + virtual int npars(void) const = 0;
  38 + virtual GModelPar* par(int index) const = 0;
  39 + virtual double eval(const GSkyDir& srcDir) = 0;
  40 + virtual double eval_gradients(const GSkyDir& srcDir) = 0;
  41 + virtual bool isptsource(void) const { return false; }
  42 +};
... ...
pyext/GModelSpatialPtsrc.i 0 โ†’ 100644
  1 +/***************************************************************************
  2 + * GModelSpatialPtsrc.i - Spatial point source model class SWIG interface*
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2009-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GModelSpatialPtsrc.i
  15 + * @brief GModelSpatialPtsrc class SWIG interface.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GModelSpatialPtsrc.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GModelSpatialPtsrc
  26 + *
  27 + * @brief Point source model interface definition.
  28 + ***************************************************************************/
  29 +class GModelSpatialPtsrc : public GModelSpatial {
  30 +public:
  31 + // Constructors and destructors
  32 + explicit GModelSpatialPtsrc(void);
  33 + explicit GModelSpatialPtsrc(const GSkyDir& dir);
  34 + GModelSpatialPtsrc(const GModelSpatialPtsrc& model);
  35 + ~GModelSpatialPtsrc(void);
  36 +
  37 + // Methods
  38 + int npars(void) const { return m_npars; }
  39 + GModelPar* par(int index) const;
  40 + double eval(const GSkyDir& srcDir);
  41 + double eval_gradients(const GSkyDir& srcDir);
  42 + bool isptsource(void) const { return true; }
  43 + double ra(void) const { return m_ra.real_value(); }
  44 + double dec(void) const { return m_dec.real_value(); }
  45 +};
  46 +
  47 +
  48 +/***********************************************************************//**
  49 + * @brief GModelSpatialPtsrc class extension
  50 + ***************************************************************************/
  51 +%extend GModelSpatialPtsrc {
  52 + char *__str__() {
  53 + static char str_buffer[1001];
  54 + std::ostringstream buffer;
  55 + buffer << *self;
  56 + std::string str = buffer.str();
  57 + strncpy(str_buffer, (char*)str.c_str(), 1001);
  58 + str_buffer[1000] = '\0';
  59 + return str_buffer;
  60 + }
  61 + GModelSpatialPtsrc copy() {
  62 + return (*self);
  63 + }
  64 +};
... ...
pyext/GModelSpectral.i 0 โ†’ 100644
  1 +/***************************************************************************
  2 + * GModelSpectral.i - Spectral model class SWIG interface *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2009-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GModelSpectral.i
  15 + * @brief GModelSpectral class SWIG interface.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GModelSpectral.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GModelSpectral
  26 + *
  27 + * @brief Abstract SWIG interface definition for the spectral model class.
  28 + ***************************************************************************/
  29 +class GModelSpectral {
  30 +public:
  31 + // Constructors and destructors
  32 + GModelSpectral(void);
  33 + GModelSpectral(const GModelSpectral& model);
  34 + virtual ~GModelSpectral();
  35 +
  36 + // Virtual methods
  37 + virtual int npars(void) const = 0;
  38 + virtual GModelPar* par(int index) const = 0;
  39 + virtual double eval(const GEnergy& srcEng) = 0;
  40 + virtual double eval_gradients(const GEnergy& srcEng) = 0;
  41 +};
... ...
pyext/GModelSpectralPlaw.i 0 โ†’ 100644
  1 +/***************************************************************************
  2 + * GModelSpectralPlaw.i - Spectral power law model class SWIG interface *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2009-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GModelSpectralPlaw.i
  15 + * @brief GModelSpectralPlaw class SWIG interface.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GModelSpectralPlaw.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GModelSpectralPlaw
  26 + *
  27 + * @brief Powerlaw SWIG interface definition.
  28 + ***************************************************************************/
  29 +class GModelSpectralPlaw : public GModelSpectral {
  30 +public:
  31 + // Constructors and destructors
  32 + GModelSpectralPlaw(void);
  33 + explicit GModelSpectralPlaw(const double& norm, const double& index);
  34 + GModelSpectralPlaw(const GModelSpectralPlaw& model);
  35 + virtual ~GModelSpectralPlaw(void);
  36 +
  37 + // Methods
  38 + int npars(void) const { return m_npars; }
  39 + GModelPar* par(int index) const;
  40 + GModelPar* par_norm(void) { return &m_norm; }
  41 + GModelPar* par_index(void) { return &m_index; }
  42 + GModelPar* par_pivot(void) { return &m_pivot; }
  43 + double eval(const GEnergy& srcEng);
  44 + double eval_gradients(const GEnergy& srcEng);
  45 + void autoscale(void);
  46 + double norm(void) const { return m_norm.real_value(); }
  47 + double index(void) const { return m_index.real_value(); }
  48 + double pivot(void) const { return m_pivot.real_value(); }
  49 +};
  50 +
  51 +
  52 +/***********************************************************************//**
  53 + * @brief GModelSpectralPlaw class extension
  54 + ***************************************************************************/
  55 +%extend GModelSpectralPlaw {
  56 + char *__str__() {
  57 + static char str_buffer[1001];
  58 + std::ostringstream buffer;
  59 + buffer << *self;
  60 + std::string str = buffer.str();
  61 + strncpy(str_buffer, (char*)str.c_str(), 1001);
  62 + str_buffer[1000] = '\0';
  63 + return str_buffer;
  64 + }
  65 + GModelSpectralPlaw copy() {
  66 + return (*self);
  67 + }
  68 +};
... ...
pyext/GModelTemporal.i 0 โ†’ 100644
  1 +/***************************************************************************
  2 + * GModelTemporal.i - Temporal model class SWIG interface *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2009-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GModelTemporal.i
  15 + * @brief GModelTemporal class SWIG interface.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GModelTemporal.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GModelTemporal
  26 + *
  27 + * @brief Abstract SWIG interface definition for the temporal model class.
  28 + ***************************************************************************/
  29 +class GModelTemporal {
  30 +public:
  31 + // Constructors and destructors
  32 + GModelTemporal(void);
  33 + GModelTemporal(const GModelTemporal& model);
  34 + virtual ~GModelTemporal(void);
  35 +
  36 + // Virtual methods
  37 + virtual int npars(void) const = 0;
  38 + virtual GModelPar* par(int index) const = 0;
  39 + virtual double eval(const GTime& srcTime) = 0;
  40 + virtual double eval_gradients(const GTime& srcTime) = 0;
  41 +};
... ...
pyext/GModelTemporalConst.i 0 โ†’ 100644
  1 +/***************************************************************************
  2 + * GModelTemporalConst.i - Temporal constant model class SWIG interface *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2009-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GModelTemporalConst.i
  15 + * @brief GModelTemporalConst class SWIG interface.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GModelTemporalConst.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GModelTemporalConst
  26 + *
  27 + * @brief SWIG interface definition for the constant model class.
  28 + ***************************************************************************/
  29 +class GModelTemporalConst : public GModelTemporal {
  30 +public:
  31 + // Constructors and destructors
  32 + GModelTemporalConst(void);
  33 + GModelTemporalConst(const GModelTemporalConst& model);
  34 + virtual ~GModelTemporalConst(void);
  35 +
  36 + // Methods
  37 + int npars(void) const { return m_npars; }
  38 + GModelPar* par(int index) const;
  39 + double eval(const GTime& srcTime);
  40 + double eval_gradients(const GTime& srcTime);
  41 +};
  42 +
  43 +
  44 +/***********************************************************************//**
  45 + * @brief GModelTemporalConst class extension
  46 + ***************************************************************************/
  47 +%extend GModelTemporalConst {
  48 + char *__str__() {
  49 + static char str_buffer[1001];
  50 + std::ostringstream buffer;
  51 + buffer << *self;
  52 + std::string str = buffer.str();
  53 + strncpy(str_buffer, (char*)str.c_str(), 1001);
  54 + str_buffer[1000] = '\0';
  55 + return str_buffer;
  56 + }
  57 + GModelTemporalConst copy() {
  58 + return (*self);
  59 + }
  60 +};
... ...
pyext/GModels.i 0 โ†’ 100644
  1 +/***************************************************************************
  2 + * GModels.i - Model container class SWIG interface *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2009-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GModels.i
  15 + * @brief GModels class SWIG interface.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GModels.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GModels
  26 + *
  27 + * @brief GModels class SWIG interface defintion.
  28 + ***************************************************************************/
  29 +class GModels : public GOptimizerPars {
  30 +public:
  31 + // Constructors and destructors
  32 + GModels(void);
  33 + GModels(const GModels& models);
  34 + ~GModels(void);
  35 +
  36 + // Methods
  37 + void append(const GModel& model);
  38 + double eval(const GInstDir& obsDir, const GEnergy& obsEng,
  39 + const GTime& obsTime, const GResponse& rsp,
  40 + const GPointing& pnt);
  41 + double eval_gradients(const GInstDir& obsDir, const GEnergy& obsEng,
  42 + const GTime& obsTime, const GResponse& rsp,
  43 + const GPointing& pnt);
  44 + int size(void) const { return m_elements; }
  45 +};
  46 +
  47 +
  48 +/***********************************************************************//**
  49 + * @brief GModels class extension
  50 + ***************************************************************************/
  51 +%extend GModels {
  52 + char *__str__() {
  53 + static char str_buffer[10001];
  54 + std::ostringstream buffer;
  55 + buffer << *self;
  56 + std::string str = buffer.str();
  57 + strncpy(str_buffer, (char*)str.c_str(), 10001);
  58 + str_buffer[10000] = '\0';
  59 + return str_buffer;
  60 + }
  61 + GModel* __getitem__(int index) {
  62 + if (index >= 0 && index < self->size())
  63 + return (*self)(index);
  64 + else
  65 + throw GException::out_of_range("__getitem__(int)", index,
  66 + self->size());
  67 + }
  68 + GModels copy() {
  69 + return (*self);
  70 + }
  71 +};
... ...
pyext/GOptimizer.i 0 โ†’ 100644
  1 +/***************************************************************************
  2 + * GOptimizer.i - Optimizer class SWIG interface *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2009-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GOptimizer.i
  15 + * @brief GOptimizer class SWIG interface.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GOptimizer.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GOptimizer
  26 + *
  27 + * @brief GOptimizer class SWIG interface defintion.
  28 + ***************************************************************************/
  29 +class GOptimizer {
  30 +public:
  31 + // Constructors and destructors
  32 + GOptimizer();
  33 + GOptimizer(const GOptimizer& opt);
  34 + virtual ~GOptimizer();
  35 +
  36 + // Operators (we need those to make the class abstract!!!)
  37 + virtual GOptimizerPars& operator() (GOptimizerFunction& fct, GOptimizerPars& p) = 0;
  38 + virtual GModels& operator() (GOptimizerFunction& fct, GModels& m) = 0;
  39 +};
... ...
pyext/GOptimizerLM.i 0 โ†’ 100644
  1 +/***************************************************************************
  2 + * GOptimizerLM.i - Levenberg Marquardt optimizer class SWIG interface *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2009-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GOptimizerLM.i
  15 + * @brief GOptimizerLM class SWIG interface.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GOptimizerLM.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GOptimizerLM
  26 + *
  27 + * @brief GOptimizerLM class SWIG interface defintion.
  28 + ***************************************************************************/
  29 +class GOptimizerLM : public GOptimizer {
  30 +public:
  31 +
  32 + // Constructors and destructors
  33 + GOptimizerLM(void);
  34 + GOptimizerLM(const GOptimizerLM& opt);
  35 + virtual ~GOptimizerLM(void);
  36 +
  37 + // Operators (we need those to make the class not abstract!!!)
  38 + GOptimizerPars& operator() (GOptimizerFunction& fct, GOptimizerPars& p);
  39 + GModels& operator() (GOptimizerFunction& fct, GModels& m);
  40 +
  41 + // Methods
  42 + void max_iter(const int& n) { m_max_iter=n; return; }
  43 + void max_stalls(const int& n) { m_max_stall=n; return; }
  44 + void lambda_start(const double& val) { m_lambda_start=val; return; }
  45 + void lambda_inc(const double& val) { m_lambda_inc=val; return; }
  46 + void lambda_dec(const double& val) { m_lambda_dec=val; return; }
  47 + void eps(const double& eps) { m_eps=eps; return; }
  48 + int max_iter(void) const { return m_max_iter; }
  49 + int max_stalls(void) const { return m_max_stall; }
  50 + int status(void) const { return m_status; }
  51 + int iter(void) const { return m_iter; }
  52 + double lambda_start(void) const { return m_lambda_start; }
  53 + double lambda_inc(void) const { return m_lambda_inc; }
  54 + double lambda_dec(void) const { return m_lambda_dec; }
  55 + //double lambda(void) const { return m_lambda; }
  56 + double eps(void) const { return m_eps; }
  57 + double value(void) const { return m_value; }
  58 +};
  59 +
  60 +
  61 +/***********************************************************************//**
  62 + * @brief GOptimizerLM class extension
  63 + ***************************************************************************/
  64 +%extend GOptimizerLM {
  65 + char *__str__() {
  66 + static char str_buffer[10001];
  67 + std::ostringstream buffer;
  68 + buffer << *self;
  69 + std::string str = buffer.str();
  70 + strncpy(str_buffer, (char*)str.c_str(), 10001);
  71 + str_buffer[10000] = '\0';
  72 + return str_buffer;
  73 + }
  74 + GOptimizerLM copy() {
  75 + return (*self);
  76 + }
  77 +};
... ...
pyext/GOptimizerPars.i 0 โ†’ 100644
  1 +/***************************************************************************
  2 + * GOptimizerPars.i - Parameter container class SWIG interface *
  3 + * ----------------------------------------------------------------------- *
  4 + * copyright (C) 2009-2010 by Jurgen Knodlseder *
  5 + * ----------------------------------------------------------------------- *
  6 + * *
  7 + * This program is free software; you can redistribute it and/or modify *
  8 + * it under the terms of the GNU General Public License as published by *
  9 + * the Free Software Foundation; either version 2 of the License, or *
  10 + * (at your option) any later version. *
  11 + * *
  12 + ***************************************************************************/
  13 +/**
  14 + * @file GOptimizerPars.i
  15 + * @brief GOptimizerPars class SWIG interface.
  16 + * @author J. Knodlseder
  17 + */
  18 +%{
  19 +/* Put headers and other declarations here that are needed for compilation */
  20 +#include "GOptimizerPars.hpp"
  21 +%}
  22 +
  23 +
  24 +/***********************************************************************//**
  25 + * @class GOptimizerPars
  26 + *
  27 + * @brief GOptimizerPars container class SWIG interface defintion.
  28 + ***************************************************************************/
  29 +class GOptimizerPars {
  30 +public:
  31 + // Constructors and destructors
  32 + GOptimizerPars(void);
  33 + GOptimizerPars(const GOptimizerPars& pars);
  34 + ~GOptimizerPars();
  35 +
  36 + // Methods
  37 + int npars(void) const { return m_npars; }
  38 + int nfree(void) const;
  39 + GModelPar* par(int index) const;
  40 +};
  41 +
  42 +
  43 +/***********************************************************************//**
  44 + * @brief GOptimizerPars class extension
  45 + ***************************************************************************/
  46 +%extend GOptimizerPars {
  47 + char *__str__() {
  48 + static char str_buffer[10001];
  49 + std::ostringstream buffer;
  50 + buffer << *self;
  51 + std::string str = buffer.str();
  52 + strncpy(str_buffer, (char*)str.c_str(), 10001);
  53 + str_buffer[10000] = '\0';
  54 + return str_buffer;
  55 + }
  56 + GOptimizerPars copy() {
  57 + return (*self);
  58 + }
  59 +};
... ...