Questions on the construction and manipulation of sparse arrays in Mathematica, with functions like SparseArray[] and Band[].

learn more… | top users | synonyms

4
votes
3answers
122 views

Constructing Tri-Diagonal Matrices

Fractional Calculus Course, we are instructed to create an $n \times n$ Tri-Diagonal matrix in the form of: \begin{array} a A &= \begin{bmatrix} 2 & -1 & 0 & 0 & ... ...
8
votes
2answers
181 views

Analytic determinant of a sparse 25x25 matrix?

I would like to compute the analytic determinant of the following sparse matrix ...
2
votes
1answer
108 views

When are sparse arrays effective?

Sparse arrays are not effective in Mathematica 10. More computational time is needed to perform arithmetic operations on sparse arrays. Their size is also bigger than normal arrays. Here is a simple ...
6
votes
2answers
377 views

How to interpret the FullForm of a SparseArray?

SparseArrays are atomic objects, but they do have a FullForm which reveals information about them. What is the meaning of the ...
3
votes
0answers
97 views

Det and MatrixRank freezes on SparseArray with nonzero default value

Bug introduced in 7.0 or earlier and fixed in 9.0.1 or earlier Why does the following simple code never come to an end (at least with version 8) ...
11
votes
1answer
2k views

How to work around Mathematica hanging when showing a large SparseArray?

Bug introduced in 9.0 and fixed in 9.0.1 In Mathematica 9, if I display any large SparseArray object in the default way (which looks something like ...
4
votes
0answers
40 views

Bug? Kernel Crash on SparseArray access [duplicate]

Bug introduced in 5.2 and fixed in 10.1.0 The following simple code s = SparseArray[{}, {10, 10}] s[[1, {1, 2, 3, 1, 1}]] = {a, b, c, d, e} on my machine ...
1
vote
0answers
51 views

Addition of sparse array objects [duplicate]

Bug introduced in 9.0.0 and fixed in 10.0.0 I have been having some trouble with the addition of large (but very sparse) matrices using SparseArray. Here is the simplest example to illustrate the ...
15
votes
1answer
347 views

Adding three integer sparse matrices is very slow. Adding only two is fast

Bug introduced in 9.0.0 and fixed in 10.0.0 Adding more than two sparse matrices in one step in Mathematica 9 is very slow (in fact I couldn't even wait for it to finish). Here's an example. ...
2
votes
0answers
41 views

Approximate inverse of large sparse matrix with small diagonal element

I need to find inverse of a large sparse matrix with small diagonal element. I follow this question - Is there any way to obtain an approximate inverse for very large sparse matrices? and try to use ...
4
votes
0answers
66 views

How can I force the use of sparse diagonalization methods?

When I evaluate the Eigenvalues function on a very large (e.g. 2^16 x 2^16) sparse matrix, Mathematica says something like: Because finding 65536 out of the ...
2
votes
1answer
51 views

Non-numeric elements in banded sparse array

The documentation mentions that "the elements in SparseArray need not be numeric", although "the individual elements of a sparse array cannot themselves be lists." ...
15
votes
0answers
201 views

Simple Matrix multiplication takes very long

Bug introduced in 10.1.0 I came across some strange behaviour during a computation involving matrices with symbolic values. It is reproduced below. Multiplying a random 30x30 array with symbolic ...
22
votes
2answers
1k views

Using the Krylov method for Solve: Speeding up a SparseArray calculation

I'm trying to implement this Total Variation Regularized Numerical Differentiation (TVDiff) code in MMA (which I found through this SO answer): essentially I want to differentiate noisy data. The full ...
2
votes
4answers
167 views

Given a matrix of integer, create a matrix with 1 or 0 according to which numbers are in the first matrix

Not sure the title gives the idea of what I need, so here is a sample: I have ten (w) combinations (subsets) of 20 (n) numbers taken 4 (k) at time. I need a matrix of dimension w x n with 0/1 in each ...
2
votes
1answer
96 views

Memory usage optimization for a large Association/SparseArray

Reformulating my question in simpler terms. Take two lists list1 = RandomInteger[{1, 100000000}, 25000000]; list2 = RandomReal[{1, 10}, 25000000]; Make an ...
12
votes
2answers
950 views

Find the eigenvector associated with the smallest eigenvalue, not smallest in magnitude

I am trying to find the eigenvector of a $20000 \times 20000$ sparse matrix associated with the smallest eigenvalue. I realized that the smallest eigenvalue might be negative; for example, if the ...
18
votes
1answer
400 views

What are SparseArray Properties? How and when should they be used?

A strange undocumented form of SparseArray is increasingly used in answers on this site: ...
-1
votes
1answer
100 views

Laplace equation

I tried to run this code, but it doesn't work for NDSolve ...
2
votes
0answers
71 views

Memory used by SparseArray objects

In dealing with a quantum mechanics problem, I am representing some many-body states in two different ways in Mathematica. For two parameters n and ...
1
vote
2answers
67 views

conditional rules for sparse matrix

why does the following not work (Table isn't plugging in values for k): ...
-2
votes
1answer
91 views

Recreating in Mathematica a matrix created in Python [closed]

I need to recreate in Mathematica this matrix that I created in Python: ...
1
vote
2answers
100 views

Filing matrix by bands [closed]

I need to fill a matrix, CSI, by taking elements from an array, inverse, which is the Inverse Fast Fourier Transform of an array ...
2
votes
1answer
72 views

sparse array with list [closed]

i'm trying to populate a sparse array with lists in certain positions, i tried the following code, ...
7
votes
1answer
157 views

Instant kernel crash when using `+=` on `SparseArray` with repeated entries

Bug introduced in 5.2 and fixed in 10.1.0 Not sure if this is known behavior or not, but the following two lines produce an instant kernel crash (I'm using Mathematica 10.0.1 Windows 64-bit): ...
3
votes
1answer
97 views

speeding up creation of SparseArray

I have to create the following sparse arrays, which are reshaped in a two dimensional matrix, so that i can use the build in Dot[] function to do a kind of ...
14
votes
1answer
215 views

Why won't SparseArray let me store values with the head List?

When you attempt to define a SparseArray with elements that have the head List it complains: ...
5
votes
4answers
519 views

Elegant mehod of generating this matrix?

Good evening, I need to determine an elegant (as possible) method of computing an nxn matrix below (the matrix shown is just a 16x16 example). I've been toying with For loops, Tables, Bands, ...
4
votes
1answer
59 views
7
votes
1answer
135 views

Possible bug: SparseArray Part assignment loses default value?

fixed in 10.0.2 This sure looks like a bug to me (Mathematica 10.0.0, MacOS): ...
1
vote
1answer
77 views

Entering block matrices, general case doesn't work

I want to enter several matrices at different positions in blocks. There is already a very similar answer here: http://mathematica.stackexchange.com/a/3562/6138 I thought that simply generalizing ...
0
votes
0answers
42 views

Permute indices of a large sparse array

I'm starting with a very large rank 3 tensor, F, that is stored as a SparseArray, and I need to permute its indices. I first tried using ArrayRules to get the positions of the non-zero elements, to ...
2
votes
2answers
68 views
11
votes
2answers
240 views

Temporal database reconstruction in mathematica

<EDIT> after some internet research I found the database domain that deals with this kind of thing: Temporal Databases. I think my question therefore becomes how to reconstruct a temporal ...
13
votes
1answer
385 views

How to use SparseArray in CUDA?

Sparse arrays are widely used in many scientific applications where memory and time are strictly limited. For a considerable speedup one can use CUDA. Since Mathematica 8 we can conveniently use CUDA ...
4
votes
1answer
178 views

Efficient Dyson series implementation

I'm trying to implement a Dyson series \begin{array}{lcl} U(x,x_0) & = & 1 + \int_{x_0}^{x}{dy_1V(y_1)}+\int_{x_0}^x{dy_1\int_{x_0}^{y_1}{dy_2V(y_1)V(y_2)}}+\cdots \\ & &{} + ...
4
votes
1answer
110 views

Parallelizing sparse array construction

I have a very large sparse array, and the computation of individual matrix elements is fairly expensive. The Matrix is Hermitian and traceless, so I would like to construct only the sub-diagonal ...
10
votes
1answer
196 views

Sporadic bugs in multidimensional SparseArray objects

Udate This SparseArray[] bug is (apparently) fixed on version 10.0 ...
4
votes
1answer
150 views

How can I efficiently ArrayFlatten a matrix of sparse matrices?

I have a matrix of sparse matrices that I want to convert to a sparse block matrix. So, basically I want what ArrayFlatten does, except that I want the output to be ...
1
vote
1answer
71 views

Conditions in SparseArray

I got confused by {i_, j_} /; in the following code. I didn't see an explanation in the SparseArray documentation. Can anyone ...
0
votes
1answer
38 views

Interactively Manipulate SparseArrays or Lists

I'd love to use SparseArrayor List to group a set of parameters together in a function. ...
8
votes
1answer
191 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. ...
3
votes
1answer
367 views

Transforming a huge rectangular table to Sparse Array

I am interested in the most efficient way to transform a huge rectangular array to a sparse array structure. Consider a numeric rectangular table that is rather sparse, with zero positions being set ...
1
vote
1answer
69 views

Devising a sparse array rule

Suppose I have a matrix A={{1, 2}, {3, 4}} that defines the positions of non-zero values in a sparse array: ...
2
votes
2answers
344 views

Create a matrix of matrices using Band and ArrayFlatten [duplicate]

I can easily write a simple Band matrix using: SparseArray[{Band[{2, 1}] -> a}, {Dim, Dim}] where a is a number. Now, I ...
0
votes
1answer
56 views

What's wrong with my rule? [duplicate]

Consider a simple code to form a SparseArray: Q = 5; a = Table[i, {i, Q}]; SparseArray[{{j_} /; j > 2 -> a[[j]]}, {Q}] Part::pspec: Part specification j ...
3
votes
1answer
243 views

Are there any more time-efficient ways to solve a matrix equation than with SparseArray and LinearSolve?

I am trying to solve a matrix equation, with the matrix being tridiagonal. The problem I am having is that a message keeps appearing that I don't have enough memory. Here is the code: ...
2
votes
1answer
158 views

How to handle a sparse array of lists

I have data in the form of a sparse array of lists. For example: ...