ABObj.h

Go to the documentation of this file.
00001 // @(#)root/minuit2:$Id: ABObj.h 34019 2010-06-21 15:19:37Z rdm $
00002 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei   2003-2005  
00003 
00004 /**********************************************************************
00005  *                                                                    *
00006  * Copyright (c) 2005 LCG ROOT Math team,  CERN/PH-SFT                *
00007  *                                                                    *
00008  **********************************************************************/
00009 
00010 #ifndef ROOT_Minuit2_ABObj
00011 #define ROOT_Minuit2_ABObj
00012 
00013 #include "Minuit2/ABTypes.h"
00014 
00015 namespace ROOT {
00016 
00017    namespace Minuit2 {
00018 
00019 
00020 template<class mtype, class M, class T>
00021 class ABObj {
00022 
00023 public:
00024 
00025   typedef mtype Type;
00026 
00027 private:
00028 
00029   ABObj() : fObject(M()), fFactor(T(0.)) {}
00030 
00031   ABObj& operator=(const ABObj&) {return *this;}
00032 
00033   template<class a, class b, class c>
00034   ABObj(const ABObj<a,b,c>&) : fObject(M()), fFactor(T(0.)) {}
00035 
00036   template<class a, class b, class c>
00037   ABObj& operator=(const ABObj<a,b,c>&) {return *this;}
00038   
00039 public:
00040 
00041   ABObj(const M& obj) : fObject(obj), fFactor(T(1.)) {}
00042 
00043   ABObj(const M& obj, T factor) : fObject(obj), fFactor(factor) {}
00044 
00045   ~ABObj() {}
00046 
00047   ABObj(const ABObj& obj) : 
00048     fObject(obj.fObject), fFactor(obj.fFactor) {}
00049 
00050   template<class b, class c>
00051   ABObj(const ABObj<mtype,b,c>& obj) : 
00052      fObject(M(obj.Obj() )), fFactor(T(obj.f() )) {}
00053 
00054   const M& Obj() const {return fObject;}
00055 
00056   T f() const {return fFactor;}
00057 
00058 private:
00059 
00060   M fObject;
00061   T fFactor;
00062 };
00063 
00064 class LAVector;
00065 template <> class ABObj<vec, LAVector, double> {
00066 
00067 public:
00068 
00069   typedef vec Type;
00070 
00071 private:
00072 
00073   ABObj& operator=(const ABObj&) {return *this;}
00074   
00075 public:
00076 
00077   ABObj(const LAVector& obj) : fObject(obj), fFactor(double(1.)) {}
00078 
00079   ABObj(const LAVector& obj, double factor) : fObject(obj), fFactor(factor) {}
00080 
00081   ~ABObj() {}
00082 
00083   // remove copy constructure to Fix a problem in AIX 
00084   // should be able to use the compiler generated one
00085 //   ABObj(const ABObj& obj) : 
00086 //     fObject(obj.fObject), fFactor(obj.fFactor) {}
00087 
00088   template<class c>
00089   ABObj(const ABObj<vec,LAVector,c>& obj) : 
00090     fObject(obj.fObject), fFactor(double(obj.fFactor)) {}
00091 
00092   const LAVector& Obj() const {return fObject;}
00093 
00094   double f() const {return fFactor;}
00095 
00096 private:
00097 
00098   const LAVector& fObject;
00099   double fFactor;
00100 };
00101 
00102 class LASymMatrix;
00103 template <> class ABObj<sym, LASymMatrix, double> {
00104 
00105 public:
00106 
00107   typedef sym Type;
00108 
00109 private:
00110 
00111   ABObj& operator=(const ABObj&) {return *this;}
00112   
00113 public:
00114 
00115   ABObj(const LASymMatrix& obj) : fObject(obj), fFactor(double(1.)) {}
00116 
00117   ABObj(const LASymMatrix& obj, double factor) : fObject(obj), fFactor(factor) {}
00118 
00119   ~ABObj() {}
00120 
00121   ABObj(const ABObj& obj) : 
00122     fObject(obj.fObject), fFactor(obj.fFactor) {}
00123 
00124   template<class c>
00125   ABObj(const ABObj<vec,LASymMatrix,c>& obj) : 
00126     fObject(obj.fObject), fFactor(double(obj.fFactor)) {}
00127 
00128   const LASymMatrix& Obj() const {return fObject;}
00129 
00130   double f() const {return fFactor;}
00131 
00132 private:
00133 
00134   const LASymMatrix& fObject;
00135   double fFactor;
00136 };
00137 
00138 // templated scaling operator *
00139 template<class mt, class M, class T>
00140 inline ABObj<mt, M, T> operator*(T f, const M& obj) {
00141   return ABObj<mt, M, T>(obj, f);
00142 }
00143 
00144 // templated operator /
00145 template<class mt, class M, class T>
00146 inline ABObj<mt, M, T> operator/(const M& obj, T f) {
00147   return ABObj<mt, M, T>(obj, T(1.)/f);
00148 }
00149 
00150 // templated unary operator -
00151 template<class mt, class M, class T>
00152 inline ABObj<mt,M,T> operator-(const M& obj) {
00153   return ABObj<mt,M,T>(obj, T(-1.));
00154 }
00155 
00156 /*
00157 // specialization for LAVector
00158 
00159 inline ABObj<vec, LAVector, double> operator*(double f, const LAVector& obj) {
00160   return ABObj<vec, LAVector, double>(obj, f);
00161 }
00162 
00163 inline ABObj<vec, LAVector, double> operator/(const LAVector& obj, double f) {
00164   return ABObj<vec, LAVector, double>(obj, double(1.)/f);
00165 }
00166 
00167 inline ABObj<vec,LAVector,double> operator-(const LAVector& obj) {
00168   return ABObj<vec,LAVector,double>(obj, double(-1.));
00169 }
00170 */
00171 
00172   }  // namespace Minuit2
00173 
00174 }  // namespace ROOT
00175 
00176 #endif  // ROOT_Minuit2_ABObj

Generated on Tue Jul 5 14:25:40 2011 for ROOT_528-00b_version by  doxygen 1.5.1