Scine::Sparrow  5.0.0
Library for fast and agile quantum chemical calculations with semiempirical methods.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Pages
Spectrum.h
Go to the documentation of this file.
1 
7 #ifndef SPARROW_SPECTRUM_H
8 #define SPARROW_SPECTRUM_H
9 
10 #include <Eigen/Core>
11 
12 namespace Scine {
13 namespace Sparrow {
14 namespace RealTimeSpectroscopy {
15 
16 class IncorrectSpectrumSizeException : public std::exception {
17  const char* what() const noexcept final {
18  return "Incorrect number of data points in spectrum assignment.";
19  }
20 };
21 
22 class Spectrum {
23  public:
28  explicit Spectrum(int size) {
29  xData_.resize(size);
30  yData_.resize(size);
31  }
32 
38  Spectrum(const Eigen::VectorXd& xData, const Eigen::VectorXd& yData) {
39  if (xData.size() != yData.size())
41  xData_ = xData;
42  yData_ = yData;
43  }
44  Spectrum(const Eigen::VectorXd& xData, const Eigen::VectorXd& yData, std::pair<std::string, std::string> labels)
45  : Spectrum(xData, yData) {
46  labels_ = std::move(labels);
47  }
48 
52  int size() const {
53  return xData_.size();
54  }
55 
59  const Eigen::VectorXd& getXData() const {
60  return xData_;
61  }
62 
66  const Eigen::VectorXd& getYData() const {
67  return yData_;
68  }
69 
73  double getXData(int point) const {
74  return xData_(point);
75  }
76 
80  double getYData(int point) const {
81  return yData_(point);
82  }
83 
84  const std::pair<std::string, std::string>& getLabels() const {
85  return labels_;
86  }
91  void setXData(const Eigen::VectorXd& xData) {
92  if (xData.size() != xData_.size())
94  xData_ = xData;
95  }
96 
101  void setYData(const Eigen::VectorXd& yData) {
102  if (yData.size() != yData_.size())
104  yData_ = yData;
105  }
106 
110  void setXLabel(std::string xLabel) {
111  labels_.first = std::move(xLabel);
112  }
116  void setYLabel(std::string yLabel) {
117  labels_.second = std::move(yLabel);
118  }
119 
120  private:
121  Eigen::VectorXd xData_;
122  Eigen::VectorXd yData_;
123  std::pair<std::string, std::string> labels_;
124 };
125 
126 } // namespace RealTimeSpectroscopy
127 } // namespace Sparrow
128 } // namespace Scine
129 
130 #endif // SPARROW_SPECTRUM_H
double getYData(int point) const
Gets the y data points in the spectrum.
Definition: Spectrum.h:80
const Eigen::VectorXd & getYData() const
Gets the y data points in the spectrum.
Definition: Spectrum.h:66
Spectrum(int size)
Constructor initializing the number of data points in the spectrum.
Definition: Spectrum.h:28
void setXLabel(std::string xLabel)
Changes the label of the x axis.
Definition: Spectrum.h:110
void setYLabel(std::string yLabel)
Changes the label of the y axis.
Definition: Spectrum.h:116
void setYData(const Eigen::VectorXd &yData)
Changes the y data points in the spectrum.
Definition: Spectrum.h:101
void setXData(const Eigen::VectorXd &xData)
Changes the x data points in the spectrum.
Definition: Spectrum.h:91
int size() const
Getter for the number of (x,y) points in the spectrum.
Definition: Spectrum.h:52
Spectrum(const Eigen::VectorXd &xData, const Eigen::VectorXd &yData)
Constructor initializing the x and y points.
Definition: Spectrum.h:38
const Eigen::VectorXd & getXData() const
Gets the x data points in the spectrum.
Definition: Spectrum.h:59
double getXData(int point) const
Gets the x data points in the spectrum.
Definition: Spectrum.h:73