CLHEP 2.4.6.4
C++ Class Library for High Energy Physics
Loading...
Searching...
No Matches
Genfun::Power Class Reference

#include <Power.hh>

+ Inheritance diagram for Genfun::Power:

Public Member Functions

 Power (double n)
 
 Power (int n)
 
 Power (unsigned int n)
 
 Power (const Power &right)
 
virtual ~Power ()
 
virtual double operator() (double argument) const override
 
virtual double operator() (const Argument &a) const override
 
Derivative partial (unsigned int) const override
 
virtual bool hasAnalyticDerivative () const override
 
- Public Member Functions inherited from Genfun::AbsFunction
 AbsFunction ()
 
 AbsFunction (const AbsFunction &right)
 
virtual ~AbsFunction ()
 
virtual unsigned int dimensionality () const
 
virtual double operator() (double argument) const =0
 
virtual double operator() (const Argument &argument) const =0
 
virtual AbsFunctionclone () const =0
 
virtual FunctionComposition operator() (const AbsFunction &f) const
 
virtual ParameterComposition operator() (const AbsParameter &p) const
 
Derivative derivative (const Variable &v) const
 
Derivative prime () const
 
virtual bool hasAnalyticDerivative () const
 
virtual Derivative partial (unsigned int) const
 

Detailed Description

Author

Definition at line 19 of file Power.hh.

Constructor & Destructor Documentation

◆ Power() [1/4]

Genfun::Power::Power ( double  n)

Definition at line 19 of file Power.cc.

19 :
20 _doublePower(n),
21 _asInteger(false)
22{}

◆ Power() [2/4]

Genfun::Power::Power ( int  n)

Definition at line 9 of file Power.cc.

9 :
10 _intPower(n),
11 _asInteger(true)
12{}

◆ Power() [3/4]

Genfun::Power::Power ( unsigned int  n)

Definition at line 14 of file Power.cc.

14 :
15 _intPower(n),
16 _asInteger(true)
17{}

◆ Power() [4/4]

Genfun::Power::Power ( const Power right)

Definition at line 24 of file Power.cc.

25 : AbsFunction(right),
26 _doublePower(right._doublePower),
27 _intPower(right._intPower),
28 _asInteger(right._asInteger)
29{}

◆ ~Power()

Genfun::Power::~Power ( )
virtual

Definition at line 31 of file Power.cc.

31 {
32}

Member Function Documentation

◆ hasAnalyticDerivative()

virtual bool Genfun::Power::hasAnalyticDerivative ( ) const
inlineoverridevirtual

Reimplemented from Genfun::AbsFunction.

Definition at line 45 of file Power.hh.

45{return true;}

◆ operator()() [1/2]

virtual double Genfun::Power::operator() ( const Argument a) const
inlineoverridevirtual

Implements Genfun::AbsFunction.

Definition at line 39 of file Power.hh.

39{return operator() (a[0]);}
virtual double operator()(double argument) const override
Definition: Power.cc:34

◆ operator()() [2/2]

double Genfun::Power::operator() ( double  argument) const
overridevirtual

Implements Genfun::AbsFunction.

Definition at line 34 of file Power.cc.

34 {
35 if (_asInteger) {
36 if (_intPower==0) {
37 return 1;
38 }
39 else if (_intPower>0) {
40 double f = 1;
41 for (int i=0;i<_intPower;i++) {
42 f *=x;
43 }
44 return f;
45 }
46 else {
47 double f = 1;
48 for (int i=0;i<-_intPower;i++) {
49 f /=x;
50 }
51 return f;
52 }
53 }
54 else {
55 return std::pow(x,_doublePower);
56 }
57
58}
void f(void g())
Definition: excDblThrow.cc:38

Referenced by operator()().

◆ partial()

Derivative Genfun::Power::partial ( unsigned int  ) const
overridevirtual

Reimplemented from Genfun::AbsFunction.

Definition at line 62 of file Power.cc.

62 {
63 if (_asInteger) {
64 const AbsFunction & fPrime = _intPower*Power(_intPower-1);
65 return Derivative(&fPrime);
66 }
67 else {
68 const AbsFunction & fPrime = _doublePower*Power(_doublePower-1);
69 return Derivative(&fPrime);
70 }
71
72}
Power(double n)
Definition: Power.cc:19
FunctionNoop Derivative
Definition: AbsFunction.hh:42

The documentation for this class was generated from the following files: