TimeSeries< FP > Class Template Reference
|
CPP API
|
stores vectors of values at time points (or some other abstract variable) the value at each time point is a vector. More...
#include <time_series.h>
Public Types | |
| using | const_iterator = TimeSeriesValueIterator< FP, true > |
| using | const_reverse_iterator = std::reverse_iterator< const_iterator > |
| using | const_reverse_time_iterator = std::reverse_iterator< const_time_iterator > |
| using | const_time_iterator = TimeSeriesTimeIterator< FP, true > |
| using | difference_type = typename iterator::difference_type |
| using | iterator = TimeSeriesValueIterator< FP, false > |
| using | Matrix = Eigen::Matrix< FP, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor > |
| type that stores the data More... | |
| using | reference = typename iterator::reference |
| using | reverse_iterator = std::reverse_iterator< iterator > |
| using | reverse_time_iterator = std::reverse_iterator< time_iterator > |
| using | size_type = Eigen::Index |
| using | time_iterator = TimeSeriesTimeIterator< FP, false > |
| using | value_type = typename iterator::value_type |
| using | Vector = Eigen::Matrix< FP, Eigen::Dynamic, 1 > |
| base type of expressions of vector values at a time point More... | |
Public Member Functions | |
| Eigen::Ref< Vector > | add_time_point () |
| add one uninitialized time point More... | |
| Eigen::Ref< Vector > | add_time_point (FP t) |
| add one time point. More... | |
| template<class Expr > | |
| Eigen::Ref< Vector > | add_time_point (FP t, Expr &&expr) |
| add one time point. More... | |
| iterator | begin () |
| const_iterator | begin () const |
| const_iterator | cbegin () const |
| const_iterator | cend () const |
| const_reverse_iterator | crbegin () const |
| const_reverse_iterator | crend () const |
| FP * | data () |
| raw data storage. More... | |
| const FP * | data () const |
| iterator | end () |
| const_iterator | end () const |
| IOResult< void > | export_csv (const std::string &filename, const std::vector< std::string > &column_labels={}, char separator=',', int precision=6) const |
| Exports a TimeSeries object into a CSV file. More... | |
| Eigen::Index | get_capacity () const |
| current capacity More... | |
| Range< const_reverse_time_iterator > | get_const_reverse_times () const |
| Range< const_time_iterator > | get_const_times () const |
| FP & | get_last_time () |
| time of time point at index num_time_points - 1 More... | |
| const FP & | get_last_time () const |
| Eigen::Ref< Vector > | get_last_value () |
| Eigen::Ref< const Vector > | get_last_value () const |
| reference to value vector at time point (num_timepoints - 1) More... | |
| Eigen::Index | get_num_elements () const |
| number of elements of vector at each time point More... | |
| Eigen::Index | get_num_rows () const |
| number of rows in data storage (includes time) More... | |
| Eigen::Index | get_num_time_points () const |
| number of time points in the series More... | |
| Range< reverse_time_iterator > | get_reverse_times () |
| Range< const_reverse_time_iterator > | get_reverse_times () const |
| FP & | get_time (Eigen::Index i) |
| time of time point at index i More... | |
| const FP & | get_time (Eigen::Index i) const |
| Range< time_iterator > | get_times () |
| Range< const_time_iterator > | get_times () const |
| Eigen::Ref< Vector > | get_value (Eigen::Index i) |
| Eigen::Ref< const Vector > | get_value (Eigen::Index i) const |
| reference to value vector at time point i More... | |
| bool | is_strictly_monotonic () const |
| Check if the time is strictly monotonic increasing. More... | |
| TimeSeries & | operator= (const TimeSeries &other) |
| copy assignment More... | |
| TimeSeries & | operator= (TimeSeries &&other)=default |
| Eigen::Ref< Vector > | operator[] (Eigen::Index i) |
| Eigen::Ref< const Vector > | operator[] (Eigen::Index i) const |
| reverse_iterator | rbegin () |
| const_reverse_iterator | rbegin () const |
| void | remove_last_time_point () |
| void | remove_time_point (Eigen::Index i) |
| remove time point. More... | |
| reverse_iterator | rend () |
| const_reverse_iterator | rend () const |
| void | reserve (Eigen::Index n) |
| reserve capacity for n time points More... | |
| template<class IOContext > | |
| void | serialize (IOContext &io) const |
| TimeSeries (const TimeSeries &other) | |
| copy ctor More... | |
| TimeSeries (Eigen::Index num_elements) | |
| initialize empty TimeSeries. More... | |
| template<typename Expr > | |
| TimeSeries (FP t, Expr &&expr) | |
| initialize TimeSeries with one time point. More... | |
| TimeSeries (std::vector< std::vector< FP >> table) | |
| Initialize a TimeSeries with a table. More... | |
| TimeSeries (TimeSeries &&other)=default | |
| move ctor and assignment More... | |
| auto | matrix () |
| Matrix expression that contains one time point per column. More... | |
| auto | matrix () const |
| Matrix expression that contains one time point per column. More... | |
| void | print_table (std::ostream &out, const std::vector< std::string > &column_labels={}, size_t width=16, size_t precision=5, char separator=' ', const std::string header_prefix="\n") const |
| Print out the TimeSeries as a table. More... | |
| void | print_table (const std::vector< std::string > &column_labels={}, size_t width=16, size_t precision=5, char separator=' ', const std::string header_prefix="\n") const |
| Print out the TimeSeries as a table. More... | |
Static Public Member Functions | |
| template<class IOContext > | |
| static IOResult< TimeSeries > | deserialize (IOContext &io) |
| static TimeSeries | zero (Eigen::Index num_time_points, Eigen::Index num_elements) |
| constructs TimeSeries instance and initializes it with zeros More... | |
Private Member Functions | |
| void | add_time_point_noinit () |
| auto | get_valid_block () |
| currently occupied block of storage More... | |
| auto | get_valid_block () const |
Private Attributes | |
| Matrix | m_data |
| data storage More... | |
| Eigen::Index | m_num_time_points |
| number of time points (i.e. More... | |
Friends | |
| void | PrintTo (const TimeSeries &self, std::ostream *os) |
| print this object (googletest) More... | |
Detailed Description
template<class FP>
class mio::TimeSeries< FP >
stores vectors of values at time points (or some other abstract variable) the value at each time point is a vector.
size of the vector is determined at runtime but is equal for all time points. grows efficiently (like std::vector) in time dimension. Time and values of a single point are stored together in memory: {t0, v0[0], v0[1], ...}, {t1, v1[0], v1[1], ...}, {t2, v20, ...
- Template Parameters
-
FP any floating point like type accepted by Eigen
Member Typedef Documentation
◆ const_iterator
| using mio::TimeSeries< FP >::const_iterator = TimeSeriesValueIterator<FP, true> |
◆ const_reverse_iterator
| using mio::TimeSeries< FP >::const_reverse_iterator = std::reverse_iterator<const_iterator> |
◆ const_reverse_time_iterator
| using mio::TimeSeries< FP >::const_reverse_time_iterator = std::reverse_iterator<const_time_iterator> |
◆ const_time_iterator
| using mio::TimeSeries< FP >::const_time_iterator = TimeSeriesTimeIterator<FP, true> |
◆ difference_type
| using mio::TimeSeries< FP >::difference_type = typename iterator::difference_type |
◆ iterator
| using mio::TimeSeries< FP >::iterator = TimeSeriesValueIterator<FP, false> |
◆ Matrix
| using mio::TimeSeries< FP >::Matrix = Eigen::Matrix<FP, Eigen::Dynamic, Eigen::Dynamic, Eigen::ColMajor> |
type that stores the data
◆ reference
| using mio::TimeSeries< FP >::reference = typename iterator::reference |
◆ reverse_iterator
| using mio::TimeSeries< FP >::reverse_iterator = std::reverse_iterator<iterator> |
◆ reverse_time_iterator
| using mio::TimeSeries< FP >::reverse_time_iterator = std::reverse_iterator<time_iterator> |
◆ size_type
| using mio::TimeSeries< FP >::size_type = Eigen::Index |
◆ time_iterator
| using mio::TimeSeries< FP >::time_iterator = TimeSeriesTimeIterator<FP, false> |
◆ value_type
| using mio::TimeSeries< FP >::value_type = typename iterator::value_type |
◆ Vector
| using mio::TimeSeries< FP >::Vector = Eigen::Matrix<FP, Eigen::Dynamic, 1> |
base type of expressions of vector values at a time point
Constructor & Destructor Documentation
◆ TimeSeries() [1/5]
|
inline |
initialize empty TimeSeries.
- Parameters
-
num_elements size of vector at each time point
◆ TimeSeries() [2/5]
|
inline |
initialize TimeSeries with one time point.
size of vector at each time point determined from input.
- Template Parameters
-
Expr any type that can be assigned to TimeSeries::Vector
- Parameters
-
t time of initial time point expr vector expression that evaluates to value at first time point
◆ TimeSeries() [3/5]
|
inline |
Initialize a TimeSeries with a table.
- Parameters
-
table Consists of a list of time points, each of the form (time, value_0, value_1, ..., value_n) for some fixed n >= 0.
◆ TimeSeries() [4/5]
|
inline |
copy ctor
◆ TimeSeries() [5/5]
|
default |
move ctor and assignment
Member Function Documentation
◆ add_time_point() [1/3]
|
inline |
add one uninitialized time point
◆ add_time_point() [2/3]
|
inline |
add one time point.
initialize time;
◆ add_time_point() [3/3]
|
inline |
add one time point.
Initialize time and value. Expr can be any vector expression assignable to TimeSeries::Vector.
◆ add_time_point_noinit()
|
inlineprivate |
◆ begin() [1/2]
|
inline |
◆ begin() [2/2]
|
inline |
◆ cbegin()
|
inline |
◆ cend()
|
inline |
◆ crbegin()
|
inline |
◆ crend()
|
inline |
◆ data() [1/2]
|
inline |
raw data storage.
at least num_rows * num_time_points scalars. packed {t0, v0[0], v0[1], ...}, {t1, v1[0], v1[1], ...}, ...
◆ data() [2/2]
|
inline |
◆ deserialize()
|
inlinestatic |
◆ end() [1/2]
|
inline |
◆ end() [2/2]
|
inline |
◆ export_csv()
|
inline |
Exports a TimeSeries object into a CSV file.
The first column of the CSV file contains the time points. The remaining columns contain the values at each time point. Column headers can be specified with column_labels. This function utilizes the print_table method with a width of 1, the specified separator, and an empty string as header prefix.
- Parameters
-
[in] filepath Path to the CSV file. [in] column_labels [Default: {}] Vector of labels for each column after the time column. [in] separator [Default: ','] Separator character. [in] precision [Default: 6] Number of decimals for floating point values.
- Returns
- IOResult<void> indicating success or failure.
◆ get_capacity()
|
inline |
current capacity
◆ get_const_reverse_times()
|
inline |
◆ get_const_times()
|
inline |
◆ get_last_time() [1/2]
|
inline |
time of time point at index num_time_points - 1
◆ get_last_time() [2/2]
|
inline |
◆ get_last_value() [1/2]
|
inline |
◆ get_last_value() [2/2]
|
inline |
reference to value vector at time point (num_timepoints - 1)
◆ get_num_elements()
|
inline |
number of elements of vector at each time point
◆ get_num_rows()
|
inline |
number of rows in data storage (includes time)
◆ get_num_time_points()
|
inline |
number of time points in the series
◆ get_reverse_times() [1/2]
|
inline |
◆ get_reverse_times() [2/2]
|
inline |
◆ get_time() [1/2]
|
inline |
time of time point at index i
◆ get_time() [2/2]
|
inline |
◆ get_times() [1/2]
|
inline |
◆ get_times() [2/2]
|
inline |
◆ get_valid_block() [1/2]
|
inlineprivate |
currently occupied block of storage
◆ get_valid_block() [2/2]
|
inlineprivate |
◆ get_value() [1/2]
|
inline |
◆ get_value() [2/2]
|
inline |
reference to value vector at time point i
◆ is_strictly_monotonic()
|
inline |
Check if the time is strictly monotonic increasing.
◆ matrix() [1/2]
|
inline |
Matrix expression that contains one time point per column.
Each column contains the corresponding time at index 0.
◆ matrix() [2/2]
|
inline |
Matrix expression that contains one time point per column.
Each column contains the corresponding time at index 0.
◆ operator=() [1/2]
|
inline |
copy assignment
◆ operator=() [2/2]
|
default |
◆ operator[]() [1/2]
|
inline |
◆ operator[]() [2/2]
|
inline |
◆ print_table() [1/2]
|
inline |
Print out the TimeSeries as a table.
All row entries in the table are separated by the given separator, followed by additional spaces filling the width of the next entry. Each row is terminated by a newline character '
'. The first row of the table starts with "Time", followed by other column labels. Each row after that contains the time (see get_time) followed by the value (see get_value) for every row (i.e. time point) in the TimeSeries. The width parameter sets the minimum width of each table entry. For the numbers from the TimeSeries, this width includes the decimals and decimal point. If a number or column label is too long, they will not be cut off, but the table will no longer look nicely formatted. If the column_labels vector is too short, the default column label "#i" is used for the i-th column (starting at 1, as "Time" is used for column 0). Labels in the column_labels vector that go beyond the TimeSeries column numbers are ignored.
This method can be called in two ways:
- With an output stream as the first parameter: print_table(out, column_labels, width, precision, separator, header_prefix)
- Without specifying an output stream (defaults to std::cout): print_table(column_labels, width, precision, separator, header_prefix)
- Parameters
-
[in,out] out Which ostream to use (optional, see above). [in] column_labels Vector of custom labels for each column. [in] width The number of characters reserved for each number. [in] precision The number of decimals. [in] separator Separator character between columns. [in] header_prefix Prefix before the header row.
◆ print_table() [2/2]
|
inline |
Print out the TimeSeries as a table.
All row entries in the table are separated by the given separator, followed by additional spaces filling the width of the next entry. Each row is terminated by a newline character '
'. The first row of the table starts with "Time", followed by other column labels. Each row after that contains the time (see get_time) followed by the value (see get_value) for every row (i.e. time point) in the TimeSeries. The width parameter sets the minimum width of each table entry. For the numbers from the TimeSeries, this width includes the decimals and decimal point. If a number or column label is too long, they will not be cut off, but the table will no longer look nicely formatted. If the column_labels vector is too short, the default column label "#i" is used for the i-th column (starting at 1, as "Time" is used for column 0). Labels in the column_labels vector that go beyond the TimeSeries column numbers are ignored.
This method can be called in two ways:
- With an output stream as the first parameter: print_table(out, column_labels, width, precision, separator, header_prefix)
- Without specifying an output stream (defaults to std::cout): print_table(column_labels, width, precision, separator, header_prefix)
- Parameters
-
[in,out] out Which ostream to use (optional, see above). [in] column_labels Vector of custom labels for each column. [in] width The number of characters reserved for each number. [in] precision The number of decimals. [in] separator Separator character between columns. [in] header_prefix Prefix before the header row.
◆ rbegin() [1/2]
|
inline |
◆ rbegin() [2/2]
|
inline |
◆ remove_last_time_point()
|
inline |
◆ remove_time_point()
|
inline |
remove time point.
- Parameters
-
i index to remove
◆ rend() [1/2]
|
inline |
◆ rend() [2/2]
|
inline |
◆ reserve()
|
inline |
reserve capacity for n time points
◆ serialize()
|
inline |
◆ zero()
|
inlinestatic |
constructs TimeSeries instance and initializes it with zeros
- Parameters
-
num_time_points number of time steps num_elements number of compartiments * number of groups
- Returns
Friends And Related Function Documentation
◆ PrintTo
|
friend |
print this object (googletest)
Member Data Documentation
◆ m_data
|
private |
data storage
◆ m_num_time_points
|
private |
number of time points (i.e.
occupied columns in m_data)
Generated by