User`s manual
Examples of Fortran MEX-Files
3-23
C==============================================================
C
C Computational subroutine
subroutine convec(x, y, z, nx, ny)
complex*16 x(*), y(*), z(*)
integer nx, ny
C Initialize the output array.
do 10 i=1,nx+ny-1
z(i) = (0.0,0.0)
10 continue
do 30 i=1,nx
do 20 j=1,ny
z(i+j-1) = z(i+j-1) + x(i) * y(j)
20 continue
30 continue
return
end
C The gateway routine.
subroutine mexFunction(nlhs, plhs, nrhs, prhs)
integer nlhs, nrhs
C--------------------------------------------------------------
C (pointer) Replace integer by integer*8 on the DEC Alpha
C platform.
C
integer plhs(*), prhs(*)
integer mxGetPr, mxGetPi, mxCreateFull
C--------------------------------------------------------------
C
integer mx, nx, my, ny, nz
integer mxGetM, mxGetN, mxIsComplex
complex*16 x(100), y(100), z(199)
C Check for proper number of arguments.
if (nrhs .ne. 2) then
call mexErrMsgTxt('Two inputs required.')
elseif (nlhs .gt. 1) then
call mexErrMsgTxt('Too many output arguments.')