# Questions tagged [sparse-arrays]

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

329 questions
Filter by
Sorted by
Tagged with
75 views

### Efficient construction of Hermitian block matrix

I need to construct large Hermitian matrices $H$, which can be built out of blocks. The matrix $H$ is of total size $Lx\times Ly$, with blocks of size $Ly$. For $Lx=5,\,Ly=3$ and $L=2$ (which is the ...
• 85
1 vote
58 views

### Arnoldi method for generalized eigenvalue problem with sparse matrices

I would like to solve a generalized eigenvalue problem involving sparse matrices using the Arnoldi method. I would like to use the Arnoldi method in the hope of speeding up the calculation. Problem is,...
• 361
53 views

### Workaround for SparseArray "ExplicitPositions" in version 12.0

I have some work that utilizes the "ExplicitPositions" property of Sparse Arrays that was at least available starting at version 13.0. However, I am trying to run some of my work on a ...
• 1,134
82 views

• 777
185 views

### Defining a SparseArray functions in Mathematica 13

I am defining a sparse array as a function of argument x, i.e. f[x_] = SparseArray[{1->x}, {3}] In Mathematica 12 this works perfectly, I can pass arguments and ...
• 91
975 views

### How to convert an SparseArray into a Matrix?

I have the following sparse array and I want to change it to a matrix. Could you please tell me how to do that? ...
124 views

### How to create a 3D matrix from different blocks?

I would like to generate a $3D$ matrix of dimension $(n1\times n1\times n1)$ compose of $216$ matrix blocks $(n2\times n2\times n2)$. All 216 matrix blocks are subdivided into 4 groups, each one with ...
• 1,335
205 views

### SparseArray Input

How to create a SparseArray without using lists of rule in MMA? In MMA we can define a SparseArray using lists of rule ...
• 1,856
55 views

### Is there a way to make SparseArray distinguish between background values of different precision that are numerically equal?

To illustrate what I mean, consider the following: SparseArray[{{1} -> 1, {5} -> 1.}, Automatic, 0] // Normal {1, 0, 0, 0, 1.} As you can see, the ...
• 23.8k
34 views

The code ...
• 183
203 views

### Building a Matrix as a piecewise-function of the indices without for loops [closed]

I'm very new to Mathematica and this site. I've read that building matrices with For loops is slow, and I have experienced this myself on the current project. I'm trying to wrap my head around ...
110 views

### How to efficiently build a large sparse matrix and overloading a compiled function?

I would like to construct a large sparse matrix folding from rank-4 tensor given by the following: $\mathcal{L}_{1L}^{00}(i,j)=\mathcal{L}_{1L}^{00}(m_1,m_2;M_1,M_2)$ The indices of matrix $(i,j)$ are ...
• 445
478 views

### Speedup the production of a sparse symmetric matrix with a dense vector

The optimization of the production of a sparse symmetric matrix with a dense vector has existed for a long time. Someone once compared the matrix operations of Mathematica with MATLAB, and then came ...
• 141
1 vote
138 views

### How to dynamically define matrix with blocks in subdiagonals?

...
• 445
1 vote
I am trying to create a sparse matrix by the SparseArray command. For a set of index pairs $(i,j)$ I want to calculate the $A_{i,j}$ element and then use this ...