MathGroup Archive 2014

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

Search the Archive

Faster than Fold in M9?

  • To: mathgroup at
  • Subject: [mg132290] Faster than Fold in M9?
  • From: qbdoud at
  • Date: Sat, 1 Feb 2014 00:54:36 -0500 (EST)
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:
  • Delivered-to:

I have a largish data set in a grid and want to evaluate a lengthy list of operations or functions against computer selected data rows.   

Reckon[rows_, operations_] := Module[{tempdata = globaldatamatrix[[#]] & /@ rows},
      ToString[tempdata[[#]] ] <> ToString[operations[[#]] ] & /@ 
       Range[1, numberofoperationsisabouteight]] 
       <> "1.0"(*multiple by one point zero to keep symbolic computation in check, the <> symbols join strings*)]

This works, but is a tad slow- the messy string operations unaccountably seem faster than the following Fold implementation.

Fold[Consider[#1, #2] &, 0, onerowsandoperationscombo] 

Each fold generates a nested function that in would look something like
Consider[row_and_function1, Consider[row_and_function2, Consider[row_and_function3, firstrow] ] ]
if translated for brevity and readability.

Is there a better way to do this kind of thing?   I want to Compile but understand I can't work with lists.  

Helpful ideas?

  • Next by Date: Re: Result to DEQ with WA versus Step-by-Step Yields
  • Next by thread: Re: Result to DEQ with WA versus Step-by-Step Yields