Commit 2b558c78b6e0d4f616fc83b92eeccc66e8af2bf6
1 parent
3af07206
use pointers in eval_gradient()
Showing
13 changed files
with
15 additions
and
15 deletions
include/GModel.hpp
| ... | ... | @@ -56,7 +56,7 @@ public: |
| 56 | 56 | void name(const std::string& name) { m_name=name; return; } |
| 57 | 57 | int npars(void) const { return m_npars; } |
| 58 | 58 | GModelPar* par(int index) const; |
| 59 | - void eval_gradients(GSkyDir& dir, const double& energy, const double& time); | |
| 59 | + void eval_gradients(GSkyDir* dir, double* energy, double* time); | |
| 60 | 60 | |
| 61 | 61 | protected: |
| 62 | 62 | // Protected methods | ... | ... |
include/GModelSpatial.hpp
| ... | ... | @@ -45,7 +45,7 @@ public: |
| 45 | 45 | // Virtual methods |
| 46 | 46 | virtual int npars(void) const = 0; |
| 47 | 47 | virtual GModelPar* par(int index) const = 0; |
| 48 | - virtual void eval_gradients(GSkyDir& dir) = 0; | |
| 48 | + virtual void eval_gradients(GSkyDir* dir) = 0; | |
| 49 | 49 | |
| 50 | 50 | protected: |
| 51 | 51 | // Protected methods | ... | ... |
include/GModelSpatialPtsrc.hpp
| ... | ... | @@ -49,7 +49,7 @@ public: |
| 49 | 49 | // Methods |
| 50 | 50 | int npars(void) const { return m_npars; } |
| 51 | 51 | GModelPar* par(int index) const; |
| 52 | - void eval_gradients(GSkyDir& dir); | |
| 52 | + void eval_gradients(GSkyDir* dir); | |
| 53 | 53 | double ra(void) const { return m_ra.real_value(); } |
| 54 | 54 | double dec(void) const { return m_dec.real_value(); } |
| 55 | 55 | ... | ... |
include/GModelSpectral.hpp
| ... | ... | @@ -45,7 +45,7 @@ public: |
| 45 | 45 | // Virtual methods |
| 46 | 46 | virtual int npars(void) const = 0; |
| 47 | 47 | virtual GModelPar* par(int index) const = 0; |
| 48 | - virtual void eval_gradients(const double& energy) = 0; | |
| 48 | + virtual void eval_gradients(double* energy) = 0; | |
| 49 | 49 | |
| 50 | 50 | protected: |
| 51 | 51 | // Protected methods | ... | ... |
include/GModelSpectralPlaw.hpp
| ... | ... | @@ -48,7 +48,7 @@ public: |
| 48 | 48 | // Methods |
| 49 | 49 | int npars(void) const { return m_npars; } |
| 50 | 50 | GModelPar* par(int index) const; |
| 51 | - void eval_gradients(const double& energy); | |
| 51 | + void eval_gradients(double* energy); | |
| 52 | 52 | void autoscale(void); |
| 53 | 53 | double norm(void) const { return m_norm.real_value(); } |
| 54 | 54 | double index(void) const { return m_index.real_value(); } | ... | ... |
include/GModelTemporal.hpp
| ... | ... | @@ -45,7 +45,7 @@ public: |
| 45 | 45 | // Virtual methods |
| 46 | 46 | virtual int npars(void) const = 0; |
| 47 | 47 | virtual GModelPar* par(int index) const = 0; |
| 48 | - virtual void eval_gradients(const double& time) = 0; | |
| 48 | + virtual void eval_gradients(double* time) = 0; | |
| 49 | 49 | |
| 50 | 50 | protected: |
| 51 | 51 | // Protected methods | ... | ... |
include/GModelTemporalConst.hpp
include/GModels.hpp
| ... | ... | @@ -48,7 +48,7 @@ public: |
| 48 | 48 | |
| 49 | 49 | // Methods |
| 50 | 50 | void add(const GModel& model); |
| 51 | - void eval_gradients(GSkyDir& dir, const double& energy, const double& time); | |
| 51 | + void eval_gradients(GSkyDir* dir, double* energy, double* time); | |
| 52 | 52 | |
| 53 | 53 | protected: |
| 54 | 54 | // Protected methods | ... | ... |
src/model/GModel.cpp
| ... | ... | @@ -167,7 +167,7 @@ GModelPar* GModel::par(int index) const |
| 167 | 167 | /***********************************************************************//** |
| 168 | 168 | * @brief Evaluate function gradients |
| 169 | 169 | ***************************************************************************/ |
| 170 | -void GModel::eval_gradients(GSkyDir& dir, const double& energy, const double& time) | |
| 170 | +void GModel::eval_gradients(GSkyDir* dir, double* energy, double* time) | |
| 171 | 171 | { |
| 172 | 172 | // Evaluate gradients in all components |
| 173 | 173 | if (m_spatial != NULL) m_spatial->eval_gradients(dir); | ... | ... |
src/model/GModelSpatialPtsrc.cpp
| ... | ... | @@ -161,7 +161,7 @@ GModelPar* GModelSpatialPtsrc::par(int index) const |
| 161 | 161 | /***********************************************************************//** |
| 162 | 162 | * @brief Evaluate function gradients |
| 163 | 163 | ***************************************************************************/ |
| 164 | -void GModelSpatialPtsrc::eval_gradients(GSkyDir& dir) | |
| 164 | +void GModelSpatialPtsrc::eval_gradients(GSkyDir* dir) | |
| 165 | 165 | { |
| 166 | 166 | // Return |
| 167 | 167 | return; | ... | ... |
src/model/GModelSpectralPlaw.cpp
| ... | ... | @@ -166,7 +166,7 @@ GModelPar* GModelSpectralPlaw::par(int index) const |
| 166 | 166 | * |
| 167 | 167 | * @param[in] energy Energy at which the gradients are to be computed. |
| 168 | 168 | ***************************************************************************/ |
| 169 | -void GModelSpectralPlaw::eval_gradients(const double& energy) | |
| 169 | +void GModelSpectralPlaw::eval_gradients(double* energy) | |
| 170 | 170 | { |
| 171 | 171 | // Set gradient to 0 is all parameters are fixed ... |
| 172 | 172 | if ( !m_norm.isfree() && !m_index.isfree() && !m_pivot.isfree() ) { |
| ... | ... | @@ -179,7 +179,7 @@ void GModelSpectralPlaw::eval_gradients(const double& energy) |
| 179 | 179 | else { |
| 180 | 180 | |
| 181 | 181 | // Precompute some values |
| 182 | - double e = energy/m_pivot.value(); | |
| 182 | + double e = *energy/m_pivot.value(); | |
| 183 | 183 | double p = pow(e, m_index.value()); |
| 184 | 184 | |
| 185 | 185 | // Compute normalization gradient |
| ... | ... | @@ -190,7 +190,7 @@ void GModelSpectralPlaw::eval_gradients(const double& energy) |
| 190 | 190 | |
| 191 | 191 | // Compute index gradient |
| 192 | 192 | if (m_index.isfree()) { |
| 193 | - double g = m_norm.value() * p * log(energy); | |
| 193 | + double g = m_norm.value() * p * log(*energy); | |
| 194 | 194 | m_index.gradient(g); |
| 195 | 195 | } |
| 196 | 196 | else | ... | ... |
src/model/GModelTemporalConst.cpp
| ... | ... | @@ -142,7 +142,7 @@ GModelPar* GModelTemporalConst::par(int index) const |
| 142 | 142 | /***********************************************************************//** |
| 143 | 143 | * @brief Evaluate function gradients |
| 144 | 144 | ***************************************************************************/ |
| 145 | -void GModelTemporalConst::eval_gradients(const double& time) | |
| 145 | +void GModelTemporalConst::eval_gradients(double* time) | |
| 146 | 146 | { |
| 147 | 147 | // Return |
| 148 | 148 | return; | ... | ... |
src/model/GModels.cpp
| ... | ... | @@ -165,7 +165,7 @@ void GModels::add(const GModel& model) |
| 165 | 165 | /***********************************************************************//** |
| 166 | 166 | * @brief Evaluate function gradients |
| 167 | 167 | ***************************************************************************/ |
| 168 | -void GModels::eval_gradients(GSkyDir& dir, const double& energy, const double& time) | |
| 168 | +void GModels::eval_gradients(GSkyDir* dir, double* energy, double* time) | |
| 169 | 169 | { |
| 170 | 170 | // Evaluate gradients for all models |
| 171 | 171 | for (int i = 0; i < m_elements; ++i) | ... | ... |