以下Fortran代碼填充的2D陣列X具有值vF2PY:傳遞單元件陣列到Fortran
subroutine fill(x,v,m,n)
real*8 x(m,n),v
integer m,n,i
cf2py intent(in) :: x,v,m,n
forall(i=1:m,j=1:n) x(i,j) = v
end
當Python調用此函數:
x = numpy.array([[[0.0]]],order='F')
fill(x[:,:,0],2.0)
assert(x[0,0,0]==2.0) # Assertion failed
爲什麼這個斷言故障?
嗯......'copy(x,y)'你是指'copy(x,y,1)'? – dmckee 2010-01-29 02:17:47