Value.h
1//-*-C++-*-
2/***************************************************************************
3 *
4 * Copyright (C) 2011 by Willem van Straten
5 * Licensed under the Academic Free License version 2.1
6 *
7 ***************************************************************************/
8
9// psrchive/More/MEAL/MEAL/Complex2Value.h
10
11#ifndef __MEAL_Value_H
12#define __MEAL_Value_H
13
14#include "MEAL/NoParameters.h"
15#include "MEAL/NotCached.h"
16
17namespace MEAL {
18
20 template<typename T>
21 class Value : public T {
22
23 public:
24
25 typedef typename T::Result Result;
26
28 Value () { init(); }
29
31 Value (const Result& _value) { init(); value = _value; }
32
34 void set_value (const Result& _value)
35 {
36 if (value == _value)
37 return;
38
39 value = _value;
40 this->set_evaluation_changed();
41 }
42
44 const Result& get_value () const { return value; }
45
47 std::string get_name () const
48 { return "Value<" + std::string(T::Name)+ ">"; }
49
50 protected:
51
53 void calculate (Result& result, std::vector<Result>* grad=0)
54 {
55 result = value;
56 if (grad) grad->resize(0);
57 }
58
59 void init ()
60 {
61 this->parameter_policy = new NoParameters;
62 this->evaluation_policy = new NotCached<T> (this);
63 }
64
66 Result value;
67
68 };
69
70}
71
72#endif
Represents a model with no parameters.
Definition NoParameters.h:19
An evaluation policy that does not cache calculations.
Definition NotCached.h:23
Result value
The value.
Definition Value.h:66
void calculate(Result &result, std::vector< Result > *grad=0)
Return the value (and gradient, if requested) of the function.
Definition Value.h:53
const Result & get_value() const
Get the value.
Definition Value.h:44
std::string get_name() const
Return the name of the class.
Definition Value.h:47
Value()
Default constructor.
Definition Value.h:28
Value(const Result &_value)
Construct with initial value.
Definition Value.h:31
void set_value(const Result &_value)
Set the value.
Definition Value.h:34
Namespace in which all modeling and calibration related code is declared.
Definition ExampleComplex2.h:16

Generated using doxygen 1.14.0