# Tagged Questions

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 ...

3answers
78 views

### Getting directly a packed array of repeated packed arrays

Consider this code: Needs["Developer"]; N@Range[5]; PackedArrayQ@% Table[%%, 5]; PackedArrayQ@% which prints True, ...
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 ...
3answers
974 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 ...
0answers
38 views

### Fast way to export large amount of data in “Table” format

I have about a million 3D points, say data = Table[{1. x, 1. y, 0.}, {x, 1000}, {y, 10^3}]~Flatten~1; I want to visualize them, but ...
1answer
65 views

### Nested list can not be packed?

Why can't nested list be packed? In[252]:= ftest = {1., {3.}}; ftest = DeveloperToPackedArray[ftest]; Developer`PackedArrayQ[ftest] Out[254]= False
1answer
229 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 ...
1answer
249 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 (...
1answer
120 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 ...
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: ...
4answers
348 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 ...
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 ...
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 ...
1answer
514 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 ...
1answer
348 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 ...
1answer
375 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 ...
1answer
248 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. <...
2answers
134 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 ...
1answer
264 views

### Isn't it possible to Pack a SparseArray?

I have the following matrix Va: ...
1answer
132 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. ...
2answers
912 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 ...
1answer
107 views

### Memory handling by ConstantArray

I noticed the following issue when using ConstantArray: a = ConstantArray[0., {10000, 100}]; ByteCount[a] (* 8000152 *) Then ...
3answers
802 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}] ...
4answers
252 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: ...
2answers
692 views

### Speeding up construction of simple tridiagonal matrix

I have the following code to construct a tridiagonal matrix: ...
2answers
392 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 ...
1answer
223 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 ...
1answer
261 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 ...
3answers
934 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 ...
2answers
244 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 ...
1answer
216 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 ...