7 #include "GeoGenericFunctions/FunctionDifference.h" 11 FUNCTION_OBJECT_IMP(FunctionDifference)
13 FunctionDifference::FunctionDifference(const AbsFunction *arg1, const AbsFunction *arg2):
17 if (arg1->dimensionality()!=arg2->dimensionality()) {
18 throw std::runtime_error(
"FunctionDifference: dimension mismatch");
23 FunctionDifference::FunctionDifference(
const FunctionDifference & right):
25 _arg1(right._arg1->clone()),
26 _arg2(right._arg2->clone())
31 unsigned int FunctionDifference::dimensionality()
const {
32 return _arg1->dimensionality();
35 FunctionDifference::~FunctionDifference()
43 double FunctionDifference::operator ()(
double x)
const 45 return (*_arg1)(x)-(*_arg2)(x);
48 double FunctionDifference::operator ()(
const Argument & x)
const 50 return (*_arg1)(x)-(*_arg2)(x);
54 Derivative FunctionDifference::partial(
unsigned int index)
const {
55 const Derivative & d1=_arg1->partial(index);
56 const Derivative & d2=_arg2->partial(index);
57 const AbsFunction & fPrime = d1-d2;
58 return Derivative(&fPrime);