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

learn more… | top users | synonyms

16
votes
3answers
712 views

Efficient way to combine SparseArray objects?

I have several SparseArray objects, say sa11, sa12, sa21, sa22, which I would like to combine into the equivalent of {{sa11, sa12}, {sa21, sa22}}. As an example, I ...
5
votes
2answers
252 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 ...
14
votes
1answer
281 views

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

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. Let's generate a large sparse matrix: ...
6
votes
2answers
567 views

Efficient by-element updates to SparseArrays

I have a very large SparseArray called A. What is the most efficient way to update say element ...
4
votes
3answers
236 views

SparseArray row operations

Given a large (very) sparse matrix, A, how can I efficiently "operate" on only the nonzeros in a given row? For example: For each row in A, generate a list of column indices that have a magnitude ...
1
vote
1answer
482 views

Import Excel sheet into 3D array?

I have an excel spreadsheet that I would like to plot in a 3D graph using mathematica. The X and Y values are the location of the cell, and the Z value is the number of the scale. How can I import ...
9
votes
2answers
420 views

Speeding up construction of simple tridiagonal matrix

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

How to relate memory usage with occupied positions of SparseArrays?

What is the relation of memory usage of a SparseArray and the number of its occupied positions? Let's say you build a 100.000.000 by 10 element SparseArray. And fill the two position 1/1 and ...
11
votes
2answers
197 views

Bug with SparseArray selector in Pick

I have created a notebook with two cells. This is the content of the first: ...
10
votes
1answer
1k views

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

Note: This is fixed in 9.0.1. In Mathematica 9, if I display any large SparseArray object in the default way (which looks something like ...
16
votes
2answers
769 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 ...
14
votes
6answers
567 views

Matrix Rotation

If I have a matrix of any size, say $\begin{pmatrix} 72 & 32 & 64 \\ 18 & 8 & 16 \\ 63 & 28 & 56 \\ \end{pmatrix}$ $\begin{pmatrix} 72 & 32 \\ 18 & 8 \\ 63 ...
9
votes
2answers
294 views

Speed up 4D matrix/array generation

I have to fill a 4D array, whose entries are $\mathrm{sinc}\left[j(a-b)^2+j(c-d)^2-\phi\right]$ for a fixed value of $\phi$ (normally -15) and a fixed value of $j$ (normally about 0.00005). The way ...
8
votes
1answer
778 views

Exporting a Large Multidimensional Sparse Array

I'm trying to export a sparse array from Mathematica to share with collaborators who primarily use Matlab. The sparse array in question is 4 dimensional, (72 x 93 x 94 x 172) with ~4M non-zero ...
6
votes
1answer
334 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 ...
4
votes
2answers
110 views

Values (or positions) of array row elements within a specified number of positions from target value

I have the need to collect values from the rows of rectangular arrays of arbitrary precision integers, given a target element value and allowed "distance" (positions +/- within the row from found ...
3
votes
1answer
300 views

How to get the determinant and inverse of a large sparse symmetric matrix?

For example, the following is a $12\times 12$ symmetric matrix. Det and Inverse take too much time and don't even work on my ...
5
votes
0answers
99 views

SparseArray internal structure [duplicate]

According to the documentation: SparseArray is treated as a raw object by functions like AtomQ and for purposes of pattern ...
5
votes
1answer
175 views

What's wrong with this code to create a matrix?

Here is my code: ...
4
votes
3answers
319 views

Finding elements from a sparse matrix

I am dealing sparse matrices of very large dimensions. I need to locate the positive and negative elements of the matrices and make lists of their corresponding positions. Of course I can write a ...
3
votes
3answers
323 views

Support for Compressed Sparse Column sparse matrix representation

Is there native support for Compressed Sparse Column (CSC) format for sparse matrices, like importing and manipulating them?