Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Fortran Programming Language

mex file in matlab using compaq fortran compiler


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/helpdesk/help/techdoc/index.html?/acc...

HTH...

On 4?21?, ??3?40?, dpb <bozart@gmail.com> wrote:

Thanks. The url helps me very much. I finally construct mex file.
Thanks.
Btw do you know how to swtich mexw32 to dll?

best

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc