From: robin on 13 Aug 2010 10:46 "Ron Shepard" <ronshepard(a)NOSPAM.comcast.net> wrote in message news:ronshepard9FD13E.16323410082010(a)news60.forteinc.com...  In article <Rd2dndSu6ZUm4PzRnZ2dnUVZ7v4AAAAA(a)giganews.com>,  Vincenzo Mercuri <comp(a)lang.c> wrote:   > I've been always told of the C language as the best choice  > to accomplish any kind of task in numerical algorithms implementation.   Maybe newer versions of C are better, but the older versions of C were  particularly bad when it came to numerical algorithms. For example, in  traditional K&R C, parentheses could not be used to force operations to  occur in a particular order, something that is very important when  writing numerical code. Also, float arguments were promoted to double  in all function calls, another troublesome feature when trying to write  careful numerical code. And, of course, all arrays in C must be  zerobased, which seldom matches the numerical problem at hand.  Multidimensional arrays are also a problem in C, especially the ones  with dimensions determined at runtime rather than with constants at  compile time. The floating point declarations sometimes are a pain in  C. For example, something declared as float on one machine might have  the same precision as something declared as double or as long double on  some other machine. And finally, perhaps the biggest problem with  numerical code in C, is that the value of some simple expressions such  as "i/j" in which either one or both of the integer values are negative  were not defined in C (they could round either up or down); this means  that to write truly portable C code you need to test for negative values  and evaluate the expressions using positive values only.   All these things are much better in fortran. Fortran has always  respected parentheses in expressions, and fortran has never silently  promoted arguments in subroutine calls. Fortran does allow mixedmode  and mixedprecision expressions, which are sort of like promotion, but  the programmer has control over this in fortran by the way the  expressions are written. Arrays in fortran can have any base at all,  whatever best fits the problem at hand. Multidimensional arrays in  fortran are no problem, they are as easy to declare, use, allocate, or  deallocate as 1D arrays. Newer versions of fortran (since 1990) have a  nice way of parameterizing floating point precision that avoids many of  the portability problems in ancient fortrans (f77 and earlier); C has  not yet caught up in this respect. And, "i/j" has always had a  welldefined value in fortran for any combination of negative or  positive integers (well, j cannot be zero, but that is a different  issue). Also, fortran has a nice array syntax which allows complicated  expressions to be expressed in a simple way, very much like the  mathematical expression you would write on paper; being able to write  clear, simple, code is important in numerical work. The same things can be said about PL/I. It was designed for implementing numerical algorithms, (among other things). In particular, it was designed to perform arrayvalued operations some 25 years before Fortran had them. As well, it provides for error recovery, one of the banes of numerical programs in other languages.  I would say that it is difficult to even think of a numerical problem  that can be done better in C than in fortran. Agreed.

Pages: 1 Prev: AVG Internet Security 9.0 key till 2018 Next: check available memory 