Tomographer
v5.4
Tomographer C++ Framework Documentation
|
A MATLAB variable in the MAT file. More...
#include <tomographer/tools/ezmatio.h>
Public Member Functions | |
Var (File &matf, const std::string &varname, bool load_data=true) | |
Read variable from MATLAB data file. More... | |
Var (const Var ©) | |
Var objects are copyable. Beware though that the data is shared. | |
Var (Var &&other) | |
Var implements C++11 move semantics. | |
const std::string & | varName () const |
The variable name. More... | |
int | ndims () const |
Number of dimensions of this object. More... | |
DimList | dims () const |
Specific dimensions of this numeric array or tensor. More... | |
int | numel () const |
The total number of elements in this array or tensor. More... | |
bool | isComplex () const |
Whether this variable is complex or real. More... | |
bool | isSquareMatrix () const |
Whether this is a square matrix. More... | |
bool | hasData () const |
Whether data for this Var object has been loaded. More... | |
template<typename T > | |
VarValueDecoder< T >::RetType | value () const |
Read this variable data as native C++ object. More... | |
template<typename T , ENABLED_IF( tomo_internal::has_params_member< VarValueDecoder< T > >::value) > | |
VarValueDecoder< T >::RetType | value (const typename VarValueDecoder< T >::Params ¶ms) |
Read this variable data as native C++ object. More... | |
const matvar_t * | getMatvarPtr () const |
Access the underlying C pointer to the MatIO structure. Use with care. More... | |
Var & | operator= (Var &&other) |
Move assignment operator as this object implements C++11 move semantics. More... | |
Var & | operator= (const Var ©) |
Var objects are copyable. Beware though that the data is shared. | |
Static Public Member Functions | |
static Var | takeOver (matvar_t *varinfo) |
Take in charge the given C matvar_t pointer. More... | |
A MATLAB variable in the MAT file.
This object is a wrapper around MatIO's API for reading data of a variable in the data file.
This object can be moved around using C++11 move semantics. Also, this object is copyable. (But don't modify the object, as the data is shared.)
Var objects may, or may not, have the actual data loaded (hasData()). If no data is loaded, information about the variable (type, shape, etc.) may be accessed. There is currently no way to load the data subsequently for the same Var object, just re-construct a new Var object.
To read the data, you should use the template method value(). The type you can request is any type for which a corresponding VarValueDecoder has been defined.
|
inline |
Read variable from MATLAB data file.
This constructor initializes this variable from the given open MATLAB data file matf by looking up the variable named varname.
If load_data is true
, then the data is also loaded. Otherwise, only the type and shape information is loaded. See hasData().
Calling this constructor directly is the same as calling File::var().
|
inline |
Specific dimensions of this numeric array or tensor.
This returns a DimList, which is essentially a std::vector<int>.
|
inline |
|
inline |
Whether data for this Var object has been loaded.
If not, then to access data (e.g. value<T>()), then you need to re-obtain a fresh Var object with data loaded.
|
inline |
Whether this variable is complex or real.
Returns true
if the data stored by this variable is complex.
If the data is complex, then the variable pointer's data is in fact a pointer to a mat_complex_split_t
which stores the real and imaginary parts of the array separately. See MatIO's documentation for more info.
|
inline |
|
inline |
|
inline |
|
inlinestatic |
|
inline |
Read this variable data as native C++ object.
This function returns the data stored by the variable in a C++ object of type T.
The type T may be any type for which a specialization of VarValueDecoder has been defined.
Examples:
You may also equivalently call Tomographer::MAT::value<T>:
|
inline |
Read this variable data as native C++ object.
See value<T>().
This overload accepts an additional params parameter, but only if the corresponding VarValueDecoder<T> accepts it. This is in case the behavior of the decoding should depend on additional parameters given at runtime. Currently, no built-in VarValueDecoder<T> specializations use this.
|
inline |