Skip to main content

Questions tagged [sparse-arrays]

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

0 votes
0 answers
78 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 ...
Kaio's user avatar
  • 85
1 vote
1 answer
62 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,...
coussin's user avatar
  • 361
6 votes
1 answer
54 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 ...
BioPhysicist's user avatar
  • 1,134
4 votes
2 answers
88 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 $\...
Matteo's user avatar
  • 283
6 votes
1 answer
141 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_]: ...
jrekier's user avatar
  • 525
7 votes
3 answers
177 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 ...
David G. Stork's user avatar
3 votes
2 answers
182 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 \...
Shasa's user avatar
  • 1,043
5 votes
2 answers
188 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 ...
coussin's user avatar
  • 361
1 vote
1 answer
173 views

Why does using a sparse matrix for least squares instead slow down the speed?

Here is the code. The matrix appears to be relatively sparse in terms of its visual representation, but why does using least squares result in significantly slower speed compared to the previously ...
Yilin Cheng's user avatar
2 votes
0 answers
69 views

Performance of multiplying two identity matrices

I am running Mathematica 13.3.1.0 on a M1 Mac, and I ran the following codes to check on the time spent on matrix multiplication. ...
Lelouch's user avatar
  • 543
0 votes
0 answers
57 views

Sparse Kronecker Product of Pauli Matricies

Suppose I have a list of Pauli matrices (X, Z and I type) paulis = {x,z,z,i,z,x,i,z}; I would like to compute a sparse array equivalent to $$x \otimes z\otimes z \...
user2757771's user avatar
1 vote
1 answer
49 views

Best way to Simplify (or applying other functions to) a SymmetrizedArray

I wanted to perform an element-wise Simplify[] on a SymmetrizedArray, but I couldn't find an efficient way to do so without converting it to a "Normal" ...
infernophys's user avatar
8 votes
1 answer
314 views

How can I prevent conversion of a SparseArray to a DenseArray?

The Problem I'm trying to implement an efficient Whitker-Eliers smoother in Mathematica. In Matlab, this is a few lines of code (taken from the SI of the above paper): ...
BesselFunct's user avatar
5 votes
2 answers
195 views

Reshaping sparse arrays to have extra index

I have an $n \times m \times p$ array, let's call it $r$. I want to obtain an $n \times m \times p \times 5$ array (let's call it $q$) where $q$ is the same as $r$ except that every non-zero component ...
Facieod's user avatar
  • 175
6 votes
1 answer
114 views

DeleteDuplicates without destroying SparseArray

When I use DeleteDuplicates to delete equal rows of a sparse array, the output is not a sparse array anymore. In my application, the sparse arrays are huge but very ...
Gert's user avatar
  • 1,620

15 30 50 per page
1
2 3 4 5
22