matfileIO.hh
Go to the documentation of this file.
66 // -> Write new get_/add_ routine for the object (matfileIO_C /matfileIO_R for Cmplx/Real based ones)
69 // To generalise this class to rank > 2 objects (cubes, general multi-arrays) it could be a good idea to add a assertRank_
165 throw conceptsException(MatfileIOError(__FILE__, __LINE__, __FUNCTION__, "Cannot add something. No *.mat-file opened."));
171 throw conceptsException(MatfileIOError(__FILE__, __LINE__, __FUNCTION__, "Not able to add : a variable with the same name is being added currently. Close the MatfileIO and retry again with overwrite rights."));
188 throw conceptsException(MatfileIOError(__FILE__, __LINE__, __FUNCTION__, " The variable '" + varName + "' has been declared not to be overwritten."));
201 throw conceptsException(MatfileIOError(__FILE__, __LINE__, __FUNCTION__, "Some unhandled/ unknown error arisen in add-Routine in MatfileIO."));
235 //for sparse, int and uint use Mat_VarRead method, so structure = 1, (structure = 0, ie. for dense)
243 matvar_ = structure ? Mat_VarRead(mat_, varName.c_str()): Mat_VarReadInfo(mat_, varName.c_str()) ;
415 //collection of all names of variables that are going to be added in the current mat-file-stream
bool exists(const std::string &varName) const
Returns true if the variable /c varName exists, false otherwise.
std::string filename() const
Returns the name of the current open *.mat-file.
Definition: matfileIO.hh:304
void assertQuadratic_(matvar_t *&var) const
throws an exception if the variable is not rank 2 and quadratic.
bool isCmplx(const std::string &varName) const
Return true if the variable /c varName is of type double complex.
void add_(const std::vector< T > &vec, const std::string &varName, enum matio_compression compress)
Add routine for a std::vector, i.e.
void assertOpenFile_(mat_t *file) const
throws an exception if mat-file could not be opened
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
void assertVector_(matvar_t *&var) const
throws an exception if the variable has no Vector_structur.
void assertQuadratic(const std::string &varName) const
Throws an exception if the variable is not a quadratic rank 2 object.
void get_(std::vector< Vector< T > > &seq, matvar_t *&matvar)
Getter routine for an std::vector<concepts::Vector>, i.e.
void add_(const Point< Cmplx, dim > &point, const std::string &varName, enum matio_compression compress)
Add routine for a cmplx concepts::Point.
virtual std::ostream & info(std::ostream &os) const
Gives an overview about the variables that are in a current open *.mat-file.
concepts::Set< std::string > matvar_str_cur_
Definition: matfileIO.hh:418
void get(T &u, const std::string varName)
Method to get various objects out of the current open MatfileIO.
Definition: matfileIO.hh:233
void createDenseReal_(uint m, uint n, const std::string &varName, Real *&dataAccP)
Creates the mat variable for a dense real structure and sets a pointer to the data of the variable.
void add_(const Cmplx &scalar, const std::string &varName, enum matio_compression compress)
Add routine for a cmplx scalar.
void get_(SparseMatrix< T > &sparse, matvar_t *&matvar)
Getter routine for a concepts::SparseMatrix.
bool isReal_(matvar_t *var) const
Returns 1 if the variables field is Real, otherwise 0.
Definition: matfileIO.hh:690
bool isScalar(const std::string &varName) const
Return true if the variable /c varName is a scalar.
bool isReal(const std::string &varName) const
Return true if the variable /c varName is of type double.
bool isUint(const std::string &varName) const
Returns true if the variable /c varname is uint, else 0.
void add_(const Point< Real, dim > &point, const std::string &varName, enum matio_compression compress)
Add routine for a real concepts::Point.
void add_(const Mapping< Real, dim > &map, const std::string &varName, enum matio_compression compress)
Add routine for a real concepts::Mapping.
bool isVector_(matvar_t *var) const
tests if object has vector size, i.e.
void createDenseCmplx_(uint m, uint n, const std::string &varName, Real *&realP, Real *&imgP)
Creates the mat variable for a dense complex structure and sets pointers to the real and the imaginar...
void get_(DenseMatrix< T > &dense, matvar_t *&matvar)
Getter routine for a concepts::DenseMatrix.
void overWrite(bool toOverWrite)
Method with that u can secure already existing variables in a current open *.mat-file.
Definition: matfileIO.hh:314
void assertScalar_(matvar_t *&var) const
throws an exception if the variable has no Scalar structure.
void assertExistence(const std::string &varName) const
Throws an exception if the variable does not exist.
std::string matfileEnding_(const std::string &filename)
adds the ending .mat if needed
bool isScalar_(matvar_t *var) const
test if the requested variable is scalar.
bool remove(const std::string varName)
Removes the requested variable named 'str' if it exist in the current matfile.
void reopen()
Method to reopen the *.mat-file that was once opened with the constructor.
void get_(Mapping< Cmplx, dim > &map, matvar_t *&matvar)
Getter routine for a cmplx concepts::Mapping.
void add_(const Real &scalar, const std::string &varName, enum matio_compression compress)
Add routine for a real scalar.
bool isDense_(matvar_t *var) const
Returns true if the variable is a dense Matlab object.
Definition: matfileIO.hh:710
void assertDiagStructur_(matvar_t *&var) const
throws an exception if the variable has no diagonal structure, that is if it is a dense/sparse matrix...
void add_(const Mapping< Cmplx, dim > &map, const std::string &varName, enum matio_compression compress)
Add routine for a cmplx concepts::Mapping.
bool isUint_(matvar_t *var) const
Returns true if the variable is a uint matlab object.
Definition: matfileIO.hh:726
void add_(const Vector< T > &vec, const std::string &varName, enum matio_compression compress)
Add routine for a concepts::Vector.
void add_(const Array< Point< Real, dim > > &array, const std::string &varName, enum matio_compression compress)
Add routine for a real concepts::Array<concepts::Point>
std::complex< Real > Cmplx
Type for a complex number. It also depends on the setting of Real.
Definition: typedefs.hh:39
MatfileIO(const std::string filename)
Constructor to open/create a *.mat with given name.
void assertVector(const std::string &varName) const
Throws an exception if the variable has no vector struct, that is at most one dimension is larger tha...
void get_(DiagonalMatrix< T > &sparse, matvar_t *&matvar)
Getter routine for a concepts::DiagonalMatrix This methods works iff matvar-data has vector structur ...
void add_(const uint scalar, const std::string &str, enum matio_compression compress)
Add routine for int scalar.
uint lengthVector_(matvar_t *var) const
returns the length of a vector structure, else 0
concepts::Set< std::string > matvar_str_
Definition: matfileIO.hh:413
void get_(Point< Real, dim > &point, matvar_t *&matvar)
Getter routine for a real concepts::Point.
virtual const char * what() const
void get_(Array< T > &arr, matvar_t *&matvar)
Getter routine for a concepts::Array.
void assertDimension_(uint dim, uint vardim) const
throws an exception if the dimensions mismatch, application for Mapping/ Points
void add_(const ElementMatrix< T > &dense, const std::string &varName, enum matio_compression compress)
Add routine for an concepts::ElementMatrix, i.e.
bool isSparse(const std::string &varName) const
Returns true if the variable /c varName is sparse, else 0.
void get_(Cmplx &scalar, matvar_t *&matvar)
Getter routine for a cmplx scalar.
MatfileIOError(const std::string &file, const unsigned int line, const std::string &function, const std::string &errorMessage)
Constructor.
bool isInt(const std::string &varName) const
Returns true if the variable /c varname is int, else 0.
void add_(const int scalar, const std::string &str, enum matio_compression compress)
Add routine for int scalar.
void assertCmplx(const std::string &varName) const
Throws an exception if the variable is not (at least) a complex.
bool hasDiagStructur_(matvar_t *var) const
test if object has diagonal confortable structure, that is diagonal square matrix or vector
void get_(Point< Cmplx, dim > &point, matvar_t *&matvar)
Getter routine for a cmplx concepts::Point.
uint lengthVector(const std::string &varName) const
Return its length if /c varName is a vector, 0 otherwise.
bool isQuadratic_(matvar_t *var) const
test if the requested variable is quadratic and a 2D Tensor (used for Mapping)
Definition: matfileIO.hh:746
bool isDense(const std::string &varName) const
Returns true if the variable /c varName is dense, else 0.
bool isSparse_(matvar_t *var) const
Returns true if the variable is a Matlab sparse array, 0 else.
Definition: matfileIO.hh:703
void get_(Vector< T > &vec, matvar_t *&matvar)
Getter routine for a concepts::Vector.
void assertVar_(mat_sparse_t *var) const
Throws an exception if the matvar sparse pointer is Null use i.e.
bool isCmplx_(matvar_t *var) const
Returns 1 if the variable's field is Complex, otherwise 0.
Definition: matfileIO.hh:696
void wrongField_(matvar_t *&var) const
void wrongStructure_(matvar_t *&var) const
throws an exception for wrong structure.
void add_(const Array< T > &array, const std::string &varName, enum matio_compression compress)
Add routine for an concepts::Array.
void add_(const SparseMatrix< T > &sparseM, const std::string &varName, enum matio_compression compress)
adds a SparseMatrix to the current *.mat file.
void add_(const DiagonalMatrix< T > &diagM, const std::string &varName, enum matio_compression compress)
adds a DiagonalMatrix to the current *.mat file.
void get_(std::vector< T > &seq, matvar_t *&matvar)
Getter routine for an std::vector, i.e.
void get_(Real &scalar, matvar_t *&matvar)
Getter routine for a real scalar.
bool isInt_(matvar_t *var) const
Returns true if the variable is a int matlab object.
Definition: matfileIO.hh:717
void add_(const Array< Point< Cmplx, dim > > &array, const std::string &varName, enum matio_compression compress)
Add routine for a complex concepts::Array<concepts::Point>
void get_(ElementMatrix< T > &dense, matvar_t *&matvar)
Getter routine for a concepts::ElementMatrix.
void add(const T &u, const std::string varName, enum matio_compression compress=MAT_COMPRESSION_NONE)
Method to add various objects to a current open MatfileIO.
Definition: matfileIO.hh:160
Exception class to handle errors in the matfileIO class.
Definition: matfileIO.hh:33
void get_(Mapping< Real, dim > &map, matvar_t *&matvar)
Getter routine for a real concepts::Mapping.
void assertVar_(matvar_t *var) const
Throws an exception if the matvar pointer is Null use i.e.