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

FunctionDifference.cc

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

Generated on 15 Nov 2012 for CLHEP by  doxygen 1.4.7