MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Conditionals -- what is "fastest" way to evaluate

  • To: mathgroup at
  • Subject: [mg84284] Conditionals -- what is "fastest" way to evaluate
  • From: "Coleman, Mark" <Mark.Coleman at>
  • Date: Mon, 17 Dec 2007 19:16:33 -0500 (EST)


I've built a simple function that calculates the distance between a pair
of points on the Great Circle, e.g.., the distance between two addresses
given their latitude-longitude coordinates. I need to apply this against
very large lists of points, resulting in potentially tens or hundreds of
millions of calculations. The input data that I am processing will list
a point's location as (0,0) if for some reason the lat-long coordinate
is not known (nb: this is a poor way to return a lat-long coordinate,
but I am taking these as given from another processing system). For
pairs of points where at least one of the arguments is (0,0), I'd like
to skip the calculation and return an error code or a perhaps a value of

I'm curious as to what is the fastest way to apply a conditional test in
Mathematica under these circumstances? Is it a simple If[ ] statement, a "/;"
construct, Boole, etc? I am happy to test out all of the alternatives,
but many times some very ingenious solutions are presented on MathGroup,
so I thought I'd pose the question. (note: I am presuming that is it
faster to process a conditional test than to evaluate the underlying



  • Prev by Date: FindRoot / Jacobian
  • Next by Date: Re: quadratic multiplication
  • Previous by thread: Re: FindRoot / Jacobian
  • Next by thread: Re: Conditionals -- what is "fastest" way to evaluate