MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Uživatelský manuál Strana 120

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 408
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 119
3 Creating Fortran MEX-Files
3-10
A First Example — Passing a Scalar
Let’s look at a simple example of Fortran code and its MEX-file equivalent.
Here is a Fortran computational routine that takes a scalar and doubles it.
subroutine timestwo(y, x)
real*8 x, y
C
y = 2.0 * x
return
end
Below is the same function written in the MEX-file format.
C--------------------------------------------------------------
C timestwo.f
C
C Multiply the input argument by 2.
C This is a MEX-file for MATLAB.
C Copyright (c) 1984-2000 The MathWorks, Inc.
C $Revision: 1.11 $
subroutine mexFunction(nlhs, plhs, nrhs, prhs)
C--------------------------------------------------------------
C (pointer) Replace integer by integer*8 on the DEC Alpha
C platform.
C
integer plhs(*), prhs(*)
integer mxGetPr, mxCreateFull
integer x_pr, y_pr
C--------------------------------------------------------------
C
integer nlhs, nrhs
integer mxGetM, mxGetN, mxIsNumeric
integer m, n, size
real*8 x, y
Zobrazit stránku 119
1 2 ... 115 116 117 118 119 120 121 122 123 124 125 ... 407 408

Komentáře k této Příručce

Žádné komentáře