MathGroup Archive 1999

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

Search the Archive

Re: Packed Array Angst

  • To: mathgroup at smc.vnet.net
  • Subject: [mg21033] Re: [mg20962] Packed Array Angst
  • From: john.tanner at gecm.com
  • Date: Sun, 12 Dec 1999 23:51:03 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

I have also had severe difficulties with Packed Arrays, and there has
been some discussion already in the MathGroup which might help you.

The relevant postings in the Mathgroup are as follows: (see
http://smc.vnet.com/mathgroupsearch.html, or 
http://smc.vnet.net/mathgroup/archive/mg17974 (etc) for specific
mesages) :


[mg17923],[mg17974]  -  WRI response to a previous query

[mg18963],[mg18990],[mg19014],[mg19081],
[mg19082],[mg19130],[mg19132] - discussion around my own problems

see also [mg19095] for a major bug.

Other strange effects I have noticed recently include the fact that
Table only produces a PackedArray if the number of elements exceeds
249 in total..

The best thing to do, as suggested by Ted Ersek in mg[18990], is to
modify the definitions of the functions most affected, using 
Developer`ToPackedArray[] around the function.  This is probably
internally inefficient but at least returns a PackedArray under most 
circumstances, avoiding problms with the NEXT operation.

I now have Ted's method implemented as modifications to Transpose, Map
and Outer (my most problematic cases) but unfortunately it does often
need fine tuning for specific cases.  It does NOT work for lower-level
functions like Times, and specific problems with complex numbers still
require individual attention. In particular, use N[I] instead of I,
and be careful when Lists have mixed types present - forcing a
PackedArray of a specific type (e.g. Real, Complex) is often the only
solution.

Mark Reeve (msreeve at earthlink.net) wrote:
> Hello,
>
> This is mainly a question to WRI personnel, though I'd appreciate 
> any
> thoughts anyone else might have as well.
> 
> I've been experimenting with packed arrays and have observed that a
> number of common functional programming constructs force unpacking,
> thus
> greatly lessening the utility of packed arrays.  At the latest
> Developers' Conference Tom Wickham-Jones mentioned that he was 
> working
> on upgrades to allow the pattern matcher to work better with packed
> arrays and perhaps the problems I'm encountering are already on the
> list
> for generalization.
>
> For example:  Transpose, Inner, Outer, and MapThread.  The latter is
  > particularly annoying.  I should clarify that for a 2-D array (and
> possibly for higher-dimensions as well), Transpose[arr], works just
> fine
> and preserves packing.  But if the user specifies a permutation
> vector,
> even the trivial Transpose[arr2d,{1,2}], unpacking occurs.
>
> Another nasty thing is that if "a" and "b" are two packed arrays,
> the
> composite c={a,b} is not, although c[[1]] and c[[2]] are still each
> packed.
>
> Has anyone found a way around some of these limitations?  A generic
> replacement for MapThread which preserves packing?  I have
> experimented
> with several forms but have so far only run into further
> limitations.
>
> -Mark

-- 
John Tanner
BAE SYSTEMS






  • Prev by Date: AngularFormat again
  • Next by Date: Help: Uncertain gif size for multiple uses of Display function.
  • Previous by thread: RE: Packed Array Angst
  • Next by thread: 1999 Mathematica Developers Conference Summary and Proceedings