summaryrefslogtreecommitdiff
path: root/a4/octave.h
diff options
context:
space:
mode:
authorBent Bisballe Nyeng <deva@aasimon.org>2023-08-01 08:27:01 +0200
committerBent Bisballe Nyeng <deva@aasimon.org>2023-08-01 08:27:01 +0200
commit6a8ae2de4261fecd0281685b9eea66bbd82bd7fb (patch)
treea775f79c34e91afcd77cedc10f55a3aa9096114c /a4/octave.h
parent9c69c2c6bcfa0d56178e9d801c1e5cf24c9cde0b (diff)
A4: WIP
Diffstat (limited to 'a4/octave.h')
-rw-r--r--a4/octave.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/a4/octave.h b/a4/octave.h
new file mode 100644
index 0000000..3c814c5
--- /dev/null
+++ b/a4/octave.h
@@ -0,0 +1,45 @@
+// -*- c++ -*-
+#pragma once
+
+#include <string>
+#include <utility>
+#include <fstream>
+#include <vector>
+#include <deque>
+
+class Plot
+{
+public:
+ Plot(const std::string& title) : title(title) {}
+
+ const std::string& getTitle() const;
+ void add(const std::pair<double, double>& point);
+ void add(double y);
+ void setX(double x);
+
+ friend const Plot& operator<<(std::ostream& out, const Plot& plot);
+
+private:
+ std::vector<std::pair<double, double>> data;
+ std::string title;
+ double x{};
+};
+
+class Octave
+{
+public:
+ Octave(const std::string& file);
+ ~Octave();
+
+ Plot& add(const std::string& title);
+ void setAxis(const std::string& x_axis, const std::string& y_axis);
+
+private:
+ std::deque<Plot> plots;
+ std::ofstream out;
+
+ std::string x_axis;
+ std::string y_axis;
+
+ std::string file;
+};