Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

why are some functions not listable over packed arrays?

  • To: mathgroup at
  • Subject: [mg53845] why are some functions not listable over packed arrays?
  • From: barrowes at
  • Date: Sat, 29 Jan 2005 06:02:56 -0500 (EST)
  • Sender: owner-wri-mathgroup at

I am trying to make the common numerical logical operators (like Equal,
Or, And, etc.) listable, but when array sizes become large, Equal and
Unequal don't thread properly over matrices.

For example, after
the following works fine
to yield
However, when a matrix has more than 249 elements in it, this no longer
aa = Table[Random[Real, 100], {250}]
{list of numbers}=50

Not what I want. However, it works for a Table size of 249 and below.
I looked around a bit and found this has to do with aa defaulting to a
packed array for arrays with > 249 elements. Indeed, when
was True, Equal was not Threaded properly over the array. Unequal also
has this problem, though Greater, LessEqual, etc., seem to be fine.

Note that this won't even work when a section of large array aa smaller
than 250 is used:
also fails when aa has >249 elements.

I have found two workarounds. The first is to set the default size at
which any array automatically becomes a packed array to infinity by:
Developer`SetSystemOptions["CompileOptions" -> "TableCompileLength" ->
But this has the undesirable side effect of eliminating many speedups
associated with packed array numerical implementations internal to
The other workaround is to make sure that Equal is overloaded


For some reason, this works. In fact, explicitly calling
works for large aa even when:
does not.

BTW, probably an easy question, but:
(with the underscore pattern matcher) will not work. Why?

After redefining Equal as above, however,
works for any size array.

Is this a bug?

  • Prev by Date: Re: Integrate a Piecewise funition, stange behaviour
  • Next by Date: Re: Algebra of Einstein velocity addition
  • Previous by thread: Re: Solving matrix equation
  • Next by thread: small puzzle programming