MathGroup Archive 2009

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

Search the Archive

SparseArray and Compile

  • To: mathgroup at
  • Subject: [mg99722] SparseArray and Compile
  • From: andreas.kohlmajer at
  • Date: Tue, 12 May 2009 03:09:11 -0400 (EDT)


I have difficulties to speed up my calculation regarding SparseArray:

rp = {};
AppendTo[rp, SparseArray[UnitStep[0.01 - dat - dat[[#]]]]] & /@

dat is a list of Reals containing approx. 24000 elements. I had to use
SparseArray for each line to prevent a memory crash; the final matrix
has 574 million elements. The calculation takes 2' 43'' on my WinXP
Dell workstation (DualCore @ 1.6 GHz, 3 GB RAM)

I would like to speed up the calculation using compile, but the
SparseArray object doesn't fit the tensor format. I have tried:

Compile[{{data, _Real, 1}},
 Block[{rp}, rp = {};
  AppendTo[rp, SparseArray[UnitStep[0.01 - data - data[[#]]]]] & /@

Compile::cpts: The result after evaluating Insert[rp,SparseArray
[[System`Private`CompileSymbol[<<1>>]]]]]]],-1] should be a tensor.
Nontensor lists are not supported at present; evaluation will proceed
with the uncompiled function. >>

The calculation is used calculate a recurrence plot. The fixed value
of 0.01 will be replaced by a variable later on; therefore, I need to
speed up the calculation.

Any help is appreciated.

  • Prev by Date: Re: Introducing the Wolfram Mathematica Tutorial Collection
  • Next by Date: Optimize speed of plotting mesh
  • Previous by thread: Re: Problem with strings and backslashes
  • Next by thread: Re: SparseArray and Compile