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 _arg1(right._arg1->clone()),
21 _arg2(right._arg2->clone())
22 {}
23 
25 {
26  delete _arg1;
27  delete _arg2;
28 }
29 
31  return _arg2->dimensionality();
32 }
33 
34 double FunctionComposition::operator ()(double argument) const {
35  if (dimensionality()!=1) {
36  std::cerr
37  << "Warning: LifetimeResolutionConvolution function/argument "
38  << "dimension mismatch"
39  << std::endl;
40  assert(0);
41  return 0;
42  }
43  else {
44  return (*_arg1)((*_arg2)(argument));
45  }
46 }
47 
48 double FunctionComposition::operator() (const Argument & v) const {
49  if (v.dimension()!=_arg2->dimensionality()) {
50  std::cerr
51  << "Warning: FunctionComposition function/argument dimension mismatch"
52  << std::endl;
53  assert(0);
54  return 0;
55  }
56  else {
57  return (*_arg1)((*_arg2)(v));
58  }
59 }
60 
61 
62 Derivative FunctionComposition::partial(unsigned int index) const {
63  const AbsFunction & fPrime = (_arg1->partial(0))(*_arg2)*_arg2->partial(index);
64  return Derivative(&fPrime);
65 }
66 
67 
68 } // namespace Genfun