Project
Loading...
Searching...
No Matches
Vector3D.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
17
18#ifndef ALICEO2_TPC_VECTOR3D_H_
19#define ALICEO2_TPC_VECTOR3D_H_
20
21namespace o2
22{
23namespace tpc
24{
25
27
29template <typename DataT = double>
31{
32 public:
37 Vector3D(const unsigned int nr, const unsigned int nz, const unsigned int nphi) : mNr{nr}, mNz{nz}, mNphi{nphi}, mStorage{nr * nz * nphi} {};
38
40 Vector3D() = default;
41
43 DataT& operator()(const unsigned int iR, const unsigned int iZ, const unsigned int iPhi)
44 {
45 return mStorage[getIndex(iR, iZ, iPhi)];
46 }
47
49 const DataT& operator()(const unsigned int iR, const unsigned int iZ, const unsigned int iPhi) const
50 {
51 return mStorage[getIndex(iR, iZ, iPhi)];
52 }
53
55 DataT& operator[](const unsigned int index)
56 {
57 return mStorage[index];
58 }
59
60 const DataT& operator[](const unsigned int index) const
61 {
62 return mStorage[index];
63 }
64
69 int getIndex(const unsigned int iR, const unsigned int iZ, const unsigned int iPhi) const
70 {
71 return iR + mNr * (iZ + mNz * iPhi);
72 }
73
78 void resize(const unsigned int nr, const unsigned int nz, const unsigned int nphi)
79 {
80 mNr = nr;
81 mNz = nz;
82 mNphi = nphi;
83 mStorage.resize(nr * nz * nphi);
84 }
85
86 const auto& data() const { return mStorage; }
87 auto& data() { return mStorage; }
88
89 unsigned int getNr() const { return mNr; }
90 unsigned int getNz() const { return mNz; }
91 unsigned int getNphi() const { return mNphi; }
92 unsigned int size() const { return mStorage.size; }
93
94 auto begin() const { return mStorage.begin(); }
95 auto begin() { return mStorage.begin(); }
96
97 auto end() const { return mStorage.end(); }
98 auto end() { return mStorage.end(); }
99
100 private:
101 unsigned int mNr{};
102 unsigned int mNz{};
103 unsigned int mNphi{};
104 std::vector<DataT> mStorage{};
105};
106
107} // namespace tpc
108} // namespace o2
109
110#endif
this is a simple vector class which is used in the poisson solver class
Definition Vector3D.h:31
const auto & data() const
Definition Vector3D.h:86
const DataT & operator[](const unsigned int index) const
Definition Vector3D.h:60
unsigned int getNphi() const
get number of data points in phi direction
Definition Vector3D.h:91
unsigned int getNr() const
get number of data points in r direction
Definition Vector3D.h:89
Vector3D(const unsigned int nr, const unsigned int nz, const unsigned int nphi)
Definition Vector3D.h:37
void resize(const unsigned int nr, const unsigned int nz, const unsigned int nphi)
Definition Vector3D.h:78
unsigned int size() const
get number of data points
Definition Vector3D.h:92
auto end() const
Definition Vector3D.h:97
DataT & operator[](const unsigned int index)
operator to directly access the values
Definition Vector3D.h:55
const DataT & operator()(const unsigned int iR, const unsigned int iZ, const unsigned int iPhi) const
operator to read the values
Definition Vector3D.h:49
auto & data()
Definition Vector3D.h:87
Vector3D()=default
default constructor
DataT & operator()(const unsigned int iR, const unsigned int iZ, const unsigned int iPhi)
operator to set the values
Definition Vector3D.h:43
int getIndex(const unsigned int iR, const unsigned int iZ, const unsigned int iPhi) const
Definition Vector3D.h:69
unsigned int getNz() const
get number of data points in z direction
Definition Vector3D.h:90
auto begin() const
Definition Vector3D.h:94
GLuint index
Definition glcorearb.h:781
a couple of static helper functions to create timestamp values for CCDB queries or override obsolete ...