Re: MATLAB <-> FORTRAN



Oh boy, Ax=b. This is a research question even until today. Lots
(LOTS!) of algorithms have been devised depending on some properties
of the matrix you have some solvers are better (WAY BETTER!) than
others. When you do A\b it just calls the basic solvers Matlab knows,
in some cases Gauss Elimination. Matlab sometimes choose to use a
better solver by itself, however, in many cases, it is slow. Gauss
Elimination with partial pivoting is O(N^3).
I imagine your matrix is not huge, otherwise A\b could be very slow.
In this case you can find a Gauss Solver, or LU factorization solver.
Gauss with partial pivoting is the brutal force and attack-all
solution for nonsingular matrices. If your matrix is singular Matlab
actually uses least squares. In this case it is NOT a Ax=b problem
anymore.
Look at Numerical Recipes in Fortran. The book should have the
subroutine you need. btw, the best solution to your problem is, I
bet, find a pal with Matlab and compile your code there.

Ally wrote:


I empathise with you.
I've been faced with the same problem several times.
In all cases, I've bitten the bullet and converted to Fortran
95.
Actually, it's not too bad. Fortran 95 is vectorised, so you
can
convert most lines as they stand.
But you need to convert for..next loops to do... end do, and
if...end
to if...endif, etc.
The most difficult thing is finding equivalent built-in
functions
such
as interp1.
But if you use Google, you can find them. Mostly, they're
written
in
Fortran 77 or even Fortran 4, but they are usually debugged and
ready
to use.
Recently I was looking for spline interpolation and I found
that
the
old Fortran 77 version I located is almost certainly the one
used
in
Matlab.

Good Luck.




Thanks for the advice. Actually I have already started it. My
biggest
problem is "solving linear systems of n equations with n unknowns",
ie, AX=B. As you know, tihs can simply be done in MATLAB using X =
A
\ B. The operator "\" in MATLAB is super sophosticated and
powerful,
it actually can solves any system of equations that I have in my
design program, correct and fast. In FORTRAN, however and as you
said, I need a subroutine for this. I have tried the Recipes and
Netlib routines (including gauss-elimination method), but they all
gave me "singularity" error message. This is the last piece of the
chain, if I find it I am there.

I have spent a lot of time on this, searched google, etc.. but was
not able to find such a nice and decent routine for solving AX=B.

Please, if you know where I can find it, let me know. I don't care
if
it is slow, as long as it works, I am happy.

Thank you!
.



Relevant Pages

  • Re: about my previous question
    ... The problem that I have the attached code is designed in Fortran 77, ... The problem is that you lack the code for the DGEAR subroutine. ... I see from a quick google that this is a solver for stiff ODEs, and that it is part of the IMSL library. ... The other option is to recode your program in Matlab. ...
    (comp.soft-sys.matlab)
  • Re: Matlab Vectorisation Speed - How is it done in c++?
    ... Beating the performance of vectorized Matlab code is very ... Matlab makes calls to optimized C and Fortran libraries ... Use optimization level 3 on numerical code and level 2 on non- ...
    (comp.soft-sys.matlab)
  • Re: Calling MATLAB from Fortran
    ... Fortran saves the data which Matlab m-file needs and then Matlab would read them as input from the file and after calculation save then in a file for Fortran. ... returns mxArray * ...
    (comp.soft-sys.matlab)
  • Re: pass 1D vector from matlab to fortran
    ... matlab to fortran: ... %input: timeseries ts and constants ... polynomial in seasonal smoothing ...
    (comp.soft-sys.matlab)
  • Re: Problems when calling functions from a .dll
    ... > I have quite some problems with calling functions from a .dll. ... originally written in Fortran and compiled by ... > PRECISION (double in Matlab); ... > as a basic for my header file, which is based on the example file ...
    (comp.soft-sys.matlab)