Exemplo n.º 1
0
def test_memset():
    a = [1, 2, 3, 4]
    x = numpy.array(a).astype(numpy.float32)
    x_c = x.ctypes.data_as(C.POINTER(C.c_float))

    cfunc = CFunctions()
    cfunc.memset(x_c, 0, x.nbytes)

    output = numpy.ctypeslib.as_array(x_c, shape=(4, ))

    print(output)
    assert all(output == numpy.zeros(4))
Exemplo n.º 2
0
def test_memset():
    a = [1, 2, 3, 4]
    x = np.array(a).astype(np.float32)
    x_c = x.ctypes.data_as(C.POINTER(C.c_float))
    arg = Argument(numpy=x, ctypes=x_c)

    cfunc = CFunctions()
    cfunc.memset(arg, 0, x.nbytes)

    output = np.ctypeslib.as_array(x_c, shape=(4,))

    print(output)
    assert all(output == np.zeros(4))
    assert all(x == np.zeros(4))
def test_memset():
    a = [1, 2, 3, 4]
    x = numpy.array(a).astype(numpy.float32)
    x_c = x.ctypes.data_as(C.POINTER(C.c_float))
    arg = Argument(numpy=x, ctypes=x_c)

    cfunc = CFunctions()
    cfunc.memset(arg, 0, x.nbytes)

    output = numpy.ctypeslib.as_array(x_c, shape=(4,))

    print(output)
    assert all(output == numpy.zeros(4))
    assert all(x == numpy.zeros(4))