// @(#)root/minuit2:$Id$ // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei 2003-2005 /********************************************************************** * * * Copyright (c) 2005 LCG ROOT Math team, CERN/PH-SFT * * * **********************************************************************/ #ifndef ROOT_Minuit2_ABObj #define ROOT_Minuit2_ABObj #include "Minuit2/ABTypes.h" namespace ROOT { namespace Minuit2 { template class ABObj { public: typedef mtype Type; private: ABObj() : fObject(M()), fFactor(T(0.)) {} ABObj& operator=(const ABObj&) {return *this;} template ABObj(const ABObj&) : fObject(M()), fFactor(T(0.)) {} template ABObj& operator=(const ABObj&) {return *this;} public: ABObj(const M& obj) : fObject(obj), fFactor(T(1.)) {} ABObj(const M& obj, T factor) : fObject(obj), fFactor(factor) {} ~ABObj() {} ABObj(const ABObj& obj) : fObject(obj.fObject), fFactor(obj.fFactor) {} template ABObj(const ABObj& obj) : fObject(M(obj.Obj() )), fFactor(T(obj.f() )) {} const M& Obj() const {return fObject;} T f() const {return fFactor;} private: M fObject; T fFactor; }; class LAVector; template <> class ABObj { public: typedef vec Type; private: ABObj& operator=(const ABObj&) {return *this;} public: ABObj(const LAVector& obj) : fObject(obj), fFactor(double(1.)) {} ABObj(const LAVector& obj, double factor) : fObject(obj), fFactor(factor) {} ~ABObj() {} // remove copy constructure to Fix a problem in AIX // should be able to use the compiler generated one // ABObj(const ABObj& obj) : // fObject(obj.fObject), fFactor(obj.fFactor) {} template ABObj(const ABObj& obj) : fObject(obj.fObject), fFactor(double(obj.fFactor)) {} const LAVector& Obj() const {return fObject;} double f() const {return fFactor;} private: const LAVector& fObject; double fFactor; }; class LASymMatrix; template <> class ABObj { public: typedef sym Type; private: ABObj& operator=(const ABObj&) {return *this;} public: ABObj(const LASymMatrix& obj) : fObject(obj), fFactor(double(1.)) {} ABObj(const LASymMatrix& obj, double factor) : fObject(obj), fFactor(factor) {} ~ABObj() {} ABObj(const ABObj& obj) : fObject(obj.fObject), fFactor(obj.fFactor) {} template ABObj(const ABObj& obj) : fObject(obj.fObject), fFactor(double(obj.fFactor)) {} const LASymMatrix& Obj() const {return fObject;} double f() const {return fFactor;} private: const LASymMatrix& fObject; double fFactor; }; // templated scaling operator * template inline ABObj operator*(T f, const M& obj) { return ABObj(obj, f); } // templated operator / template inline ABObj operator/(const M& obj, T f) { return ABObj(obj, T(1.)/f); } // templated unary operator - template inline ABObj operator-(const M& obj) { return ABObj(obj, T(-1.)); } /* // specialization for LAVector inline ABObj operator*(double f, const LAVector& obj) { return ABObj(obj, f); } inline ABObj operator/(const LAVector& obj, double f) { return ABObj(obj, double(1.)/f); } inline ABObj operator-(const LAVector& obj) { return ABObj(obj, double(-1.)); } */ } // namespace Minuit2 } // namespace ROOT #endif // ROOT_Minuit2_ABObj