Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
BasicFunctionGradient.h
Go to the documentation of this file.
1 // @(#)root/minuit2:$Id$
2 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005
3 
4 /**********************************************************************
5  * *
6  * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT *
7  * *
8  **********************************************************************/
9 
10 #ifndef ROOT_Minuit2_BasicFunctionGradient
11 #define ROOT_Minuit2_BasicFunctionGradient
12 
13 #include "Minuit2/MnMatrix.h"
14 
15 #include "Minuit2/StackAllocator.h"
16 
17 namespace ROOT {
18 
19  namespace Minuit2 {
20 
21 
22 //extern StackAllocator gStackAllocator;
23 
24 class BasicFunctionGradient {
25 
26 private:
27 
28 public:
29 
30  explicit BasicFunctionGradient(unsigned int n) :
31  fGradient(MnAlgebraicVector(n)), fG2ndDerivative(MnAlgebraicVector(n)),
32  fGStepSize(MnAlgebraicVector(n)), fValid(false),
33  fAnalytical(false) {}
34 
35  explicit BasicFunctionGradient(const MnAlgebraicVector& grd) :
36  fGradient(grd), fG2ndDerivative(MnAlgebraicVector(grd.size())),
37  fGStepSize(MnAlgebraicVector(grd.size())), fValid(true),
38  fAnalytical(true) {}
39 
40  BasicFunctionGradient(const MnAlgebraicVector& grd, const MnAlgebraicVector& g2, const MnAlgebraicVector& gstep) :
41  fGradient(grd), fG2ndDerivative(g2),
42  fGStepSize(gstep), fValid(true), fAnalytical(false) {}
43 
44  ~BasicFunctionGradient() {}
45 
46  BasicFunctionGradient(const BasicFunctionGradient& grad) : fGradient(grad.fGradient), fG2ndDerivative(grad.fG2ndDerivative), fGStepSize(grad.fGStepSize), fValid(grad.fValid) {}
47 
48  BasicFunctionGradient& operator=(const BasicFunctionGradient& grad) {
49  fGradient = grad.fGradient;
50  fG2ndDerivative = grad.fG2ndDerivative;
51  fGStepSize = grad.fGStepSize;
52  fValid = grad.fValid;
53  return *this;
54  }
55 
56  void* operator new(size_t nbytes) {
57  return StackAllocatorHolder::Get().Allocate(nbytes);
58  }
59 
60  void operator delete(void* p, size_t /*nbytes */) {
61  StackAllocatorHolder::Get().Deallocate(p);
62  }
63 
64  const MnAlgebraicVector& Grad() const {return fGradient;}
65  const MnAlgebraicVector& Vec() const {return fGradient;}
66  bool IsValid() const {return fValid;}
67 
68  bool IsAnalytical() const {return fAnalytical;}
69  const MnAlgebraicVector& G2() const {return fG2ndDerivative;}
70  const MnAlgebraicVector& Gstep() const {return fGStepSize;}
71 
72 private:
73 
74  MnAlgebraicVector fGradient;
75  MnAlgebraicVector fG2ndDerivative;
76  MnAlgebraicVector fGStepSize;
77  bool fValid;
78  bool fAnalytical;
79 };
80 
81  } // namespace Minuit2
82 
83 } // namespace ROOT
84 
85 #endif // ROOT_Minuit2_BasicFunctionGradient