Teuchos Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
parameterlist
src
Teuchos_StandardFunctionObjects.hpp
Go to the documentation of this file.
1
// @HEADER
2
// ***********************************************************************
3
//
4
// Teuchos: Common Tools Package
5
// Copyright (2004) Sandia Corporation
6
//
7
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
8
// license for use of this work by or on behalf of the U.S. Government.
9
//
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38
//
39
// ***********************************************************************
40
// @HEADER
41
42
#ifndef Teuchos_STANDARD_FUNCTION_OBJECTS_H
43
#define Teuchos_STANDARD_FUNCTION_OBJECTS_H
44
48
49
#include "
Teuchos_FunctionObject.hpp
"
50
51
52
namespace
Teuchos
{
53
58
template
<
class
OperandType>
59
class
SimpleFunctionObject
:
public
FunctionObject
60
{
61
public
:
62
64
65
70
SimpleFunctionObject
():
71
FunctionObject
(){}
72
79
SimpleFunctionObject
(OperandType modifyingOperand):
80
FunctionObject
(),
81
_modifyingOperand
(modifyingOperand){}
82
84
92
virtual
OperandType
runFunction
(OperandType arguement)
const
=0;
93
95
96
100
inline
OperandType
getModifiyingOperand
()
const
{
101
return
_modifyingOperand
;
102
}
103
110
inline
OperandType
setModifyingOperand
(OperandType newOperand){
111
_modifyingOperand
= newOperand;
112
}
113
115
116
private
:
118
119
123
OperandType
_modifyingOperand
;
124
126
};
127
136
template
<
class
OperandType>
137
class
SubtractionFunction
:
138
public
SimpleFunctionObject
<OperandType>
139
{
140
public
:
142
143
147
SubtractionFunction
():
SimpleFunctionObject
<OperandType>(){}
148
155
SubtractionFunction
(OperandType amountToSubtract):
156
SimpleFunctionObject
<OperandType>(amountToSubtract){}
157
159
161
162
164
OperandType
runFunction
(OperandType arguement)
const
{
165
return
166
arguement
167
-
168
SimpleFunctionObject<OperandType>::getModifiyingOperand
();
169
}
170
172
174
175
177
std::string
getTypeAttributeValue
()
const
{
178
return
179
"SubtractionFunction("
180
+
TypeNameTraits<OperandType>::name
()
181
+
")"
;
182
}
183
185
};
186
195
template
<
class
OperandType>
196
class
AdditionFunction
:
197
public
SimpleFunctionObject
<OperandType>
198
{
199
public
:
201
202
206
AdditionFunction
():
SimpleFunctionObject
<OperandType>(){}
207
214
AdditionFunction
(OperandType amountToAdd):
215
SimpleFunctionObject
<OperandType>(amountToAdd){}
216
218
220
221
223
OperandType
runFunction
(OperandType arguement)
const
{
224
return
225
arguement
226
+
227
SimpleFunctionObject<OperandType>::getModifiyingOperand
();
228
}
229
231
233
234
236
std::string
getTypeAttributeValue
()
const
{
237
return
238
"AdditionFunction("
239
+
TypeNameTraits<OperandType>::name
()
240
+
")"
;
241
}
242
244
};
245
254
template
<
class
OperandType>
255
class
MultiplicationFunction
:
256
public
SimpleFunctionObject
<OperandType>
257
{
258
public
:
260
261
266
MultiplicationFunction
():
SimpleFunctionObject
<OperandType>(){}
267
275
MultiplicationFunction
(OperandType amountToMultiplyBy):
276
SimpleFunctionObject
<OperandType>(amountToMultiplyBy){}
277
279
281
282
284
OperandType
runFunction
(OperandType arguement)
const
{
285
return
286
arguement
287
*
288
SimpleFunctionObject<OperandType>::getModifiyingOperand
();
289
}
290
292
294
295
297
std::string
getTypeAttributeValue
()
const
{
298
return
"MultiplicationFunction("
+
299
TypeNameTraits<OperandType>::name
()
300
+
")"
;
301
}
302
304
};
305
314
template
<
class
OperandType>
315
class
DivisionFunction
:
316
public
SimpleFunctionObject
<OperandType>
317
{
318
public
:
319
321
322
327
DivisionFunction
():
SimpleFunctionObject
<OperandType>(){}
328
336
DivisionFunction
(OperandType amountToDivideBy):
337
SimpleFunctionObject
<OperandType>(amountToDivideBy){}
338
340
342
343
345
OperandType
runFunction
(OperandType arguement)
const
{
346
return
347
arguement
348
/
349
SimpleFunctionObject<OperandType>::getModifiyingOperand
();
350
}
351
353
355
356
358
std::string
getTypeAttributeValue
()
const
{
359
return
360
"DivisionFunction("
361
+
TypeNameTraits<OperandType>::name
()
362
+
")"
;
363
}
364
366
367
};
368
369
}
// namespace Teuchos
370
371
372
#endif
Teuchos_FunctionObject.hpp
An object representation of a function.
Teuchos::AdditionFunction::AdditionFunction
AdditionFunction(OperandType amountToAdd)
Constructs a AdditionFunction.
Definition
Teuchos_StandardFunctionObjects.hpp:214
Teuchos::AdditionFunction::runFunction
OperandType runFunction(OperandType arguement) const
Definition
Teuchos_StandardFunctionObjects.hpp:223
Teuchos::AdditionFunction::AdditionFunction
AdditionFunction()
Constructs a AdditionFunction.
Definition
Teuchos_StandardFunctionObjects.hpp:206
Teuchos::AdditionFunction::getTypeAttributeValue
std::string getTypeAttributeValue() const
Definition
Teuchos_StandardFunctionObjects.hpp:236
Teuchos::DivisionFunction::DivisionFunction
DivisionFunction(OperandType amountToDivideBy)
Constructs a DivisionFunction.
Definition
Teuchos_StandardFunctionObjects.hpp:336
Teuchos::DivisionFunction::runFunction
OperandType runFunction(OperandType arguement) const
Definition
Teuchos_StandardFunctionObjects.hpp:345
Teuchos::DivisionFunction::DivisionFunction
DivisionFunction()
Constructs a DivisionFunction.
Definition
Teuchos_StandardFunctionObjects.hpp:327
Teuchos::DivisionFunction::getTypeAttributeValue
std::string getTypeAttributeValue() const
Definition
Teuchos_StandardFunctionObjects.hpp:358
Teuchos::FunctionObject
A function object represents an arbitrary function.
Definition
Teuchos_FunctionObject.hpp:59
Teuchos::MultiplicationFunction::MultiplicationFunction
MultiplicationFunction(OperandType amountToMultiplyBy)
Constructs a MultiplicationFunction.
Definition
Teuchos_StandardFunctionObjects.hpp:275
Teuchos::MultiplicationFunction::runFunction
OperandType runFunction(OperandType arguement) const
Definition
Teuchos_StandardFunctionObjects.hpp:284
Teuchos::MultiplicationFunction::getTypeAttributeValue
std::string getTypeAttributeValue() const
Definition
Teuchos_StandardFunctionObjects.hpp:297
Teuchos::MultiplicationFunction::MultiplicationFunction
MultiplicationFunction()
Constructs a MultiplicationFunction.
Definition
Teuchos_StandardFunctionObjects.hpp:266
Teuchos::SimpleFunctionObject::runFunction
virtual OperandType runFunction(OperandType arguement) const =0
Teuchos::SimpleFunctionObject::SimpleFunctionObject
SimpleFunctionObject()
Constructs a SimpleFunctionObject.
Definition
Teuchos_StandardFunctionObjects.hpp:70
Teuchos::SimpleFunctionObject::getModifiyingOperand
OperandType getModifiyingOperand() const
Returns the modifying operand.
Definition
Teuchos_StandardFunctionObjects.hpp:100
Teuchos::SimpleFunctionObject::setModifyingOperand
OperandType setModifyingOperand(OperandType newOperand)
Sets the modifyingOperand.
Definition
Teuchos_StandardFunctionObjects.hpp:110
Teuchos::SimpleFunctionObject::_modifyingOperand
OperandType _modifyingOperand
The modifying operand.
Definition
Teuchos_StandardFunctionObjects.hpp:123
Teuchos::SimpleFunctionObject::SimpleFunctionObject
SimpleFunctionObject(OperandType modifyingOperand)
Constructs a SimpleFunctionObject.
Definition
Teuchos_StandardFunctionObjects.hpp:79
Teuchos::SubtractionFunction::getTypeAttributeValue
std::string getTypeAttributeValue() const
Definition
Teuchos_StandardFunctionObjects.hpp:177
Teuchos::SubtractionFunction::SubtractionFunction
SubtractionFunction()
Constructs a SubtractionFunction.
Definition
Teuchos_StandardFunctionObjects.hpp:147
Teuchos::SubtractionFunction::SubtractionFunction
SubtractionFunction(OperandType amountToSubtract)
Constructs a SubtractionFunction.
Definition
Teuchos_StandardFunctionObjects.hpp:155
Teuchos::SubtractionFunction::runFunction
OperandType runFunction(OperandType arguement) const
Definition
Teuchos_StandardFunctionObjects.hpp:164
Teuchos::TypeNameTraits::name
static std::string name()
Definition
Teuchos_TypeNameTraits.hpp:88
Teuchos
Definition
Teuchos_AbstractFactory.hpp:47
Generated by
1.17.0