Antares Simulator
Power System Simulator
|
A n-by-n matrix. More...
#include <matrix.h>
Classes | |
struct | PredicateIdentity |
Public Types | |
enum | Options { optNone = 0 , optFixedSize = 1 , optQuiet = 2 , optImmediate = 4 , optMarkAsModified = 8 , optNoWarnIfEmpty = 16 , optNeverFails = 32 } |
Options when loading a file. More... | |
enum | { filesizeHardLimit = 1536 * 1024 * 1024 } |
using | Type = T |
Type. | |
using | TypePtr = T* |
Pointer. | |
using | MatrixType = Matrix<T, ReadWriteT> |
Matrix type. | |
using | ReadWriteType = ReadWriteT |
Read / Write type. | |
using | MatrixPtr = Matrix<T>* |
Pointer. | |
using | Vector = std::set<MatrixPtr> |
Vector. | |
using | ColumnType = typename Antares::Memory::Stored<T>::Type |
Column type. | |
using | BufferType = Yuni::Clob |
A buffer, for large amount of data. | |
Public Member Functions | |
template<class U > | |
Matrix< T, ReadWriteT > & | operator= (const Matrix< U > &rhs) |
Constructors & Destructor | |
Matrix () | |
Default Constructor. | |
Matrix (const Matrix &rhs) | |
Copy constructor. | |
Matrix (Matrix &&rhs) noexcept | |
Move constructor. | |
template<class U , class V > | |
Matrix (const Matrix< U, V > &rhs) | |
Copy constructor. | |
Matrix (uint w, uint h) | |
Constructor with a initial size. | |
virtual | ~Matrix () |
Destructor. | |
Copy / Paste | |
template<class U , class V > | |
void | copyFrom (const Matrix< U, V > &rhs) |
Copy values from another matrix. | |
template<class U , class V > | |
void | copyFrom (const Matrix< U, V > *rhs) |
void | swap (MatrixType &rhs) noexcept |
Swap contents of Matrix with another. | |
File manipulation | |
virtual bool | loadFromCSVFile (const AnyString &filename, uint minWidth, uint maxHeight, uint options=optNone, BufferType *buffer=NULL) |
Load entries from a CSV file. | |
bool | loadFromCSVFile (const AnyString &filename, uint minWidth, uint maxHeight, BufferType *buffer) |
bool | loadFromCSVFile (const AnyString &filename) |
virtual bool | openFile (Yuni::IO::File::Stream &file, const AnyString &filename) const |
Trying to open a file. | |
virtual void | saveBufferToFile (std::string &buffer, Yuni::IO::File::Stream &f) const |
bool | saveToCSVFile (const AnyString &filename, uint precision=6, bool print_dimensions=false, bool saveEvenIfAllZero=false) const |
Write the content of a matrix into a single file. | |
template<class PredicateT > | |
bool | saveToCSVFile (const AnyString &filename, uint precision, bool print_dimensions, PredicateT &predicate, bool saveEvenIfAllZero=false) const |
Write the content of a matrix into a single file. | |
virtual Yuni::IO::Error | loadFromFileToBuffer (BufferType &buffer, const AnyString &filename) const |
template<class PredicateT > | |
void | saveToFileDescriptor (std::string &data, uint precision, bool print_dimensions, PredicateT &predicate) const |
Operations on columns and rows | |
void | resize (uint w, uint h, bool fixedSize=false) |
Resize the matrix. | |
void | resizeWithoutDataLost (uint x, uint y, const T &defVal=T()) |
Resize the matrix without destroying its content. | |
void | clear () |
Empty the matrix. | |
void | reset () |
Empty the matrix and mark it as modified. | |
void | reset (uint w, uint h, bool fixedSize=false) |
Resize a matrix and reset its values. | |
ColumnType & | column (uint n) |
Get the Nth column. | |
const ColumnType & | column (uint n) const |
Get the Nth column (const) | |
void | zero () |
Make the matrix a zero matrix. | |
void | fill (const T &v) |
Fill the matrix with a given value. | |
void | fillUnit () |
Make the matrix an unit matrix (identity matrix) | |
template<class U > | |
void | multiplyAllEntriesBy (const U &c) |
Multiply all entries by a given value. | |
template<class U > | |
void | multiplyColumnBy (uint x, const U &c) |
Multiply or divide a column by a given value. | |
template<class U > | |
void | divideColumnBy (uint x, const U &c) |
void | averageTimeseries (bool roundValues=true) |
Compute the average of all timeseries (derated mode) | |
void | roundAllEntries () |
Round all entries. | |
T | findLowerBound () const |
Find the lower bound. | |
T | findUpperBound () const |
Find the upper bound. | |
void | makeAllEntriesAbsolute () |
Make all entries absolute. | |
template<class U > | |
void | pasteToColumn (uint x, const U *data) |
Copy values into a given column in the matrix. | |
void | fillColumn (uint x, const T &value) |
Set a entire column with a given value. | |
void | columnToZero (uint x) |
Set to zero a entire column. | |
bool | containsOnlyZero () const |
Get if the matrix only contains zero. | |
template<class PredicateT > | |
bool | containsOnlyZero (PredicateT &predicate) const |
Get if the matrix only contains zero. | |
void | circularShiftRows (uint count) |
Shift all rows. | |
void | circularShiftRows (uint column, uint count) |
Shift all rows of a specific column. | |
Memory Management | |
bool | forceReload (bool reload=false) const |
Force the Load of data (if not done) for the next save and mark the matrix as modified. | |
void | unloadFromMemory () const |
Try to remove from memory all data from the matrix. | |
void | markAsModified () const |
Mark the matrix as modified. | |
bool | empty () const |
Get if the matrix is empty. | |
void | print () const |
Print the matrix to std::cout (debug) | |
Operators | |
uint | width |
Width of the matrix. | |
uint | height |
Height of the matrix. | |
ColumnType * | entry |
All entries of the matrix (bidimensional array) | |
JIT::Informations * | jit |
Just-in-time informations. | |
Matrix & | operator= (const Matrix &rhs) |
Assignement. | |
Matrix & | operator= (Matrix &&rhs) noexcept |
template<class U > | |
Matrix & | operator= (const Matrix< U > &rhs) |
Assignement. | |
ColumnType & | operator[] (uint column) |
operator [] | |
const ColumnType & | operator[] (uint column) const |
void | saveToBuffer (std::string &data, uint precision=6) const |
template<class PredicateT > | |
void | saveToBuffer (std::string &data, uint precision, bool print_dimensions, PredicateT &predicate, bool saveEvenIfAllZero) const |
A n-by-n matrix.
T | A pod type for each cell of the matrix |
ReadWriteT | The type to use when reading/saving the matrix |
anonymous enum |
enum Antares::Matrix::Options |
Options when loading a file.
|
inline |
Set to zero a entire column.
x | The column index (zero-based) |
bool Antares::Matrix< T, ReadWriteT >::containsOnlyZero | ( | PredicateT & | predicate | ) | const |
Get if the matrix only contains zero.
predicate | A predicate to modify the values on the fly |
|
inline |
Get if the matrix is empty.
This method is equivalent to :
void Antares::Matrix< T, ReadWriteT >::fillColumn | ( | uint | x, |
const T & | value ) |
Set a entire column with a given value.
x | The column index (zero-based) |
data | The data to copy |
bool Antares::Matrix< T, ReadWriteT >::forceReload | ( | bool | reload = false | ) | const |
Force the Load of data (if not done) for the next save and mark the matrix as modified.
This method is only useful if the load-on-demand is used. The matrix will be marked as modified to force the written.
reload | True to load all JIT data |
|
virtual |
Load entries from a CSV file.
The data might not be actually loaded, if the load-on-demand is enabled. If the param fixedSize
is false, the number of columns will be automatically detected from the first row in the CSV file.
filename | A filename to a CSV file |
minWidth | The minimum allowed width |
maxHeight | The new height |
fixedSize | True to not automatically determine the width of the matrix |
warning | True to produce warnings when an error occurs |
immediate | True to not postpone the loading |
buffer | An optional buffer for reading the file |
Reimplemented in Matrix_load_bypass< T, ReadWriteT >.
|
inline |
Mark the matrix as modified.
This routine has no effect when the UI is not present
|
virtual |
Trying to open a file.
file | The file object |
filename | The full path of the file we try to open |
Reimplemented in Matrix_easy_to_fill< T, ReadWriteT >, and Matrix_easy_to_fill< double, double >.
void Antares::Matrix< T, ReadWriteT >::pasteToColumn | ( | uint | x, |
const U * | data ) |
Copy values into a given column in the matrix.
x | The column index (zero-based) |
data | The data to copy |
|
inline |
void Antares::Matrix< T, ReadWriteT >::resize | ( | uint | w, |
uint | h, | ||
bool | fixedSize = false ) |
Resize the matrix.
All data will be lost in the process.
w | The new width |
h | The new height |
bool Antares::Matrix< T, ReadWriteT >::saveToCSVFile | ( | const AnyString & | filename, |
uint | precision, | ||
bool | print_dimensions, | ||
PredicateT & | predicate, | ||
bool | saveEvenIfAllZero = false ) const |
Write the content of a matrix into a single file.
If JIT is enabled, the matrix will be resized to 0x0 if the write is successful.
m | The matrix |
filename | The file where to write data |
predicate | A predicate for modyfing values on the fly |
bool Antares::Matrix< T, ReadWriteT >::saveToCSVFile | ( | const AnyString & | filename, |
uint | precision = 6, | ||
bool | print_dimensions = false, | ||
bool | saveEvenIfAllZero = false ) const |
Write the content of a matrix into a single file.
If JIT is enabled, the matrix will be resized to 0x0 if the write is successful.
m | The matrix |
filename | The file where to write data |
void Antares::Matrix< T, ReadWriteT >::unloadFromMemory | ( | ) | const |
Try to remove from memory all data from the matrix.
This is possible only when enough informations is provided by the JIT structure and when the matrix is not modified