MINT2
HyperName.cpp
Go to the documentation of this file.
1 #include "Mint/HyperName.h"
2 
6  for(int i = 0; i < dim; i++){
7  TString name = "var_"; name += i;
8  _names.push_back( name );
9  _units.push_back( " " );
10  }
11 }
12 
15 HyperName::HyperName(std::vector<TString> names){
16  _names = names;
17  _units = std::vector<TString>(names.size(), " ");
18 
19 }
20 
23 HyperName::HyperName(TString name0){
24  _names.push_back(name0);
25  _units.push_back(" ");
26 }
27 
30 HyperName::HyperName(TString name0, TString name1){
31  _names.push_back(name0);
32  _names.push_back(name1);
33  _units.push_back(" ");
34  _units.push_back(" ");
35 }
36 
39 HyperName::HyperName(TString name0, TString name1, TString name2){
40  _names.push_back(name0);
41  _names.push_back(name1);
42  _names.push_back(name2);
43  _units.push_back(" ");
44  _units.push_back(" ");
45  _units.push_back(" ");
46 }
47 
50 HyperName::HyperName(TString name0, TString name1, TString name2, TString name3){
51  _names.push_back(name0);
52  _names.push_back(name1);
53  _names.push_back(name2);
54  _names.push_back(name3);
55  _units.push_back(" ");
56  _units.push_back(" ");
57  _units.push_back(" ");
58  _units.push_back(" ");
59 }
60 
63 HyperName::HyperName(TString name0, TString name1, TString name2, TString name3, TString name4){
64  _names.push_back(name0);
65  _names.push_back(name1);
66  _names.push_back(name2);
67  _names.push_back(name3);
68  _names.push_back(name4);
69  _units.push_back(" ");
70  _units.push_back(" ");
71  _units.push_back(" ");
72  _units.push_back(" ");
73  _units.push_back(" ");
74 }
75 
78 void HyperName::setUnits(TString units){
79  for(unsigned i = 0; i < _units.size(); i++){
80  _units.at(i) = units;
81  }
82 }
83 
86 void HyperName::setUnits(TString units, int dim){
87  if (dim < 0 || dim >= (int)_names.size()){
88  std::cout << "Trying to set the units of the HyperName element that doesn't exist" << std::endl;
89  return;
90  }
91  _units.at(dim) = units;
92 }
93 
96 TString HyperName::getAxisString(int dim){
97  if (dim < 0 || dim >= (int)_names.size()){
98  std::cout << "Trying call HyperName::getAxisString on an element that doesn't exist" << std::endl;
99  return "ERROR";
100  }
101  TString retVal = _names.at(dim);
102  if (_units.at(dim) != " ") retVal += " [" + _units.at(dim) + "]";
103  return retVal;
104 }
105 
106 
108  return _names.size();
109 }
110 
114 HyperName HyperName::slice(std::vector<int> sliceDims){
115 
116  int nStartingDims = getDimension();
117  int nSliceDims = sliceDims.size();
118 
119  HyperName names( nStartingDims - nSliceDims );
120  int count = 0;
121 
122  for (int i = 0; i < nStartingDims; i++){
123 
124  bool doesExist = false;
125 
126  for (int j = 0; j < nSliceDims; j++){
127  int dim = sliceDims.at(j);
128  if (i == dim) {
129  doesExist = true;
130  break;
131  }
132  }
133 
134  if (doesExist == false) {
135  names.at(count) = at(i); count++;
136  }
137  }
138 
139  return names;
140 
141 }
142 
143 
144 
148 
149 }
150 
151 
std::vector< TString > _units
Definition: HyperName.h:27
TString getAxisString(int dim)
Definition: HyperName.cpp:96
void setUnits(TString units)
Definition: HyperName.cpp:78
int getDimension() const
Definition: HyperName.cpp:107
HyperName slice(std::vector< int > sliceDims)
Definition: HyperName.cpp:114
std::vector< TString > _names
Definition: HyperName.h:26
const TString & at(int dim) const
Definition: HyperName.h:50
HyperName(int dim)
Definition: HyperName.cpp:5