Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:22:11

0001 // @(#)root/minuit2:$Id$
0002 // Authors: M. Winkler, F. James, L. Moneta, A. Zsenei   2003-2005
0003 
0004 /**********************************************************************
0005  *                                                                    *
0006  * Copyright (c) 2005 LCG ROOT Math team,  CERN/PH-SFT                *
0007  *                                                                    *
0008  **********************************************************************/
0009 
0010 #ifndef ROOT_Minuit2_ABObj
0011 #define ROOT_Minuit2_ABObj
0012 
0013 #include "Minuit2/ABTypes.h"
0014 
0015 namespace ROOT {
0016 
0017 namespace Minuit2 {
0018 
0019 template <class mtype, class M, class T>
0020 class ABObj {
0021 
0022 public:
0023    typedef mtype Type;
0024 
0025 private:
0026    ABObj() : fObject(M()), fFactor(T(0.)) {}
0027 
0028    ABObj &operator=(const ABObj &) { return *this; }
0029 
0030    template <class a, class b, class c>
0031    ABObj(const ABObj<a, b, c> &) : fObject(M()), fFactor(T(0.))
0032    {
0033    }
0034 
0035    template <class a, class b, class c>
0036    ABObj &operator=(const ABObj<a, b, c> &)
0037    {
0038       return *this;
0039    }
0040 
0041 public:
0042    ABObj(const M &obj) : fObject(obj), fFactor(T(1.)) {}
0043 
0044    ABObj(const M &obj, T factor) : fObject(obj), fFactor(factor) {}
0045 
0046    ~ABObj() {}
0047 
0048    ABObj(const ABObj &obj) : fObject(obj.fObject), fFactor(obj.fFactor) {}
0049 
0050    template <class b, class c>
0051    ABObj(const ABObj<mtype, b, c> &obj) : fObject(M(obj.Obj())), fFactor(T(obj.f()))
0052    {
0053    }
0054 
0055    const M &Obj() const { return fObject; }
0056 
0057    T f() const { return fFactor; }
0058 
0059 private:
0060    M fObject;
0061    T fFactor;
0062 };
0063 
0064 class LAVector;
0065 template <>
0066 class ABObj<vec, LAVector, double> {
0067 
0068 public:
0069    typedef vec Type;
0070 
0071 private:
0072    ABObj &operator=(const ABObj &) = delete;
0073 
0074 public:
0075    ABObj(const LAVector &obj) : fObject(obj), fFactor(double(1.)) {}
0076 
0077    ABObj(const LAVector &obj, double factor) : fObject(obj), fFactor(factor) {}
0078 
0079    ~ABObj() {}
0080 
0081    // remove copy constructor to Fix a problem in AIX
0082    // should be able to use the compiler generated one
0083    //   ABObj(const ABObj& obj) :
0084    //     fObject(obj.fObject), fFactor(obj.fFactor) {}
0085 
0086    template <class c>
0087    ABObj(const ABObj<vec, LAVector, c> &obj) : fObject(obj.fObject), fFactor(double(obj.fFactor))
0088    {
0089    }
0090 
0091    const LAVector &Obj() const { return fObject; }
0092 
0093    double f() const { return fFactor; }
0094 
0095 private:
0096    const LAVector &fObject;
0097    double fFactor;
0098 };
0099 
0100 class LASymMatrix;
0101 template <>
0102 class ABObj<sym, LASymMatrix, double> {
0103 
0104 public:
0105    typedef sym Type;
0106 
0107 private:
0108    ABObj &operator=(const ABObj &) { return *this; }
0109 
0110 public:
0111    ABObj(const LASymMatrix &obj) : fObject(obj), fFactor(double(1.)) {}
0112 
0113    ABObj(const LASymMatrix &obj, double factor) : fObject(obj), fFactor(factor) {}
0114 
0115    ~ABObj() {}
0116 
0117    ABObj(const ABObj &obj) : fObject(obj.fObject), fFactor(obj.fFactor) {}
0118 
0119    template <class c>
0120    ABObj(const ABObj<vec, LASymMatrix, c> &obj) : fObject(obj.fObject), fFactor(double(obj.fFactor))
0121    {
0122    }
0123 
0124    const LASymMatrix &Obj() const { return fObject; }
0125 
0126    double f() const { return fFactor; }
0127 
0128 private:
0129    const LASymMatrix &fObject;
0130    double fFactor;
0131 };
0132 
0133 // templated scaling operator *
0134 template <class mt, class M, class T>
0135 inline ABObj<mt, M, T> operator*(T f, const M &obj)
0136 {
0137    return ABObj<mt, M, T>(obj, f);
0138 }
0139 
0140 // templated operator /
0141 template <class mt, class M, class T>
0142 inline ABObj<mt, M, T> operator/(const M &obj, T f)
0143 {
0144    return ABObj<mt, M, T>(obj, T(1.) / f);
0145 }
0146 
0147 // templated unary operator -
0148 template <class mt, class M, class T>
0149 inline ABObj<mt, M, T> operator-(const M &obj)
0150 {
0151    return ABObj<mt, M, T>(obj, T(-1.));
0152 }
0153 
0154 /*
0155 // specialization for LAVector
0156 
0157 inline ABObj<vec, LAVector, double> operator*(double f, const LAVector& obj) {
0158   return ABObj<vec, LAVector, double>(obj, f);
0159 }
0160 
0161 inline ABObj<vec, LAVector, double> operator/(const LAVector& obj, double f) {
0162   return ABObj<vec, LAVector, double>(obj, double(1.)/f);
0163 }
0164 
0165 inline ABObj<vec,LAVector,double> operator-(const LAVector& obj) {
0166   return ABObj<vec,LAVector,double>(obj, double(-1.));
0167 }
0168 */
0169 
0170 } // namespace Minuit2
0171 
0172 } // namespace ROOT
0173 
0174 #endif // ROOT_Minuit2_ABObj