Questions tagged [sparse-arrays]
Questions on the construction and manipulation of sparse arrays in Mathematica, with functions like SparseArray[] and Band[].
335 questions
5
votes
1
answer
138
views
How to quickly extract a consecutive portion of a sparse vector?
Say I have this very sparse vector of gigantic size:
...
3
votes
1
answer
98
views
BinCounts: force/block SparseArray output
BinCounts sometimes outputs data as SparseArray, and sometimes Normal.
This does not depend ...
1
vote
2
answers
166
views
Creating a large sparse array
I want to create a large sparse matrix by given 2 matrices with dimensions of $m\times m$ and $n\times n$. It will not be $6\times 6$ as in the picture, I only tried to give a simple example. I do not ...
4
votes
1
answer
292
views
How does Mathematica MatrixExp Krylov method scale with sparse matrices? [closed]
People say that mathematica is not as good as matlab for nunmerics. For my specific use case, I am trying to solve differential equations with the MatrixExp method ...
1
vote
0
answers
137
views
Efficient eigenvalue calculation of large matrix
My question is related to my issue from yesterday (Initializing very large matrices). It was recommended to use SparseArray to initialize large matrices efficiently....
3
votes
2
answers
198
views
Best way to extend the size and add terms to a SparseArray without expanding
Let's say I have a "small" SparseArray of any size, in the example $2\times2$
...
3
votes
1
answer
151
views
There is a mistake when using SparseArray in the Table function
I discovered a difference between version 12.0 and version 14.0 in how they handle SparseArray within the Table function.
For ...
0
votes
0
answers
134
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 ...
3
votes
1
answer
268
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,...
6
votes
1
answer
80
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 ...
4
votes
2
answers
192
views
Speed up sparse Hermitian matrix-vector product
I am interested in speeding up as much as possible the dot product in the specific case of a multiplication of a $n\times n$ sparse hermitian matrix $H$ (where $n$ is typically large, let's say $\...
6
votes
1
answer
198
views
MapIndexed on a table of SparseArray structures produces different output in Mathematica 12 and 14.0
Here is a snippet I use to dynamically define a bunch of functions f[i][x_]:
...
7
votes
3
answers
291
views
Counting non-zero multiplications in large sparse matrix multiplications
Suppose I have several large, fixed, sparse matrices of real-valued entries. To make things simple, assume each is $n \times n$. I will multiply them, e.g., matA.matB.matC. Of course I can reduce ...
3
votes
2
answers
262
views
Creating a sparse matrix
I would like to create the following sparse matrix
\begin{equation}
A =
\begin{pmatrix}
a1+b1 t & k-1 & 0 & \ldots &0 \\
a2^{2}+b2^{2} t & a1+b1t & k-2 & \ldots &0 \...
5
votes
2
answers
307
views
Efficiently construct a SparseArray of a given "shape"
I have a given SparseArray, let's call it A.
I want to construct another SparseArray, let's call it B, which has the same "shape" as A.
Right now, I construct B by applying a certain ...