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

learn more… | top users | synonyms

4
votes
0answers
125 views

Finding eigenvalues in Mathematica: why so slow?

I am trying to find the eigensystem of a large sparse real symmetric matrix, and I only need the lowest 40 or so eigenstates. The relevant code is as follows: ...
0
votes
1answer
37 views

LinearSolve on non-square matrices?

I just came across a strange behaviour for LinearSolve (on Mathematica 8.0.0.0). Consider the following definitions: ...
5
votes
4answers
133 views

Add to matrix missing elements (for list of time series)

This question is an extension of the 43122. I’ve looked through many interesting post (like this) but (as always) missed the direct matching. So the setting is simple: ...
1
vote
1answer
53 views

Assemble rule replacement from pairs of positions

I want to create a rule replacement list, which I then use to create a SparseArray. The input is a list of positions of the from ...
4
votes
3answers
153 views

Problem with Conditionals: Why does mathematica add an extra empty list to my output

I have a set of positions where I want to slice a list of numbers. If I Total the values in that list, and they are greater than or equal to 1, I want to remember ...
0
votes
1answer
53 views

Timing and memory use is critical:fast partitioning of binary sparse array

I do experiments were I measure a signal, and I need to know at what time points it is above a threshold. If at a given time point, the signal is above the threshold, then a '1' gets put into the ...
0
votes
0answers
35 views

What is stored for a sparse matrix in memory?

I am wondering if a sparse matrix is stored in memory as a list which is its ArrayRules? The reason to ask this is I am trying to write a function to produce a large sparse matrix. However, I am not ...
2
votes
0answers
65 views

How to solve lowest eigenvalue with Lanczos or Arnoldi algorithm? [closed]

By setting Method->Arnoldi in Eigensystem I was able to solve lowest eigenvalue and eigenstate of a large sparse matrix. ...
9
votes
0answers
83 views

Efficient solution of huge sparse linear system

I'm trying to improve efficiency of my code in which main task is a solution to huge (~$10^4\times 10^4$) but sparse linear system $$Ax=b$$ (In fact my aim is to solve nonlinear equations $F(x)=0$, ...
17
votes
2answers
182 views

Speeding up generation of block diagonal matrix

I'm struggling with the following problem. I have $48$ square matrices (full, filled with real machine precision numbers, thus are packed, all different) of size $128$. I wolud like to place them on a ...
18
votes
1answer
412 views

Sparse Cholesky Decomposition

I am working with square matrices with a special form, which for large rank ($> 100,000$) would be best stored and manipulated as a SparseArray. I believe that ...
1
vote
0answers
26 views

Why variable in SparseArray can't be replaced? [duplicate]

SparseArray[{1, 1} -> t] /. t -> 1 Still contains t. Why t is not replaced by 1?
6
votes
1answer
98 views

Adding two SparseArrays produces zeros in the reported “NonzeroValues”

When two SparseArrays are added together and new zero values are created, these new zero values are reported as "NonzeroValues". Example, produced with Mathematica version 10.2: ...
9
votes
2answers
159 views

Does LinearSolve know that I gave it a Sparse lower triangular matrix?

Let $\mathbf L$ be a nonsingular numeric (non-symbolic) large, lower triangular sparse matrix. Let $\mathbf b$ be an appropriately sized vector. I want to solve $\mathbf L\mathbf x=\mathbf b$. ...
19
votes
1answer
159 views

What are pattern sparse arrays and how do I use them?

I found a few references to something called a "pattern sparse array" that does not contain any values, only positions. What is this data structure? How and when do I use it? From the ...
5
votes
4answers
173 views

How to populate a large sparse array efficiently

I am trying to populate a large 2D sparse array and sum up all the columns at the end. I tried generating a set of rules and then generate a matrix using SparseArray or break the data into chunks but ...
3
votes
0answers
91 views

How to speed up summing a large number of vectors

First let me explain what I am trying to do in my code. Assume that I send a very short chirp (2,000 ms long) into a domain filled with 20,000 particles randomly scattered in the domain. The ...
2
votes
3answers
96 views

How to store the nonzero elements of a sparse array in a file? [duplicate]

Often I need to use same matrix several times and for that I save them in an external file. Converting the matrix into SparseArray can save a lot of space in this ...
4
votes
3answers
298 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 & ... ...
2
votes
1answer
128 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 ...
10
votes
2answers
225 views

Analytic determinant of a sparse 25x25 matrix?

I would like to compute the analytic determinant of the following sparse matrix ...
2
votes
0answers
60 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
107 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
59 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." ...
17
votes
1answer
294 views

Simple Matrix multiplication takes very long

Bug introduced in 10.1.0 and fixed in 10.3.0 I came across some strange behaviour during a computation involving matrices with symbolic values. It is reproduced below. Multiplying a random 30x30 ...
2
votes
4answers
172 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
137 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 ...
25
votes
1answer
484 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: ...
2
votes
0answers
95 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
71 views

conditional rules for sparse matrix

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

Laplace equation

I tried to run this code, but it doesn't work for NDSolve ...
-2
votes
1answer
110 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
104 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
86 views

sparse array with list [closed]

i'm trying to populate a sparse array with lists in certain positions, i tried the following code, ...
3
votes
1answer
107 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 ...
5
votes
4answers
525 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
0answers
42 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 ...
8
votes
1answer
104 views

SparseArray output triggers “unsafe dynamic content” warning

The first basic example in the documentation of SparseArray: ...
7
votes
1answer
164 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): ...
1
vote
1answer
82 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 ...
2
votes
2answers
80 views

editing entries of a sparse array + sparse Smith normal form

Why does the following code ...
12
votes
2answers
278 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 ...
15
votes
1answer
531 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
391 views
15
votes
1answer
242 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: ...
4
votes
1answer
204 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
129 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 ...
5
votes
1answer
173 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
74 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
41 views

Interactively Manipulate SparseArrays or Lists

I'd love to use SparseArrayor List to group a set of parameters together in a function. ...