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

learn more… | top users | synonyms

7
votes
1answer
120 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. ...
5
votes
2answers
93 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 ...
4
votes
1answer
168 views

Isn't it possible to Pack a SparseArray?

I have the following matrix Va: ...
15
votes
1answer
292 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 ...
4
votes
1answer
100 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. ...
21
votes
0answers
288 views

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

This is another question on the design choices in Mathematica. I understand that without direct reply from the developers it may not be possible to give a definitive and exhaustive answer to "why" ...
1
vote
1answer
98 views

Memory handling by ConstantArray

I noticed the following issue when using ConstantArray: a = ConstantArray[0., {10000, 100}]; ByteCount[a] (* 8000152 *) Then ...
7
votes
4answers
218 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
248 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 ...
19
votes
2answers
684 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 ...
3
votes
1answer
96 views

Discrepancy with TakeWhile between RandomInteger result and list on Linux

I have to following code that solves a problem for me. The example that is given to us is as follows: lst = {1,-2, 3, 4,5,-3, -4, 9,7,0,8}, predicate = ...
2
votes
3answers
349 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}] ...
10
votes
2answers
459 views

Speeding up construction of simple tridiagonal matrix

I have the following code to construct a tridiagonal matrix: ...
9
votes
1answer
192 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 ...
10
votes
1answer
261 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 ...
1
vote
1answer
223 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 ...
5
votes
3answers
507 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 ...
28
votes
3answers
629 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 ...
47
votes
2answers
2k 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 ...
9
votes
1answer
176 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 ...
7
votes
4answers
296 views

Unexpected behavior from GatherBy in version 7

I have come across what appears to be a bug in GatherBy. It appears similar to the problem of using Table[Random[], {1000}] in ...
12
votes
2answers
186 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 ...