# \#sparse

**URL:** https://discourse.julialang.org/tag/sparse/368.md

[Latest](https://discourse.julialang.org/latest.md) · [Categories](https://discourse.julialang.org/categories.md) · [Tags](https://discourse.julialang.org/tags.md)

---

## [Sparse vector in imfilter kernel](https://discourse.julialang.org/t/sparse-vector-in-imfilter-kernel/139133)

<div class="topic-metadata">

**Author:** [@xor0110](https://discourse.julialang.org/u/xor0110)\
**Replies:** 0\
**Last updated:** [September 1, 2026, 7:00am UTC](https://discourse.julialang.org/t/sparse-vector-in-imfilter-kernel/139133 "2026-09-01T07:00:33Z")

</div>

What would it take to make ImageFiltering.imfilter work with sparse or “dilated” kernels? I know it supports OffsetArrays, for instance. We basically need to skip every few values so a filter like \[-1,0,0,0,1\] only perfo…

---

## [Downsampling of binary images](https://discourse.julialang.org/t/downsampling-of-binary-images/61425)

<div class="topic-metadata">

**Author:** [@ettersi](https://discourse.julialang.org/u/ettersi)\
**Replies:** 1\
**Last updated:** [July 17, 2026, 4:06am UTC](https://discourse.julialang.org/t/downsampling-of-binary-images/61425 "2026-07-17T04:06:49Z")

</div>

The spy-style printing of sparse matrices that landed in v1.6 is awesome, but it turns out that the downsampling used for very large matrices has some aliasing issues, see https://github.com/JuliaLang/julia/issues/40799.…

---

## [Best practice: threaded sparse matrix assembly](https://discourse.julialang.org/t/best-practice-threaded-sparse-matrix-assembly/137447)

<div class="topic-metadata">

**Author:** [@tduretz](https://discourse.julialang.org/u/tduretz)\
**Replies:** 13\
**Last updated:** [June 6, 2026, 1:57pm UTC](https://discourse.julialang.org/t/best-practice-threaded-sparse-matrix-assembly/137447 "2026-06-06T13:57:05Z")

</div>

What is current state-of-the-art regarding threaded sparse matrix assembly? We’re currently having an issue where sparse matrix assembly is taking more time than the linear solver (at low resolutions). One way to improv…

---

## [Is the linear system solver \\ also multi threaded in Julia as in Matlab? And how to “multithread” it in Julia?](https://discourse.julialang.org/t/is-the-linear-system-solver-also-multi-threaded-in-julia-as-in-matlab-and-how-to-multithread-it-in-julia/47404)

<div class="topic-metadata">

**Author:** [@nico](https://discourse.julialang.org/u/nico)\
**Replies:** 34\
**Last updated:** [May 1, 2026, 7:34am UTC](https://discourse.julialang.org/t/is-the-linear-system-solver-also-multi-threaded-in-julia-as-in-matlab-and-how-to-multithread-it-in-julia/47404 "2026-05-01T07:34:35Z")

</div>

I am trying to compare speed and performance between Matlab and Julia. I am looking at a code that does topology optimization of a continuum structure subjected to a given load. The code I am looking at is the public cod…

---

## [What is the fastest way of realizing transpose of a CSR (or CSC) matrix?](https://discourse.julialang.org/t/what-is-the-fastest-way-of-realizing-transpose-of-a-csr-or-csc-matrix/136241)

<div class="topic-metadata">

**Author:** [@PetrKryslUCSD](https://discourse.julialang.org/u/PetrKryslUCSD)\
**Replies:** 33\
**Last updated:** [March 19, 2026, 7:37pm UTC](https://discourse.julialang.org/t/what-is-the-fastest-way-of-realizing-transpose-of-a-csr-or-csc-matrix/136241 "2026-03-19T19:37:49Z")

</div>

What is the fastest way of realizing sparse matrix transpose? I don’t mean a lazy transpose, I mean realization such that typeof(CSC') === typeof(CSC) (and analogously for CSR). There seems to be the algorithm of Gustav…

---

## [Block Jacobian Storage for DSGE](https://discourse.julialang.org/t/block-jacobian-storage-for-dsge/136053)

<div class="topic-metadata">

**Author:** [@charlesknipp](https://discourse.julialang.org/u/charlesknipp)\
**Replies:** 0\
**Last updated:** [March 5, 2026, 9:17pm UTC](https://discourse.julialang.org/t/block-jacobian-storage-for-dsge/136053 "2026-03-05T21:17:09Z")

</div>

Summary When working with large system matrices, it is often convenient to express them in block form; moreover, since I consider a particular class of dynamic models, this system often yields a block Toeplitz form which…

---

## [SparseArrays vs CUSPARSE](https://discourse.julialang.org/t/sparsearrays-vs-cusparse/135320)

<div class="topic-metadata">

**Author:** [@rcalxrc08](https://discourse.julialang.org/u/rcalxrc08)\
**Replies:** 0\
**Last updated:** [January 29, 2026, 10:55am UTC](https://discourse.julialang.org/t/sparsearrays-vs-cusparse/135320 "2026-01-29T10:55:13Z")

</div>

I have no idea if this is intentional or not, at the moment there is an inconstency in the julia and or CUDA stack when dense and sparse vectors are interacting: using SparseArrays, CUDA N=10 x\_cpu=randn(N); x\_sparse=sp…

---

## [Eigenvalues of large, sparse matrices](https://discourse.julialang.org/t/eigenvalues-of-large-sparse-matrices/135208)

<div class="topic-metadata">

**Author:** [@pjk](https://discourse.julialang.org/u/pjk)\
**Replies:** 11\
**Last updated:** [January 23, 2026, 7:24pm UTC](https://discourse.julialang.org/t/eigenvalues-of-large-sparse-matrices/135208 "2026-01-23T19:24:55Z")

</div>

Hi all, I am working on a problem which involves the calculation of the eigenvalues (specifically the spectral radius) of matrices with a particular structure. These are specifically sparse, asymmetric matrices with bin…

---

## [How to efficiently update a Sparse Matrix (Diagonal + Sparse) in-place inside a hot loop?](https://discourse.julialang.org/t/how-to-efficiently-update-a-sparse-matrix-diagonal-sparse-in-place-inside-a-hot-loop/134705)

<div class="topic-metadata">

**Author:** [@Matt\_jl](https://discourse.julialang.org/u/Matt_jl)\
**Replies:** 3\
**Last updated:** [December 23, 2025, 3:51pm UTC](https://discourse.julialang.org/t/how-to-efficiently-update-a-sparse-matrix-diagonal-sparse-in-place-inside-a-hot-loop/134705 "2025-12-23T15:51:57Z")

</div>

Hi everyone, I am working on an iterative algorithm where I need to construct and solve a linear system inside a “hot loop”. Currently, my code allocates a new sparse matrix A at every iteration because of the operati…

---

## [Eigenvectors with the most overlap with v](https://discourse.julialang.org/t/eigenvectors-with-the-most-overlap-with-v/134008)

<div class="topic-metadata">

**Author:** [@Nichola](https://discourse.julialang.org/u/Nichola)\
**Replies:** 7\
**Last updated:** [December 18, 2025, 1:39am UTC](https://discourse.julialang.org/t/eigenvectors-with-the-most-overlap-with-v/134008 "2025-12-18T01:39:40Z")

</div>

Given a sparse matrix M and a vector v, I would like to get the k eigenvectors of M that have the most overlap with v. Is there an efficient method for doing this with sparse matrices ? All sparse solvers I ran into tar…

---

## [Thread-safety of SparseArray](https://discourse.julialang.org/t/thread-safety-of-sparsearray/134468)

<div class="topic-metadata">

**Author:** [@songjhaha](https://discourse.julialang.org/u/songjhaha)\
**Replies:** 5\
**Last updated:** [December 10, 2025, 9:42pm UTC](https://discourse.julialang.org/t/thread-safety-of-sparsearray/134468 "2025-12-10T21:42:42Z")

</div>

The setindex! op of SparseArray is not thread-safe. There is a MWE: function foo(x::AbstractArray) y = similar(x) Threads.@threads for i = 1:length(x) y\[i\] = cos(x\[i\]) end end using SparseArrays x = …

---

## [Linear Algebra Manipulations with Cholesky Factors](https://discourse.julialang.org/t/linear-algebra-manipulations-with-cholesky-factors/133899)

<div class="topic-metadata">

**Author:** [@gideonsimpson](https://discourse.julialang.org/u/gideonsimpson)\
**Replies:** 1\
**Last updated:** [November 15, 2025, 6:51pm UTC](https://discourse.julialang.org/t/linear-algebra-manipulations-with-cholesky-factors/133899 "2025-11-15T18:51:20Z")

</div>

I’m working on a problem where I need to do some Gaussian random variable sampling, which would naive be implemented as: nx = 10 e = ones(nx) A = spdiagm(-1 =\> -e\[1:end-1\], 0 =\> 2e, 1 =\> -e\[1:end-1\]) chol = cholesky(A, …

---

## [Is there a package for block-sparse matrix processing?](https://discourse.julialang.org/t/is-there-a-package-for-block-sparse-matrix-processing/133067)

<div class="topic-metadata">

**Author:** [@photor](https://discourse.julialang.org/u/photor)\
**Replies:** 5\
**Last updated:** [October 12, 2025, 7:46pm UTC](https://discourse.julialang.org/t/is-there-a-package-for-block-sparse-matrix-processing/133067 "2025-10-12T19:46:11Z")

</div>

As in the title, I mean every block is dense, but there are only a small percentage of non-vanishing blocks.

---

## [Large Sparse Hermitian Matrix - Intermediate Eigenvalue Problem](https://discourse.julialang.org/t/large-sparse-hermitian-matrix-intermediate-eigenvalue-problem/131600)

<div class="topic-metadata">

**Author:** [@Neilis](https://discourse.julialang.org/u/Neilis)\
**Replies:** 9\
**Last updated:** [September 23, 2025, 2:22pm UTC](https://discourse.julialang.org/t/large-sparse-hermitian-matrix-intermediate-eigenvalue-problem/131600 "2025-09-23T14:22:14Z")

</div>

Hi, I am trying to find eigenvalues and eigenvectors for a rather large, sparse, hermitian matrix (size ~1E7 x 1E7). I am mainly interested in around 40 eigenvalues in the middle of the spectrum. To solve this original…

---

## [Sparse 3D arrays](https://discourse.julialang.org/t/sparse-3d-arrays/16488)

<div class="topic-metadata">

**Author:** [@jw3126](https://discourse.julialang.org/u/jw3126)\
**Replies:** 10\
**Last updated:** [September 17, 2025, 7:17am UTC](https://discourse.julialang.org/t/sparse-3d-arrays/16488 "2025-09-17T07:17:41Z")

</div>

It seems that SparseArrays only offers sparse vectors and matrices. Are there packages for higher dimensional sparse arrays? I am mainly interested in 3d.

---

## [Efficient representation of a sparse "pentadiagonal" matrix?](https://discourse.julialang.org/t/efficient-representation-of-a-sparse-pentadiagonal-matrix/131744)

<div class="topic-metadata">

**Author:** [@bremez](https://discourse.julialang.org/u/bremez)\
**Replies:** 8\
**Last updated:** [August 21, 2025, 6:53pm UTC](https://discourse.julialang.org/t/efficient-representation-of-a-sparse-pentadiagonal-matrix/131744 "2025-08-21T18:53:13Z")

</div>

I am interested in the eigenspectrum of Hermitian matrices that have a “pentadiagonal” structure, with A\[m,n\]=0 if abs(m-n)\>2. I am most interested in eigenstates with values close to zero. At present I am using Arpack.j…

---

## [Sparse matrix multiplication for Metal](https://discourse.julialang.org/t/sparse-matrix-multiplication-for-metal/131088)

<div class="topic-metadata">

**Author:** [@Marco\_Lombardi](https://discourse.julialang.org/u/Marco_Lombardi)\
**Replies:** 15\
**Last updated:** [July 31, 2025, 5:59pm UTC](https://discourse.julialang.org/t/sparse-matrix-multiplication-for-metal/131088 "2025-07-31T17:59:44Z")

</div>

I need to perform a multiplication between two fairly large sparse matrices C = A \* B and I would like to try using the GPU for that. The problem arises in a context where A represents a fixed 2D convolution kernel, whil…

---

## [Combining \`SparseDiffTools.jl\` and \`OrdinaryDiffEq.jl\`](https://discourse.julialang.org/t/combining-sparsedifftools-jl-and-ordinarydiffeq-jl/130555)

<div class="topic-metadata">

**Author:** [@DanDoe](https://discourse.julialang.org/u/DanDoe)\
**Replies:** 8\
**Last updated:** [July 9, 2025, 10:53am UTC](https://discourse.julialang.org/t/combining-sparsedifftools-jl-and-ordinarydiffeq-jl/130555 "2025-07-09T10:53:43Z")

</div>

I managed to get the sparsity structure detection (via SparseDiffTools.j) of the rhs! function (the RHS of the ODE problem fed into OrdinaryDiffEq.jl) for our code Trixi.jl to run. Can I supply the cache = sparse\_jacob…

---

## [SparseDiffTools - PolyesterForwardDiff Pre-allocation difficulties](https://discourse.julialang.org/t/sparsedifftools-polyesterforwarddiff-pre-allocation-difficulties/130292)

<div class="topic-metadata">

**Author:** [@cardoza2](https://discourse.julialang.org/u/cardoza2)\
**Replies:** 20\
**Last updated:** [July 8, 2025, 10:10am UTC](https://discourse.julialang.org/t/sparsedifftools-polyesterforwarddiff-pre-allocation-difficulties/130292 "2025-07-08T10:10:04Z")

</div>

I’m trying to pre-allocate a cache to be used with SparseDiffTools and PolyesterForwardDiff, but I’m struggling to get a working example. My attempt is based off of the jacobian tests: difftype = ADTypes.AutoSparse(ADT…

---

## [Condition number of sparse matrix](https://discourse.julialang.org/t/condition-number-of-sparse-matrix/77131)

<div class="topic-metadata">

**Author:** [@jecs](https://discourse.julialang.org/u/jecs)\
**Replies:** 6\
**Last updated:** [May 27, 2025, 7:08am UTC](https://discourse.julialang.org/t/condition-number-of-sparse-matrix/77131 "2025-05-27T07:08:48Z")

</div>

Hello. Early adopter (v0.4-v0.5) coming back to Julia after wrangling with other languages for too long. I am trying to compute the condition number of a sparse matrix but cannot find a method overloaded for sparse matr…

---

## [Matrix (linear map function) exponential multiplied with vector in ExponentialUtilities.jl](https://discourse.julialang.org/t/matrix-linear-map-function-exponential-multiplied-with-vector-in-exponentialutilities-jl/126957)

<div class="topic-metadata">

**Author:** [@eveningsilverfox](https://discourse.julialang.org/u/eveningsilverfox)\
**Replies:** 10\
**Last updated:** [March 15, 2025, 12:04am UTC](https://discourse.julialang.org/t/matrix-linear-map-function-exponential-multiplied-with-vector-in-exponentialutilities-jl/126957 "2025-03-15T00:04:07Z")

</div>

I am trying to multiply the exponential of a matrix (available as a function which linearly maps the input vector to an output vector), to a given vector, using expv from ExponentialUtilities.jl using MKL using LinearAl…

---

## [How to obtain U^-1 factor from sparse Cholesky factorization?](https://discourse.julialang.org/t/how-to-obtain-u-1-factor-from-sparse-cholesky-factorization/126887)

<div class="topic-metadata">

**Author:** [@juliohm](https://discourse.julialang.org/u/juliohm)\
**Replies:** 2\
**Last updated:** [March 12, 2025, 8:14pm UTC](https://discourse.julialang.org/t/how-to-obtain-u-1-factor-from-sparse-cholesky-factorization/126887 "2025-03-12T20:14:17Z")

</div>

Given a dense positive semi-definite symmetric matrix A, we can easily obtain the U^{-1} factor from the Cholesky factorization object: julia\> using LinearAlgebra julia\> A = Symmetric(\[2 1; 1 2\]) 2×2 Symmetric{Int64, M…

---

## [How to spawn persistent threads and reuse them?](https://discourse.julialang.org/t/how-to-spawn-persistent-threads-and-reuse-them/126002)

<div class="topic-metadata">

**Author:** [@Leo\_I](https://discourse.julialang.org/u/Leo_I)\
**Replies:** 16\
**Last updated:** [February 17, 2025, 9:50pm UTC](https://discourse.julialang.org/t/how-to-spawn-persistent-threads-and-reuse-them/126002 "2025-02-17T21:50:25Z")

</div>

Let nt=nthreads(). I have a loop for k=1:n compute!(k, ...) end that I wish to parallelize. I did so as for k0=1:nt:n k1 = min(k0+nt-1,n); @threads for k=k0:k1 compute!(k, ...) end compress\_results!(k0…

---

## [Sparse matrix of vectors](https://discourse.julialang.org/t/sparse-matrix-of-vectors/125636)

<div class="topic-metadata">

**Author:** [@pulk\_jain](https://discourse.julialang.org/u/pulk_jain)\
**Replies:** 5\
**Last updated:** [February 6, 2025, 11:59pm UTC](https://discourse.julialang.org/t/sparse-matrix-of-vectors/125636 "2025-02-06T23:59:56Z")

</div>

Hi, I wanted to store some information as a sparse matrix of vectors (or a tuple) to save on memory requirements. I am simulating a system of N(~50) particles in a box. If two particles contact then there are interactio…

---

## [Computing ODE sensitivities with sparse Jacobians in solver](https://discourse.julialang.org/t/computing-ode-sensitivities-with-sparse-jacobians-in-solver/125536)

<div class="topic-metadata">

**Author:** [@Neodym](https://discourse.julialang.org/u/Neodym)\
**Replies:** 3\
**Last updated:** [February 4, 2025, 6:31pm UTC](https://discourse.julialang.org/t/computing-ode-sensitivities-with-sparse-jacobians-in-solver/125536 "2025-02-04T18:31:17Z")

</div>

Hey there, I’m trying to compute the derivatives of a function involving an ODE solution. This works if I use dense Jacobians in the ODE solver. However, the Jacobian is actually sparse (PDE discretization, stiff) and …

---

## [\[ANN\] Finch.jl: Sparse and Structured Array Fusion](https://discourse.julialang.org/t/ann-finch-jl-sparse-and-structured-array-fusion/123178)

<div class="topic-metadata">

**Author:** [@willow](https://discourse.julialang.org/u/willow)\
**Replies:** 15\
**Last updated:** [December 30, 2024, 6:33pm UTC](https://discourse.julialang.org/t/ann-finch-jl-sparse-and-structured-array-fusion/123178 "2024-12-30T18:33:06Z")

</div>

Finch.jl: Sparse and Structured Array Fusion Hi everyone, I’m excited to release Finch 1.0.0! Finch is a Julia-to-Julia compiler for sparse or structured multidimensional arrays. Finch empowers users to write high-level …

---

## [Speeding up elementwise Vector-SparseMatrixCSC multiplication broadcasting](https://discourse.julialang.org/t/speeding-up-elementwise-vector-sparsematrixcsc-multiplication-broadcasting/79437)

<div class="topic-metadata">

**Author:** [@bcsj](https://discourse.julialang.org/u/bcsj)\
**Replies:** 11\
**Last updated:** [December 12, 2024, 9:45am UTC](https://discourse.julialang.org/t/speeding-up-elementwise-vector-sparsematrixcsc-multiplication-broadcasting/79437 "2024-12-12T09:45:23Z")

</div>

I noticed today a bottleneck in my code which was causing significant performance loss. Given a vector b and a sparse matrix A, let b \\odot A be the elementwise multiplication of b on each column of A. An example in Ju…

---

## [Sparse non-square linear problem](https://discourse.julialang.org/t/sparse-non-square-linear-problem/122650)

<div class="topic-metadata">

**Author:** [@Nichola](https://discourse.julialang.org/u/Nichola)\
**Replies:** 3\
**Last updated:** [November 15, 2024, 1:00am UTC](https://discourse.julialang.org/t/sparse-non-square-linear-problem/122650 "2024-11-15T01:00:17Z")

</div>

I would like to solve Ax = b where A is a sparse non-square array. For example : using SparseArrays using LinearSolve n = 3 m = 4 A = sparse(rand(ComplexF64, m, n)) b = rand(ComplexF64, m) prob = LinearProblem(A, b) …

---

## [Solve Large Scale Underdetermined Linear Equation with per Element Equality Constraint](https://discourse.julialang.org/t/solve-large-scale-underdetermined-linear-equation-with-per-element-equality-constraint/119655)

<div class="topic-metadata">

**Author:** [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Replies:** 16\
**Last updated:** [September 25, 2024, 5:10pm UTC](https://discourse.julialang.org/t/solve-large-scale-underdetermined-linear-equation-with-per-element-equality-constraint/119655 "2024-09-25T17:10:56Z")

</div>

I have the following linear system to solve: \\boldsymbol{A} \\boldsymbol{x} = \\boldsymbol{0}, \\quad \\text{subject to} \\; {x}\_{i} = {v}\_{i} \\; \\forall i \\in \\mathcal{V} Where \\boldsymbol{A} \\in \\mathbb{R}^{m \\times n} w…

---

## [Cholesky Decomposition of a Sparse Symmetric Positive Semidefinite (SPSD) Singular Matrix](https://discourse.julialang.org/t/cholesky-decomposition-of-a-sparse-symmetric-positive-semidefinite-spsd-singular-matrix/119682)

<div class="topic-metadata">

**Author:** [@RoyiAvital](https://discourse.julialang.org/u/RoyiAvital)\
**Replies:** 19\
**Last updated:** [September 23, 2024, 5:31pm UTC](https://discourse.julialang.org/t/cholesky-decomposition-of-a-sparse-symmetric-positive-semidefinite-spsd-singular-matrix/119682 "2024-09-23T17:31:44Z")

</div>

Is there such equivalent for sparse matrix? I don’t see the pivoting option for SparseMatrixCSC. How would you handle a Sparse SPSD matrix? Currently I just use check = false. Probably small shift should help but i…

[Next page](https://discourse.julialang.org/tag/sparse/368.md?match_all_tags=true&page=1&tags%5B%5D=sparse)
