# Tagged Questions

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

73 views

### Why isn't SparseArray working in this case?

This works: SparseArray[{{1, 1} -> 1, {2, 2} -> 2}]\ (* {{1, 0}, {0, 2}} *) This works: ...
100 views

### Efficiently compute this Table of NullSpace

I have two $(2n,2n)$ matrices, $A_1$ and $A_2$, and I would like to compute $$\ker(A_1^p A_2^q -I)$$ for $p,q\leq 2n$. Both matrices are orthogonal and have exactly four non-zeros values on each ...
303 views

### Why is IdentityMatrix not defined as a SparseArray by default?

Simple (possibly silly) question: why are IdentityMatrix, DiagonalMatrix, ConstantArray ...
77 views

### What would be the Mathematica equivalent of sparse in MATLAB?

The sparse function in MATLAB does the following: S = sparse(i,j,v) generates a sparse matrix S from the triplets i, j, and v such that S(i(k),j(k)) = v(k). The ...
147 views

### Something wrong when I apply Derivative on a SparseArray

Bug introduced in v5.0 or earlier, and persisting through v10.4.1. There, I create a SparseArray using command ...
36 views

### Matrix with equations as entries - how to choose them and solve them

I have a matrix in Mathematica, which I have built using Normal[SparseArray]. Each entry of this matrix is an equation in one variable. What I need to do is 1) to select some of the entries of the ...
120 views

### Using Cases to pick out entries of a SparseArray

I'm trying to use a SparseArray for some large homological algebra calculations. I'd like to find indices of a SparseArray ...
118 views

### Possible Bug in LinearSolveFunction with Sparse Vectors

Bug introduced in 5.0 and persists through 10.4.1 LinearSolveFunction is new in 5.0 Consider the following set of equations and corresponding variables: ...
70 views

### How to compile code that involve sparse array?

I have the following code ...
162 views

### Nonzero element positions of a matrix

Let m={{1, 2, 0}, {4, 0, 9}}; I want to find the position of every nonzero element of the above matrix. The code ...
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: ...
256 views

### LinearSolve and Krylov Method options

I need to solve a large, sparse, linear system. At some point Method -> "Multifrontal" fails and a bit later also "Pardiso" ...
64 views

### How to create overlapped block matrices and simplify the result

This is sort of a duplicate of Creating overlapped block matrices, but the question wasn't fully answered since the OP never returned to clarify. I am using Kuba's answer for FEM, but I have been ...
395 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 ...
86 views

### How to convert a matrix into a sparse matrix [duplicate]

If I have a matrix: row 1)1 0 0 4 row 2)0 0 0 0 row 3)5 1 0 0 row 4)0 5 0 0 row 5)0 0 0 9 How would I put it in a sparse matrix format: ...
59 views

...
101 views

### efficient element wise multiplication of SparseArray vector and matrix

I have a large SparseArray $P$ of dimensions $\{d,d\}$ and I want to multiply a vector (also a SparseArray) $v$ of length $d$ ...
256 views

### How to convert a sparse matrix to a list of sparse arrays?

I have a matrix stored as a SparseArray. How can I convert it to a List of its rows, where each row is stored as a ...
177 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: ...
62 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: ...
295 views

251 views

### Analytic determinant of a sparse 25x25 matrix?

I would like to compute the analytic determinant of the following sparse matrix ...
138 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 ...
490 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 ...
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) ...
3k 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 ...
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 (...
53 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 ...