Conditionals -- what is "fastest" way to evaluate
- To: mathgroup at smc.vnet.net
- Subject: [mg84284] Conditionals -- what is "fastest" way to evaluate
- From: "Coleman, Mark" <Mark.Coleman at LibertyMutual.com>
- Date: Mon, 17 Dec 2007 19:16:33 -0500 (EST)
Greetings, 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 infinity. 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 function) Thanks, Mark