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

FunctionComposition.cc

Go to the documentation of this file.
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 AbsFunction(right),
00021 _arg1(right._arg1->clone()),
00022 _arg2(right._arg2->clone())
00023 {}
00024 
00025 FunctionComposition::~FunctionComposition()
00026 {
00027   delete _arg1;
00028   delete _arg2;
00029 }
00030 
00031 unsigned int FunctionComposition::dimensionality() const {
00032   return _arg2->dimensionality();
00033 }
00034 
00035 double FunctionComposition::operator ()(double argument) const {
00036   if (dimensionality()!=1) {
00037     std::cerr
00038       << "Warning: LifetimeResolutionConvolution function/argument "
00039       << "dimension mismatch"
00040       << std::endl;
00041     assert(0);
00042     return 0;
00043   }
00044   else {
00045     return (*_arg1)((*_arg2)(argument));
00046   }
00047 }
00048 
00049 double FunctionComposition::operator() (const Argument &  v) const {
00050   if (v.dimension()!=_arg2->dimensionality()) {
00051     std::cerr
00052       << "Warning: FunctionComposition function/argument dimension mismatch"
00053       <<  std::endl;
00054     assert(0);
00055     return 0;
00056   }
00057   else {
00058     return (*_arg1)((*_arg2)(v));
00059   }
00060 }
00061 
00062 
00063 Derivative FunctionComposition::partial(unsigned int index) const {
00064   const AbsFunction & fPrime = (_arg1->partial(0))(*_arg2)*_arg2->partial(index);
00065   return Derivative(&fPrime);
00066 }
00067 
00068 
00069 } // namespace Genfun

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7