Doxygen
1.9.1
|
Class that stores values, i.e., model outputs, the order of the values is in sync with the order of some MultiIndexSet. More...
#include <tsgIndexSets.hpp>
Public Member Functions | |
StorageSet () | |
Default constructor, makes an empty set. | |
StorageSet (int cnum_outputs, int cnum_values, std::vector< double > &&vals) | |
Move constructor from a known vector. | |
template<typename iomode > | |
StorageSet (std::istream &is, iomode) | |
Read constructor. | |
~StorageSet ()=default | |
Default destructor. | |
template<bool useAscii> | |
void | write (std::ostream &os) const |
Write the set to ASCII or binary stream, use with std::ofstream and std::ifstream. More... | |
void | resize (int cnum_outputs, int cnum_values) |
Clear the existing values and assigns new dimensions, does not allocate memory for the new values. | |
size_t | getNumOutputs () const |
Returns the number of outputs. | |
double const * | getValues (int i) const |
Returns const reference to the i-th value. | |
double * | getValues (int i) |
Returns reference to the i-th value. | |
void | setValues (const double vals[]) |
Replace the existing values with a copy of vals, the size must be at least num_outputs times num_values | |
void | setValues (std::vector< double > &&vals) |
Replace the existing values with vals using move semantics, the size of vals must be num_outputs times num_values. | |
StorageSet | splitValues (int ibegin, int iend) const |
Return a StorageSet with values between ibegin and iend. | |
std::vector< double >::const_iterator | begin () const |
Returns a const iterator to the beginning of the internal data. | |
std::vector< double >::const_iterator | end () const |
Returns a const iterator to the end of the internal data. | |
std::vector< double > | release () |
Moves the values vector out of the class, this method invalidates the object. | |
void | addValues (const MultiIndexSet &old_set, const MultiIndexSet &new_set, const double new_vals[]) |
Add more values to the set, the old_set and new_set are the associated multi-index sets required to maintain order. More... | |
Class that stores values, i.e., model outputs, the order of the values is in sync with the order of some MultiIndexSet.
The StorageSet stores the floating-point values (model outputs) in a contiguous order, suitable for interfacing with BLAS/cuBlas. The values associated with one model simulation are adjacent to each other in a stride of size num_outputs. Each grid type has one instance of the StorageSet and the order of the stored values is kept in sync with the points multi-index set. Synchronization is achieved by merging values before merging multi-indexes, when the addValues() is called with the old and new multi-index sets and the new values.
void TasGrid::StorageSet::write | ( | std::ostream & | os | ) | const |
Write the set to ASCII or binary stream, use with std::ofstream and std::ifstream.
The format consists of two int
values corresponding to the number of dimensions and number of indexes, followed by all the entries of the array on a single line separated by a space, or dump of a single write command.
void TasGrid::StorageSet::addValues | ( | const MultiIndexSet & | old_set, |
const MultiIndexSet & | new_set, | ||
const double | new_vals[] | ||
) |
Add more values to the set, the old_set and new_set are the associated multi-index sets required to maintain order.
Add more values to an existing set of values, where old_set and new_set indicate the order. The old_set contains the ordered multi-indexes associated with the current values, the new_set corresponds to the order of the new_vals. After the merge, the order of the values will match that of the union of old_set and new_set.
Note that the two multi-index sets cannot have repeated entries.