CLHEP VERSION Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

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 $
4#include <assert.h>
5
6namespace Genfun {
7FUNCTION_OBJECT_IMP(FunctionComposition)
8
9FunctionComposition::FunctionComposition(const AbsFunction *arg1, const AbsFunction *arg2):_arg1(arg1->clone()),_arg2(arg2->clone())
10{
11 if (arg1->dimensionality()!=1) {
12 std::cout
13 << "Warning: dimension mismatch in function convolution"
14 << std::endl;
15 assert(0);
16 }
17}
18
20AbsFunction(right),
21_arg1(right._arg1->clone()),
22_arg2(right._arg2->clone())
23{}
24
26{
27 delete _arg1;
28 delete _arg2;
29}
30
32 return _arg2->dimensionality();
33}
34
35double FunctionComposition::operator ()(double argument) const {
36 if (dimensionality()!=1) {
37 std::cerr
38 << "Warning: LifetimeResolutionConvolution function/argument "
39 << "dimension mismatch"
40 << std::endl;
41 assert(0);
42 return 0;
43 }
44 else {
45 return (*_arg1)((*_arg2)(argument));
46 }
47}
48
50 if (v.dimension()!=_arg2->dimensionality()) {
51 std::cerr
52 << "Warning: FunctionComposition function/argument dimension mismatch"
53 << std::endl;
54 assert(0);
55 return 0;
56 }
57 else {
58 return (*_arg1)((*_arg2)(v));
59 }
60}
61
62
63Derivative FunctionComposition::partial(unsigned int index) const {
64 const AbsFunction & fPrime = (_arg1->partial(0))(*_arg2)*_arg2->partial(index);
65 return Derivative(&fPrime);
66}
67
68
69} // namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
virtual Derivative partial(unsigned int) const
virtual unsigned int dimensionality() const
Derivative partial(unsigned int) const
virtual double operator()(double argument) const
FunctionComposition(const AbsFunction *arg1, const AbsFunction *arg2)
virtual unsigned int dimensionality() const