Logo ROOT   6.13/01
Reference Guide
ABObj.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_ABObj
11 #define ROOT_Minuit2_ABObj
12 
13 #include "Minuit2/ABTypes.h"
14 
15 namespace ROOT {
16 
17  namespace Minuit2 {
18 
19 
20 template<class mtype, class M, class T>
21 class ABObj {
22 
23 public:
24 
25  typedef mtype Type;
26 
27 private:
28 
29  ABObj() : fObject(M()), fFactor(T(0.)) {}
30 
31  ABObj& operator=(const ABObj&) {return *this;}
32 
33  template<class a, class b, class c>
34  ABObj(const ABObj<a,b,c>&) : fObject(M()), fFactor(T(0.)) {}
35 
36  template<class a, class b, class c>
37  ABObj& operator=(const ABObj<a,b,c>&) {return *this;}
38 
39 public:
40 
41  ABObj(const M& obj) : fObject(obj), fFactor(T(1.)) {}
42 
43  ABObj(const M& obj, T factor) : fObject(obj), fFactor(factor) {}
44 
45  ~ABObj() {}
46 
47  ABObj(const ABObj& obj) :
48  fObject(obj.fObject), fFactor(obj.fFactor) {}
49 
50  template<class b, class c>
51  ABObj(const ABObj<mtype,b,c>& obj) :
52  fObject(M(obj.Obj() )), fFactor(T(obj.f() )) {}
53 
54  const M& Obj() const {return fObject;}
55 
56  T f() const {return fFactor;}
57 
58 private:
59 
62 };
63 
64 class LAVector;
65 template <> class ABObj<vec, LAVector, double> {
66 
67 public:
68 
69  typedef vec Type;
70 
71 private:
72 
73  ABObj& operator=(const ABObj&) {return *this;}
74 
75 public:
76 
77  ABObj(const LAVector& obj) : fObject(obj), fFactor(double(1.)) {}
78 
79  ABObj(const LAVector& obj, double factor) : fObject(obj), fFactor(factor) {}
80 
81  ~ABObj() {}
82 
83  // remove copy constructure to Fix a problem in AIX
84  // should be able to use the compiler generated one
85 // ABObj(const ABObj& obj) :
86 // fObject(obj.fObject), fFactor(obj.fFactor) {}
87 
88  template<class c>
90  fObject(obj.fObject), fFactor(double(obj.fFactor)) {}
91 
92  const LAVector& Obj() const {return fObject;}
93 
94  double f() const {return fFactor;}
95 
96 private:
97 
98  const LAVector& fObject;
99  double fFactor;
100 };
101 
102 class LASymMatrix;
103 template <> class ABObj<sym, LASymMatrix, double> {
104 
105 public:
106 
107  typedef sym Type;
108 
109 private:
110 
111  ABObj& operator=(const ABObj&) {return *this;}
112 
113 public:
114 
115  ABObj(const LASymMatrix& obj) : fObject(obj), fFactor(double(1.)) {}
116 
117  ABObj(const LASymMatrix& obj, double factor) : fObject(obj), fFactor(factor) {}
118 
119  ~ABObj() {}
120 
121  ABObj(const ABObj& obj) :
122  fObject(obj.fObject), fFactor(obj.fFactor) {}
123 
124  template<class c>
126  fObject(obj.fObject), fFactor(double(obj.fFactor)) {}
127 
128  const LASymMatrix& Obj() const {return fObject;}
129 
130  double f() const {return fFactor;}
131 
132 private:
133 
135  double fFactor;
136 };
137 
138 // templated scaling operator *
139 template<class mt, class M, class T>
140 inline ABObj<mt, M, T> operator*(T f, const M& obj) {
141  return ABObj<mt, M, T>(obj, f);
142 }
143 
144 // templated operator /
145 template<class mt, class M, class T>
146 inline ABObj<mt, M, T> operator/(const M& obj, T f) {
147  return ABObj<mt, M, T>(obj, T(1.)/f);
148 }
149 
150 // templated unary operator -
151 template<class mt, class M, class T>
152 inline ABObj<mt,M,T> operator-(const M& obj) {
153  return ABObj<mt,M,T>(obj, T(-1.));
154 }
155 
156 /*
157 // specialization for LAVector
158 
159 inline ABObj<vec, LAVector, double> operator*(double f, const LAVector& obj) {
160  return ABObj<vec, LAVector, double>(obj, f);
161 }
162 
163 inline ABObj<vec, LAVector, double> operator/(const LAVector& obj, double f) {
164  return ABObj<vec, LAVector, double>(obj, double(1.)/f);
165 }
166 
167 inline ABObj<vec,LAVector,double> operator-(const LAVector& obj) {
168  return ABObj<vec,LAVector,double>(obj, double(-1.));
169 }
170 */
171 
172  } // namespace Minuit2
173 
174 } // namespace ROOT
175 
176 #endif // ROOT_Minuit2_ABObj
ABObj(const ABObj< vec, LASymMatrix, c > &obj)
Definition: ABObj.h:125
Namespace for new ROOT classes and functions.
Definition: TFoamSampler.h:19
T f() const
Definition: ABObj.h:56
ABObj & operator=(const ABObj< a, b, c > &)
Definition: ABObj.h:37
double T(double x)
Definition: ChebyshevPol.h:34
const LASymMatrix & Obj() const
Definition: ABObj.h:128
Class describing a symmetric matrix of size n.
Definition: LASymMatrix.h:51
ABObj(const LAVector &obj, double factor)
Definition: ABObj.h:79
ABObj< mt, M, T > operator*(T f, const M &obj)
Definition: ABObj.h:140
ABObj< mt, M, T > operator-(const M &obj)
Definition: ABObj.h:152
ABObj(const ABObj &obj)
Definition: ABObj.h:47
ABObj(const LASymMatrix &obj, double factor)
Definition: ABObj.h:117
const LAVector & Obj() const
Definition: ABObj.h:92
ABObj(const ABObj< a, b, c > &)
Definition: ABObj.h:34
ABObj(const ABObj< vec, LAVector, c > &obj)
Definition: ABObj.h:89
ABObj(const M &obj)
Definition: ABObj.h:41
ABObj< mt, M, T > operator/(const M &obj, T f)
Definition: ABObj.h:146
ABObj & operator=(const ABObj &)
Definition: ABObj.h:31
ABObj & operator=(const ABObj &)
Definition: ABObj.h:73
const M & Obj() const
Definition: ABObj.h:54
ABObj(const ABObj< mtype, b, c > &obj)
Definition: ABObj.h:51
ABObj(const M &obj, T factor)
Definition: ABObj.h:43