comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Numerical Recipes Article
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Numerical Recipes Article [message #10240] Wed, 05 November 1997 00:00
Paul E Howland is currently offline  Paul E Howland
Messages: 2
Registered: November 1997
Junior Member
Wayne Landsman wrote:

> In one example, they
> compare a "sort and select" algorithm, as coded in Fortran 77, Fortran
> 90, Mathematica, and IDL. The IDL code clearly wins out in terms of
> readability and simplicity -- they call it "almost crystaline in its
> clarity".

As both a Mathematica and IDL user, I too was interested to read this
article. The principal reason for the IDL code "clearly winning" lies
in the way they have written their code. A better Mathematica example
would have been:

Reverse[#]&/@Select[Transpose[{vels,mags}], (100<#[[1]]<=200)&]
answer=%[[Ceiling[Length[%]/4]]][[1]]

which performs the sort and select without even having to explicitly
call the Sort routine. I would argue that this is not much more
complicated than the IDL example:

temp=mags(where(vels le 200. and vels gt 100., n))
answer=temp((sort(temp))(ceil(n/4)))

In fact, if the data structure had been better suited to Mathematica,
ie. a two dimensional list (equivalent of FLTARR(2,m) in IDL), first row
containing mags and second row vels, then suddenly Mathematica seems the
more elegant:

Reverse[#]&/@Select[data, (100<#[[1]]<=200)&]
answer=%[[Ceiling[Length[%]/4]]][[1]]

compared with the required IDL:

temp=data(0,(where(data(1,*) le 200. and data(1,*) gt 100., n)))
answer=temp((sort(temp))(ceil(n/4)))

I think the important messages are:
1. Don't judge a product by a single test
2. Use the most appropriate tool for the job

I use both IDL and Mathematica, and would not dream of arguing that one
is better than the other. It depends on what I want to do.

Interestingly enough, the article tends to argue that compiled languages
"have an important future in scientific programming" and "environments
like IDL or Mathematica are additional great tools to have". I would
have placed the emphasis the other way round.

Paul

Paul E Howland PhD MEng CEng MIEE Room BY209
Senior Scientist DERA (Malvern)
Land Systems Sector St Andrews Road
Defence Evaluation & Research Agency Malvern
tel. +44-(0)1684-895767 Worcestershire
fax. +44-(0)1684-896315 UK

Email PEHowland@dera.gov.uk
Web Site http://www.dera.gov.uk

Official Disclaimer:
The views expressed above are entirely those of the writer
amd do not represent the views, policy or understanding of
any other person or official body.
[Message index]
 
Read Message
Previous Topic: save routines
Next Topic: Re: prob. w/ subtracting scaler from an array

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 10:43:37 PDT 2025

Total time taken to generate the page: 1.52020 seconds