def matrix_to_string(inp_mat):
    """Convert a 2D np.array to a 1D string."""
    flat_mat = inp_mat.flatten()
    return_str = ""
    for flt in flat_mat:
        return_str = return_str + str(flt) + " "
    return return_str[:-1]