Commit aed61473cd6f109c23a37a6d4f82de5fbdec992d
1 parent
397cf822
Replace GIntegrand by GFunction.
Showing
11 changed files
with
104 additions
and
94 deletions
include/GIntegral.hpp
| ... | ... | @@ -30,7 +30,7 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | 32 | #include "GBase.hpp" |
| 33 | -#include "GIntegrand.hpp" | |
| 33 | +#include "GFunction.hpp" | |
| 34 | 34 | |
| 35 | 35 | |
| 36 | 36 | /***********************************************************************//** |
| ... | ... | @@ -47,7 +47,7 @@ public: |
| 47 | 47 | |
| 48 | 48 | // Constructors and destructors |
| 49 | 49 | explicit GIntegral(void); |
| 50 | - explicit GIntegral(GIntegrand* integrand); | |
| 50 | + explicit GIntegral(GFunction* kernel); | |
| 51 | 51 | GIntegral(const GIntegral& integral); |
| 52 | 52 | virtual ~GIntegral(void); |
| 53 | 53 | |
| ... | ... | @@ -55,20 +55,20 @@ public: |
| 55 | 55 | GIntegral& operator=(const GIntegral& integral); |
| 56 | 56 | |
| 57 | 57 | // Methods |
| 58 | - void clear(void); | |
| 59 | - GIntegral* clone(void) const; | |
| 60 | - void max_iter(const int& max_iter) { m_max_iter=max_iter; } | |
| 61 | - void eps(const double& eps) { m_eps=eps; } | |
| 62 | - void silent(const bool& silent) { m_silent=silent; } | |
| 63 | - const int& iter(void) const { return m_iter; } | |
| 64 | - const int& max_iter(void) const { return m_max_iter; } | |
| 65 | - const double& eps(void) const { return m_eps; } | |
| 66 | - const bool& silent(void) const { return m_silent; } | |
| 67 | - void integrand(GIntegrand* integrand) { m_integrand=integrand; } | |
| 68 | - const GIntegrand* integrand(void) const { return m_integrand; } | |
| 69 | - double romb(double a, double b, int k = 5); | |
| 70 | - double trapzd(double a, double b, int n = 1, double result = 0.0); | |
| 71 | - std::string print(void) const; | |
| 58 | + void clear(void); | |
| 59 | + GIntegral* clone(void) const; | |
| 60 | + void max_iter(const int& max_iter) { m_max_iter=max_iter; } | |
| 61 | + void eps(const double& eps) { m_eps=eps; } | |
| 62 | + void silent(const bool& silent) { m_silent=silent; } | |
| 63 | + const int& iter(void) const { return m_iter; } | |
| 64 | + const int& max_iter(void) const { return m_max_iter; } | |
| 65 | + const double& eps(void) const { return m_eps; } | |
| 66 | + const bool& silent(void) const { return m_silent; } | |
| 67 | + void kernel(GFunction* kernel) { m_kernel=kernel; } | |
| 68 | + const GFunction* kernel(void) const { return m_kernel; } | |
| 69 | + double romb(double a, double b, int k = 5); | |
| 70 | + double trapzd(double a, double b, int n = 1, double result = 0.0); | |
| 71 | + std::string print(void) const; | |
| 72 | 72 | |
| 73 | 73 | protected: |
| 74 | 74 | // Protected methods |
| ... | ... | @@ -78,11 +78,11 @@ protected: |
| 78 | 78 | double polint(double* xa, double* ya, int n, double x, double *dy); |
| 79 | 79 | |
| 80 | 80 | // Protected data area |
| 81 | - GIntegrand* m_integrand; //!< Pointer to integrand | |
| 82 | - double m_eps; //!< Integration precision | |
| 83 | - int m_max_iter; //!< Maximum number of iterations | |
| 84 | - int m_iter; //!< Number of iterations used | |
| 85 | - bool m_silent; //!< Suppress integration warnings | |
| 81 | + GFunction* m_kernel; //!< Pointer to function kernel | |
| 82 | + double m_eps; //!< Integration precision | |
| 83 | + int m_max_iter; //!< Maximum number of iterations | |
| 84 | + int m_iter; //!< Number of iterations used | |
| 85 | + bool m_silent; //!< Suppress integration warnings | |
| 86 | 86 | }; |
| 87 | 87 | |
| 88 | 88 | #endif /* GINTEGRAL_HPP */ | ... | ... |
include/GModelSpectralExpPlaw.hpp
| ... | ... | @@ -33,7 +33,7 @@ |
| 33 | 33 | #include "GModelSpectral.hpp" |
| 34 | 34 | #include "GEnergy.hpp" |
| 35 | 35 | #include "GXmlElement.hpp" |
| 36 | -#include "GIntegrand.hpp" | |
| 36 | +#include "GFunction.hpp" | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | /***********************************************************************//** |
| ... | ... | @@ -91,7 +91,7 @@ protected: |
| 91 | 91 | void update_mc_cache(const GEnergy& emin, const GEnergy& emax) const; |
| 92 | 92 | |
| 93 | 93 | // Photon flux integration kernel |
| 94 | - class flux_kernel : public GIntegrand { | |
| 94 | + class flux_kernel : public GFunction { | |
| 95 | 95 | public: |
| 96 | 96 | flux_kernel(const double& norm, |
| 97 | 97 | const double& index, |
| ... | ... | @@ -110,7 +110,7 @@ protected: |
| 110 | 110 | }; |
| 111 | 111 | |
| 112 | 112 | // Energy flux integration kernel |
| 113 | - class eflux_kernel : public GIntegrand { | |
| 113 | + class eflux_kernel : public GFunction { | |
| 114 | 114 | public: |
| 115 | 115 | eflux_kernel(const double& norm, |
| 116 | 116 | const double& index, | ... | ... |
inst/cta/include/GCTAModelRadialAcceptance.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCTAModelRadialAcceptance.hpp - Radial acceptance model class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GCTAModelRadialAcceptance.hpp |
| 23 | 23 | * @brief Radial acceptance model class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GCTAMODELRADIALACCEPTANCE_HPP |
| ... | ... | @@ -37,7 +37,7 @@ |
| 37 | 37 | #include "GEvent.hpp" |
| 38 | 38 | #include "GObservation.hpp" |
| 39 | 39 | #include "GXmlElement.hpp" |
| 40 | -#include "GIntegrand.hpp" | |
| 40 | +#include "GFunction.hpp" | |
| 41 | 41 | #include "GCTAEventList.hpp" |
| 42 | 42 | #include "GCTAModelRadial.hpp" |
| 43 | 43 | |
| ... | ... | @@ -95,12 +95,15 @@ protected: |
| 95 | 95 | GModelTemporal* xml_temporal(const GXmlElement& temporal) const; |
| 96 | 96 | |
| 97 | 97 | // ROI integration kernel |
| 98 | - class roi_kern : public GIntegrand { | |
| 98 | + class roi_kern : public GFunction { | |
| 99 | 99 | public: |
| 100 | 100 | roi_kern(const GCTAModelRadial* parent, const double& roi, const double& dist) : |
| 101 | 101 | m_parent(parent), |
| 102 | - m_roi(roi), m_cosroi(cos(roi)), | |
| 103 | - m_dist(dist), m_cosdist(cos(dist)), m_sindist(sin(dist)) { return; } | |
| 102 | + m_roi(roi), | |
| 103 | + m_cosroi(std::cos(roi)), | |
| 104 | + m_dist(dist), | |
| 105 | + m_cosdist(std::cos(dist)), | |
| 106 | + m_sindist(std::sin(dist)) { } | |
| 104 | 107 | double eval(double r); |
| 105 | 108 | protected: |
| 106 | 109 | const GCTAModelRadial* m_parent; //!< Pointer to radial model | ... | ... |
inst/cta/include/GCTAModelRadialGauss.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCTAModelRadialGauss.hpp - Radial Gaussian CTA model class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Jurgen Knodlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GCTAModelRadialGauss.hpp |
| 23 | 23 | * @brief Radial Gaussian model class interface definition |
| 24 | - * @author J. Knodlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GCTAMODELRADIALGAUSS_HPP |
| ... | ... | @@ -29,11 +29,12 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | +#include <cmath> | |
| 32 | 33 | #include "GModelPar.hpp" |
| 33 | 34 | #include "GXmlElement.hpp" |
| 34 | 35 | #include "GCTAModelRadial.hpp" |
| 35 | 36 | #include "GCTAInstDir.hpp" |
| 36 | -#include "GIntegrand.hpp" | |
| 37 | +#include "GFunction.hpp" | |
| 37 | 38 | |
| 38 | 39 | |
| 39 | 40 | /***********************************************************************//** |
| ... | ... | @@ -87,14 +88,14 @@ protected: |
| 87 | 88 | |
| 88 | 89 | // Radial integration class (used by omega() method). Note that the |
| 89 | 90 | // sigma parameter is given in rad^2 |
| 90 | - class integrand : public GIntegrand { | |
| 91 | + class integrand : public GFunction { | |
| 91 | 92 | public: |
| 92 | 93 | integrand(double sigma) : m_sigma(sigma) { } |
| 93 | 94 | double eval(double x) { |
| 94 | 95 | double arg = x * x / m_sigma; |
| 95 | 96 | double arg2 = arg * arg; |
| 96 | - double f = exp(-0.5 * arg2); | |
| 97 | - return (f*sin(x)); | |
| 97 | + double f = std::exp(-0.5 * arg2); | |
| 98 | + return (f*std::sin(x)); | |
| 98 | 99 | } |
| 99 | 100 | private: |
| 100 | 101 | double m_sigma; | ... | ... |
inst/cta/include/GCTAModelRadialPolynom.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCTAModelRadialPolynom.hpp - Radial Polynom CTA model class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GCTAModelRadialPolynom.hpp |
| 23 | 23 | * @brief Radial Polynom model class interface definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GCTAMODELRADIALPOLYNOM_HPP |
| ... | ... | @@ -30,12 +30,13 @@ |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | 32 | #include <vector> |
| 33 | +#include <cmath> | |
| 33 | 34 | #include "GTools.hpp" |
| 34 | 35 | #include "GModelPar.hpp" |
| 35 | 36 | #include "GXmlElement.hpp" |
| 36 | 37 | #include "GCTAModelRadial.hpp" |
| 37 | 38 | #include "GCTAInstDir.hpp" |
| 38 | -#include "GIntegrand.hpp" | |
| 39 | +#include "GFunction.hpp" | |
| 39 | 40 | |
| 40 | 41 | |
| 41 | 42 | /***********************************************************************//** |
| ... | ... | @@ -90,11 +91,11 @@ protected: |
| 90 | 91 | |
| 91 | 92 | // Radial integration class (used by omega() method). Note that the |
| 92 | 93 | // integration is done in radians |
| 93 | - class integrand : public GIntegrand { | |
| 94 | + class integrand : public GFunction { | |
| 94 | 95 | public: |
| 95 | 96 | integrand(const GCTAModelRadialPolynom* model) : m_model(model) { } |
| 96 | 97 | double eval(double x) { |
| 97 | - return (sin(x)*m_model->eval(x*rad2deg)); | |
| 98 | + return (std::sin(x)*m_model->eval(x*rad2deg)); | |
| 98 | 99 | } |
| 99 | 100 | private: |
| 100 | 101 | const GCTAModelRadialPolynom* m_model; | ... | ... |
inst/cta/include/GCTAModelRadialProfile.hpp
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | * GCTAModelRadialProfile.hpp - Radial Profile CTA model class * |
| 3 | 3 | * ----------------------------------------------------------------------- * |
| 4 | - * copyright (C) 2011 by Juergen Knoedlseder * | |
| 4 | + * copyright (C) 2011-2012 by Juergen Knoedlseder * | |
| 5 | 5 | * ----------------------------------------------------------------------- * |
| 6 | 6 | * * |
| 7 | 7 | * This program is free software: you can redistribute it and/or modify * |
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GCTAModelRadialProfile.hpp |
| 23 | 23 | * @brief Radial Profile model class interface definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GCTAMODELRADIALPROFILE_HPP |
| ... | ... | @@ -29,12 +29,13 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <string> |
| 32 | +#include <cmath> | |
| 32 | 33 | #include "GTools.hpp" |
| 33 | 34 | #include "GModelPar.hpp" |
| 34 | 35 | #include "GXmlElement.hpp" |
| 35 | 36 | #include "GCTAModelRadial.hpp" |
| 36 | 37 | #include "GCTAInstDir.hpp" |
| 37 | -#include "GIntegrand.hpp" | |
| 38 | +#include "GFunction.hpp" | |
| 38 | 39 | |
| 39 | 40 | |
| 40 | 41 | /***********************************************************************//** |
| ... | ... | @@ -93,11 +94,11 @@ protected: |
| 93 | 94 | |
| 94 | 95 | // Radial integration class (used by omega() method). Note that the |
| 95 | 96 | // integration is done in radians |
| 96 | - class integrand : public GIntegrand { | |
| 97 | + class integrand : public GFunction { | |
| 97 | 98 | public: |
| 98 | 99 | integrand(const GCTAModelRadialProfile* model) : m_model(model) { } |
| 99 | 100 | double eval(double x) { |
| 100 | - return (sin(x)*m_model->eval(x*rad2deg)); | |
| 101 | + return (std::sin(x)*m_model->eval(x*rad2deg)); | |
| 101 | 102 | } |
| 102 | 103 | private: |
| 103 | 104 | const GCTAModelRadialProfile* m_model; | ... | ... |
inst/cta/src/GCTAResponse_helpers.hpp
| ... | ... | @@ -35,7 +35,7 @@ |
| 35 | 35 | #include "GEnergy.hpp" |
| 36 | 36 | #include "GTime.hpp" |
| 37 | 37 | #include "GModelRadial.hpp" |
| 38 | -#include "GIntegrand.hpp" | |
| 38 | +#include "GFunction.hpp" | |
| 39 | 39 | |
| 40 | 40 | /* __ Type definitions ___________________________________________________ */ |
| 41 | 41 | |
| ... | ... | @@ -47,7 +47,7 @@ |
| 47 | 47 | * |
| 48 | 48 | * @brief Integration kernel for npsf() method |
| 49 | 49 | ***************************************************************************/ |
| 50 | -class cta_npsf_kern_rad_azsym : public GIntegrand { | |
| 50 | +class cta_npsf_kern_rad_azsym : public GFunction { | |
| 51 | 51 | public: |
| 52 | 52 | cta_npsf_kern_rad_azsym(const GCTAResponse* rsp, |
| 53 | 53 | double roi, |
| ... | ... | @@ -89,7 +89,7 @@ protected: |
| 89 | 89 | * |
| 90 | 90 | * @brief Kernel for radial model zenith angle integration of IRF |
| 91 | 91 | ***************************************************************************/ |
| 92 | -class cta_irf_radial_kern_rho : public GIntegrand { | |
| 92 | +class cta_irf_radial_kern_rho : public GFunction { | |
| 93 | 93 | public: |
| 94 | 94 | cta_irf_radial_kern_rho(const GCTAResponse* rsp, |
| 95 | 95 | const GModelRadial* model, |
| ... | ... | @@ -141,7 +141,7 @@ protected: |
| 141 | 141 | * |
| 142 | 142 | * @brief Kernel for radial model azimuth angle IRF integration |
| 143 | 143 | ***************************************************************************/ |
| 144 | -class cta_irf_radial_kern_omega : public GIntegrand { | |
| 144 | +class cta_irf_radial_kern_omega : public GFunction { | |
| 145 | 145 | public: |
| 146 | 146 | cta_irf_radial_kern_omega(const GCTAResponse* rsp, |
| 147 | 147 | double zenith, |
| ... | ... | @@ -192,7 +192,7 @@ protected: |
| 192 | 192 | * |
| 193 | 193 | * @brief Kernel for zenith angle Npred integration of radial model |
| 194 | 194 | ***************************************************************************/ |
| 195 | -class cta_npred_radial_kern_theta : public GIntegrand { | |
| 195 | +class cta_npred_radial_kern_theta : public GFunction { | |
| 196 | 196 | public: |
| 197 | 197 | cta_npred_radial_kern_theta(const GCTAResponse* rsp, |
| 198 | 198 | const GModelRadial* model, |
| ... | ... | @@ -237,7 +237,7 @@ protected: |
| 237 | 237 | * |
| 238 | 238 | * @brief Kernel for azimuth angle Npred integration of radial model |
| 239 | 239 | ***************************************************************************/ |
| 240 | -class cta_npred_radial_kern_phi : public GIntegrand { | |
| 240 | +class cta_npred_radial_kern_phi : public GFunction { | |
| 241 | 241 | public: |
| 242 | 242 | cta_npred_radial_kern_phi(const GCTAResponse* rsp, |
| 243 | 243 | const GEnergy* srcEng, |
| ... | ... | @@ -272,7 +272,7 @@ protected: |
| 272 | 272 | * |
| 273 | 273 | * @brief Kernel for IRF offest angle integration of the diffuse source model |
| 274 | 274 | ***************************************************************************/ |
| 275 | -class cta_irf_diffuse_kern_theta : public GIntegrand { | |
| 275 | +class cta_irf_diffuse_kern_theta : public GFunction { | |
| 276 | 276 | public: |
| 277 | 277 | cta_irf_diffuse_kern_theta(const GCTAResponse* rsp, |
| 278 | 278 | const GModelSpatial* model, |
| ... | ... | @@ -320,7 +320,7 @@ protected: |
| 320 | 320 | * |
| 321 | 321 | * @brief Kernel for IRF azimuth angle integration of the diffuse source model |
| 322 | 322 | ***************************************************************************/ |
| 323 | -class cta_irf_diffuse_kern_phi : public GIntegrand { | |
| 323 | +class cta_irf_diffuse_kern_phi : public GFunction { | |
| 324 | 324 | public: |
| 325 | 325 | cta_irf_diffuse_kern_phi(const GCTAResponse* rsp, |
| 326 | 326 | const GModelSpatial* model, |
| ... | ... | @@ -365,7 +365,7 @@ protected: |
| 365 | 365 | * |
| 366 | 366 | * @brief Kernel for Npred offest angle integration of diffuse model |
| 367 | 367 | ***************************************************************************/ |
| 368 | -class cta_npred_diffuse_kern_theta : public GIntegrand { | |
| 368 | +class cta_npred_diffuse_kern_theta : public GFunction { | |
| 369 | 369 | public: |
| 370 | 370 | cta_npred_diffuse_kern_theta(const GCTAResponse* rsp, |
| 371 | 371 | const GModelSpatial* model, |
| ... | ... | @@ -395,7 +395,7 @@ protected: |
| 395 | 395 | * |
| 396 | 396 | * @brief Kernel for Npred azimuth angle integration of diffuse model |
| 397 | 397 | ***************************************************************************/ |
| 398 | -class cta_npred_diffuse_kern_phi : public GIntegrand { | |
| 398 | +class cta_npred_diffuse_kern_phi : public GFunction { | |
| 399 | 399 | public: |
| 400 | 400 | cta_npred_diffuse_kern_phi(const GCTAResponse* rsp, |
| 401 | 401 | const GModelSpatial* model, | ... | ... |
inst/lat/include/GLATPsfV1.hpp
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GLATPsfV1.hpp |
| 23 | 23 | * @brief Fermi:LAT point spread function version 1 class definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GLATPSFV1_HPP |
| ... | ... | @@ -29,10 +29,11 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <vector> |
| 32 | +#include <cmath> | |
| 32 | 33 | #include "GLATPsfBase.hpp" |
| 33 | 34 | #include "GFits.hpp" |
| 34 | 35 | #include "GFitsTable.hpp" |
| 35 | -#include "GIntegrand.hpp" | |
| 36 | +#include "GFunction.hpp" | |
| 36 | 37 | |
| 37 | 38 | |
| 38 | 39 | /***********************************************************************//** |
| ... | ... | @@ -75,7 +76,7 @@ private: |
| 75 | 76 | // Integrand class. This class is used to perform the radial |
| 76 | 77 | // integration of the PSF that assures the proper normalization |
| 77 | 78 | // of the PSF at low energies. |
| 78 | - class base_integrand : public GIntegrand { | |
| 79 | + class base_integrand : public GFunction { | |
| 79 | 80 | public: |
| 80 | 81 | base_integrand(double ncore, double ntail, double sigma, |
| 81 | 82 | double gcore, double gtail) : |
| ... | ... | @@ -86,7 +87,7 @@ private: |
| 86 | 87 | double u = 0.5 * r * r; |
| 87 | 88 | double f = m_ncore * base_fct(u, m_gcore) + |
| 88 | 89 | m_ntail * base_fct(u, m_gtail); |
| 89 | - return (f*sin(x)); | |
| 90 | + return (f*std::sin(x)); | |
| 90 | 91 | } |
| 91 | 92 | private: |
| 92 | 93 | double m_ncore; | ... | ... |
inst/lat/include/GLATPsfV3.hpp
| ... | ... | @@ -21,7 +21,7 @@ |
| 21 | 21 | /** |
| 22 | 22 | * @file GLATPsfV3.hpp |
| 23 | 23 | * @brief Fermi/LAT point spread function version 3 class definition |
| 24 | - * @author J. Knoedlseder | |
| 24 | + * @author Juergen Knoedlseder | |
| 25 | 25 | */ |
| 26 | 26 | |
| 27 | 27 | #ifndef GLATPSFV3_HPP |
| ... | ... | @@ -29,10 +29,11 @@ |
| 29 | 29 | |
| 30 | 30 | /* __ Includes ___________________________________________________________ */ |
| 31 | 31 | #include <vector> |
| 32 | +#include <cmath> | |
| 32 | 33 | #include "GLATPsfBase.hpp" |
| 33 | 34 | #include "GFits.hpp" |
| 34 | 35 | #include "GFitsTable.hpp" |
| 35 | -#include "GIntegrand.hpp" | |
| 36 | +#include "GFunction.hpp" | |
| 36 | 37 | |
| 37 | 38 | |
| 38 | 39 | /***********************************************************************//** |
| ... | ... | @@ -83,7 +84,7 @@ private: |
| 83 | 84 | // Integrand class. This class is used to perform the radial |
| 84 | 85 | // integration of the PSF to assure the proper normalization. |
| 85 | 86 | // Note that score and stail need to be scaled by energy. |
| 86 | - class base_integrand : public GIntegrand { | |
| 87 | + class base_integrand : public GFunction { | |
| 87 | 88 | public: |
| 88 | 89 | base_integrand(double ncore, double ntail, |
| 89 | 90 | double score, double stail, |
| ... | ... | @@ -98,7 +99,7 @@ private: |
| 98 | 99 | double ut = 0.5 * rt * rt; |
| 99 | 100 | double f = m_ncore * (base_fct(uc, m_gcore) + |
| 100 | 101 | m_ntail * base_fct(ut, m_gtail)); |
| 101 | - return (f*sin(x)); | |
| 102 | + return (f*std::sin(x)); | |
| 102 | 103 | } |
| 103 | 104 | private: |
| 104 | 105 | double m_ncore; | ... | ... |
pyext/GIntegral.i
| ... | ... | @@ -43,24 +43,24 @@ public: |
| 43 | 43 | |
| 44 | 44 | // Constructors and destructors |
| 45 | 45 | explicit GIntegral(void); |
| 46 | - explicit GIntegral(GIntegrand* integrand); | |
| 46 | + explicit GIntegral(GFunction* kernel); | |
| 47 | 47 | GIntegral(const GIntegral& integral); |
| 48 | 48 | virtual ~GIntegral(void); |
| 49 | 49 | |
| 50 | 50 | // Methods |
| 51 | - void clear(void); | |
| 52 | - GIntegral* clone(void) const; | |
| 53 | - void max_iter(const int& max_iter) { m_max_iter=max_iter; } | |
| 54 | - void eps(const double& eps) { m_eps=eps; } | |
| 55 | - void silent(const bool& silent) { m_silent=silent; } | |
| 56 | - const int& iter(void) const { return m_iter; } | |
| 57 | - const int& max_iter(void) const { return m_max_iter; } | |
| 58 | - const double& eps(void) const { return m_eps; } | |
| 59 | - const bool& silent(void) const { return m_silent; } | |
| 60 | - void integrand(GIntegrand* integrand) { m_integrand=integrand; } | |
| 61 | - const GIntegrand* integrand(void) const { return m_integrand; } | |
| 62 | - double romb(double a, double b, int k = 5); | |
| 63 | - double trapzd(double a, double b, int n = 1, double result = 0.0); | |
| 51 | + void clear(void); | |
| 52 | + GIntegral* clone(void) const; | |
| 53 | + void max_iter(const int& max_iter); | |
| 54 | + void eps(const double& eps); | |
| 55 | + void silent(const bool& silent); | |
| 56 | + const int& iter(void) const; | |
| 57 | + const int& max_iter(void) const; | |
| 58 | + const double& eps(void) const; | |
| 59 | + const bool& silent(void) const; | |
| 60 | + void kernel(GFunction* kernel); | |
| 61 | + const GFunction* kernel(void) const; | |
| 62 | + double romb(double a, double b, int k = 5); | |
| 63 | + double trapzd(double a, double b, int n = 1, double result = 0.0); | |
| 64 | 64 | }; |
| 65 | 65 | |
| 66 | 66 | ... | ... |
src/numerics/GIntegral.cpp
| ... | ... | @@ -59,20 +59,20 @@ GIntegral::GIntegral(void) |
| 59 | 59 | |
| 60 | 60 | |
| 61 | 61 | /***********************************************************************//** |
| 62 | - * @brief Integrand constructor | |
| 62 | + * @brief Function kernel constructor | |
| 63 | 63 | * |
| 64 | - * @param[in] integrand Pointer to integrand. | |
| 64 | + * @param[in] kernel Pointer to function kernel. | |
| 65 | 65 | * |
| 66 | - * The Integrand constructor assigns the integrand pointer in constructing | |
| 67 | - * the object. | |
| 66 | + * The function kernel constructor assigns the function kernel pointer in | |
| 67 | + * constructing the object. | |
| 68 | 68 | ***************************************************************************/ |
| 69 | -GIntegral::GIntegral(GIntegrand* integrand) | |
| 69 | +GIntegral::GIntegral(GFunction* kernel) | |
| 70 | 70 | { |
| 71 | 71 | // Initialise members |
| 72 | 72 | init_members(); |
| 73 | 73 | |
| 74 | - // Set integrand | |
| 75 | - m_integrand = integrand; | |
| 74 | + // Set function kernel | |
| 75 | + m_kernel = kernel; | |
| 76 | 76 | |
| 77 | 77 | // Return |
| 78 | 78 | return; |
| ... | ... | @@ -166,6 +166,8 @@ void GIntegral::clear(void) |
| 166 | 166 | |
| 167 | 167 | /***********************************************************************//** |
| 168 | 168 | * @brief Clone instance |
| 169 | + * | |
| 170 | + * @return Pointer to deep copy of integral. | |
| 169 | 171 | ***************************************************************************/ |
| 170 | 172 | GIntegral* GIntegral::clone(void) const |
| 171 | 173 | { |
| ... | ... | @@ -292,8 +294,8 @@ double GIntegral::trapzd(double a, double b, int n, double result) |
| 292 | 294 | if (n == 1) { |
| 293 | 295 | |
| 294 | 296 | // Evaluate integrand at boundaries |
| 295 | - double y_a = m_integrand->eval(a); | |
| 296 | - double y_b = m_integrand->eval(b); | |
| 297 | + double y_a = m_kernel->eval(a); | |
| 298 | + double y_b = m_kernel->eval(b); | |
| 297 | 299 | |
| 298 | 300 | // Compute result |
| 299 | 301 | result = 0.5*(b-a)*(y_a + y_b); |
| ... | ... | @@ -337,7 +339,7 @@ double GIntegral::trapzd(double a, double b, int n, double result) |
| 337 | 339 | for (int j = 0; j < it; ++j, x+=del) { |
| 338 | 340 | |
| 339 | 341 | // Evaluate integrand |
| 340 | - double y = m_integrand->eval(x); | |
| 342 | + double y = m_kernel->eval(x); | |
| 341 | 343 | |
| 342 | 344 | // Add integrand |
| 343 | 345 | sum += y; |
| ... | ... | @@ -393,7 +395,7 @@ std::string GIntegral::print(void) const |
| 393 | 395 | void GIntegral::init_members(void) |
| 394 | 396 | { |
| 395 | 397 | // Initialise members |
| 396 | - m_integrand = NULL; | |
| 398 | + m_kernel = NULL; | |
| 397 | 399 | m_eps = 1.0e-6; |
| 398 | 400 | m_max_iter = 20; |
| 399 | 401 | m_iter = 0; |
| ... | ... | @@ -412,11 +414,11 @@ void GIntegral::init_members(void) |
| 412 | 414 | void GIntegral::copy_members(const GIntegral& integral) |
| 413 | 415 | { |
| 414 | 416 | // Copy attributes |
| 415 | - m_integrand = integral.m_integrand; | |
| 416 | - m_eps = integral.m_eps; | |
| 417 | - m_max_iter = integral.m_max_iter; | |
| 418 | - m_iter = integral.m_iter; | |
| 419 | - m_silent = integral.m_silent; | |
| 417 | + m_kernel = integral.m_kernel; | |
| 418 | + m_eps = integral.m_eps; | |
| 419 | + m_max_iter = integral.m_max_iter; | |
| 420 | + m_iter = integral.m_iter; | |
| 421 | + m_silent = integral.m_silent; | |
| 420 | 422 | |
| 421 | 423 | // Return |
| 422 | 424 | return; | ... | ... |