# Questions tagged [sparse-arrays]

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

256 questions
Filter by
Sorted by
Tagged with
158 views

### How I can generate a matrix from a set of terms?

I want to build a matrix, from the following set $S = \{a b , a c\}$ S = {a b , a c} where the terms of S represent the raw of the matrix ...
165 views

### Find Eigenvalues close to a Target for a Generalised Eigenvalue problem of the type Ax=λBx with A and B very sparse

So I have been using Mathematica as a tool to discretise large linear systems of PDEs and cast them as algebraic eigenvalue problems involving very large sparse matrices. These are usually complex and ...
217 views

### Why does SparseArray allow some patterns but not others?

When building a SparseArray, patterns of the form {i_, i_} and {i_, j_} are fine, but ...
121 views

### Using sparse matrices when value depends on position

I am working with solving a linear system that becomes a tridiagonal matrix. In order to speed up the process for large matrices, I want to use sparse matrices. My problem is that the values are not ...
1k views

### How to create a lists of matrices?

I would like to creat a list of matrices from the following rules: 1- All matrices of the list have diagonal equal to zero. 2- The first matrix have 2x2 dimension, ...
181 views

### Creating a list of arrays according to given rules

I want to create a list of matrices from the following rules: All matrices of the list have diagonal equal to zero. The first element of the list is a 2x2 matrix, having elements are given by ...
122 views

### Parse large ASCII matrix

I am parsing a large ASCII sparse matrix, output of PETSc, but my current implementation is impossibly slow. I don't know how I could speed that up. The ASCII file of a sparse PETSc ...
294 views

### Problems with RandomChoice

Consider an Matrix of dimension n1xn1. I would like to get a list with n2 distinct matrix (of dimension ...
234 views

### Why the sparse array is ill-conditioned?

Bug introduced in 8.0 or earlier and persisting through 11.1.0 or later Given that I have a knot vector $\mathbf U$ and a set of parameter values $\mathbf T$: ...
178 views

### Build sparse matrix in mathematica knowing position i,j and value to store, from file

I have a file formatted in this way: Row Column Value i j Vij i= INT Number row where in sparse matrix I want the ...
180 views

### Merging SparseArrays (or normal arrays)

I have a list of SparseArrays, and I want to combine them into one array that concatenates their rules. I don't want to connect them together like ...
153 views

### Multiplying SparseArray by negative number Crashes Kernel

Bug introduced in 9.0 and persisting through 11.0 Can anyone reproduce the following bug, or figure out a work-around. The following crashes the kernel on both Mathematica 10 and 11, on my macs, ...
136 views

### Nonsparse SparseArray crashes the Kernel

Bug introduced in 10.0 and fixed in 11.1 On Windows 10, 64 bit, version 11.0.1, my kernel just started crashing for no reason as for as I can see. Does/should the following crash your kernel? ...
54 views

### Map entries of StructuredArray

I have the following defintion arr = SymmetrizedArray[{1, 2} -> 1, {4, 4}, Antisymmetric[{1, 2}]] which gives a ...
69 views

### How to modify the default value of a SparseArray without intermediate non sparse matrices [duplicate]

How to modify the default value of a SparseArray? All of my ideas doesn't work, because of the ReadProtected attribute. Is there ...
264 views

### directly change the background value of a SparseArray?

given a SparseArray s = SparseArray[{1, 10} -> 1, {1, 10}, a] I can extract the background value (see What are SparseArray ...
219 views

### Bug? Strange behaviour of FullSimplify when checking an equality of SparseArray's

Edit (15 Dec '16): bug noticed in v11.0 and reported as CASE:3796403. Edit (03 May '17): bug fixed in v11.1 (verified in v11.1.1). I stumbled upon the following strange behaviour. Disclaimer: I ...
411 views

### How to find position where a sequence drops off to zero

Suppose I have a sequence seq = {0,0,0,1,2,3,1,0,0,0,4,5,8,0} and I want to find the first position after which the sequence drops to zero (which in this case, is ...
226 views

### How to build a histogram from the mean of 100 matrices

I have a matrix that looks like this: ...
36 views

616 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: ...
363 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: ...
235 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: ...