CLHEP 2.0.4.7 Reference Documentation
CLHEP Home Page CLHEP Documentation CLHEP Bug Reports |
00001 // -*- C++ -*- 00002 // $Id: FunctionComposition.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $ 00003 #include "CLHEP/GenericFunctions/FunctionComposition.hh" 00004 #include <assert.h> 00005 00006 namespace Genfun { 00007 FUNCTION_OBJECT_IMP(FunctionComposition) 00008 00009 FunctionComposition::FunctionComposition(const AbsFunction *arg1, const AbsFunction *arg2):_arg1(arg1->clone()),_arg2(arg2->clone()) 00010 { 00011 if (arg1->dimensionality()!=1) { 00012 std::cout 00013 << "Warning: dimension mismatch in function convolution" 00014 << std::endl; 00015 assert(0); 00016 } 00017 } 00018 00019 FunctionComposition::FunctionComposition(const FunctionComposition & right): 00020 _arg1(right._arg1->clone()), 00021 _arg2(right._arg2->clone()) 00022 {} 00023 00024 FunctionComposition::~FunctionComposition() 00025 { 00026 delete _arg1; 00027 delete _arg2; 00028 } 00029 00030 unsigned int FunctionComposition::dimensionality() const { 00031 return _arg2->dimensionality(); 00032 } 00033 00034 double FunctionComposition::operator ()(double argument) const { 00035 if (dimensionality()!=1) { 00036 std::cerr 00037 << "Warning: LifetimeResolutionConvolution function/argument " 00038 << "dimension mismatch" 00039 << std::endl; 00040 assert(0); 00041 return 0; 00042 } 00043 else { 00044 return (*_arg1)((*_arg2)(argument)); 00045 } 00046 } 00047 00048 double FunctionComposition::operator() (const Argument & v) const { 00049 if (v.dimension()!=_arg2->dimensionality()) { 00050 std::cerr 00051 << "Warning: FunctionComposition function/argument dimension mismatch" 00052 << std::endl; 00053 assert(0); 00054 return 0; 00055 } 00056 else { 00057 return (*_arg1)((*_arg2)(v)); 00058 } 00059 } 00060 00061 00062 Derivative FunctionComposition::partial(unsigned int index) const { 00063 const AbsFunction & fPrime = (_arg1->partial(0))(*_arg2)*_arg2->partial(index); 00064 return Derivative(&fPrime); 00065 } 00066 00067 00068 } // namespace Genfun