CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
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 $
3#include "CLHEP/GenericFunctions/FunctionConvolution.hh"
4#include <assert.h>
5#include <iostream>
6
7namespace Genfun {
8FUNCTION_OBJECT_IMP(FunctionConvolution)
9
10FunctionConvolution::FunctionConvolution(const AbsFunction *arg1, const AbsFunction *arg2, double x0, double x1):_arg1(arg1->clone()),_arg2(arg2->clone()),_x0(x0), _x1(x1)
11{
12 if ((arg1->dimensionality()!=1) || arg2->dimensionality()!=1) {
13 std::cout
14 << "Warning: dimension mismatch in function convolution"
15 << std::endl;
16 assert(0);
17 }
18}
19
21AbsFunction(right),
22_arg1(right._arg1->clone()),
23_arg2(right._arg2->clone()),
24_x0(right._x0),
25_x1(right._x1)
26{}
27
29{
30 delete _arg1;
31 delete _arg2;
32}
33
34
35
36double FunctionConvolution::operator ()(double argument) const
37{
38 const double NDIVISIONS=200.0;
39 double dx = (_x1-_x0)/NDIVISIONS;
40 double result=0.0;
41 for (double x=_x0; x<_x1; x+=dx) {
42 result += (*_arg1)(argument-x)*(*_arg2)(x);
43 }
44 result/=NDIVISIONS;
45 return result;
46}
47
48} // namespace Genfun
#define FUNCTION_OBJECT_IMP(classname)
Definition: AbsFunction.hh:149
virtual double operator()(double argument) const override
FunctionConvolution(const AbsFunction *arg1, const AbsFunction *arg2, double x0, double x1)
Definition: Abs.hh:14