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 
6 namespace Genfun {
7 FUNCTION_OBJECT_IMP(FunctionComposition)
8 
9 FunctionComposition::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 
20 AbsFunction(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 
35 double 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 
49 double FunctionComposition::operator() (const Argument & v) const {
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 
63 Derivative 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
FunctionComposition(const AbsFunction *arg1, const AbsFunction *arg2)
Derivative partial(unsigned int) const
virtual unsigned int dimensionality() const
#define FUNCTION_OBJECT_IMP(classname)
virtual Derivative partial(unsigned int) const
Definition: AbsFunction.cc:40
virtual unsigned int dimensionality() const
Definition: AbsFunction.cc:79
virtual double operator()(double argument) const