예제 #1
0
파일: test.py 프로젝트: frykis/SeSEproject
def cast_matrix(matrix, ffi):
        """
        Transform array into a double** which can be passed to a c-function.
        """
        ptr_ptr = ffi.new("double* [%d]" % (matrix.shape[0])) # List of pointers
        ptr = ffi.cast("double*", matrix.ctypes.data) # Pointer to data set
        for i in range(matrix.shape[0]):
                ptr_ptr[i] = ptr + i*matrix.shape[1]
        return ptr_ptr
예제 #2
0
파일: test.py 프로젝트: frykis/SeSEproject
def test_example_FFT_manipulate_list():
        """
        Test: Send a list of integers to a c-function. Manipulate the first element and return. Check that this is done correctly.
        """
        NUM_POINTS = 4
        coeff = [1.0]*NUM_POINTS
        temp = ffi.new("double []", coeff)
        lib.example_FFT_manipulate_list(temp)
        newList = c2pyList(temp,NUM_POINTS)
        coeff[0] = 2
        assert newList == coeff