CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
FunctionDifference.cc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id: FunctionDifference.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
3#include "CLHEP/GenericFunctions/FunctionDifference.hh"
4#include <assert.h>
5#include <iostream>
6
7namespace Genfun {
8FUNCTION_OBJECT_IMP(FunctionDifference)
9
11 _arg1(arg1->clone()),
12 _arg2(arg2->clone())
13{
14 if (arg1->dimensionality()!=arg2->dimensionality()) {
15 std::cout
16 << "Warning: dimension mismatch in function difference"
17 << std::endl;
18 assert(0);
19 }
20}
21
22
24 AbsFunction(right),
25 _arg1(right._arg1->clone()),
26 _arg2(right._arg2->clone())
27{
28}
29
30
32 return _arg1->dimensionality();
33}
34
36{
37 delete _arg1;
38 delete _arg2;
39}
40
41
42
43double FunctionDifference::operator ()(double x) const
44{
45 return (*_arg1)(x)-(*_arg2)(x);
46}
47
49{
50 return (*_arg1)(x)-(*_arg2)(x);
51}
52
53
54Derivative FunctionDifference::partial(unsigned int index) const {
55 const AbsFunction & fPrime = _arg1->partial(index) - _arg2->partial(index);
56 return Derivative(&fPrime);
57}
58
59
60
61} // namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
Definition: AbsFunction.hh:149
virtual Derivative partial(unsigned int) const
Definition: AbsFunction.cc:40
virtual unsigned int dimensionality() const
Definition: AbsFunction.cc:79
FunctionDifference(const AbsFunction *arg1, const AbsFunction *arg2)
virtual unsigned int dimensionality() const override
virtual double operator()(double argument) const override
Derivative partial(unsigned int) const override
Definition: Abs.hh:14
FunctionNoop Derivative
Definition: AbsFunction.hh:42