GeoModel - GeoModelCore
ArrayFunction.h
1 //==========================================================================//
2 // Imported from the QAT library (qat.pitt.edu) by the copyright holder //
3 // Joe Boudreau. Software licensed under the terms and conditions of the //
4 // GNU Lesser Public License v3. //
5 //==========================================================================//
6 #ifndef _ArrayFunction_h_
7 #define _ArrayFunction_h_
8 //-------------------------------------------------------//
9 // This one dimensional function takes its values from //
10 // an array..which it copies in. //
11 //-------------------------------------------------------//
12 
13 #include "GeoGenericFunctions/AbsFunction.h"
14 
15 #include <vector>
16 #include <initializer_list>
17 
18 namespace GeoGenfun {
19 class ArrayFunction : public AbsFunction {
20 
21  FUNCTION_OBJECT_DEF(ArrayFunction)
22 
23  public:
24 
25  // Constructor
26  ArrayFunction(const double *begin, const double *end);
27 
28  // Initializer list constructor:
29  ArrayFunction(std::initializer_list<double> values);
30 
31  // Destructor
32  virtual ~ArrayFunction();
33 
34  // Copy constructor
35  ArrayFunction(const ArrayFunction &right);
36 
37  // Retreive function value
38  virtual double operator ()(double argument) const override;
39  virtual double operator ()(const Argument & a) const override {return operator() (a[0]);}
40 
41  // Derivative.
42  virtual Derivative partial (unsigned int) const override;
43 
44  // Does this function have an analytic derivative?
45  virtual bool hasAnalyticDerivative() const override {return true;}
46 
47  // Access to the array of values
48  const std::vector<double> & values() const { return _values;}
49 
50  private:
51 
52  // It is illegal to assign a ArrayFunction
53  const ArrayFunction & operator=(const ArrayFunction &right);
54 
55  std::vector<double> _values;
56 };
57 }
58 #endif
Definition: Abs.h:15