votca 2024-dev
Loading...
Searching...
No Matches
table.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 The VOTCA Development Team (http://www.votca.org)
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18#ifndef VOTCA_TOOLS_TABLE_H
19#define VOTCA_TOOLS_TABLE_H
20
21// Standard includes
22#include <string>
23#include <vector>
24
25// Local VOTCA includes
26#include "eigen.h"
27#include "types.h"
28
29namespace votca {
30namespace tools {
31
36class Table {
37 public:
38 void clear();
39
40 void GenerateGridSpacing(double min, double max, double spacing);
41 void resize(Index N);
42 Index size() const { return x_.size(); }
43
44 double &x(Index i) { return x_[i]; }
45 double &y(Index i) { return y_[i]; }
46
47 const double &x(Index i) const { return x_[i]; }
48 const double &y(Index i) const { return y_[i]; }
49 char &flags(Index i) { return flags_[i]; }
50 double &yerr(Index i) { return yerr_[i]; }
51
52 void set(const Index &i, const double &x, const double &y) {
53 x_[i] = x;
54 y_[i] = y;
55 }
56 void set(const Index &i, const double &x, const double &y,
57 const char &flags) {
58 x_[i] = x;
59 y_[i] = y;
60 flags_[i] = flags;
61 }
62 void set(const Index &i, const double &x, const double &y, const char &flags,
63 const double &yerr) {
64 x_[i] = x;
65 y_[i] = y;
66 flags_[i] = flags;
67 yerr_[i] = yerr;
68 }
69
70 void set_comment(const std::string comment) {
71 has_comment_ = true;
72 comment_line_ = comment;
73 }
74
75 void Load(std::string filename);
76 void Save(std::string filename) const;
77
78 void Smooth(Index Nsmooth);
79
80 bool GetHasYErr() { return has_yerr_; }
81 void SetHasYErr(bool has_yerr) { has_yerr_ = has_yerr; }
82
87 double getMaxY() const;
92 double getMinY() const;
97 double getMaxX() const;
102 double getMinX() const;
103
104 Eigen::VectorXd &x() { return x_; }
105 Eigen::VectorXd &y() { return y_; }
106 std::vector<char> &flags() { return flags_; }
107 Eigen::VectorXd &yerr() { return yerr_; }
108
109 void push_back(double x, double y, char flags = ' ');
110
111 const std::string &getErrorDetails() { return error_details_; }
112
113 void setErrorDetails(std::string str) { error_details_ = str; }
114
115 private:
116 Eigen::VectorXd x_;
117 Eigen::VectorXd y_;
118 std::vector<char> flags_;
119 Eigen::VectorXd yerr_;
120 std::string error_details_ = "";
121
122 bool has_yerr_ = false;
123 bool has_comment_ = false;
124
125 friend std::ostream &operator<<(std::ostream &out, const Table &t);
126 friend std::istream &operator>>(std::istream &in, Table &t);
127
128 std::string comment_line_;
129};
130
131} // namespace tools
132} // namespace votca
133#endif // VOTCA_TOOLS_TABLE_H
class to store tables like rdfs, tabulated potentials, etc
Definition table.h:36
double & x(Index i)
Definition table.h:44
Eigen::VectorXd & yerr()
Definition table.h:107
double getMinY() const
Gets the minimum value in the y column.
Definition table.cc:86
Index size() const
Definition table.h:42
double & yerr(Index i)
Definition table.h:50
bool GetHasYErr()
Definition table.h:80
double getMaxX() const
Gets the maximum value in the x column.
Definition table.cc:88
Eigen::VectorXd & y()
Definition table.h:105
void GenerateGridSpacing(double min, double max, double spacing)
Definition table.cc:180
void SetHasYErr(bool has_yerr)
Definition table.h:81
void set(const Index &i, const double &x, const double &y, const char &flags, const double &yerr)
Definition table.h:62
std::vector< char > & flags()
Definition table.h:106
void set(const Index &i, const double &x, const double &y)
Definition table.h:52
Eigen::VectorXd yerr_
Definition table.h:119
std::string error_details_
Definition table.h:120
std::string comment_line_
Definition table.h:128
friend std::istream & operator>>(std::istream &in, Table &t)
Definition table.cc:94
double getMaxY() const
Gets the maximum value in the y column.
Definition table.cc:84
void Load(std::string filename)
Definition table.cc:47
void set(const Index &i, const double &x, const double &y, const char &flags)
Definition table.h:56
Eigen::VectorXd y_
Definition table.h:117
char & flags(Index i)
Definition table.h:49
void set_comment(const std::string comment)
Definition table.h:70
void resize(Index N)
Definition table.cc:38
friend std::ostream & operator<<(std::ostream &out, const Table &t)
Definition table.cc:207
double & y(Index i)
Definition table.h:45
const double & y(Index i) const
Definition table.h:48
Eigen::VectorXd & x()
Definition table.h:104
const std::string & getErrorDetails()
Definition table.h:111
const double & x(Index i) const
Definition table.h:47
void Save(std::string filename) const
Definition table.cc:59
void Smooth(Index Nsmooth)
Definition table.cc:194
std::vector< char > flags_
Definition table.h:118
double getMinX() const
Gets the minimum value in the x column.
Definition table.cc:90
void setErrorDetails(std::string str)
Definition table.h:113
void push_back(double x, double y, char flags=' ')
Definition table.cc:235
Eigen::VectorXd x_
Definition table.h:116
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26