Tag for questions about packed arrays. Packed Arrays are data structures that can be seen as monolithic blocks containing a single data type, particularly Integers and Reals. Many functions operate very efficient on packed arrays. Questions may deal with packed array generation, conversion, and ...

learn more… | top users | synonyms (1)

72
votes
3answers
3k views

What is a Mathematica packed array?

A simple sounding question with a few sub questions: What is the difference between unpacked vs packed array? Are packed arrays more space efficent, how much so? Are packed arrays more time ...
39
votes
3answers
921 views

Are there guidelines for avoiding the unpacking of a packed array?

Packed arrays are very useful because they save memory and generally allow speedier and more efficient calculation times. If a list of data currently stored as a packed array is unpacked, it can slow ...
23
votes
1answer
505 views

Why does list assignment with a packed array result in unpacked values?

Bug introduced in 5.2 or earlier and fixed in 10.1.0 This is another question on the design choices in Mathematica. I understand that without direct reply from the developers it may not be ...
20
votes
2answers
896 views

Why does ImageData need four times more memory?

Background We are dealing with very large TIFF image files that are imported, processed and exported using Mathematica 9.0.1. Many of our algorithms only work with an array representation of the ...
17
votes
1answer
367 views

Unpacked eigenvectors of complex matrices

Edit: This bug is fixed in Mathematica 10.0.0 I want to calculate eigenvectors of a Hermitian matrix. For example ...
14
votes
1answer
338 views

Why doesn't Mathematica pack Boolean arrays?

I've been wondering about this for a while now, so I'm going to ask. This is a question about the design of Mathematica, which perhaps cannot be directly answered by anyone but the designers, however ...
13
votes
2answers
242 views

How do you determine the optimal autocompilation length on your system

When you pack lists there is an overhead therefore packing a list with, say, 2 elements is likely to cost more than you get back in efficiency. Mathematica has default list lengths for which functions ...
11
votes
2answers
669 views

Speeding up construction of simple tridiagonal matrix

I have the following code to construct a tridiagonal matrix: ...
11
votes
1answer
247 views

Why does Outer sometimes return a packed array, and sometimes not?

For example In[342]:= test3 = Flatten[Outer[Plus, Range[1000], Range[1000]], 1]; // AbsoluteTiming Out[342]= {0.0198735, Null} returns PackedArray ...
10
votes
1answer
213 views

Future-proofing access to packed array tools

Most of the Mathematica users beyond beginner level will be aware of the phenomenon of Packed Arrays. The user-accessible functions related to packed arrays live in the ...
9
votes
4answers
343 views

Unexpected behavior from GatherBy in version 7

Bug introduced in 7.0 or earlier and fixed in 8.0.4 or earlier I have come across what appears to be a bug in GatherBy. It appears similar to the problem of ...
9
votes
1answer
217 views

Speed up construction of a dense matrix

I wish to find the numerical eigenvalues of a relatively small (100 dimensional) Hermitian matrix. While the eigenvalue calculation itself is fast, the construction of the matrix is taking longer than ...
9
votes
1answer
221 views

Forcing efficient numerical arrays

I encounter strange behaviour of Mathematica when evaluating multi-dimensional arrays of double-precision data. Mathematica can express large arrays of machine-precision numbers using a specialized ...
8
votes
1answer
233 views

Building sparse array from packed arrays

Suppose I have two large packed arrays a and b, that respectively contain the position of the elements of a square matrix (i.e. ...
7
votes
4answers
251 views

Why does array packing in Table behave like this?

Consider the following example, which generate two identical arrays. Why sometimes the array is packed and sometimes it doesn't? And why they perform differently? Here the arrays are packed: ...
6
votes
2answers
376 views

Fastest way to test if a numerical array has complex elements

I am looking for the fastest way to test whether an n-dimensional numerical (NumericQ) array (in the ArrayQ sense) is complex or ...
5
votes
3answers
886 views

Multidimensional array reduction through summation over one of its dimensions

1. Introduction I am using an array of dimension 3 (might become more) to store some values. I would like to implement a function that takes as argument the array and a couple of numbers smaller than ...
5
votes
2answers
132 views

ReplaceAll performance problem: packed arrays on the LHS are unpacked when the RHS is too long

The following is one of the most mysterious performance problems I encountered and came up while extending the booleval function mentioned here. I am looking for a ...
5
votes
1answer
257 views

Isn't it possible to Pack a SparseArray?

I have the following matrix Va: ...
5
votes
1answer
118 views

Discrepancy with TakeWhile between RandomInteger result and list on Linux

Bug introduced in 8.0.0 and fixed in 8.0.1 I have to following code that solves a problem for me. The example that is given to us is as follows: ...
5
votes
1answer
119 views

Why are so many built-in numerical function doesn't check its argument is packed array or not? [closed]

This question is brought by this one. Outer[Times, RandomReal[1., 1000000], {1., 2.}]; is much slower than ...
4
votes
1answer
127 views

Memory usage of timeseries - lists of {Integer32, Real32}

A list of {Integer32, Real32} items in Mathematica seems to use 12-times as much memory than the C equivalent array of structs. ...
3
votes
1answer
63 views

Nested list can not be packed?

Why can't nested list be packed? In[252]:= ftest = {1., {3.}}; ftest = Developer`ToPackedArray[ftest]; Developer`PackedArrayQ[ftest] Out[254]= False
2
votes
3answers
745 views

Use elements of Array inside function definition

I'm trying to define a function which modifies and sums over the elements of an array. Here is a very simplified version. myF[kmax_] = Sum[v[[k]]/k, {k, 1, kmax}] ...
2
votes
1answer
257 views

How can I permute a multiset?

I have a multiset {1, 3, 3, 1, 2} and would like to randomly permute the classes like so: {2, 1, 1, 2, 3} or {3, 2, 2, 3, 1}, what is the simplest and most efficient way to do this? In reality the ...
2
votes
0answers
76 views

Compilation of a function that needs to call Subsets

I'm working on a code that runs many (easy) operations on combinations (subsets) of different size (6, 7, 8, 9) taken from a big set of numbers (normally more that 40). So, this means the code has to ...
1
vote
1answer
106 views

Memory handling by ConstantArray

I noticed the following issue when using ConstantArray: a = ConstantArray[0., {10000, 100}]; ByteCount[a] (* 8000152 *) Then ...
0
votes
0answers
70 views

Handling really large Arrays (by possibly using lower precision) [duplicate]

I know there have been a few questions about efficient memory storage on mathematica.stackexchange, but I could not find a sufficient answer for my problem (except that it might not work at all). So ...