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

ConstTimesFunction.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: ConstTimesFunction.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
00003 #include "CLHEP/GenericFunctions/ConstTimesFunction.hh"
00004 
00005 namespace Genfun {
00006 FUNCTION_OBJECT_IMP(ConstTimesFunction)
00007 
00008 ConstTimesFunction::ConstTimesFunction(double constant, const AbsFunction *arg):
00009   _constant(constant),
00010   _arg(arg->clone())
00011 {
00012 }
00013 
00014 ConstTimesFunction::ConstTimesFunction(const ConstTimesFunction & right) :
00015 AbsFunction(right),
00016 _constant(right._constant),
00017 _arg(right._arg->clone())
00018 {}
00019 
00020 unsigned int ConstTimesFunction::dimensionality() const {
00021   return _arg->dimensionality();
00022 }
00023 
00024 ConstTimesFunction::~ConstTimesFunction()
00025 {
00026   delete _arg;
00027 }
00028 
00029 
00030 
00031 double ConstTimesFunction::operator ()(double x) const
00032 {
00033   return _constant * (*_arg)(x);
00034 }
00035 
00036 
00037 double ConstTimesFunction::operator ()(const Argument & x) const
00038 {
00039   return _constant * (*_arg)(x);
00040 }
00041 
00042 Derivative ConstTimesFunction::partial(unsigned int index) const {
00043   // d/dx (k*f) = k*(df/dx)
00044   const AbsFunction & fPrime = _constant*(_arg->partial(index));
00045   return Derivative(& fPrime);
00046 }
00047 
00048 } // namespace Genfun

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7