MathGroup Archive 2003

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

Search the Archive

SparseArray problem

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42292] SparseArray problem
  • From: "Steve Luttrell" <luttrell at _removemefirst_westmal.demon.co.uk>
  • Date: Fri, 27 Jun 2003 06:31:20 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

This works (3-dimensional array with a few elements assigned)

f[i_, j_, k_] := Abs[i - j] + Abs[i - k] + Abs[j - k];
a3 = SparseArray[{i_, j_, k_} /; f[i, j, k] < 5 -> 1, {10, 10, 10}]

but this hangs (4-dimensional array with a few elements assigned)

f[i_, j_, k_, l_] := Abs[i - j] + Abs[i - k] + Abs[i - l] + Abs[j - k] +
Abs[j - l] + Abs[k - l];
a4 = SparseArray[{i_, j_, k_, l_} /; f[i, j, k, l] < 5 -> 1, {10, 10, 10,
10}]

The 4-dimensional case can be worked around by explicitly listing all of the
elements that need to be assigned, but it would be much nicer to be able to
use a pattern to achieve the required effect.

--
Steve Luttrell
West Malvern, UK



  • Prev by Date: Re: Screensaver with Mathematica 5.0 Logo
  • Next by Date: Nesting Pure Functions with more than one variable
  • Previous by thread: High-speed sparse matrix operations with Mathematica 4.2 ???
  • Next by thread: Nesting Pure Functions with more than one variable