51
52
# https://www-old.cae.wisc.edu/pipermail/octave-maintainers/2007-May/002824.html
52
53
mxOBJECT_CLASS_FROM_MATRIX_H = 18
69
'file_header': [('description', 'S116'),
70
('subsystem_offset', 'i8'),
72
('endian_test', 'S2')],
73
'tag_full': [('mdtype', 'u4'), ('byte_count', 'u4')],
74
'tag_smalldata':[('byte_count_mdtype', 'u4'), ('data', 'S4')],
75
'array_flags': [('data_type', 'u4'),
82
mclass_dtypes_template = {
117
'f8': mxDOUBLE_CLASS,
118
'c32': mxDOUBLE_CLASS,
119
'c24': mxDOUBLE_CLASS,
120
'c16': mxDOUBLE_CLASS,
121
'f4': mxSINGLE_CLASS,
122
'c8': mxSINGLE_CLASS,
127
'u8': mxUINT64_CLASS,
128
'u4': mxUINT32_CLASS,
129
'u2': mxUINT16_CLASS,
134
''' Before release v7.1 (release 14) matlab (TM) used the system
135
default character encoding scheme padded out to 16-bits. Release 14
136
and later use Unicode. When saving character data, R14 checks if it
137
can be encoded in 7-bit ascii, and saves in that format if so.'''
140
miUTF8: {'codec': 'utf_8', 'width': 1},
141
miUTF16: {'codec': 'utf_16', 'width': 2},
142
miUTF32: {'codec': 'utf_32','width': 4},
146
def _convert_codecs(template, byte_order):
147
''' Convert codec template mapping to byte order
149
Set codecs not on this system to None
154
key, value are respectively codec name, and root name for codec
155
(without byte order suffix)
156
byte_order : {'<', '>'}
157
code for little or big endian
162
key, value are name, codec (as in .encode(codec))
165
postfix = byte_order == '<' and '_le' or '_be'
166
for k, v in template.items():
180
for _bytecode in '<>':
182
_def['dtypes'] = convert_dtypes(mdtypes_template, _bytecode)
183
_def['classes'] = convert_dtypes(mclass_dtypes_template, _bytecode)
184
_def['codecs'] = _convert_codecs(codecs_template, _bytecode)
185
MDTYPES[_bytecode] = _def
55
188
class mat_struct(object):
56
189
''' Placeholder for holding read data from structs