def write_matrix(a, name):
    """Writes the matrix a to the file name.
    """
    Nx, Ny = a.shape
    f = open(name, 'w')
    for x in range(Nx):
        for y in range(Ny):
            print('{} '.format(a[x, y]), file=f, end='')
        print('', file=f)
    f.close()
