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