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