Go to the documentation of this file.
63 using namespace StringUtils;
67 Namelist::Namelist(
const unsigned int& n)
74 for (
unsigned int i = 0; i < n; i++)
77 oss <<
"NAME" << setw(3) << setfill(
'0') << i;
79 labels.push_back(name);
88 Namelist::Namelist(
const std::vector<std::string>& names)
92 for (
unsigned int i = 0; i < names.size(); i++)
95 for (
unsigned int j = i + 1; j < names.size(); j++)
97 if (names[i] == names[j])
104 labels.push_back(names[i]);
114 Namelist& Namelist::operator+=(
const std::string& name)
122 labels.push_back(name);
132 Namelist& Namelist::operator-=(
const std::string& name)
136 vector<string>::iterator it;
137 it = find(labels.begin(), labels.end(), name);
138 if (it != labels.end())
150 void Namelist::swap(
const unsigned int& i,
const unsigned int& j)
158 if (i >= labels.size() || j >= labels.size())
162 string str = labels[i];
163 labels[i] = labels[j];
173 void Namelist::sort()
178 std::sort(labels.begin(), labels.end());
187 void Namelist::resize(
unsigned int n)
191 if (n == labels.size())
195 int N = labels.size();
196 while (labels.size() < n)
202 oss <<
"NAME" << setw(3) << setfill(
'0') << N;
205 }
while (contains(s));
208 while (labels.size() > n)
220 void Namelist::randomize(
long seed)
224 if (labels.size() <= 1)
234 for (
int i = labels.size() - 1; i > 0; --i)
237 swap(labels[i], labels[std::rand() % (i + 1)]);
251 for (
unsigned int i = 0; i < labels.size(); i++)
252 for (
unsigned int j = i + 1; j < labels.size(); j++)
253 if (labels[i] == labels[j])
264 bool Namelist::contains(
const std::string& name)
const
268 for (
unsigned int i = 0; i < labels.size(); i++)
270 if (labels[i] == name)
294 for (
unsigned int i = 0; i < N1.
size(); i++)
296 unsigned int match = 0;
297 for (
unsigned int j = 0; j < N2.
size(); j++)
343 for (
unsigned int i = 0; i < N1.
size(); i++)
407 for (
unsigned int i = 0; i < N.
labels.size(); i++)
409 if (contains(N.
labels[i]))
430 for (
unsigned int i = 0; i < N.
labels.size(); i++)
432 if (!(contains(N.
labels[i])))
453 for (i = 0; i < labels.size(); i++)
460 for (i = 0; i < N.
labels.size(); i++)
462 if (!(contains(N.
labels[i])))
485 std::string Namelist::getName(
const unsigned int in)
const
489 if (in >= labels.size())
491 return string(
"out-of-range");
504 bool Namelist::setName(
const unsigned int in,
const std::string& name)
508 if (in >= labels.size())
512 if (labels[in] == name)
530 int Namelist::index(
const std::string& name)
const
534 for (
unsigned int i = 0; i < labels.size(); i++)
536 if (labels[i] == name)
556 for (
unsigned int i = 0; i < N.
labels.size(); i++)
558 os <<
" / " << N.
labels[i];
582 if (LV.
msg.size() > 0)
589 for (i = 0; i < LV.
NL.
size(); i++)
609 os << LV.
tag <<
" " << s <<
" ";
618 for (i = 0; i < LV.
V.
size(); i++)
622 os << setw(LV.
wid) << setprecision(LV.
prec) << LV.
V(i);
623 if (i - LV.
V.
size() + 1)
642 size_t i, j, jlast, n;
650 os <<
" Error -- Namelists in LabeledMatrix are empty! ";
667 if (LM.
msg.size() > 0)
676 if (
int(LM.
msg.size()) > 0 &&
int(LM.
msg.size()) < LM.
wid)
689 for (i = 0; i < n; i++)
714 if (
int(LM.
msg.size()) > LM.
wid)
716 nspace = LM.
msg.size() - LM.
wid + 2;
718 else if (
int(LM.
msg.size()))
728 for (i = 0; i < LM.
M.
rows(); i++)
749 jlast = (LM.
sym ? i + 1 : LM.
M.
cols());
750 for (j = 0; j < jlast; j++)
753 if (LM.
cln && ::fabs(LM.
M(i, j)) < ::pow(10.0, -LM.
prec))
759 os << setw(LM.
wid) << setprecision(LM.
prec) << LM.
M(i, j);
766 if (i < LM.
M.
rows() - 1)
const Namelist & NL
Namelist of names.
bool sym
if true, print only lower triangle
std::vector< std::string > labels
vector of names (strings)
const Namelist & NLrows
Namelist of rows.
const Namelist & NLcols
Namelist of columns.
bool contains(const std::string &name) const
does the Namelist contain the input name?
size_t cols() const
The number of columns in the matrix.
size_t rows() const
The number of rows in the matrix.
bool operator!=(const Namelist &N1, const Namelist &N2)
int form
format: 1=fixed, 2=scientific
int wid
width of fields, in characters
bool identical(const Namelist &N1, const Namelist &N2)
std::string tag
text at beginning of each line (row)
std::string msg
label (name in Namelist) for each row
Namelist operator|(const Namelist &N1, const Namelist &N2)
unsigned int size() const
return the size of the list.
std::string msg
label (name in Namelist) for each row
bool operator==(const Namelist &N1, const Namelist &N2)
std::string getName(const unsigned int in) const
#define GNSSTK_RETHROW(exc)
std::ostream & operator<<(std::ostream &s, gnsstk::StringUtils::FFLead v)
const Matrix< double > & M
Matrix to print.
Namelist operator&(const Namelist &N1, const Namelist &N2)
std::string & rightJustify(std::string &s, const std::string::size_type length, const char pad=' ')
size_t size() const
STL size.
int rc
label rows only (1) columns only (2) or both (0)
std::string tag
text at beginning of each line (row)
std::string & leftJustify(std::string &s, const std::string::size_type length, const char pad=' ')
#define GNSSTK_THROW(exc)
int wid
width of fields, in characters
int prec
precision of fixed, in digits
Namelist operator^(const Namelist &N1, const Namelist &N2)
int prec
precision of fixed, in digits
const Vector< double > & V
Vector to print.
bool cln
if true, print 0.0 as "0"
int form
format - 0=general, 1=fixed(default), 2=integer
gnsstk
Author(s):
autogenerated on Wed Oct 25 2023 02:40:40