# Questions tagged [sparse-arrays]

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

260 questions
Filter by
Sorted by
Tagged with
136 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 ...
61 views

### Interactively Manipulate SparseArrays or Lists

I'd love to use SparseArrayor List to group a set of parameters together in a function. ...
178 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): ...
197 views

### Bug in PositiveDefiniteMatrixQ?

Fixed in 10.1.0. Exists in at least 9.0.1 -- 10.0.2. This seems like a bug in PositiveDefiniteMatrixQ to me: ...
454 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. <...
169 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: ...
1k 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 ...
463 views

### The Jacobi-Davidson method

Does any implementation of the Jacobi-Davidson method for Mathematica exist? A highly parallelized version for sparse matrices would be of special interest.
71 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 ...
555 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 ...
650 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: ...
390 views

### How to handle a sparse array of lists

I have data in the form of a sparse array of lists. For example: ...
133 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 ...
271 views

### Bug with SparseArray selector in Pick

Bug introduced in version 8 or earlier and fixed in 10.0 I have created a notebook with two cells. This is the content of the first: ...
156 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 ...
639 views

### Manipulating sparse array elements

Suppose I have two sparse arrays ...
5k 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 ...
1k 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 ...
66 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 ...
244 views

### Sporadic bugs in multidimensional SparseArray objects

Bug introduced in 9.0 and fixed in 10.0 Update This SparseArray[] bug is (apparently) fixed on version 10.0 ...
200 views

### Product of non-zero elements in sparse array

How can I multiply the non-zero elements of a SparseArray? Example: ...
455 views

### Specify positions in a SparseArray using patterns with functions

I spent some time trying to figure out what was what was making so slow the calculation of the following array(actually this is only a SUPERsimple toy model): Input to the array: ...
178 views

### Efficient storage of Kronecker sum of circulant matrices+diagonal matrix

I have a square matrix of the form $$M=D+\overset{N}{\underset{n=1}\bigoplus}R_n,$$ where $R_n$ are circulant matrices, $D$ is a diagonal matrix and $\oplus$ is Kronecker sum. Its size is quite big, ...
256 views

### Opposite function to Normal

Is there any function opposite to Normal? For example, let as say that I have an SparseMatrix A, then, let as say that for convenience for a certain operation like Packing, I convert it into an Array ...
818 views

### Approximate minimum degree permutation algorithm in Mathematica

In MATLAB there is a nice implementation of the so called AMD (approximate minimum degree permutation) algorithm named amd (see Online MATLAB Documentation). There is an alternative algorithm called ...
529 views

### Upsampling matrix by inserting zeros in between elements

I want to essentially take an image with $n \times n$ pixels and expand it into a sparse array, spacing out the pixels by a factor $2$ or $3$. Each pixel in the input image occupies one of the corners ...
545 views

The goal is to assemble a SparseArray in an additive fashion. Let us assume we have a large List of indices (some will be ...
146 views

### ArrayRules for a ragged list

Let there be a sample list as , l = {a, {{b, c}}, {d, e}, {f}, {{g, {y}, u, h}, {{{{k, j}}}}},k, {{{{q}, {w}, {r}, {x}}}}}; ArrayRules[l] ArrayRules::rect: ...
439 views

304 views

1k 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 ...
986 views

### How to create a large sparse block matrix

I need to generate a very large sparse block matrix, with blocks consisting only of ones along the diagonal. I have tried several ways of doing this, but I seem to always run out of memory. The ...
451 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. Let's ...
987 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 ...