CLHEP 2.0.4.7 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 _arg1(right._arg1->clone()),
00021 _arg2(right._arg2->clone()),
00022 _x0(right._x0),
00023 _x1(right._x1)
00024 {}
00025 
00026 FunctionConvolution::~FunctionConvolution()
00027 {
00028   delete _arg1;
00029   delete _arg2;
00030 }
00031 
00032 
00033 
00034 double FunctionConvolution::operator ()(double argument) const
00035 {
00036   const double NDIVISIONS=200.0;
00037   double dx = (_x1-_x0)/NDIVISIONS;
00038   double result=0.0;
00039   for (double x=_x0; x<_x1; x+=dx) {
00040     result += (*_arg1)(argument-x)*(*_arg2)(x);
00041   }
00042   result/=NDIVISIONS;
00043   return result;
00044 }
00045 
00046 } // namespace Genfun

Generated on Thu Jul 1 22:02:30 2010 for CLHEP by  doxygen 1.4.7