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

FunctionProduct.cc

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

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7