'Overwrites self with array.
\'array\' should have a size smaller than that of the array used to
initialize the CUDAMatrix. The method will not throw an Exception just
yet if this is not true. It will throw exceptions or behave in strange
ways later on.'

def overwrite(self, array, copy_to_device=True):

    assert (type(array) == np.ndarray), 'array    must    be    a    np.ndarray.'
    array = reformat(array)
    self.numpy_array = array
    _cudamat.init_from_array(self.p_mat, array.ctypes.data_as(ct.POINTER(ct.c_float)), ct.c_int(array.shape[0]), ct.c_int(array.shape[1]))
    _cudamat.set_on_device(self.p_mat)
    if copy_to_device:
        err_code = _cudamat.copy_to_device(self.p_mat)
        if err_code:
            raise generate_exception(err_code)
