Teuchos - Trilinos Tools Package  Version of the Day
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Teuchos_StandardFunctionObjects.hpp
1 // @HEADER
2 // *****************************************************************************
3 // Teuchos: Common Tools Package
4 //
5 // Copyright 2004 NTESS and the Teuchos contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9 
10 #ifndef Teuchos_STANDARD_FUNCTION_OBJECTS_H
11 #define Teuchos_STANDARD_FUNCTION_OBJECTS_H
12 
18 
19 
20 namespace Teuchos{
21 
26 template<class OperandType>
28 {
29 public:
30 
32 
33 
39  FunctionObject(){}
40 
47  SimpleFunctionObject(OperandType modifyingOperand):
49  _modifyingOperand(modifyingOperand){}
50 
52 
60  virtual OperandType runFunction(OperandType arguement) const=0;
61 
63 
64 
68  inline OperandType getModifiyingOperand() const{
69  return _modifyingOperand;
70  }
71 
78  inline OperandType setModifyingOperand(OperandType newOperand){
79  _modifyingOperand = newOperand;
80  }
81 
83 
84 private:
86 
87 
91  OperandType _modifyingOperand;
92 
94 };
95 
104 template<class OperandType>
106  public SimpleFunctionObject<OperandType>
107 {
108 public:
110 
111 
116 
123  SubtractionFunction(OperandType amountToSubtract):
124  SimpleFunctionObject<OperandType>(amountToSubtract){}
125 
127 
129 
130 
132  OperandType runFunction(OperandType arguement) const{
133  return
134  arguement
135  -
137  }
138 
140 
142 
143 
145  std::string getTypeAttributeValue() const{
146  return
147  "SubtractionFunction("
149  +")";
150  }
151 
153 };
154 
163 template<class OperandType>
165  public SimpleFunctionObject<OperandType>
166 {
167 public:
169 
170 
175 
182  AdditionFunction(OperandType amountToAdd):
183  SimpleFunctionObject<OperandType>(amountToAdd){}
184 
186 
188 
189 
191  OperandType runFunction(OperandType arguement) const{
192  return
193  arguement
194  +
196  }
197 
199 
201 
202 
204  std::string getTypeAttributeValue() const{
205  return
206  "AdditionFunction("
208  +")";
209  }
210 
212 };
213 
222 template<class OperandType>
224  public SimpleFunctionObject<OperandType>
225 {
226 public:
228 
229 
235 
243  MultiplicationFunction(OperandType amountToMultiplyBy):
244  SimpleFunctionObject<OperandType>(amountToMultiplyBy){}
245 
247 
249 
250 
252  OperandType runFunction(OperandType arguement) const{
253  return
254  arguement
255  *
257  }
258 
260 
262 
263 
265  std::string getTypeAttributeValue() const{
266  return "MultiplicationFunction(" +
268  +")";
269  }
270 
272 };
273 
282 template<class OperandType>
284  public SimpleFunctionObject<OperandType>
285 {
286 public:
287 
289 
290 
296 
304  DivisionFunction(OperandType amountToDivideBy):
305  SimpleFunctionObject<OperandType>(amountToDivideBy){}
306 
308 
310 
311 
313  OperandType runFunction(OperandType arguement) const{
314  return
315  arguement
316  /
318  }
319 
321 
323 
324 
326  std::string getTypeAttributeValue() const{
327  return
328  "DivisionFunction("
330  +")";
331  }
332 
334 
335 };
336 
337 } // namespace Teuchos
338 
339 
340 #endif
A simple function object that multiplys a specififed value from the given arguement in the runFunctio...
SimpleFunctionObject()
Constructs a SimpleFunctionObject.
A simple function object that adds a specififed value from the given arguement in the runFunction fun...
OperandType setModifyingOperand(OperandType newOperand)
Sets the modifyingOperand.
SubtractionFunction(OperandType amountToSubtract)
Constructs a SubtractionFunction.
virtual OperandType runFunction(OperandType arguement) const =0
MultiplicationFunction(OperandType amountToMultiplyBy)
Constructs a MultiplicationFunction.
OperandType runFunction(OperandType arguement) const
An object representation of a function.
A simple function object that subtracts a specififed value from the given arguement in the runFunctio...
OperandType runFunction(OperandType arguement) const
SubtractionFunction()
Constructs a SubtractionFunction.
AdditionFunction()
Constructs a AdditionFunction.
OperandType runFunction(OperandType arguement) const
OperandType getModifiyingOperand() const
Returns the modifying operand.
A simple function object that divides a specififed value from the given arguement in the runFunction ...
DivisionFunction()
Constructs a DivisionFunction.
AdditionFunction(OperandType amountToAdd)
Constructs a AdditionFunction.
A function object represents an arbitrary function.
MultiplicationFunction()
Constructs a MultiplicationFunction.
OperandType runFunction(OperandType arguement) const
SimpleFunctionObject(OperandType modifyingOperand)
Constructs a SimpleFunctionObject.
DivisionFunction(OperandType amountToDivideBy)
Constructs a DivisionFunction.
A simple function object that applies a given operand to a spcified arguement using a specific operat...