Code covered by the BSD License  

Highlights from
matlab2fmex

image thumbnail

matlab2fmex

by

 

03 Feb 2004 (Updated )

matlab2fmex.m is a small translator which aims to convert numerical M-files to Fortran90 mex.

Editor's Notes:

This author's upload was somehow corrupted. We fixed this on March 29, 2006. At that time, we also converted it from a GZ file a ZIP file for better cross platform portability.

outstr=getmexoperators
function outstr=getmexoperators
r=char(10);
outstr{1}=['module mexoperators',r,...
	   ' interface mxs',r,...
	   '    module procedure mxs_r2',r,...
	   '    module procedure mxs_c2',r,...
	   '    module procedure mxs_i2',r,...
	   '    module procedure mxs_r1',r,...
	   '    module procedure mxs_c1',r,...
	   '    module procedure mxs_i1',r,...
	   '    module procedure mxs_r',r,...
	   '    module procedure mxs_c',r,...
	   '    module procedure mxs_i',r,...
	   ' end interface mxs',r,...
           ' interface assignment (=)',r,...
           '    module procedure l_to_i',r,...
           '    module procedure l1_to_i1',r,...
           '    module procedure l2_to_i2',r,...
           '    module procedure l_to_r',r,...
           '    module procedure l1_to_r1',r,...
           '    module procedure l2_to_r2',r,...
           '    module procedure l_to_c',r,...
           '    module procedure l1_to_c1',r,...
           '    module procedure l2_to_c2',r,...
           ' end interface',...
           r];
outstr{2}=['contains',r,...
	   '',r,...
           ' function mxs_r2(a) result(out)',r,...
           '  real, dimension(:,:) :: a',r,...
           '  real out',r,...
           '  out=a(1,1)',r,...
           ' end function mxs_r2',r,...
           ' function mxs_c2(a) result(out)',r,...
           '  complex, dimension(:,:) :: a',r,...
           '  complex out',r,...
           '  out=a(1,1)',r,...
           ' end function mxs_c2',r,...
           ' function mxs_i2(a) result(out)',r,...
           '  integer, dimension(:,:) :: a',r,...
           '  integer out',r,...
           '  out=a(1,1)',r,...
           ' end function mxs_i2',r,...
           ' function mxs_r1(a) result(out)',r,...
           '  real, dimension(:) :: a',r,...
           '  real out',r,...
           '  out=a(1)',r,...
           ' end function mxs_r1',r,...
           ' function mxs_c1(a) result(out)',r,...
           '  complex, dimension(:) :: a',r,...
           '  complex out',r,...
           '  out=a(1)',r,...
           ' end function mxs_c1',r,...
           ' function mxs_i1(a) result(out)',r,...
           '  integer, dimension(:) :: a',r,...
           '  integer out',r,...
           '  out=a(1)',r,...
           ' end function mxs_i1',r,...
           ' function mxs_r(a) result(out)',r,...
           '  real :: a',r,...
           '  real out',r,...
           '  out=a',r,...
           ' end function mxs_r',r,...
           ' function mxs_c(a) result(out)',r,...
           '  complex :: a',r,...
           '  complex out',r,...
           '  out=a',r,...
           ' end function mxs_c',r,...
           ' function mxs_i(a) result(out)',r,...
           '  integer :: a',r,...
           '  integer out',r,...
           '  out=a',r,...
           ' end function mxs_i',r,...
           '',r,...
           ' subroutine l_to_i (numout, login)',r,...
           '  logical, intent(in)  :: login',r,...
           '  integer, intent(out) :: numout',r,...
           '  if (login) then',r,...
           '   numout=1.0',r,...
           '  else',r,...
           '   numout=0.0',r,...
           '  end if',r,...
           ' end subroutine l_to_i',r,...
           ' subroutine l1_to_i1 (numout, login)',r,...
           '  logical, intent(in)  :: login(:)',r,...
           '  integer, intent(out) :: numout(size(login))',r,...
           '  where (login) numout=1.0',r,...
           '  where (.not.login) numout=0.0',r,...
           ' end subroutine l1_to_i1',r,...
           ' subroutine l2_to_i2 (numout, login)',r,...
           '  logical, intent(in)  :: login(:,:)',r,...
           '  integer, intent(out) :: numout(size(login,1),size(login,2))',r,...
           '  where (login) numout=1.0',r,...
           '  where (.not.login) numout=0.0',r,...
           ' end subroutine l2_to_i2',r,...
           ' subroutine l_to_r (numout, login)',r,...
           '  logical, intent(in)  :: login',r,...
           '  real,    intent(out) :: numout',r,...
           '  if (login) then',r,...
           '   numout=1.0',r,...
           '  else',r,...
           '   numout=0.0',r,...
           '  end if',r,...
           ' end subroutine l_to_r',r,...
           ' subroutine l1_to_r1 (numout, login)',r,...
           '  logical, intent(in)  :: login(:)',r,...
           '  real,    intent(out) :: numout(size(login))',r,...
           '  where (login) numout=1.0',r,...
           '  where (.not.login) numout=0.0',r,...
           ' end subroutine l1_to_r1',r,...
           ' subroutine l2_to_r2 (numout, login)',r,...
           '  logical, intent(in)  :: login(:,:)',r,...
           '  real,    intent(out) :: numout(size(login,1),size(login,2))',r,...
           '  where (login) numout=1.0',r,...
           '  where (.not.login) numout=0.0',r,...
           ' end subroutine l2_to_r2',r,...
           ' subroutine l_to_c (numout, login)',r,...
           '  logical, intent(in)  :: login',r,...
           '  complex,    intent(out) :: numout',r,...
           '  if (login) then',r,...
           '   numout=1.0',r,...
           '  else',r,...
           '   numout=0.0',r,...
           '  end if',r,...
           ' end subroutine l_to_c',r,...
           ' subroutine l1_to_c1 (numout, login)',r,...
           '  logical, intent(in)  :: login(:)',r,...
           '  complex,    intent(out) :: numout(size(login))',r,...
           '  where (login) numout=1.0',r,...
           '  where (.not.login) numout=0.0',r,...
           ' end subroutine l1_to_c1',r,...
           ' subroutine l2_to_c2 (numout, login)',r,...
           '  logical, intent(in)  :: login(:,:)',r,...
           '  complex,    intent(out) :: numout(size(login,1),size(login,2))',r,...
           '  where (login) numout=1.0',r,...
           '  where (.not.login) numout=0.0',r,...
           ' end subroutine l2_to_c2',...
           r,r];
outstr{3}=['end module mexoperators',r];


%%%
%%%outstr{1}=['module mexoperators',r,...
%%%	   ' interface mxs',r,...
%%%	   '  module procedure mxs_r2',r,...
%%%	   '  module procedure mxs_c2',r,...
%%%	   '  module procedure mxs_i2',r,...
%%%	   '  module procedure mxs_r1',r,...
%%%	   '  module procedure mxs_c1',r,...
%%%	   '  module procedure mxs_i1',r,...
%%%	   '  module procedure mxs_r',r,...
%%%	   '  module procedure mxs_c',r,...
%%%	   '  module procedure mxs_i',r,...
%%%	   ' end interface mxs',r,...
%%%           ' INTERFACE ASSIGNMENT (=)',r,...
%%%           '    module procedure l_to_i',r,...
%%%           '    module procedure l1_to_i1',r,...
%%%           '    module procedure l2_to_i2',r,...
%%%           '    module procedure l_to_r',r,...
%%%           '    module procedure l1_to_r1',r,...
%%%           '    module procedure l2_to_r2',r,...
%%%           '    module procedure l_to_c',r,...
%%%           '    module procedure l1_to_c1',r,...
%%%           '    module procedure l2_to_c2',r,...
%%%           ' end INTERFACE',...
%%%           r];
%%%outstr{2}=['contains',r,...
%%%	   '',r,...
%%%	   ' function mxs_r2(a) result(out)',r,...
%%%	   ' real, dimension(:,:) :: a',r,...
%%%	   ' real out',r,...
%%%	   ' out=a(1,1)',r,...
%%%	   ' end function mxs_r2',r,...
%%%	   ' function mxs_c2(a) result(out)',r,...
%%%	   ' complex, dimension(:,:) :: a',r,...
%%%	   ' complex out',r,...
%%%	   ' out=a(1,1)',r,...
%%%	   ' end function mxs_c2',r,...
%%%	   ' function mxs_i2(a) result(out)',r,...
%%%	   ' integer, dimension(:,:) :: a',r,...
%%%	   ' integer out',r,...
%%%	   ' out=a(1,1)',r,...
%%%	   ' end function mxs_i2',r,...
%%%	   ' function mxs_r1(a) result(out)',r,...
%%%	   ' real, dimension(:) :: a',r,...
%%%	   ' real out',r,...
%%%	   ' out=a(1)',r,...
%%%	   ' end function mxs_r1',r,...
%%%	   ' function mxs_c1(a) result(out)',r,...
%%%	   ' complex, dimension(:) :: a',r,...
%%%	   ' complex out',r,...
%%%	   ' out=a(1)',r,...
%%%	   ' end function mxs_c1',r,...
%%%	   ' function mxs_i1(a) result(out)',r,...
%%%	   ' integer, dimension(:) :: a',r,...
%%%	   ' integer out',r,...
%%%	   ' out=a(1)',r,...
%%%	   ' end function mxs_i1',r,...
%%%	   ' function mxs_r(a) result(out)',r,...
%%%	   ' real :: a',r,...
%%%	   ' real out',r,...
%%%	   ' out=a',r,...
%%%	   ' end function mxs_r',r,...
%%%	   ' function mxs_c(a) result(out)',r,...
%%%	   ' complex :: a',r,...
%%%	   ' complex out',r,...
%%%	   ' out=a',r,...
%%%	   ' end function mxs_c',r,...
%%%	   ' function mxs_i(a) result(out)',r,...
%%%	   ' integer :: a',r,...
%%%	   ' integer out',r,...
%%%	   ' out=a',r,...
%%%	   ' end function mxs_i',r,...
%%%           '',r,...
%%%           ' subroutine l_to_i (numout, login)',r,...
%%%           '  logical, intent(in)  :: login',r,...
%%%           '  integer, intent(out) :: numout',r,...
%%%           '  if (login) then',r,...
%%%           '   numout=1.0',r,...
%%%           '  else',r,...
%%%           '   numout=0.0',r,...
%%%           '  end if',r,...
%%%           ' end subroutine l_to_i',r,...
%%%           ' subroutine l1_to_i1 (numout, login)',r,...
%%%           '  logical, intent(in)  :: login(:)',r,...
%%%           '  integer, intent(out) :: numout(size(login))',r,...
%%%           '  where (login) numout=1.0',r,...
%%%           '  where (.not.login) numout=0.0',r,...
%%%           ' end subroutine l1_to_i1',r,...
%%%           ' subroutine l2_to_i2 (numout, login)',r,...
%%%           '  logical, intent(in)  :: login(:,:)',r,...
%%%           '  integer, intent(out) :: numout(size(login,1),size(login,2))',r,...
%%%           '  where (login) numout=1.0',r,...
%%%           '  where (.not.login) numout=0.0',r,...
%%%           ' end subroutine l2_to_i2',r,...
%%%           ' subroutine l_to_r (numout, login)',r,...
%%%           '  logical, intent(in)  :: login',r,...
%%%           '  real,    intent(out) :: numout',r,...
%%%           '  if (login) then',r,...
%%%           '   numout=1.0',r,...
%%%           '  else',r,...
%%%           '   numout=0.0',r,...
%%%           '  end if',r,...
%%%           ' end subroutine l_to_r',r,...
%%%           ' subroutine l1_to_r1 (numout, login)',r,...
%%%           '  logical, intent(in)  :: login(:)',r,...
%%%           '  real,    intent(out) :: numout(size(login))',r,...
%%%           '  where (login) numout=1.0',r,...
%%%           '  where (.not.login) numout=0.0',r,...
%%%           ' end subroutine l1_to_r1',r,...
%%%           ' subroutine l2_to_r2 (numout, login)',r,...
%%%           '  logical, intent(in)  :: login(:,:)',r,...
%%%           '  real,    intent(out) :: numout(size(login,1),size(login,2))',r,...
%%%           '  where (login) numout=1.0',r,...
%%%           '  where (.not.login) numout=0.0',r,...
%%%           ' end subroutine l2_to_r2',r,...
%%%           ' subroutine l_to_c (numout, login)',r,...
%%%           '  logical, intent(in)  :: login',r,...
%%%           '  complex,    intent(out) :: numout',r,...
%%%           '  if (login) then',r,...
%%%           '   numout=1.0',r,...
%%%           '  else',r,...
%%%           '   numout=0.0',r,...
%%%           '  end if',r,...
%%%           ' end subroutine l_to_c',r,...
%%%           ' subroutine l1_to_c1 (numout, login)',r,...
%%%           '  logical, intent(in)  :: login(:)',r,...
%%%           '  complex,    intent(out) :: numout(size(login))',r,...
%%%           '  where (login) numout=1.0',r,...
%%%           '  where (.not.login) numout=0.0',r,...
%%%           ' end subroutine l1_to_c1',r,...
%%%           ' subroutine l2_to_c2 (numout, login)',r,...
%%%           '  logical, intent(in)  :: login(:,:)',r,...
%%%           '  complex,    intent(out) :: numout(size(login,1),size(login,2))',r,...
%%%           '  where (login) numout=1.0',r,...
%%%           '  where (.not.login) numout=0.0',r,...
%%%           ' end subroutine l2_to_c2',...
%%%           r,r];
%%%outstr{3}=['end module mexoperators',r];

Contact us