numpy with multidimensional array
I have checked example which is wrapping c by using numpy.
there is two converting function( function for converting numpy to c,
function for converting c to numpy)
and they both use malloc function.
but if I do not use memory copy, how can I make the code? 


----------------------------------------------------------------------------------
def matmul1(np.ndarray[DTYPE_t, ndim=2] a, np.ndarray[DTYPE_t, ndim=2]
b):
    ''' Matrix multiplication. Takes two square Float32 numpy arrays.
'''

    cdef int N = a.shape[0]
    cdef int i
    cdef float **a_c
    cdef float **b_c
    cdef float **res

    # check if square arrays:
    if a.shape[1] != N or b.shape[0] != N or b.shape[1] != N:
        raise ValueError, 'matmul1: need square arrays for
multiplication!'

    # check if contiguous, if not force C contiguous arrays
    if not (<object>a).flags["C_CONTIGUOUS"]:
        a = a.copy('C')
    if not (<object>b).flags["C_CONTIGUOUS"]:
        b = b.copy('C')

    # convert using the function
    a_c = npy2c_float(a)
    b_c = npy2c_float(b)

    # allocate res
    res = <float **> malloc(N*sizeof(float*))
    for i in range(N):
        res[i] = <float *> malloc(N * sizeof(float))

    matmul(a_c,b_c,res,N)

    free(a_c)
    free(b_c)

    # convert to numpy array and free res
    result = c2npy_float(res,N,N)

    return result
---------------------------------------------------------------------------------- 
numpy with multidimensional array
===

I have checked example which is wrapping c by using numpy.
there is two converting function( function for converting numpy to c,
function for converting c to numpy)
and they both use malloc function.
but if I do not use memory copy, how can I make the code? 


----------------------------------------------------------------------------------
def matmul1(np.ndarray[DTYPE_t, ndim=2] a, np.ndarray[DTYPE_t, ndim=2]
b):
    ''' Matrix multiplication. Takes two square Float32 numpy arrays.
'''

    cdef int N = a.shape[0]
    cdef int i
    cdef float **a_c
    cdef float **b_c
    cdef float **res

    # check if square arrays:
    if a.shape[1] != N or b.shape[0] != N or b.shape[1] != N:
        raise ValueError, 'matmul1: need square arrays for
multiplication!'

    # check if contiguous, if not force C contiguous arrays
    if not (<object>a).flags["C_CONTIGUOUS"]:
        a = a.copy('C')
    if not (<object>b).flags["C_CONTIGUOUS"]:
        b = b.copy('C')

    # convert using the function
    a_c = npy2c_float(a)
    b_c = npy2c_float(b)

    # allocate res
    res = <float **> malloc(N*sizeof(float*))
    for i in range(N):
        res[i] = <float *> malloc(N * sizeof(float))

    matmul(a_c,b_c,res,N)

    free(a_c)
    free(b_c)

    # convert to numpy array and free res
    result = c2npy_float(res,N,N)

    return result
---------------------------------------------------------------------------------- 