# Tagged Questions

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

114 views

### Laplace equation

I tried to run this code, but it doesn't work for NDSolve ...
126 views

### Recreating in Mathematica a matrix created in Python [closed]

I need to recreate in Mathematica this matrix that I created in Python: ...
111 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 ...
98 views

### sparse array with list [closed]

i'm trying to populate a sparse array with lists in certain positions, i tried the following code, ...
126 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 ...
536 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, ...
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 (...
111 views

### SparseArray output triggers “unsafe dynamic content” warning

The first basic example in the documentation of SparseArray: ...
174 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): <...
91 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 ...
86 views

### editing entries of a sparse array + sparse Smith normal form

Why does the following code ...
302 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 ...
725 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 ...
487 views

### How to speed up band matrix-matrix multiplication?

I have a band matrix ...
280 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: ...
228 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 \\ & &{} + \int_{x_0}...
147 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 ...
402 views

### How to convert a sparse array to a graph?

s = Import["hello.mat"]; t = GraphEmbedding[Graph[s[[1]]], "GridEmbedding"]; I get the following error: GraphEmbedding::graph: A graph object is expected ...
212 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 ...
79 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 ...
48 views

### Interactively Manipulate SparseArrays or Lists

I'd love to use SparseArrayor List to group a set of parameters together in a function. ...
156 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): ...
158 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: ...
244 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. <...
82 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: ...
605 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 ...
60 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 ...
406 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 ...
352 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: ...
176 views

### How to handle a sparse array of lists

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

### Manipulating sparse array elements

Suppose I have two sparse arrays ...
2k 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 ...
817 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 ...
54 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 ...
205 views

### Sporadic bugs in multidimensional SparseArray objects

Udate This SparseArray[] bug is (apparently) fixed on version 10.0 ...
171 views

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

How can I multiply the non-zero elements of a SparseArray? Example: ...
217 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: ...
117 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, ...
134 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 ...
267 views

### Upsampling matrix by inserting zeros inbetween 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 ...
290 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 ...
120 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: ...
267 views

### How to create a SparseArray satisfying multiple conditions on Parts and Elements of a Matrix?

I have a matrix m1 of size $3 \times 19$. Rows $1$, $2$ and $3$ represent $3$ different groups, and columns represent $4$ different blocks: block1 - columns $1$, ...
561 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 (...
103 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) ...
156 views

### Assigning Sequence to Part of a SparseArray (bug?)

Part ▪ You can make an assignment like t[[spec]]=value to modify any part or sequence of parts in an expression. ▪ If <...
410 views

### Is it in general faster to get the eigenvectors and eigenvalues of a dense array rather than a sparse array?

I always thought that things in general go faster when working with sparse array but, I got this: Eigenvalues::arhm: Because finding 144 out of the 144 ...