MathGroup Archive 2014

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

Search the Archive

Re: Efficient function to accumulate a list of {value,coord} into array

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132525] Re: Efficient function to accumulate a list of {value,coord} into array
  • From: julian.w.francis at gmail.com
  • Date: Sat, 5 Apr 2014 01:49:34 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net
  • References: <lhiudg$dij$1@smc.vnet.net>

Dear all,

Thanks for all your replies, I also had quite a few coming in via direct email.

Comparing a number of solutions, it seems that the level of sparsity in the resulting matrix makes a big difference as to which algorithms are more efficient.

Basically most solutions seem to boil down to doing a GatherBy to group elements of the same cell, then totalling and and feeding into SparseArray.

Bob Hanlon suggested replacing the For loop with a map construct.

In my specific circumstances, I was able to double the speed by following Bob's Map suggestion.

The other solutions while more elegant than my original code, were not that much more efficient on a dense matrix.(Although they are for a sparse matrix).

The above conclusions were tested on 144*300 with 20,000 particles.

Thanks for all your help,
Julian.



  • Prev by Date: variable tube radius and variable surface thickness
  • Next by Date: Re: Copying Text From CDFs
  • Previous by thread: Re: Efficient function to accumulate a list of {value,coord} into array
  • Next by thread: Parallelization sometimes a plus, sometimes not