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

FunctionConvolution.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: FunctionConvolution.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
00003 #include "CLHEP/GenericFunctions/FunctionConvolution.hh"
00004 #include <assert.h>
00005 
00006 namespace Genfun {
00007 FUNCTION_OBJECT_IMP(FunctionConvolution)
00008 
00009 FunctionConvolution::FunctionConvolution(const AbsFunction *arg1, const AbsFunction *arg2, double x0, double x1):_arg1(arg1->clone()),_arg2(arg2->clone()),_x0(x0), _x1(x1)
00010 {
00011   if ((arg1->dimensionality()!=1) || arg2->dimensionality()!=1) {
00012     std::cout
00013       << "Warning:  dimension mismatch in function convolution"
00014       << std::endl;
00015     assert(0);
00016   }
00017 }
00018 
00019 FunctionConvolution::FunctionConvolution(const FunctionConvolution & right):
00020 AbsFunction(right),
00021 _arg1(right._arg1->clone()),
00022 _arg2(right._arg2->clone()),
00023 _x0(right._x0),
00024 _x1(right._x1)
00025 {}
00026 
00027 FunctionConvolution::~FunctionConvolution()
00028 {
00029   delete _arg1;
00030   delete _arg2;
00031 }
00032 
00033 
00034 
00035 double FunctionConvolution::operator ()(double argument) const
00036 {
00037   const double NDIVISIONS=200.0;
00038   double dx = (_x1-_x0)/NDIVISIONS;
00039   double result=0.0;
00040   for (double x=_x0; x<_x1; x+=dx) {
00041     result += (*_arg1)(argument-x)*(*_arg2)(x);
00042   }
00043   result/=NDIVISIONS;
00044   return result;
00045 }
00046 
00047 } // namespace Genfun

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7