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

ConstOverFunction.cc

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

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7