VERB4D
UpdatableMatrix.h
Go to the documentation of this file.
1 
6 #ifndef UPDATABLEMATRIX_H_
7 #define UPDATABLEMATRIX_H_
8 
9 #include <string>
10 #include <istream>
11 #include <sstream>
12 #include <vector>
13 
14 #include "Matrix.h"
15 #include "Logger.h"
16 
37 template <typename MatrixND>
38 class UpdatableMatrix : public MatrixND { // current array is the parent array - whenever we use UpdatableMatrix as an array, the parent class is used
39 private:
40  // updated matrix
41  // Matrix3D<double> updated_arr;
42 
43  //
44  // string last_data_filename; /// data-filename
45  string scale_string;
46  string update_filename;
47  string Q1_from_string;
48  string Q1_to_string;
49  string Q2_from_string;
50  string Q2_to_string;
51  string Q3_from_string;
52  string Q3_to_string;
53  string Q4_from_string;
54  string Q4_to_string;
55 
56  double last_update_time;
57 
58 public:
59  // original matrix
61 
62  // to simplify things
63  inline MatrixND& operator= (const MatrixND &M);
64  inline MatrixND& operator= (const double Val);
65 
66  void saveCurrent(); // Save current matrix as original to be scaled/limited later
67 
68  //void AllocateMemory( int size_Q1 );
69  //void AllocateMemory( int size_Q1, int size_Q2 );
70  //void AllocateMemory( int size_Q1, int size_Q2, int size_Q3 );
71  //void AllocateMemory( int size_Q1, int size_Q2, int size_Q3, int size_Q4 );
72 
73  //void readFromFile(string filename, const MatrixND grid_w); ///< Load matrix to a file
74  //void readFromFile(string filename, const MatrixND grid_w, const MatrixND grid_x); ///< Load matrix to a file
75  //void readFromFile(string filename, const MatrixND grid_w, const MatrixND grid_x, const MatrixND grid_y); ///< Load matrix to a file
76  //void readFromFile(string filename, const MatrixND grid_w, const MatrixND grid_x, const MatrixND grid_y, const MatrixND grid_z); ///< Load matrix to a file
77 
78  bool readFromIniFile(string ini_filename, MatrixND Q1, MatrixND Q2, MatrixND Q3, MatrixND Q4 = MatrixND());
79  bool readFromString(string file_line_string, MatrixND &Q1, MatrixND &Q2, MatrixND &Q3, MatrixND &Q4);
80  bool update(double time, MatrixND Q1, MatrixND Q2, MatrixND Q3, MatrixND Q4 = MatrixND());
81 
82 };
83 
102 template <typename MatrixND>
104 private:
106  vector < UpdatableMatrix<MatrixND> > matricesList;
107 
108 public:
109 
110  // to simplify things
111  inline MatrixND& operator= (const MatrixND &M);
112  inline MatrixND& operator= (const double Val);
113 
114  bool readFromIniFile(string ini_filename, MatrixND &Q1, MatrixND &Q2, MatrixND &Q3, MatrixND &Q4);
115  void update(double time, MatrixND Q1, MatrixND Q2, MatrixND Q3, MatrixND Q4 = MatrixND());
116 
117 };
118 
119 // couple of helpful functions
120 string GetCurrentTimeValue(string filename, double current_time, double &update_time);
121 bool is_number(const std::string& s);
123 double stringToValue(string string_value, double current_time);
124 
125 #endif /* UPDATABLEMATRIX_H_ */
void update(double time, MatrixND Q1, MatrixND Q2, MatrixND Q3, MatrixND Q4=MatrixND())
Definition: UpdatableMatrix.cpp:790
Matrix 1D, 2D, 3D and 4D and operations with them.
MatrixND & operator=(const MatrixND &M)
Definition: UpdatableMatrix.cpp:919
MatrixND original_arr
Indicates when the Matrix was updated last time.
Definition: UpdatableMatrix.h:60
bool readFromString(string file_line_string, MatrixND &Q1, MatrixND &Q2, MatrixND &Q3, MatrixND &Q4)
Definition: UpdatableMatrix.cpp:343
Logs the messages sent, including information, warnings, and errors.
bool is_number(const std::string &s)
Definition: UpdatableMatrix.cpp:900
bool readFromIniFile(string ini_filename, MatrixND &Q1, MatrixND &Q2, MatrixND &Q3, MatrixND &Q4)
Definition: UpdatableMatrix.cpp:729
bool readFromIniFile(string ini_filename, MatrixND Q1, MatrixND Q2, MatrixND Q3, MatrixND Q4=MatrixND())
Definition: UpdatableMatrix.cpp:289
A matrix that can be created in 1, 2, 3, or 4 dimensions with the ability to be updated.
Definition: UpdatableMatrix.h:103
bool update(double time, MatrixND Q1, MatrixND Q2, MatrixND Q3, MatrixND Q4=MatrixND())
Definition: UpdatableMatrix.cpp:475
MatrixND & operator=(const MatrixND &M)
Definition: UpdatableMatrix.cpp:937
A normal matrix that can be defined to have 1, 2, 3, or 4 dimensions which is templated for Updatable...
A matrix that can be created in 1, 2, 3, or 4 dimensions with the ability to be updated.
Definition: UpdatableMatrix.h:38
void saveCurrent()
Definition: UpdatableMatrix.cpp:168
double stringToValue(string string_value, double current_time)
FUNCTION NOT IMPLEMENTED.
string GetCurrentTimeValue(string filename, double current_time, double &update_time)
Definition: UpdatableMatrix.cpp:824