Home > Archive > Fortran > April 2007 > mex file in matlab using compaq fortran compiler
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
mex file in matlab using compaq fortran compiler
|
|
| fortee 2007-04-20, 10:04 pm |
| I am attaching two functions which I want to translate to mex file to
be used in matlab. I tried tons of time to construct a mex file(or
separate mex files) to use two functions. I am wondering how to
construct gateway files associated with the functions. Please let me
know how to do it. Thanks guys.
function nrmhermite(x,n,m,ord)
implicit none
integer:: ord
integer:: n,m
real, dimension(n,m), intent(in):: x
real, dimension(n,m):: y,ny1,ny2,nny1,ny
real, dimension(n,m):: nrmhermite
integer::j
integer:: fact
if (ord==0) then
y=1
fact=1
elseif (ord==1) then
y=2*x
fact=1
elseif (ord==2) then
y=4*x**2-2
fact=2
elseif (ord>2) then
ny2=4*x**2-2
ny1=2*x
fact=1
do j=2,ord
fact=fact*ord
enddo
do j=1,ord-2
nny1=2*x*ny2-2*(2+j-1)*ny1
ny1=ny2
ny2=nny1
enddo
y=nny1
endif
ny=(2**ord*fact*pi**(1/2))**(-1/2)*(exp(-x**2/2)*y)
nrmhermite=ny
end function nrmhermite
function legendre(x,n,m,ord)
implicit none
integer:: ord
integer:: n,m
real, dimension(n,m), intent(in):: x
real, dimension(n,m):: y,ny1,ny2,nny1,ny
real, dimension(n,m):: legendre
integer::j
if (ord==0) then
y=1
elseif (ord==1) then
y=x
elseif (ord==2) then
y=(1/2)*(3*x**2-1)
elseif (ord>2) then
ny2=(1/2)*(3*x**2-1)
ny1=x
do j=1,ord-2
nny1=((2*(2+j)-1)/(2+j))*x*ny2-((2+j-1)/(2+j))*ny1
ny1=ny2
ny2=nny1
enddo
y=nny1
endif
legendre=y
end function legendre
| |
|
| fortee wrote:
> I am attaching two functions which I want to translate to mex file to
> be used in matlab. I tried tons of time to construct a mex file(or
> separate mex files) to use two functions. I am wondering how to
> construct gateway files associated with the functions. ...
Don't recognize what you're asking w/ the phrase "gateway files" but
there are examples of Fortran mex files at The Mathworks site. Been
quite some time since I actually did so, but my recollection is that
after implementing the example for the type of result and argument I
wanted, it was then pretty simple to build the others...
If the following doesn't provide clear enough path, then you're bound
to get better help on specifics on TMW support forum as the question
is really more Matlab-specific than general Fortran...
http://www.mathworks.com/access/hel...0&rwfreq=500&rl
ead=250&sufs=0&order=r&whole=Whole_site&entire_flag=1&is_summary_on=1&ResultCount=10&query=fortran+mex+example&submit=Search
HTH...
| |
| fortee 2007-04-21, 7:04 pm |
| On 4=BF=F921=C0=CF, =BF=C0=C8=C43=BD=C340=BA=D0, dpb <bozart...@gmail.com> =
wrote:
> fortee wrote:
>
> Don't recognize what you're asking w/ the phrase "gateway files" but
> there are examples of Fortran mex files at The Mathworks site. Been
> quite some time since I actually did so, but my recollection is that
> after implementing the example for the type of result and argument I
> wanted, it was then pretty simple to build the others...
>
> If the following doesn't provide clear enough path, then you're bound
> to get better help on specifics on TMW support forum as the question
> is really more Matlab-specific than general Fortran...
>
> http://www.mathworks.com/access/hel...ex.html?/acc...
>
> HTH...
Thanks. The url helps me very much. I finally construct mex file.
Thanks.
Btw do you know how to swtich mexw32 to dll?
best
|
|
|
|
|