File indexing completed on 2025-04-19 09:09:57
0001 #ifndef ATOOLS_Phys_Spinor_H
0002 #define ATOOLS_Phys_Spinor_H
0003
0004 #include "ATOOLS/Math/Vec4.H"
0005
0006 #include <complex>
0007 #include <vector>
0008
0009 namespace ATOOLS {
0010
0011 template <class Scalar>
0012 class Spinor {
0013 public:
0014
0015 typedef std::complex<Scalar> SComplex;
0016
0017 protected:
0018
0019 static double s_accu;
0020 static unsigned int s_r1, s_r2, s_r3, s_d;
0021
0022 int m_r;
0023
0024 SComplex m_u1, m_u2;
0025
0026 template <class _Scalar> friend std::ostream &operator<<
0027 (std::ostream &ostr,const Spinor<_Scalar> &s);
0028
0029 public:
0030
0031
0032 inline Spinor(const int &r=1):
0033 m_r(r), m_u1(0.0), m_u2(0.0) {}
0034 inline Spinor(const int &r,const SComplex &u1,const SComplex &u2):
0035 m_r(r), m_u1(u1), m_u2(u2) {}
0036 inline Spinor(const int &r,const Vec4<Scalar> &p):
0037 m_r(r) { Construct(p); }
0038
0039
0040 void Construct(const Vec4<Scalar> &p);
0041
0042 SComplex operator*(const Spinor &s) const;
0043
0044 Spinor operator*(const Scalar &d) const;
0045 Spinor operator*(const SComplex &c) const;
0046 Spinor operator/(const Scalar &d) const;
0047 Spinor operator/(const SComplex &c) const;
0048
0049 Spinor operator*=(const Scalar &d);
0050 Spinor operator*=(const SComplex &c);
0051 Spinor operator/=(const Scalar &d);
0052 Spinor operator/=(const SComplex &c);
0053
0054 Spinor operator+(const Spinor &s) const;
0055 Spinor operator-(const Spinor &s) const;
0056
0057 Spinor operator+=(const Spinor &s);
0058 Spinor operator-=(const Spinor &s);
0059
0060 bool operator==(const Spinor &s) const;
0061
0062 static void SetGauge(const int gauge);
0063
0064 static Vec4<Scalar> GetK0();
0065 static Vec4<Scalar> GetK1();
0066
0067
0068 inline SComplex &operator[](const size_t &i)
0069 { return i==0?m_u1:m_u2; }
0070 inline SComplex operator()(const size_t &i) const
0071 { return i==0?m_u1:m_u2; }
0072
0073 inline SComplex U1() const { return m_u1; }
0074 inline SComplex U2() const { return m_u2; }
0075
0076 inline int R() const { return m_r; }
0077
0078 inline static Scalar PPlus(const Vec4<Scalar> &p)
0079 { return p[0]+p[s_r3]; }
0080 inline static Scalar PMinus(const Vec4<Scalar> &p)
0081 { return p[0]-p[s_r3]; }
0082
0083 inline static SComplex PT(const Vec4<Scalar> &p)
0084 { return SComplex(p[s_r1],p[s_r2]); }
0085 inline static SComplex PTC(const Vec4<Scalar> &p)
0086 { return SComplex(p[s_r1],-p[s_r2]); }
0087
0088 inline Spinor operator-() const
0089 { return Spinor(m_r,-m_u1,-m_u2); }
0090
0091 inline static void SetAccuracy(const double &accu)
0092 { s_accu=accu; }
0093 inline static void ResetAccuracy()
0094 { s_accu=1.0e-12; }
0095
0096 inline static double Accuracy() { return s_accu; }
0097
0098 inline static unsigned int R1() { return s_r1; }
0099 inline static unsigned int R2() { return s_r2; }
0100 inline static unsigned int R3() { return s_r3; }
0101
0102 inline static unsigned int DefaultGauge() { return s_d; }
0103
0104 inline static void ResetGauge() { SetGauge(s_d); }
0105 inline static void SetDefaultGauge(const int gauge)
0106 { SetGauge(s_d=gauge); }
0107
0108 };
0109
0110 template <class Scalar> std::ostream &operator<<
0111 (std::ostream &ostr,const Spinor<Scalar> &s);
0112
0113 template <class Scalar>
0114 unsigned int Spinor<Scalar>::s_r1(1);
0115 template <class Scalar>
0116 unsigned int Spinor<Scalar>::s_r2(2);
0117 template <class Scalar>
0118 unsigned int Spinor<Scalar>::s_r3(3);
0119 template <class Scalar>
0120 unsigned int Spinor<Scalar>::s_d(0);
0121
0122
0123 }
0124
0125 #define DWSpinor ATOOLS::Spinor<double>
0126 #define QWSpinor ATOOLS::Spinor<long double>
0127
0128 #endif