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

FunctionConvolution.cc
Go to the documentation of this file.
1// -*- C++ -*-
2// $Id: FunctionConvolution.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
4#include <assert.h>
5
6namespace Genfun {
7FUNCTION_OBJECT_IMP(FunctionConvolution)
8
9FunctionConvolution::FunctionConvolution(const AbsFunction *arg1, const AbsFunction *arg2, double x0, double x1):_arg1(arg1->clone()),_arg2(arg2->clone()),_x0(x0), _x1(x1)
10{
11 if ((arg1->dimensionality()!=1) || arg2->dimensionality()!=1) {
12 std::cout
13 << "Warning: dimension mismatch in function convolution"
14 << std::endl;
15 assert(0);
16 }
17}
18
20AbsFunction(right),
21_arg1(right._arg1->clone()),
22_arg2(right._arg2->clone()),
23_x0(right._x0),
24_x1(right._x1)
25{}
26
28{
29 delete _arg1;
30 delete _arg2;
31}
32
33
34
35double FunctionConvolution::operator ()(double argument) const
36{
37 const double NDIVISIONS=200.0;
38 double dx = (_x1-_x0)/NDIVISIONS;
39 double result=0.0;
40 for (double x=_x0; x<_x1; x+=dx) {
41 result += (*_arg1)(argument-x)*(*_arg2)(x);
42 }
43 result/=NDIVISIONS;
44 return result;
45}
46
47} // namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
virtual double operator()(double argument) const
FunctionConvolution(const AbsFunction *arg1, const AbsFunction *arg2, double x0, double x1)