GeoModel - GeoModelCore
ConstOverFunction.cpp
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 
7 #include "GeoGenericFunctions/ConstOverFunction.h"
8 
9 namespace GeoGenfun {
10 FUNCTION_OBJECT_IMP(ConstOverFunction)
11 
12 ConstOverFunction::ConstOverFunction(double constant, const AbsFunction *arg):
13  _constant(constant),
14  _arg(arg->clone())
15 {
16 }
17 
18 ConstOverFunction::ConstOverFunction(const ConstOverFunction & right) :
19 AbsFunction(right),
20 _constant(right._constant),
21 _arg(right._arg->clone())
22 {}
23 
24 unsigned int ConstOverFunction::dimensionality() const {
25  return _arg->dimensionality();
26 }
27 
28 ConstOverFunction::~ConstOverFunction()
29 {
30  delete _arg;
31 }
32 
33 
34 
35 double ConstOverFunction::operator ()(double x) const
36 {
37  return _constant / (*_arg)(x);
38 }
39 
40 
41 double ConstOverFunction::operator ()(const Argument & x) const
42 {
43  return _constant / (*_arg)(x);
44 }
45 
46 
47 Derivative ConstOverFunction::partial(unsigned int index) const {
48  // d/dx (k/f) = -(k/f^2)(df/dx)
49  Derivative d=_arg->partial(index);
50  const AbsFunction & fPrime = -_constant/(*_arg)/(*_arg)*(d);
51  return Derivative(& fPrime);
52 }
53 
54 
55 } // namespace GeoGenfun
Definition: Abs.h:15