ATLAS Offline Software
Tracking
TrkAlignment
TrkAlgebraUtils
src
IntVec.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
TrkAlgebraUtils/IntVec.h
"
7
#include <cstdint>
8
#include <exception>
9
#include <iostream>
10
11
namespace
Trk
{
12
13
IntVec::IntVec
()
14
: m_Nele(0), m_ptr_data(nullptr)
15
{}
16
17
IntVec::IntVec
(
int
N
)
18
: m_Nele(
N
)
19
, m_ptr_data(
new
int
[m_Nele])
20
{
21
22
for
(
int
i
=0;
i
<
m_Nele
;
i
++)
23
*(
m_ptr_data
+
i
)=0;
24
}
25
26
IntVec::IntVec
(
int
N
,
int
init
)
27
: m_Nele(
N
)
28
, m_ptr_data(
new
int
[m_Nele])
29
{
30
31
for
(
int
i
=0;
i
<
m_Nele
;
i
++)
32
*(
m_ptr_data
+
i
)=
init
;
33
}
34
35
IntVec::IntVec
(
const
IntVec
&
v
)
36
: m_Nele(
v
.m_Nele)
37
, m_ptr_data(
new
int
[m_Nele])
38
{
39
40
for
(
int
i
=0;
i
<
m_Nele
;
i
++)
41
*(
m_ptr_data
+
i
)=
v
[
i
];
42
}
43
44
IntVec::~IntVec
(){
45
delete
[]
m_ptr_data
;
46
}
47
48
IntVec
&
IntVec::operator=
(
const
IntVec
&
v
) {
49
if
(
m_Nele
!=0 &&
m_Nele
!=
v
.m_Nele) {
50
throw
std::range_error(
"IntVec Assignment: size does not match!"
);
51
}
52
53
if
(
m_ptr_data
!=
v
.m_ptr_data ) {
54
reSize
(
v
.m_Nele);
55
for
(
int
i
=0;
i
<
m_Nele
;
i
++)
56
*(
m_ptr_data
+
i
)=
v
[
i
];
57
}
58
59
return
*
this
;
60
}
61
62
int
&
IntVec::operator[]
(
int
i
) {
63
if
(
i
<0) {
64
throw
std::out_of_range(
"IntVec: Index < zero! "
);
65
}
66
else
if
(
i
>=
m_Nele
) {
67
throw
std::out_of_range(
"IntVec: Index too large! "
);
68
}
69
70
return
*(
m_ptr_data
+
i
);
71
}
72
73
const
int
&
IntVec::operator[]
(
int
i
)
const
{
74
if
(
i
<0) {
75
throw
std::out_of_range(
"IntVec: Index < zero! "
);
76
}
77
else
if
(
i
>=
m_Nele
) {
78
throw
std::out_of_range(
"IntVec: Index too large! "
);
79
}
80
81
return
*(
m_ptr_data
+
i
);
82
}
83
84
IntVec
IntVec::operator+
(
const
IntVec
&
v
) {
85
if
(
m_Nele
!=
v
.m_Nele ) {
86
throw
std::range_error(
"operator+: vectors size does not match!"
);
87
}
88
89
IntVec
b
(
m_Nele
);
90
for
(
int
i
=0;
i
<
m_Nele
;
i
++)
91
b
[
i
] = *(
m_ptr_data
+
i
) +
v
[
i
];
92
93
return
b
;
94
}
95
96
IntVec
&
IntVec::operator+=
(
const
IntVec
&
v
) {
97
if
(
m_Nele
!=
v
.m_Nele ) {
98
throw
std::range_error(
"operator+=: vectors size does not match!"
);
99
}
100
101
for
(
int
i
=0;
i
<
m_Nele
;
i
++)
102
*(
m_ptr_data
+
i
)+=
v
[
i
];
103
104
return
*
this
;
105
}
106
107
IntVec
IntVec::operator-
(
const
IntVec
&
v
) {
108
if
(
m_Nele
!=
v
.m_Nele ) {
109
throw
std::range_error(
"operator+: vectors size does not match!"
);
110
}
111
112
IntVec
b
(
m_Nele
);
113
for
(
int
i
=0;
i
<
m_Nele
;
i
++)
114
b
[
i
] = *(
m_ptr_data
+
i
) -
v
[
i
];
115
116
return
b
;
117
}
118
119
IntVec
&
IntVec::operator-=
(
const
IntVec
&
v
) {
120
if
(
m_Nele
!=
v
.m_Nele ) {
121
throw
std::range_error(
"operator+=: vectors size does not match!"
);
122
}
123
124
for
(
int
i
=0;
i
<
m_Nele
;
i
++)
125
*(
m_ptr_data
+
i
)-=
v
[
i
];
126
127
return
*
this
;
128
}
129
130
131
void
IntVec::reSize
(
int
Nnew) {
132
if
( Nnew>=0 && Nnew !=
m_Nele
) {
133
int
*
p
=
m_ptr_data
;
134
int
Nele_old =
m_Nele
;
135
m_ptr_data
=
new
int
[Nnew];
136
m_Nele
= Nnew;
137
int
k
=
m_Nele
<= Nele_old ?
m_Nele
: Nele_old;
138
139
p
+=
k
;
140
int
*
q
=
m_ptr_data
+
k
;
141
while
(
q
>
m_ptr_data
)
142
*(--
q
) = *(--
p
);
143
144
delete
[]
p
;
145
}
146
}
147
148
}
// end namespace Trk
Trk::IntVec::operator+
IntVec operator+(const IntVec &)
Definition:
IntVec.cxx:84
Trk::IntVec::operator=
IntVec & operator=(const IntVec &)
Definition:
IntVec.cxx:48
Trk::IntVec::operator+=
IntVec & operator+=(const IntVec &)
Definition:
IntVec.cxx:96
CaloCellPos2Ntuple.int
int
Definition:
CaloCellPos2Ntuple.py:24
CSV_InDetExporter.new
new
Definition:
CSV_InDetExporter.py:145
JetTiledMap::N
@ N
Definition:
TiledEtaPhiMap.h:44
Trk::IntVec::operator-=
IntVec & operator-=(const IntVec &)
Definition:
IntVec.cxx:119
Trk::IntVec::reSize
void reSize(int)
Definition:
IntVec.cxx:131
python.utils.AtlRunQueryDQUtils.p
p
Definition:
AtlRunQueryDQUtils.py:210
Trk::IntVec::m_ptr_data
int * m_ptr_data
Definition:
IntVec.h:31
lumiFormat.i
int i
Definition:
lumiFormat.py:85
Trk::IntVec::operator[]
int & operator[](int)
Definition:
IntVec.cxx:62
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition:
FakeTrackBuilder.h:9
plotBeamSpotMon.b
b
Definition:
plotBeamSpotMon.py:77
python.PyKernel.init
def init(v_theApp, v_rootStream=None)
Definition:
PyKernel.py:45
Trk::IntVec::IntVec
IntVec()
Definition:
IntVec.cxx:13
Trk::IntVec
Definition:
IntVec.h:10
Trk::IntVec::~IntVec
~IntVec()
Definition:
IntVec.cxx:44
extractSporadic.q
list q
Definition:
extractSporadic.py:98
Trk::IntVec::operator-
IntVec operator-(const IntVec &)
Definition:
IntVec.cxx:107
IntVec.h
Trk::IntVec::m_Nele
int m_Nele
Definition:
IntVec.h:30
Trk::v
@ v
Definition:
ParamDefs.h:78
fitman.k
k
Definition:
fitman.py:528
Generated on Mon Dec 23 2024 21:11:55 for ATLAS Offline Software by
1.8.18