This class implements a very simple but efficient way to temporarily store data.
This tool was created to store simulation data of a switching control system that is returned by the ode functions.
This class is NOT intended to store large numbers of small data chunks, for example single vectors. This class is intended to store an unknown number of matrices that match in one dimension. On read-out, the stored object are concatenated in one direction.
To store a large number of small data elements, preallocate memory by creating a matrix to hold several data elements. Store this matrix in the buffer class when filled and create a new one. Adaption of the size of the temporary
variable, for example doubling of the size with an upper bound, is a compromise between memory overhead and execution time.
It was kindly expressed by John D'Errico, that his tool (file-id 8334) solves a similar task.
methods of class buffer:
constructor - creates empty buffer
store - stores a matrix in the buffer
flush - reads out the buffer concatenating the elements in rows (default) or columns.
example:
buf = buffer
buf = store(buf,eye(3))
buf = store(buf,eye(3))
flush(buf)
flush(buf,1) |