'Write header for given data options
shape : sequence
array shape
mclass      - mat5 matrix class
is_complex  - True if matrix is complex
is_logical  - True if matrix is logical
nzmax        - max non zero elements for sparse arrays
We get the name and the global flag from the object, and reset
them to defaults after we\'ve used them'

def write_header(self, shape, mclass, is_complex=False, is_logical=False, nzmax=0):

    name = self._var_name
    is_global = self._var_is_global
    self._mat_tag_pos = self.file_stream.tell()
    self.write_bytes(self.mat_tag)
    af = np.zeros((), NDT_ARRAY_FLAGS)
    af['data_type'] = miUINT32
    af['byte_count'] = 8
    flags = (((is_complex << 3) | (is_global << 2)) | (is_logical << 1))
    af['flags_class'] = (mclass | (flags << 8))
    af['nzmax'] = nzmax
    self.write_bytes(af)
    self.write_element(np.array(shape, dtype='i4'))
    name = np.asarray(name)
    if (name == ''):
        self.write_smalldata_element(name, miINT8, 0)
    else:
        self.write_element(name, miINT8)
    self._var_name = ''
    self._var_is_global = False
