tbeu / matio

MATLAB MAT File I/O Library
https://matio.sourceforge.io
BSD 2-Clause "Simplified" License
338 stars 97 forks source link

data_type in matvar_t has incorrect value #114

Open rafal-c opened 5 years ago

rafal-c commented 5 years ago

Consider a simple MAT file (attached) with a single variable with data type MATRIX (14) and array class INT8. After calling Mat_VarReadInfo on this variable data_type is equal to 0 (MAT_T_UNKNOWN) and after reading data it is equal to 1 (MAT_T_INT8). Why isn't it equal to MAT_T_MATRIX which, as you can check in a hex editor, is precisely the value stored in the file?

int8.mat.tar.gz

tbeu commented 5 years ago

Duplicate of https://sourceforge.net/p/matio/discussion/609376/thread/1b6bb464/. Ok to close as wontfix?

rafal-c commented 5 years ago

In my opinion it's not a duplicate. The referenced issue focuses on the fact that Mat_ReadVarInfo doesn't read data_type whereas in this issue I show that even after data_type is populated it has incorrect value. So it seems that right now there is no way in matio to get the original data type of a variable (as stored in the file). What is the purpose of data_type if not to store the raw value of the Data Type field of a data element? (as the values of enum matio_types suggest)? I understand that for example for a MAT_T_COMPRESSED variable the actual data type after decompressing is different so maybe in that case Mat_ReadVarInfo could assign MAT_T_COMPRESSED to data_type and then Mat_ReadVar could overwrite this field with the actual data type?

tbeu commented 5 years ago

I do not know actually as I neither designed or implemented it. One purpose is, that the desired data type and the actual data type can differ. Question is, if the desired data type is respected by the data class already.