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