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

Variable.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // $Id: Variable.cc,v 1.3 2003/09/06 14:04:14 boudreau Exp $
00003 #include "CLHEP/GenericFunctions/Variable.hh"
00004 #include "CLHEP/GenericFunctions/FixedConstant.hh"
00005 #include <assert.h>
00006 namespace Genfun {
00007 FUNCTION_OBJECT_IMP(Variable)
00008 
00009 Variable::Variable(unsigned int selectionIndex, unsigned int dimensionality):
00010   _selectionIndex(selectionIndex),
00011   _dimensionality(dimensionality)
00012 {}
00013 
00014 Variable::Variable(const Variable & right):
00015   _selectionIndex(right._selectionIndex),
00016   _dimensionality(right._dimensionality)
00017 {
00018 }
00019 
00020 Variable::~Variable() {
00021 }
00022 
00023 double Variable::operator() (double x) const {
00024   assert (_selectionIndex==0);
00025   return x;
00026 }
00027 
00028 double Variable::operator () (const Argument & a) const {
00029   assert (_selectionIndex<a.dimension());
00030   return a[_selectionIndex];
00031 }
00032 
00033 unsigned int Variable::index() const {
00034   return _selectionIndex;
00035 }
00036 
00037 
00038 Derivative Variable::partial(unsigned int index) const {
00039   int kroneckerDelta = index==_selectionIndex ? 1 : 0;
00040   const AbsFunction & fPrime = FixedConstant(kroneckerDelta);
00041   return Derivative(&fPrime);
00042 }
00043 
00044 unsigned int Variable::dimensionality() const {
00045   return _dimensionality;
00046 } 
00047 
00048 } // namespace Genfun

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