EvaluationPolicy.h
1 //-*-C++-*-
2 /***************************************************************************
3  *
4  * Copyright (C) 2005 by Willem van Straten
5  * Licensed under the Academic Free License version 2.1
6  *
7  ***************************************************************************/
8 
9 // psrchive/More/MEAL/MEAL/EvaluationPolicy.h
10 
11 #ifndef __MEAL_EvaluationPolicy_H
12 #define __MEAL_EvaluationPolicy_H
13 
14 #include "MEAL/FunctionPolicy.h"
15 #include <vector>
16 
17 namespace MEAL {
18 
20  template<class Result>
21  class EvaluationPolicy : public FunctionPolicy {
22 
23  public:
24 
26  EvaluationPolicy (Function* context) : FunctionPolicy (context) { }
27 
29  virtual Result evaluate (std::vector<Result>* grad=0) const = 0;
30 
31  };
32 
34  template<typename T>
35  static EvaluationPolicy<typename T::Result>* default_evaluation_policy (T*);
36 
37 }
38 
39 #include "MEAL/Cached.h"
40 #include "MEAL/NotCached.h"
41 
42 template<typename T>
44 MEAL::default_evaluation_policy (T* thiz)
45 {
46  if (Function::cache_results)
47  return new Cached<T> (thiz);
48  else
49  return new NotCached<T> (thiz);
50 }
51 
52 #endif
Managers of Function value and gradient.
Definition: EvaluationPolicy.h:26
Namespace in which all modeling and calibration related code is declared.
Definition: ExampleComplex2.h:16
An evaluation policy that does not cache calculations.
Definition: NotCached.h:27
This evaluation policy uses previously cached results when possible.
Definition: Cached.h:29
Pure virtual base class of all functions.
Definition: Function.h:49
EvaluationPolicy(Function *context)
Default destructor.
Definition: EvaluationPolicy.h:36
virtual Result evaluate(std::vector< Result > *grad=0) const =0
Return the result (and its gradient, if requested)
Policies that customize Function behaviours.
Definition: FunctionPolicy.h:26

Generated using doxygen 1.8.17