Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!cs.utexas.edu!rutgers!mit-eddie!uw-beaver!tektronix!uunet!mcvax!cernvax!hjm
From: hjm@cernvax.UUCP (Hubert Matthews)
Newsgroups: comp.lang.fortran
Subject: Re: Fortran versus C for numerical anal
Message-ID: <834@cernvax.UUCP>
Date: 23 Sep 88 13:29:58 GMT
References: <1530@ficc.uu.net> <3746@lanl.gov> <14494@agate.BERKELEY.EDU> <1475@valhalla.ee.rochester.edu>
Reply-To: hjm@cernvax.UUCP (Hubert Matthews)
Organization: CERN European Laboratory for Particle Physics, CH-1211 Geneva, Switzerland
Lines: 51

In article <1475@valhalla.ee.rochester.edu> davis@ee.rochester.edu (Al Davis) writes:
>
>In article <14494@agate.BERKELEY.EDU> link@stew.ssl.berkeley.edu (Richard
>Here is a challenge: write a portable program that does LU decomposition of
>a matrix of arbitrary size, in Fortran.  I believe it can't be done, in a
>straightforward way.  (Read the input, do it, write the result)
>Someone please prove me wrong.
>
>Al Davis

If you wish to be really precise, then you can't do anything in C portably
as there is no I/O in the language, never mind memory allocation.  You have
to call a library function called malloc() to get memory, just like any
F77 programmer has to do.  You also have to call library functions to do
I/O; printf was designed to imitate FORTRANs formatted I/O.  You have to
call library functions to do most things in C.  Therein lies a portability
problem.  If it's in the language, then it will be there.  If it's not, then
you just have to hope.  If it's printf or malloc, you'll probably be lucky.

OK, so to make the contest into a contest (without libraries you lose) we'll
allow standard libraries.  You take  and I'll take the NAG library.
 is available on almost all machines with a C compiler.  NAG is
available on almost all machines with a FORTRAN compiler for people interested
in numerical work, so that's obviously fair.  You can't use it, as mixed
language programming is very non-portable, just as I can't use  or
malloc.  So, here's an outline of my program:

      PROGRAM MINE
      CALL GETSIZ(M,N)
C  non-portable, system specific memory allocator
      CALL GETMEM(M*N,IPTR)
      CALL RDMTRX(IPTR)
C  enormous cheat.  Call the NAG library routine to do LU decomposition
      CALL F01LBF(IPTR,M,N,some_other_parameters......)
      CALL PRNTLU(IPTR)
      STOP '5 minutes work'
      END

"But, you can't cheat like that", I hear you say.  You allowed standard
libraries, and the NAG library has been available on every machine I've
ever used for numerical work, so I'm going to use the tools available.
You take away my NAG, and I'll take away your stdio, malloc, read, printf,
and anything else that K&R didn't declare as part of C itself.

Let's see how much code you have to write to do an LU decomposition.  Let's
see how long it takes you to get it right.  (Your rules, not mine.)

	Hubert Matthews
-- 

	Hubert Matthews