Gain.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2004-2009 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/MEAL/MEAL/Gain.h
10 
11 #ifndef __MEAL_Gain_H
12 #define __MEAL_Gain_H
13 
14 #include "MEAL/OneParameter.h"
15 #include "MEAL/Function.h"
16 
17 namespace MEAL
18 {
19 
21  template<typename Parent>
22  class Gain : public Parent
23  {
24 
25  public:
26 
28  Gain ();
29 
31  void set_gain (const Estimate<double>& gain)
32  { this->set_Estimate (0, gain); }
33 
35  Estimate<double> get_gain () const
36  { return this->get_Estimate (0); }
37 
39  void set_param_name (const std::string& name)
40  { parameter.set_name (name); }
41 
43  void set_param_description (const std::string& name)
44  { parameter.set_description (name); }
45 
46  // ///////////////////////////////////////////////////////////////////
47  //
48  // Function implementation
49  //
50  // ///////////////////////////////////////////////////////////////////
51 
53  std::string get_name () const
54  { return "Gain<" + std::string(Parent::Name) + ">"; }
55 
56  protected:
57 
58  typedef typename Parent::Result Return;
59 
61  void calculate (Return& result, std::vector<Return>* gradient);
62 
63  OneParameter parameter;
64  };
65 
66 }
67 
68 template<typename Parent>
69 MEAL::Gain<Parent>::Gain () : parameter (this)
70 {
71  parameter.set_name ("gain");
72  parameter.set_param (1.0);
73 }
74 
76 template<typename Parent>
77 void MEAL::Gain<Parent>::calculate (Return& result, std::vector<Return>* grad)
78 {
79  result = this->get_param(0);
80 
82  std::cerr << "MEAL::Gain::calculate gain=" << result << std::endl;
83 
84  if (grad)
85  {
86  (*grad)[0] = 1.0;
87 
89  std::cerr << "MEAL::Gain::calculate gradient" << std::endl
90  << " " << (*grad)[0] << std::endl;
91  }
92 
93 }
94 
95 #endif
Abstract base class implements parameter storage and access.
Definition: OneParameter.h:26
void set_description(const std::string &_description)
Set the description of the parameter.
Definition: OneParameter.h:66
virtual void set_param(double value)
Set the value of the parameter.
Definition: OneParameter.C:51
void set_gain(const Estimate< double > &gain)
Set the gain.
Definition: Gain.h:41
void set_name(const std::string &_name)
Set the name of the parameter.
Definition: OneParameter.h:54
std::string get_name() const
Return the name of the class.
Definition: Gain.h:63
Gain()
Default constructor.
Definition: Gain.h:69
Namespace in which all modeling and calibration related code is declared.
Definition: ExampleComplex2.h:16
static bool verbose
Verbosity flag.
Definition: Function.h:54
void set_param_description(const std::string &name)
Set the description of the parameter.
Definition: Gain.h:53
Estimate< double > get_gain() const
Get the gain.
Definition: Gain.h:45
void set_param_name(const std::string &name)
Set the name of the parameter.
Definition: Gain.h:49
void calculate(Return &result, std::vector< Return > *gradient)
Calculate the result and its gradient.
Definition: Gain.h:77

Generated using doxygen 1.8.17