Article View: comp.soft-sys.matlab
Article #13Re: Generating FORTRAN from MATLAB code ?
From: Bengt Martensson
Date: Fri, 22 Jan 1993 11:15
Date: Fri, 22 Jan 1993 11:15
68 lines
4190 bytes
4190 bytes
In article <raghu.727577016@morgan>, raghu@morgan.ucs.mun.ca (Raghu B) writes:
|> envwpk@epb2.lbl.gov (Werner P. Keilholz) writes:
|>
|> >can anybody tell me if there is some way to automatically generate
|> >FORTRAN code from a program written with MATLAB ?
|>
|> >This question came up in a discussion with a collegue who intends
|> >to develop numerical routines with MATLAB. I tried to talk him into
|> >using MAPPLE instead, because a salesperson once showed me a niffty
|> >little command, called 'FORTRAN', which generates the FORTRAN code
|> >corresponing to a MAPPLE expression automatically. I know neither
|> >MAPPLE nor MATLAB, but I like the idea of directly using the routines
|> >written by my collegue instead of rewriting everything in FORTRAN
|> o>or C (we want to use the result in a product that should be free of
|>
|> Maple does give FORTRAN codes corresponding to Maple
|> expression. But you wouldn't want to use Maple to convert a Matrix
|> expression into Fortran Codes. You are dead then. If you have
|> say 10 x 10 matrix, Then FORTRAN will generate 100 Statements,
|> to define that matrix. You wouldn't want to do that. Another way
|> to reduce the no. of statements , is to use FORTRAN(xxx,optimize)
|> which might help you to reduce the number of statements. Overall
|> it is not an efficient way to generate FORTRAN codes, from
|> MAPLE. It is just an additional feature in MAPLE but not a
|> worthy one.
|>
|> Raghu,B
|>
With optimization, Maple actually generates quite efficient Fortran
(or C) code. As I understand it, there is quite some effort put into
those routines. If the code looks hairy, it is because you are
translating a problem to a low level language such as Fortran (or C).
To the point: If the problem is to convert a Matlab algorithm to a
compiled language (for performance reasons e.g.) I believe that the
best way would be to use a matrix class library in C++. In that way,
you can write matrix operations like in Matlab, while enjoying the
performance advantages of a compiled language. Since you don't have to
translate matrix operations, lack of automatic translation is probably
a minor issue.
One such matrix package was recently posted to comp.sources.misc,
called newmat, written by Robert Davies <robertd@kauri.vuw.ac.nz>.
There are also commercial packages available (e.g. Rogue Wave).
This is from the posting of newmat:
Newmat is an experimental matrix package in C++. It supports
matrix types: Matrix, UpperTriangularMatrix, LowerTriangularMatrix,
DiagonalMatrix, SymmetricMatrix, RowVector, ColumnVector, BandMatrix,
UpperBandMatrix, LowerBandMatrix and SymmetricBandMatrix. Only one
element type (float or double) is supported.
The package includes the operations *, +, -, (defined as operators)
inverse, transpose, conversion between types, submatrix, determinant,
Cholesky decomposition, Householder triangularisation, singular value
decomposition, eigenvalues of a symmetric matrix, sorting, fast Fourier
transform, printing, an interface with "Numerical Recipes in C" and an
emulation of exceptions.
It is intended for matrices in the range 15 x 15 up to the size your
computer can store in one block.
--
Bengt Mรฅrtensson +49 421 218-2952 (office)
Institute for Dynamical Systems +49 421 17 17 13 (home)
University of Bremen +49 421 218-4235 (fax)
P.O. Box 330 440, D-2800 Bremen 33, Germany bengt@mathematik.uni-Bremen.de
Technical Details
Message-ID:
<1993Jan22.111519.12108@informatik.uni-bremen.de>Path:
arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!yale.edu!ira.uka.de!Germany.EU.net!ubrinf!mathematik.uni-Bremen.de!bengtReferences:
<28460@dog.ee.lbl.gov> <raghu.727577016@morgan>Show Full Headers
Complete Article Headers
Newsgroups: comp.soft-sys.matlab Path: arc1-ca.pugleaf.net!sparky!uunet!spool.mu.edu!yale.edu!ira.uka.de!Germany.EU.net!ubrinf!mathematik.uni-Bremen.de!bengt From: bengt@mathematik.uni-Bremen.de (Bengt Martensson) Subject: Re: Generating FORTRAN from MATLAB code ? Message-ID: <1993Jan22.111519.12108@informatik.uni-bremen.de> Sender: news@informatik.uni-bremen.de (NEWS Service) Nntp-Posting-Host: athena Organization: University of Bremen, Germany References: <28460@dog.ee.lbl.gov> <raghu.727577016@morgan> Date: Fri, 22 Jan 1993 11:15:19 GMT Lines: 68