subroutine mexfunction(nlhs,plhs,nrhs,prhs) integer*4 plhs(*),prhs(*) integer nlhs,nrhs C Define types for mx functions. Recall that pointers used C in mex files must be of type integer*4 integer*4 mxgetpr, mxcreatefull, mxgetstring real*8 mxgetscalar integer*4 status C Variables (and pointers to variables) used by the Fortran subroutine. C The floating point variables will be referred to by pointers. C For the integer and character variables, we will use the actual C values, so we defing the variables accordingly. integer*4 a,x,y,alpha,beta character*1 trans if (nrhs .ne. 11) then call mexerrmsgtxt('Wrong number of inputs in sgemv') end if if (nlhs .ne. 1) then call mexerrmsgtxt('Wrong number of outputs in sgemv') end if C Retrieve the dimensions of the input matrix and vector. This is not C necessary, but it gives us an opportunity to check for errors. C Moreover, this will help us determine how long to make the output C vector. ma = mxgetm(prhs(4)) na = mxgetn(prhs(4)) mx = mxgetm(prhs(6)) nx = mxgetn(prhs(6)) status = mxGetString(prhs(1),trans,1) m = int(mxgetscalar(prhs(2))) n = int(mxgetscalar(prhs(3))) lda = int(mxgetscalar(prhs(6))) incx = int(mxgetscalar(prhs(8))) incy = int(mxgetscalar(prhs(11))) C Create the output variable. plhs(1) = mxcreatefull(na,1,0) alpha = mxgetpr(prhs(4)) a = mxgetpr(prhs(5)) x = mxgetpr(prhs(7)) beta = mxgetpr(prhs(9)) y = mxgetpr(prhs(10)) call dgemv(trans,m,n,%val(alpha),%val(a),lda, & %val(x),incx,%val(beta), & %val(y),incy) plhs(1) = prhs(10) return end