ATLAS Offline Software
AlVec.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRKALGS_ALVEC_H
6 #define TRKALGS_ALVEC_H
7 
8 // PBdR (17Apr2007)
9 
10 #include <exception>
11 #include <map>
12 #include <vector>
13 
14 class StatusCode;
15 
16 namespace Trk {
17 
18 class AlSymMatBase;
19 class AlSymMat;
20 class AlMat;
21 class AlSpaMat;
22 
23 class AlVec {
24  public:
25  AlVec(int N);
26  AlVec();
27  AlVec(const AlVec& v);
29  : m_size (v.m_size),
31  m_pathbin ( std::move(v.m_pathbin) ),
32  m_pathtxt ( std::move(v.m_pathtxt) )
33  {
34 
35  v.m_size = 0;
36  v.m_ptr_data = nullptr;
37  }
38 
39  ~AlVec();
40 
41  inline double& operator[](int i);
42  inline const double& operator[](int i) const;
43 
44  AlVec& operator=(const AlVec& v);
46  if (&v != this ) {
47  m_pathbin = std::move(v.m_pathbin);
48  m_pathtxt = std::move(v.m_pathtxt);
49  m_size = v.m_size;
50  m_ptr_data = v.m_ptr_data;
51  v.m_size = 0;
52  v.m_ptr_data = nullptr;
53  }
54 
55  return *this;
56 
57  }
58 
59  AlVec& operator=(const double& v);
60  AlVec operator+(const AlVec&) const;
61  AlVec& operator+=(const AlVec&);
62  AlVec operator-(const AlVec&) const;
63  AlVec& operator-=(const AlVec&);
64  double operator*(const AlVec&) const;
65  AlVec operator*(const AlMat&) const;
66  AlVec operator*(const AlSymMatBase&) const;
67  AlVec operator*(const double&) const;
68  AlVec& operator*=(const double&);
69 
70  double norm() const;
71 
72  void reSize(int);
73  void RemoveModule(int);
74  void RemoveAlignPar(int, int);
75  int RemoveElements(std::vector<int>);
76  void SetPathBin(const std::string&);
77  void SetPathTxt(const std::string&);
78  StatusCode Write(const std::string&, bool, double, std::map<int,unsigned long long>, float);
79  StatusCode WritePartial(const std::string&, bool, double, std::map<int,unsigned long long>, float);
80  StatusCode WritePartial(const std::string&, bool, double, std::map<int,std::string>, float);
81  StatusCode InitializeOutputVector(const std::string&, bool, double, float, std::ofstream&);
82 
83  static StatusCode CheckVecVersion(const std::string&, bool&);
84  StatusCode Read(const std::string&, double&, std::map<int,unsigned long long>&, float&);
85  StatusCode ReadPartial(const std::string&, double&, std::map<int,unsigned long long>&, float&);
86  StatusCode ReadProjected(const std::string&, double&, std::map<int,unsigned long long>&, float&);
87  StatusCode ReadScalaPack(const std::string&);
88  StatusCode WriteEigenvalueVec(const std::string &, bool);
89  inline int size() const;
90  inline const double* ptrData() const;
91  inline double* ptrData();
92 
93  protected:
94  int m_size;
95  double* m_ptr_data = nullptr;
96  std::string m_pathbin;
97  std::string m_pathtxt;
98 
99  void copy(const AlVec&);
100 
101  //friend class AlSymMatBase;
102  //friend class AlSymMat;
103  //friend class AlSpaMat;
104  //friend class AlMat;
105 };
106 
107 // inline methods:
108 
109 inline int AlVec::size() const {
110  return m_size;
111 }
112 
113 inline const double* AlVec::ptrData() const {
114  return m_ptr_data;
115 }
116 
117 inline double* AlVec::ptrData() {
118  return m_ptr_data;
119 }
120 
121 inline double& AlVec::operator[](int i) {
122  if( i < 0 ) {
123  throw std::out_of_range( "AlVec: Index < zero! " );
124  }
125 
126  if( i >= m_size ) {
127  throw std::out_of_range( "AlVec: Index too large! ");
128  }
129 
130  return *(m_ptr_data+i);
131 }
132 
133 inline const double& AlVec::operator[](int i) const {
134  if( i < 0 ) {
135  throw std::out_of_range( "AlVec: Index < zero! " );
136  }
137 
138  if( i >= m_size ) {
139  throw std::out_of_range( "AlVec: Index too large! " );
140  }
141 
142  return *(m_ptr_data+i);
143 }
144 
145 } // end namespace Trk
146 
147 #endif // TRKALGS_ALVEC_H
Trk::AlVec::operator-
AlVec operator-(const AlVec &) const
Definition: AlVec.cxx:124
Trk::AlVec::InitializeOutputVector
StatusCode InitializeOutputVector(const std::string &, bool, double, float, std::ofstream &)
Definition: AlVec.cxx:455
Trk::AlVec::~AlVec
~AlVec()
Definition: AlVec.cxx:54
Trk::AlVec::CheckVecVersion
static StatusCode CheckVecVersion(const std::string &, bool &)
Definition: AlVec.cxx:532
Trk::AlVec::operator*=
AlVec & operator*=(const double &)
Definition: AlVec.cxx:195
Trk::AlVec::reSize
void reSize(int)
Definition: AlVec.cxx:219
Trk::AlVec::copy
void copy(const AlVec &)
Definition: AlVec.cxx:60
Trk::AlVec
Definition: AlVec.h:23
Trk::AlSymMatBase
Definition: AlSymMatBase.h:38
Trk::AlVec::RemoveAlignPar
void RemoveAlignPar(int, int)
Definition: AlVec.cxx:249
Trk::AlVec::operator-=
AlVec & operator-=(const AlVec &)
Definition: AlVec.cxx:140
Trk::AlVec::WriteEigenvalueVec
StatusCode WriteEigenvalueVec(const std::string &, bool)
Definition: AlVec.cxx:668
Trk::AlVec::m_size
int m_size
Definition: AlVec.h:94
Trk::AlVec::operator[]
double & operator[](int i)
Definition: AlVec.h:121
Trk::AlVec::operator*
double operator*(const AlVec &) const
Definition: AlVec.cxx:153
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
Trk::AlVec::WritePartial
StatusCode WritePartial(const std::string &, bool, double, std::map< int, unsigned long long >, float)
Definition: AlVec.cxx:366
Trk::AlVec::Write
StatusCode Write(const std::string &, bool, double, std::map< int, unsigned long long >, float)
Definition: AlVec.cxx:315
Trk::AlVec::m_pathtxt
std::string m_pathtxt
Definition: AlVec.h:97
Trk::AlVec::operator*
AlVec operator*(const double &) const
Trk::AlVec::norm
double norm() const
Definition: AlVec.cxx:206
Trk::AlVec::Read
StatusCode Read(const std::string &, double &, std::map< int, unsigned long long > &, float &)
Definition: AlVec.cxx:560
lumiFormat.i
int i
Definition: lumiFormat.py:85
Trk::AlVec::size
int size() const
Definition: AlVec.h:109
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::AlVec::AlVec
AlVec()
Definition: AlVec.cxx:20
Trk::AlMat
Definition: AlMat.h:27
Trk::AlVec::RemoveElements
int RemoveElements(std::vector< int >)
Definition: AlVec.cxx:266
Trk::AlVec::ReadProjected
StatusCode ReadProjected(const std::string &, double &, std::map< int, unsigned long long > &, float &)
Definition: AlVec.cxx:609
Trk::AlVec::m_pathbin
std::string m_pathbin
Definition: AlVec.h:96
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::AlVec::AlVec
AlVec(AlVec &&v)
Definition: AlVec.h:28
Trk::AlVec::m_ptr_data
double * m_ptr_data
Definition: AlVec.h:95
Trk::AlVec::operator=
AlVec & operator=(const AlVec &v)
Definition: AlVec.cxx:82
Trk::AlVec::operator=
AlVec & operator=(AlVec &&v)
Definition: AlVec.h:45
Trk::AlVec::ReadPartial
StatusCode ReadPartial(const std::string &, double &, std::map< int, unsigned long long > &, float &)
Definition: AlVec.cxx:484
Trk::AlVec::ptrData
const double * ptrData() const
Definition: AlVec.h:113
Trk::AlVec::ReadScalaPack
StatusCode ReadScalaPack(const std::string &)
Definition: AlVec.cxx:647
Trk::AlVec::SetPathBin
void SetPathBin(const std::string &)
Definition: AlVec.cxx:303
Trk::AlVec::operator+=
AlVec & operator+=(const AlVec &)
Definition: AlVec.cxx:111
Trk::AlVec::SetPathTxt
void SetPathTxt(const std::string &)
Definition: AlVec.cxx:309
Trk::AlVec::operator+
AlVec operator+(const AlVec &) const
Definition: AlVec.cxx:95
Trk::v
@ v
Definition: ParamDefs.h:78
Trk::AlVec::RemoveModule
void RemoveModule(int)
Definition: AlVec.cxx:236