VERB4D
|
A matrix that can be created in 1, 2, 3, or 4 dimensions with the ability to be updated. More...
#include <UpdatableMatrix.h>
Public Member Functions | |
MatrixND & | operator= (const MatrixND &M) |
MatrixND & | operator= (const double Val) |
void | saveCurrent () |
bool | readFromIniFile (string ini_filename, MatrixND Q1, MatrixND Q2, MatrixND Q3, MatrixND Q4=MatrixND()) |
bool | readFromString (string file_line_string, MatrixND &Q1, MatrixND &Q2, MatrixND &Q3, MatrixND &Q4) |
bool | update (double time, MatrixND Q1, MatrixND Q2, MatrixND Q3, MatrixND Q4=MatrixND()) |
Public Attributes | |
MatrixND | original_arr |
Indicates when the Matrix was updated last time. | |
A matrix that can be created in 1, 2, 3, or 4 dimensions with the ability to be updated.
Updatable matrix - 1,2,3,4 dimensions.
It's a template because it's easier to create, maintain, and debug one class, instead of 4 classes with the same functionality
It's just like a normal matrix (and can be used just like one), but it can also be updated according to rules from an ini-file
The readFromIniFile function is used to load data into an UpdatableMatrix by storing the contents of a .tab file. The .tab file will either list a .plt file to load or a .lst file which in turn has both time steps and .plt files. The update function is called at every time step in the main function and will execute any updates that can be found from these files that match the designated timestep.
|
inline |
Overloaded = operator for any size Updatable Matrix. Copies every element from M and returns current matrix
|
inline |
Overloaded = operator for any size Updatable Matrix. Sets every elemenet to Val and returns current matrix
bool UpdatableMatrix< MatrixND >::readFromIniFile | ( | string | ini_filename, |
MatrixND | q1, | ||
MatrixND | q2, | ||
MatrixND | q3, | ||
MatrixND | q4 = MatrixND() |
||
) |
Read UpdatableMatrix rules from ini-file
Gets parameters from the first line using readFromString()
File will either be data file (such as .plt which will store data immediately) or update file (such as .lst which will update matrix values at corresponding timestep from main function)
bool UpdatableMatrix< MatrixND >::readFromString | ( | string | file_line_string, |
MatrixND & | q1, | ||
MatrixND & | q2, | ||
MatrixND & | q3, | ||
MatrixND & | q4 | ||
) |
Read UpdateMatrix parameters from a string
Will traverse the string and get the entire lines values - starting with parameter q1 and getting values until reaching q4 or running out of values for the line
If a data file (such as .plt) is selected then the contents will be stored into the matrix. If a update-file (such as .lst) is selected then no matrix values will be saved, however the update_filename field will be saved. Upon every timestep the main file will call update() on this matrix, and inside update will look for the update_filename field. If present it will update the matrix to the corresponding timestep
file_line_string | - string which contains one line of values spanning from q1 to q4 |
void UpdatableMatrix< MatrixND >::saveCurrent | ( | ) |
UpdatableMatrix has 2 arrays: original and current (=parent). We need to allocate memory for both of them when the memory is allocated for the aprent array. So we use polymorphism concept to override parent method AllocateMemory and to allocate memory for both arrays Similar to AllocateMomory, we need to update both arrays: original and current (parent) when we read values from a file Save current matrix as 'original' to be scaled/limited later
bool UpdatableMatrix< MatrixND >::update | ( | double | current_time, |
MatrixND | q1, | ||
MatrixND | q2, | ||
MatrixND | q3, | ||
MatrixND | q4 = MatrixND() |
||
) |
Update the Matrix if last update time is less than current update time
Scaling coefficients are added
Limits are set for the coefficients for q1 through q4
The limits are applied using MatrixLimit()
Record which limits were applied
This function is called at every time step from the main function. It will look to see if this matrix has the update_filename field set. If so at any time where the update_time is less than current_time it will use the update_filename to load the new matrix. This pertains to .lst files mainly