# Questions tagged [sparse-arrays]

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

300 questions
Filter by
Sorted by
Tagged with
129 views

### Insert a dynamic vector into a matrix

If I have the following dynamic vector Cs[NN_] := Table[{Sin[(2*i - 1) τ], Sin[(2*i - 1) τ]}, {i, 1, NN}] // Flatten The size of Cs depends on the integer ...
• 1,163
1 vote
69 views

### Plotting multidimensional tables

I have a tridiagonal matrix created by ...
• 295
34 views

### Trying to map SparseArray over a defined list, the SparseArray defined with 3 subvalues i want to map the 3rd. subValue(list) over the defined list

I have a SparseArray already defined as following ...
1 vote
50 views

### Erratic behavior retrieving large data (several tens of gigabytes) that has been serialized by Mathematica

Hardware: PC with 256GB RAM OS: Windows 10 Mathematica: Version 13.0.1 One of my projects has led to the creation of a SparseArray whose ByteCount is ~ 35GB in RAM. At the time of creation the ...
• 2,024
80 views

### Define a function with sparsearray

I am trying to define a function using SparseArray, but the entries were defined before. How can I avoid this error? Code is: ...
• 111
1 vote
20 views

### Why does Sparsearray diagonalization by Krylov technique become slower for very large sizes?

Here is an example sparse matrix, taken from example Hamiltonian, which was a question I asked before in this forum. ...
22 views

### Threshold on triangular SparseArray

I am confused by the behavior of Threshold on sparse UpperTringularize (and LowerTringularize...
• 7,503
68 views

### Fastest Way to make rows and columns zero and corresponding (i,i) element 1 of a large Sparse Matrix

I have a 5552 by 5552 sparse matrix: ...
230 views

• 41
201 views

### Permute association key and generate a sparse array

Imagine having an Association Av = <|{1, 4, 2, 3} -> a, {2, 4, 2, 4} -> b|> It can be much longer. I am searching ...
• 15.7k
65 views

### How can I define a function using ArrayFlatten without using SetDelayed?

I created a matrix F2 using SparseArray and ArrayFlatten as follows: ...
• 2,977
61 views

### Seeming inconsistencies with "Eigenfunction" [duplicate]

I am working on a problem which involves calculating the spectrum of a family of 2970x2970 Hermitian matrices. I have done similar things with Mathematica in the past, but this time there is an odd, ...
• 595
62 views

• 179
57 views

### How do I pass indices to a function when constructing a SparseArray?

I am trying to speed up my Mathematica code, so instead of testing and calculating the same thing again and again I want to save the result in a SparseArray. The goal is to generate a matrix which I ...
• 1,005
108 views

### Import and export a list of SparseArrays efficiently?

I have a list of integers dims and a list of SparseArrays bdrs (representing a chain complex ...
• 1,095
53 views

### How to find the rank of a sparse-array list without memory leaks?

I have a very wide list of sparse arrays (I basically just used the numbers as an encoding mechanism for vectors of polynomials), and I want to find out whether they're linearly independent. How ...
• 862
242 views

### Efficiently populate sparse matrix with band structure

I'm trying to efficiently populate elements of a very large (2^20 x 2^20) symmetric matrix with 1s - luckily the matrix is very sparse, <0.1% filling. Further, the matrix has a very well defined ...
• 811
272 views

### Multiplying two complex SparseArray objects, yielding empty SparseArray crashes kernel

Problem: When I multiply together two sparse matrices that should give back the 0 matrix, where at least one element among the two is complex and at least one is not an exact number, the kernel ...
• 1,814
268 views

### SparseArray to list of lists (column entries) efficiently?

Suppose we have a very big very sparse matrix, e.g.: ...
• 1,095
1 vote
57 views

### How to apply PolynomialMod to a SparseArray?

I have a list bdrs of SparseArrays, whose entries are polynomials in the variable t with ...
• 1,095
239 views

### Count for SparseArray

Why does Count not work with SparseArrays, and is there any function I can use to replace it? What would be an efficient ...
• 459