AbstractFunction.h 4.41 KB
Newer Older
1
2
3
4
5
6
// ============================================================================
// ==                                                                        ==
// == AMDiS - Adaptive multidimensional simulations                          ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
7
// ==  TU Dresden                                                            ==
8
// ==                                                                        ==
9
10
11
// ==  Institut fr Wissenschaftliches Rechnen                               ==
// ==  Zellescher Weg 12-14                                                  ==
// ==  01069 Dresden                                                         ==
12
13
14
15
// ==  germany                                                               ==
// ==                                                                        ==
// ============================================================================
// ==                                                                        ==
16
// ==  https://gforge.zih.tu-dresden.de/projects/amdis/                      ==
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// ==                                                                        ==
// ============================================================================

/** \file AbstractFunction.h */

#ifndef AMDIS_ABSTRACTFUNCTION_H
#define AMDIS_ABSTRACTFUNCTION_H

#include "Global.h"

namespace AMDiS {

  /** 
   * \ingroup Common
   * 
   * \brief
   * An AbstractFunction object represents a function 
   * f : ArgumentType -> ReturnType. 
   *
   * AbstractFunction is a pure virtual class interface class.
   * To create your own function you have to derive AbstractFunction and
   * overload operator(). 
   */
  template<typename ReturnType, typename ArgumentType>
  class AbstractFunction
  {
  public:
44
    /// Constructor.
45
46
    AbstractFunction(int degree = 0) : 
      degree_(degree) 
Thomas Witkowski's avatar
Thomas Witkowski committed
47
    {}
48

Thomas Witkowski's avatar
Thomas Witkowski committed
49
    virtual ~AbstractFunction() {}
50

51
    /// Returns \ref degree_.
Thomas Witkowski's avatar
Thomas Witkowski committed
52
53
    inline int getDegree() const 
    { 
54
      return degree_; 
Thomas Witkowski's avatar
Thomas Witkowski committed
55
    }
56

57
    /// Deligates the evaluation to overriden method f.
58
    virtual ReturnType operator()(const ArgumentType& x) const = 0;
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75

  protected:
    int degree_;
  };

  /**
   * \ingroup Common
   *
   * \brief
   * Interface for binary functions. 
   */
  template<typename ReturnType, 
	   typename ArgumentType1, 
	   typename ArgumentType2>
  class BinaryAbstractFunction
  {
  public:
76
    /// Constructor.
77
78
    BinaryAbstractFunction(int degree = 0) : 
      degree_(degree) 
79
    {}
80

81
    virtual ~BinaryAbstractFunction() {}
82

83
    /// Returns \ref degree_.
Thomas Witkowski's avatar
Thomas Witkowski committed
84
85
    inline int getDegree() const 
    { 
86
      return degree_; 
87
    }
88

89
    /// Deligates the evaluation to overriden method f.
90
91
    virtual ReturnType operator()(const ArgumentType1& x,
				  const ArgumentType2& y) const = 0;
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109

  protected:
    int degree_;
  };

  /**
   * \ingroup Common
   *
   * \brief
   * Interface for tertiary functions. 
   */
  template<typename ReturnType, 
	   typename ArgumentType1, 
	   typename ArgumentType2,
	   typename ArgumentType3>
  class TertiaryAbstractFunction
  {
  public:
110
    /// Constructor.
111
112
    TertiaryAbstractFunction(int degree = 0) : 
      degree_(degree) 
113
    {}
114

115
    virtual ~TertiaryAbstractFunction() {}
116

117
    /// Returns \ref degree_.
Thomas Witkowski's avatar
Thomas Witkowski committed
118
119
    inline int getDegree() const 
    { 
120
      return degree_; 
121
    }
122

123
    /// function evaluation.
124
125
126
    virtual ReturnType operator()(const ArgumentType1& x,
				  const ArgumentType2& y,
				  const ArgumentType3& z) const = 0;
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

  protected:
    int degree_;
  };

  /**
   * \ingroup Common
   *
   * \brief
   * Interface for quart functions. 
   */
  template<typename ReturnType, 
	   typename ArgumentType1, 
	   typename ArgumentType2, 
	   typename ArgumentType3,
	   typename ArgumentType4>
  class QuartAbstractFunction
  {
  public:
146
    /// Constructor.
147
148
    QuartAbstractFunction(int degree = 0) : 
      degree_(degree) 
149
    {}
150

151
    virtual ~QuartAbstractFunction() {}
152

153
    /// Returns \ref degree_.
Thomas Witkowski's avatar
Thomas Witkowski committed
154
155
    inline int getDegree() const 
    { 
156
      return degree_; 
157
    }
158

159
    /// function evaluation.
160
161
162
163
    virtual ReturnType operator()(const ArgumentType1& x,
				  const ArgumentType2& y,
				  const ArgumentType3& z,
				  const ArgumentType4& u) const = 0;
164
165
166
167
168
169
170
171
172
173
174

  protected:
    int degree_;
  };




}

#endif // AMDIS_ABSTRACTFUNCTION_H