CLHEP 2.0.4.7 Reference Documentation
   
CLHEP Home Page     CLHEP Documentation     CLHEP Bug Reports

FunctionSum.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: FunctionSum.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
00003 #include "CLHEP/GenericFunctions/FunctionSum.hh"
00004 #include <assert.h>
00005 
00006 namespace Genfun {
00007 FUNCTION_OBJECT_IMP(FunctionSum)
00008 
00009 FunctionSum::FunctionSum(const AbsFunction *arg1, const AbsFunction *arg2):
00010   _arg1(arg1->clone()),
00011   _arg2(arg2->clone())
00012 {
00013   if (arg1->dimensionality()!=arg2->dimensionality()) {
00014     std::cout
00015       << "Warning:  dimension mismatch in function sum"
00016       << std::endl;
00017     assert(0);
00018   }
00019 }
00020 
00021 FunctionSum::FunctionSum(const FunctionSum & right) :
00022 _arg1(right._arg1->clone()),
00023 _arg2(right._arg2->clone())
00024 {}
00025 
00026 unsigned int FunctionSum::dimensionality() const {
00027   return _arg1->dimensionality();
00028 }
00029 
00030 FunctionSum::~FunctionSum()
00031 {
00032   delete _arg1;
00033   delete _arg2;
00034 }
00035 
00036 
00037 
00038 double FunctionSum::operator ()(double x) const
00039 {
00040   return (*_arg1)(x)+(*_arg2)(x);
00041 }
00042 
00043 
00044 double FunctionSum::operator ()(const Argument & x) const
00045 {
00046   return (*_arg1)(x)+(*_arg2)(x);
00047 }
00048 
00049 
00050 
00051 Derivative FunctionSum::partial(unsigned int index) const {
00052   const AbsFunction & fPrime  = _arg1->partial(index) + _arg2->partial(index);
00053   return Derivative(&fPrime);
00054 }
00055 
00056 
00057 
00058 } // namespace Genfun

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