This class provides a wrapper for the MAT-file Library, which is part of the MATLAB distribution. More...
#include <matlabMatfile.hh>

Classes | |
| struct | NumTr |
| struct | NumTr< std::complex< F > > |
Public Member Functions | |
| template<typename F > | |
| int | addMatrix (Matrix< F > *p_matrix, const std::string &varname) |
| Save the matrix given by p_matrix into the currently opened MAT-file under the variable name given by varname. | |
| void | assertCmplx (const std::string &varname) const throw () |
| Throws an exception if the variable is not (at least) a complex. | |
| void | assertExistence (const std::string &varname) const throw () |
| Throws an exception if the variable does not exist. | |
| void | closeFile () |
| void | deleteMatrix (const std::string &varname) |
| Deletes the specified variable from the currently opened MAT-file. | |
| bool | exists (const std::string &varname) const |
| Returns true if the variable /c varname exists. | |
| std::string | filename () const |
| template<typename F > | |
| DenseMatrix< F > * | getDenseMatrix (const std::string &varname) |
| Similar to getMatrix, but only loads the matrix, if it is dense. | |
| std::string | getErrorMessage () const |
| Returns a error message from the last operation. An empty string is. | |
| template<typename F > | |
| Matrix< F > * | getMatrix (const std::string &varname) |
| Try to load the matrix specified by varname from the currently opened MAT-file. | |
| template<typename F > | |
| F | getScalar (const std::string &varname) |
| Returns a scalar if the variable is scalar. | |
| template<typename F > | |
| SparseMatrix< F > * | getSparseMatrix (const std::string &varname) |
| Similar to getMatrix, but only loads the matrix, if it is sparse. | |
| template<typename F > | |
| Vector< F > * | getVector (const std::string &varname) const |
| Loads a vector and returns a pointer to an vector (user has to clear it) | |
| bool | isCmplx (const std::string &varname) const |
| Return true if the variable /c varname is of type double complex. | |
| bool | isOpen () const |
| bool | isReal (const std::string &varname) const |
| Return true if the variable /c varname is of type double. | |
| bool | isScalar (const std::string &varname) const |
| Return true if the variable /c varname is a scalar. | |
| uint | lengthVector (const std::string &varname) const |
| Return its length if /c varname is a vector, 0 otherwise. | |
| MatlabMatfile (const std::string &filename) | |
| This constructor opens the given MAT-file for "u"pdating, i.e., for reading and writing. | |
| MatlabMatfile (const std::string &filename, const std::string &mode) | |
| This Constructor allows to explicitly specify the file opening mode. | |
| MatlabMatfile () | |
| void | openFile (const std::string &filename, const std::string &mode) |
| Tries to open a given Matfile. | |
| virtual | ~MatlabMatfile () |
Private Member Functions | |
| void | assertScalar_ (const std::string &varname) const throw () |
| void | assertVector_ (const std::string &varname, uint &length) const throw () |
| void | clearErrorMessage_ () const |
| void | setErrorMessage_ (const std::string &newErrorMessage) const |
Private Attributes | |
| std::stringstream | errorMessage_ |
| Last error message, also in constant objects the error message may change. | |
| MATFile * | file_ |
| The Mat-file object. | |
| std::string | filename_ |
| Name of the file to read or write. | |
Friends | |
| std::ostream & | operator<< (std::ostream &out, const MatlabMatfile &mm) |
This class provides a wrapper for the MAT-file Library, which is part of the MATLAB distribution.
It allows to read and write so-called MAT-files. A MAT-file is a binary (and usually compressed) format by which MATLAB saves variables.
Definition at line 47 of file matlabMatfile.hh.
| concepts::MatlabMatfile::MatlabMatfile | ( | ) | [inline] |
Definition at line 50 of file matlabMatfile.hh.
| concepts::MatlabMatfile::MatlabMatfile | ( | const std::string & | filename | ) | [inline] |
This constructor opens the given MAT-file for "u"pdating, i.e., for reading and writing.
If the file does not exist it will be created.
Definition at line 55 of file matlabMatfile.hh.

| concepts::MatlabMatfile::MatlabMatfile | ( | const std::string & | filename, |
| const std::string & | mode | ||
| ) | [inline] |
This Constructor allows to explicitly specify the file opening mode.
The parameter "mode" is thereby simply passed to the MAT-file library routine "matOpen", as described in the MATLAB documentation or the documentation of the member function "openFile".
Definition at line 70 of file matlabMatfile.hh.

| virtual concepts::MatlabMatfile::~MatlabMatfile | ( | ) | [inline, virtual] |
| int concepts::MatlabMatfile::addMatrix | ( | Matrix< F > * | p_matrix, |
| const std::string & | varname | ||
| ) |
Save the matrix given by p_matrix into the currently opened MAT-file under the variable name given by varname.
If p_matrix can be downcasted to a concepts::SparseMatrix<F> then the matrix is saved as a MATLAB sparse matrix. Otherwise, the matrix is saved as a MATLAB dense matrix.
| void concepts::MatlabMatfile::assertCmplx | ( | const std::string & | varname | ) | const throw () |
Throws an exception if the variable is not (at least) a complex.
| void concepts::MatlabMatfile::assertExistence | ( | const std::string & | varname | ) | const throw () |
Throws an exception if the variable does not exist.
| void concepts::MatlabMatfile::assertScalar_ | ( | const std::string & | varname | ) | const throw () [private] |
| void concepts::MatlabMatfile::assertVector_ | ( | const std::string & | varname, |
| uint & | length | ||
| ) | const throw () [private] |
| void concepts::MatlabMatfile::clearErrorMessage_ | ( | ) | const [inline, private] |
Definition at line 196 of file matlabMatfile.hh.
| void concepts::MatlabMatfile::closeFile | ( | ) | [inline] |
| void concepts::MatlabMatfile::deleteMatrix | ( | const std::string & | varname | ) | [inline] |
Deletes the specified variable from the currently opened MAT-file.
Definition at line 125 of file matlabMatfile.hh.

| bool concepts::MatlabMatfile::exists | ( | const std::string & | varname | ) | const |
Returns true if the variable /c varname exists.
| std::string concepts::MatlabMatfile::filename | ( | ) | const [inline] |
Definition at line 77 of file matlabMatfile.hh.
| DenseMatrix<F>* concepts::MatlabMatfile::getDenseMatrix | ( | const std::string & | varname | ) |
Similar to getMatrix, but only loads the matrix, if it is dense.
| std::string concepts::MatlabMatfile::getErrorMessage | ( | ) | const [inline] |
Returns a error message from the last operation. An empty string is.
Definition at line 85 of file matlabMatfile.hh.
| Matrix<F>* concepts::MatlabMatfile::getMatrix | ( | const std::string & | varname | ) |
Try to load the matrix specified by varname from the currently opened MAT-file.
If the variable specified by varname is a MATALB sparse or MATLAB dense matrix, the returned
| The | variable name of the matrix to load, as given in the MAT-file. |
| F concepts::MatlabMatfile::getScalar | ( | const std::string & | varname | ) |
Returns a scalar if the variable is scalar.
| SparseMatrix<F>* concepts::MatlabMatfile::getSparseMatrix | ( | const std::string & | varname | ) |
Similar to getMatrix, but only loads the matrix, if it is sparse.
| Vector<F>* concepts::MatlabMatfile::getVector | ( | const std::string & | varname | ) | const |
Loads a vector and returns a pointer to an vector (user has to clear it)
| bool concepts::MatlabMatfile::isCmplx | ( | const std::string & | varname | ) | const |
Return true if the variable /c varname is of type double complex.
| bool concepts::MatlabMatfile::isOpen | ( | ) | const [inline] |
Definition at line 75 of file matlabMatfile.hh.
| bool concepts::MatlabMatfile::isReal | ( | const std::string & | varname | ) | const |
Return true if the variable /c varname is of type double.
| bool concepts::MatlabMatfile::isScalar | ( | const std::string & | varname | ) | const |
Return true if the variable /c varname is a scalar.
| uint concepts::MatlabMatfile::lengthVector | ( | const std::string & | varname | ) | const |
Return its length if /c varname is a vector, 0 otherwise.
| void concepts::MatlabMatfile::openFile | ( | const std::string & | filename, |
| const std::string & | mode | ||
| ) |
Tries to open a given Matfile.
The mode parameter is analog to the mode parameter of the matOpen routine (matOpen is part of the MAT-file library), compare the parameter description.
| mode | This parameter can be "r" Open file for reading only. "u" Open file for updating (reading and writing). If the file does not exist, the open fails. "w" Open file for writing only. "w4" Open file for writing files which are compatible with MATLAB Version 4. "wz" Open file for writing compessed data. "w7.3" Open file for writing HDF5-based data, which can store more than 2 GB. |
| void concepts::MatlabMatfile::setErrorMessage_ | ( | const std::string & | newErrorMessage | ) | const [inline, private] |
Definition at line 201 of file matlabMatfile.hh.
| std::ostream& operator<< | ( | std::ostream & | out, |
| const MatlabMatfile & | mm | ||
| ) | [friend] |
std::stringstream concepts::MatlabMatfile::errorMessage_ [mutable, private] |
Last error message, also in constant objects the error message may change.
Definition at line 194 of file matlabMatfile.hh.
MATFile* concepts::MatlabMatfile::file_ [private] |
The Mat-file object.
Definition at line 188 of file matlabMatfile.hh.
std::string concepts::MatlabMatfile::filename_ [private] |
Name of the file to read or write.
Definition at line 190 of file matlabMatfile.hh.