Tomographer  v5.4
Tomographer C++ Framework Documentation
ezmatio.h File Reference

(v5.4)

Utilities for reading MATLAB "*.mat" data files. See Tomographer::MAT. More...

#include <cstdint>
#include <cerrno>
#include <complex>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <stdexcept>
#include <sstream>
#include <initializer_list>
#include <utility>
#include <matio.h>
#include <Eigen/Core>
#include <tomographer/tools/cxxutil.h>
#include <tomographer/tools/eigenutil.h>
#include <tomographer/tools/fmt.h>
#include <tomographer/mathtools/pos_semidef_util.h>
+ Include dependency graph for ezmatio.h:

Go to the source code of this file.

Classes

class  Tomographer::MAT::Exception
 Base Exception class for errors within our MAT routines. More...
 
class  Tomographer::MAT::VarError
 Exception relating to a MATLAB variable in the data file. More...
 
class  Tomographer::MAT::VarReadError
 Error while reading a variable from the MATLAB data file. More...
 
class  Tomographer::MAT::VarTypeError
 Type mismatch (wrong type requested) in a variable read from the MATLAB data file. More...
 
class  Tomographer::MAT::VarMatTypeError
 Unknown type of a variable present in the data file. More...
 
class  Tomographer::MAT::FileOpenError
 Error while opening a MATLAB file. More...
 
class  Tomographer::MAT::InvalidIndexError
 Invalid index or index list provided to a routine. More...
 
class  Tomographer::MAT::File
 A MATLAB file open for reading data. More...
 
class  Tomographer::MAT::DimList
 An array of ints which specifies a list of dimensions. More...
 
class  Tomographer::MAT::IndexList< IsRowMajor_ >
 A list of indices with an API for linear or subindices access. More...
 
class  Tomographer::MAT::IndexListIterator< IsRowMajor_, IntType_ >
 Utility to iterate over a multidim array by increasing linear index. More...
 
class  Tomographer::MAT::VarValueDecoder< T, Enabled >
 Specializable template which takes care of decoding values. More...
 
class  Tomographer::MAT::Var
 A MATLAB variable in the MAT file. More...
 
struct  Tomographer::MAT::MatType< MatTypeId >
 Map matio's constants to C/C++ types. More...
 
struct  Tomographer::MAT::MatType< MAT_T_DOUBLE >
 Specialization of MatType for MAT_T_DOUBLE. More...
 
struct  Tomographer::MAT::MatType< MAT_T_SINGLE >
 Specialization of MatType for MAT_T_DOUBLE. More...
 
struct  Tomographer::MAT::MatType< MAT_T_INT64 >
 Specialization of MatType for MAT_T_INT64. More...
 
struct  Tomographer::MAT::MatType< MAT_T_INT32 >
 Specialization of MatType for MAT_T_INT32. More...
 
struct  Tomographer::MAT::MatType< MAT_T_INT16 >
 Specialization of MatType for MAT_T_INT16. More...
 
struct  Tomographer::MAT::MatType< MAT_T_INT8 >
 Specialization of MatType for MAT_T_INT8. More...
 
struct  Tomographer::MAT::MatType< MAT_T_UINT64 >
 Specialization of MatType for MAT_T_UINT64. More...
 
struct  Tomographer::MAT::MatType< MAT_T_UINT32 >
 Specialization of MatType for MAT_T_UINT32. More...
 
struct  Tomographer::MAT::MatType< MAT_T_UINT16 >
 Specialization of MatType for MAT_T_UINT16. More...
 
struct  Tomographer::MAT::MatType< MAT_T_UINT8 >
 Specialization of MatType for MAT_T_UINT8. More...
 
class  Tomographer::MAT::VarValueDecoder< T, _IS_NUMERIC_TYPE >
 Interface to read out a single numeric value. More...
 
struct  Tomographer::MAT::VarShape
 Describe shape of variable and whether it is complex. More...
 
struct  Tomographer::MAT::GetStdVector< T_, IsRowMajor_ >
 Ask for this type in Var::value<typename T>() to get an std::vector of the data. More...
 
class  Tomographer::MAT::VarValueDecoder< GetStdVector< T, IsRowMajor > >
 Specialization of VarValueDecoder to obtain an std::vector with the matrix data. See GetStdVector. More...
 
class  Tomographer::MAT::VarValueDecoder< Eigen::Matrix< Scalar, Rows, Cols, Options, MaxRows, MaxCols > >
 Decoder for Eigen::Matrix types. More...
 
class  Tomographer::MAT::VarValueDecoder< std::vector< Eigen::Matrix< Scalar, Rows, Cols, Options, MaxRows, MaxCols >, Alloc > >
 Decoder for a std::vector of elements of type Eigen::Matrix. More...
 
class  Tomographer::MAT::EigenPosSemidefMatrixWithSqrt< EigenType_ >
 Read a positive semidefinite matrix along with its matrix square root. More...
 
class  Tomographer::MAT::EigenPosSemidefMatrixWithSqrt< EigenType_ >
 Read a positive semidefinite matrix along with its matrix square root. More...
 
struct  Tomographer::MAT::EigenPosSemidefMatrixWithSqrt< EigenType_ >::Params
 Parameters to read the positive semidefinite matrix. More...
 
class  Tomographer::MAT::VarValueDecoder< EigenPosSemidefMatrixWithSqrt< EigenType_ > >
 Specialization of VarValueDecoder for extracting a positive semidefinite matrix along with sqrt. More...
 

Namespaces

 Tomographer
 Base namespace for the Tomographer project.
 
 Tomographer::MAT
 Utilities and helpers for reading MATLAB .mat files.
 

Macros

#define MAT_SWITCH_REAL_TYPE(typ, ...)
 Useful hack to get C++ real scalar type from dynamical MAT type ID. More...
 
#define MAT_SWITCH_COMPLEX_TYPE(typ, ...)
 Useful hack to get C++ complex type from dynamical MAT type ID. More...
 
#define MAT_SWITCH_TYPE(matvar_ptr, ...)
 Useful hack to get C++ type from dynamical MAT type ID. More...
 

Functions

template<typename It , typename ValueType = typename std::iterator_traits<It>::value_type>
ValueType Tomographer::MAT::getNumEl (It begin, It end)
 Calculate the product of all dimensions. More...
 
std::ostreamTomographer::MAT::operator<< (std::ostream &out, const DimList &dlist)
 C++ output stream operators for a DimList.
 
template<bool IsRowMajor>
std::ostreamTomographer::MAT::operator<< (std::ostream &str, const IndexList< IsRowMajor > &indexlist)
 C++ output stream operator for IndexList.
 
template<bool IsRowMajor, typename IntType >
std::ostreamTomographer::MAT::operator<< (std::ostream &str, const IndexListIterator< IsRowMajor, IntType > &indexlistit)
 C++ output stream operator for IndexListIterator.
 
template<typename T >
VarValueDecoder< T >::RetType Tomographer::MAT::value (const Var &var)
 Access the value of the given variable, as a C++ type. More...
 
template<typename T , ENABLED_IF( tomo_internal::has_params_member< VarValueDecoder< T > >::value) >
VarValueDecoder< T >::RetType Tomographer::MAT::value (const Var &var, const typename VarValueDecoder< T >::Params &params)
 Access the value of the given variable, as a C++ type. More...
 
std::ostreamTomographer::MAT::operator<< (std::ostream &str, const VarShape &varshape)
 C++ output stream operator for VarShape .
 

Detailed Description

Utilities for reading MATLAB "*.mat" data files. See Tomographer::MAT.

Definition in file ezmatio.h.

Macro Definition Documentation

§ MAT_SWITCH_COMPLEX_TYPE

#define MAT_SWITCH_COMPLEX_TYPE (   typ,
  ... 
)
Value:
do { switch (typ) { \
case MAT_T_DOUBLE: { typedef std::complex<typename MatType<MAT_T_DOUBLE>::Type> Type; { __VA_ARGS__; } break; } \
case MAT_T_SINGLE: { typedef std::complex<typename MatType<MAT_T_SINGLE>::Type> Type; { __VA_ARGS__; } break; } \
default: \
throw VarMatTypeError( streamstr("Uknown/unsupported encoded type from matio: " \
<<(typ)) ); \
} \
} while (false)
STL class.
#define streamstr(tokens)
Utility macro to format stream tokens to a std::string.
Definition: fmt.h:149

Useful hack to get C++ complex type from dynamical MAT type ID.

The MAT type ID is checked against MAT_T_DOUBLE and MAT_T_SINGLE only, and the corresponding code executed with the identifier Type defined as the appropriate C++ std::complex<T> type.

Definition at line 1271 of file ezmatio.h.

§ MAT_SWITCH_REAL_TYPE

#define MAT_SWITCH_REAL_TYPE (   typ,
  ... 
)
Value:
do { switch (typ) { \
case MAT_T_DOUBLE: { typedef typename MatType<MAT_T_DOUBLE>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_SINGLE: { typedef typename MatType<MAT_T_SINGLE>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_INT64: { typedef typename MatType<MAT_T_INT64>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_INT32: { typedef typename MatType<MAT_T_INT32>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_INT16: { typedef typename MatType<MAT_T_INT16>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_INT8: { typedef typename MatType<MAT_T_INT8>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_UINT64: { typedef typename MatType<MAT_T_UINT64>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_UINT32: { typedef typename MatType<MAT_T_UINT32>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_UINT16: { typedef typename MatType<MAT_T_UINT16>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_UINT8: { typedef typename MatType<MAT_T_UINT8>::Type Type; { __VA_ARGS__; } break; } \
default: \
throw VarMatTypeError( streamstr("Uknown/unsupported encoded type from matio: " \
<<(typ)) ); \
} \
} while (false)
#define streamstr(tokens)
Utility macro to format stream tokens to a std::string.
Definition: fmt.h:149

Useful hack to get C++ real scalar type from dynamical MAT type ID.

This works like a switch(){ ... } statement, where the typ is checked against MAT_T_DOUBLE, MAT_T_SINGLE, etc. and where the given code (...) is executed with the identifier Type set to the given C++ type.

Definition at line 1247 of file ezmatio.h.

§ MAT_SWITCH_TYPE

#define MAT_SWITCH_TYPE (   matvar_ptr,
  ... 
)
Value:
do { \
if (!(matvar_ptr)->isComplex) { \
switch ((matvar_ptr)->data_type) { \
case MAT_T_DOUBLE: { typedef typename MatType<MAT_T_DOUBLE>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_SINGLE: { typedef typename MatType<MAT_T_SINGLE>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_INT64: { typedef typename MatType<MAT_T_INT64>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_INT32: { typedef typename MatType<MAT_T_INT32>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_INT16: { typedef typename MatType<MAT_T_INT16>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_INT8: { typedef typename MatType<MAT_T_INT8>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_UINT64: { typedef typename MatType<MAT_T_UINT64>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_UINT32: { typedef typename MatType<MAT_T_UINT32>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_UINT16: { typedef typename MatType<MAT_T_UINT16>::Type Type; { __VA_ARGS__; } break; } \
case MAT_T_UINT8: { typedef typename MatType<MAT_T_UINT8>::Type Type; { __VA_ARGS__; } break; } \
default: \
throw VarMatTypeError( streamstr("Uknown/unsupported encoded type from matio: " \
<< (matvar_ptr)->data_type) ); \
} \
} else { \
switch ((matvar_ptr)->data_type) { \
case MAT_T_DOUBLE: { typedef std::complex<typename MatType<MAT_T_DOUBLE>::Type> Type; { __VA_ARGS__; } break; } \
case MAT_T_SINGLE: { typedef std::complex<typename MatType<MAT_T_SINGLE>::Type> Type; { __VA_ARGS__; } break; } \
default: \
throw VarMatTypeError( streamstr("Uknown/unsupported encoded type from matio: " \
<< (matvar_ptr)->data_type) ); \
} \
} \
} while (false)
STL class.
#define streamstr(tokens)
Utility macro to format stream tokens to a std::string.
Definition: fmt.h:149

Useful hack to get C++ type from dynamical MAT type ID.

If the variable corresponding to matvar_ptr is of complex type, then this macro behaves just like MAT_SWITCH_REAL_TYPE. If it is of complex type, then it behaves just like MAT_SWITCH_COMPLEX_TYPE.

Definition at line 1289 of file ezmatio.h.