# \#sparse

**URL:** https://discourse.julialang.org/tag/sparse/368.md?match_all_tags=true&page=2&tags%5B%5D=sparse

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

**Page:** 3

---

## [Possibility to store outcome of \`ForwardDiff.jacobian\` already in sparse format](https://discourse.julialang.org/t/possibility-to-store-outcome-of-forwarddiff-jacobian-already-in-sparse-format/102635)

<div class="topic-metadata">

**Author:** [@DanDoe](https://discourse.julialang.org/u/DanDoe)\
**Replies:** 2\
**Last updated:** [August 11, 2023, 6:19am UTC](https://discourse.julialang.org/t/possibility-to-store-outcome-of-forwarddiff-jacobian-already-in-sparse-format/102635 "2023-08-11T06:19:00Z")

</div>

I use ForwardDiff.jacobian in the following way: function \_jacobian\_ad\_forward(p, t0, u0\_ode, du\_ode, config) J = ForwardDiff.jacobian(du\_ode, u0\_ode, config) do du\_ode, u\_ode f!(du\_ode, u\_ode, p, t0) en…

---

## [Inverse subset algorithm?](https://discourse.julialang.org/t/inverse-subset-algorithm/102252)

<div class="topic-metadata">

**Author:** [@ElOceanografo](https://discourse.julialang.org/u/ElOceanografo)\
**Replies:** 4\
**Last updated:** [August 7, 2023, 5:02pm UTC](https://discourse.julialang.org/t/inverse-subset-algorithm/102252 "2023-08-07T17:02:50Z")

</div>

Reading this paper, I came across a reference to the “inverse subset algorithm,” in the context of efficiently calculating the gradient of the log-determinant of a sparse symmetric matrix (Section 4.1, Equation 8 and imm…

---

## [Help with SparseArrays/ChainRules error](https://discourse.julialang.org/t/help-with-sparsearrays-chainrules-error/99425)

<div class="topic-metadata">

**Author:** [@ElOceanografo](https://discourse.julialang.org/u/ElOceanografo)\
**Replies:** 0\
**Last updated:** [May 26, 2023, 6:07am UTC](https://discourse.julialang.org/t/help-with-sparsearrays-chainrules-error/99425 "2023-05-26T06:07:01Z")

</div>

Ran into this error running code similar to this MWE, and was hoping someone who knows more about the AD ecosystem could help point me where to file an issue–is this a missing ChainRule, or overly-strict typing in Sparse…

---

## [Julia cannot solve Ax=b with LU where A is sparse,](https://discourse.julialang.org/t/julia-cannot-solve-ax-b-with-lu-where-a-is-sparse/98383)

<div class="topic-metadata">

**Author:** [@jonassoleil](https://discourse.julialang.org/u/jonassoleil)\
**Replies:** 12\
**Last updated:** [May 5, 2023, 7:10pm UTC](https://discourse.julialang.org/t/julia-cannot-solve-ax-b-with-lu-where-a-is-sparse/98383 "2023-05-05T19:10:03Z")

</div>

Hi, I get very wrong answers on solving Ax=b with LU where A is a sparse matrix. I am a bit puzzled by this, since as far as I understand Julia calls the SuiteSparse library for sparse Linear-Algebra like Matlab does. …

---

## [What is the most efficient way to compute the inverse of a sparse matrix?](https://discourse.julialang.org/t/what-is-the-most-efficient-way-to-compute-the-inverse-of-a-sparse-matrix/98167)

<div class="topic-metadata">

**Author:** [@schwob](https://discourse.julialang.org/u/schwob)\
**Replies:** 15\
**Last updated:** [May 5, 2023, 4:06pm UTC](https://discourse.julialang.org/t/what-is-the-most-efficient-way-to-compute-the-inverse-of-a-sparse-matrix/98167 "2023-05-05T16:06:57Z")

</div>

I have a sparse matrix Q that is a covariance matrix for a Gaussian Process. I need to invert Q for computations in Bayesian full-conditional distributions. For example, I need to compute terms like \\boldsymbol{\\beta}^T\\…

---

## [How to efficiently differentiate backslash operator for sparse matrix?](https://discourse.julialang.org/t/how-to-efficiently-differentiate-backslash-operator-for-sparse-matrix/43778)

<div class="topic-metadata">

**Author:** [@Liang\_Chen](https://discourse.julialang.org/u/Liang_Chen)\
**Replies:** 23\
**Last updated:** [May 1, 2023, 4:21pm UTC](https://discourse.julialang.org/t/how-to-efficiently-differentiate-backslash-operator-for-sparse-matrix/43778 "2023-05-01T16:21:24Z")

</div>

My problem is to calculate the gradient, dL(u)/dp, where L() is a loss function which takes a vector u as the input and outputs a scalar value. The vector p are parameters that defines a large sparse matrix K, such that K…

---

## [Outer Product of SparseMatrix and SparseVector](https://discourse.julialang.org/t/outer-product-of-sparsematrix-and-sparsevector/97947)

<div class="topic-metadata">

**Author:** [@ejmeitz](https://discourse.julialang.org/u/ejmeitz)\
**Replies:** 5\
**Last updated:** [April 26, 2023, 4:08pm UTC](https://discourse.julialang.org/t/outer-product-of-sparsematrix-and-sparsevector/97947 "2023-04-26T16:08:19Z")

</div>

Is there an elegant/optimized way to take the outer product of 3 sparse vectors? Problem 1: Triple Outer Product In numpy I can just chain calls to np.outer(np.outer(v,v),v) but I cannot do the same in Julia. I see th…

---

## [PyCall.jl with SparseArrays](https://discourse.julialang.org/t/pycall-jl-with-sparsearrays/97316)

<div class="topic-metadata">

**Author:** [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Replies:** 6\
**Last updated:** [April 11, 2023, 11:21pm UTC](https://discourse.julialang.org/t/pycall-jl-with-sparsearrays/97316 "2023-04-11T23:21:22Z")

</div>

I am trying to diagonalize a huge sparse Hermitian matrix (original thread here: Suggestions needed: diagonalizing large Hermitian sparse matrix) and am exploring the possibility of utilizing the PRIMME package. Since th…

---

## [Creating sparse diagonal matrix of CuArray](https://discourse.julialang.org/t/creating-sparse-diagonal-matrix-of-cuarray/97108)

<div class="topic-metadata">

**Author:** [@Hemsh94](https://discourse.julialang.org/u/Hemsh94)\
**Replies:** 0\
**Last updated:** [April 5, 2023, 9:40am UTC](https://discourse.julialang.org/t/creating-sparse-diagonal-matrix-of-cuarray/97108 "2023-04-05T09:40:42Z")

</div>

Hello everyone, If we have a vector (u), we can easily convert it into a sparse diagonal matrix using the command spdiagm(u). I want to do the same operation using CUDA where u is defined as CuArray(u). The command spd…

---

## [Complete and incomplete sparse cholesky factorization](https://discourse.julialang.org/t/complete-and-incomplete-sparse-cholesky-factorization/96918)

<div class="topic-metadata">

**Author:** [@shakedregev](https://discourse.julialang.org/u/shakedregev)\
**Replies:** 6\
**Last updated:** [April 4, 2023, 7:28am UTC](https://discourse.julialang.org/t/complete-and-incomplete-sparse-cholesky-factorization/96918 "2023-04-04T07:28:23Z")

</div>

Say I have a CuSparseCSR matrix “A” and I want to take complete and incomplete cholesky factorizations of it, but crucially leave that factorization on the GPU, how can I do that? Things I’ve tried: CuSparse.jl - depr…

---

## [Suggestions needed: diagonalizing large Hermitian sparse matrix](https://discourse.julialang.org/t/suggestions-needed-diagonalizing-large-hermitian-sparse-matrix/96580)

<div class="topic-metadata">

**Author:** [@Chong\_Wang](https://discourse.julialang.org/u/Chong_Wang)\
**Replies:** 4\
**Last updated:** [April 3, 2023, 6:03am UTC](https://discourse.julialang.org/t/suggestions-needed-diagonalizing-large-hermitian-sparse-matrix/96580 "2023-04-03T06:03:37Z")

</div>

I need to find a few eigenvalues and eigenvectors of some large Hermitian sparse matrices. Right now, I am trying Arpack.jl and KrylovKit.jl. Here are some considerations and my experiences. Arpack.jl does not have sp…

---

## [Parse vector from string](https://discourse.julialang.org/t/parse-vector-from-string/10728)

<div class="topic-metadata">

**Author:** [@cortner](https://discourse.julialang.org/u/cortner)\
**Replies:** 24\
**Last updated:** [March 27, 2023, 9:24pm UTC](https://discourse.julialang.org/t/parse-vector-from-string/10728 "2023-03-27T21:24:00Z")

</div>

I can parse(Int, „123“) but I cannot find a simple way to parse(Vector{Int}, „\[1, 2, 3\]”). Is there a “canned” solution?

---

## [Why are duplicate entries in sparse matrices allowed?](https://discourse.julialang.org/t/why-are-duplicate-entries-in-sparse-matrices-allowed/2159)

<div class="topic-metadata">

**Author:** [@mirestrepo](https://discourse.julialang.org/u/mirestrepo)\
**Replies:** 7\
**Last updated:** [February 1, 2023, 4:26pm UTC](https://discourse.julialang.org/t/why-are-duplicate-entries-in-sparse-matrices-allowed/2159 "2023-02-01T16:26:12Z")

</div>

Why does the representation of sparse matrices allow for duplicates? a = spzeros(2, 3) a\[\[1,1\],2\]=1 a\[\[1\],2\]=2 Leads to 2×3 sparse matrix with 2 Float64 nonzero entries: \[1, 2\] = 2.0 \[1, 2\] = 1.0 This behavior …

---

## [Is there a Symmetric Sparse Matrix Implementation in Julia?](https://discourse.julialang.org/t/is-there-a-symmetric-sparse-matrix-implementation-in-julia/91333)

<div class="topic-metadata">

**Author:** [@cdelv](https://discourse.julialang.org/u/cdelv)\
**Replies:** 2\
**Last updated:** [December 7, 2022, 2:28am UTC](https://discourse.julialang.org/t/is-there-a-symmetric-sparse-matrix-implementation-in-julia/91333 "2022-12-07T02:28:31Z")

</div>

Hi, I want a symmetric sparse matrix that behaves like this using StaticArrays using Accessors A = zeros(SHermitianCompact{3}) A = @set A\[1,2\] = 1 3×3 SHermitianCompact{3, Float64, 6} with indices SOneTo(3)×SOneTo(3): …

---

## [Generating a sparse matrix from a piecewise function](https://discourse.julialang.org/t/generating-a-sparse-matrix-from-a-piecewise-function/91119)

<div class="topic-metadata">

**Author:** [@RobertGregg](https://discourse.julialang.org/u/RobertGregg)\
**Replies:** 2\
**Last updated:** [December 2, 2022, 12:36am UTC](https://discourse.julialang.org/t/generating-a-sparse-matrix-from-a-piecewise-function/91119 "2022-12-02T00:36:46Z")

</div>

I’m trying to generate a random sparse matrix R where each element in R can take on the following values: r\_{ij}= \\left\\{ \\begin{array}{ll} 1 & \\text{with probability } \\frac{1}{6}\\\\ 0 & \\text{with probab…

---

## [Sparse solve with sparse rhs](https://discourse.julialang.org/t/sparse-solve-with-sparse-rhs/81595)

<div class="topic-metadata">

**Author:** [@Andrea\_Vigliotti](https://discourse.julialang.org/u/Andrea_Vigliotti)\
**Replies:** 13\
**Last updated:** [November 29, 2022, 7:32am UTC](https://discourse.julialang.org/t/sparse-solve-with-sparse-rhs/81595 "2022-11-29T07:32:34Z")

</div>

is there any news on this? It appears it is still not possible solving problems with sparse rhs. This is a problem when dealing with very large, and very sparse, matrices, where it is not possible allocate memory for a f…

---

## [Solving sparse, linear equations?](https://discourse.julialang.org/t/solving-sparse-linear-equations/90238)

<div class="topic-metadata">

**Author:** [@BLI](https://discourse.julialang.org/u/BLI)\
**Replies:** 10\
**Last updated:** [November 15, 2022, 12:09pm UTC](https://discourse.julialang.org/t/solving-sparse-linear-equations/90238 "2022-11-15T12:09:00Z")

</div>

I have a linear equation AA\*z = bb where AA is a full rank, sparse matrix : julia\> AA 650×650 SparseMatrixCSC{Float64, Int64} with 2280 stored entries: ... When I try to solve the equation, I get an error message: ju…

---

## [Is working with SubArrays of a SparseMatrix a bad idea?](https://discourse.julialang.org/t/is-working-with-subarrays-of-a-sparsematrix-a-bad-idea/90000)

<div class="topic-metadata">

**Author:** [@bmit](https://discourse.julialang.org/u/bmit)\
**Replies:** 9\
**Last updated:** [November 9, 2022, 8:16pm UTC](https://discourse.julialang.org/t/is-working-with-subarrays-of-a-sparsematrix-a-bad-idea/90000 "2022-11-09T20:16:16Z")

</div>

I’ve been trying to work with views of a SparseMatrix for a while now. The goal is to avoid extra copies when you want to operate inplace on a subsection of the sparse matrix. I’ve run into enough issues that I’m startin…

---

## [The objective function sparse is not supported by JuMP in julia](https://discourse.julialang.org/t/the-objective-function-sparse-is-not-supported-by-jump-in-julia/89726)

<div class="topic-metadata">

**Author:** [@thiagoselias](https://discourse.julialang.org/u/thiagoselias)\
**Replies:** 9\
**Last updated:** [November 3, 2022, 8:28pm UTC](https://discourse.julialang.org/t/the-objective-function-sparse-is-not-supported-by-jump-in-julia/89726 "2022-11-03T20:28:22Z")

</div>

model = Model(Gurobi.Optimizer) @objective(model, Min, DRect + 0.6DBlad + 0.6DBO) The objective function sparse(\[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, …

---

## [From toy to production code with sparse matrix and sparse-direct factorizations](https://discourse.julialang.org/t/from-toy-to-production-code-with-sparse-matrix-and-sparse-direct-factorizations/89105)

<div class="topic-metadata">

**Author:** [@Gravlax](https://discourse.julialang.org/u/Gravlax)\
**Replies:** 17\
**Last updated:** [November 1, 2022, 10:01pm UTC](https://discourse.julialang.org/t/from-toy-to-production-code-with-sparse-matrix-and-sparse-direct-factorizations/89105 "2022-11-01T22:01:25Z")

</div>

Dear all, I would like to port a toy code that assembles one sparse matrix and solves one linear system of equation to a production code that assembles many sparse matrices and solves many systems of equation iterativel…

---

## [How can I visualize the data of a sparse matrix using a vector](https://discourse.julialang.org/t/how-can-i-visualize-the-data-of-a-sparse-matrix-using-a-vector/89394)

<div class="topic-metadata">

**Author:** [@thiagoselias](https://discourse.julialang.org/u/thiagoselias)\
**Replies:** 2\
**Last updated:** [October 27, 2022, 8:24pm UTC](https://discourse.julialang.org/t/how-can-i-visualize-the-data-of-a-sparse-matrix-using-a-vector/89394 "2022-10-27T20:24:43Z")

</div>

The way I’m doing it, the index values appear all mixed up in the code: EX: v = matopen(“index.mat”); index= read(v, “v”); close(v); x = (list\[index\])

---

## [DataDriven Approach for recovering DAE system of governing equations](https://discourse.julialang.org/t/datadriven-approach-for-recovering-dae-system-of-governing-equations/88822)

<div class="topic-metadata">

**Author:** [@CurioMath](https://discourse.julialang.org/u/CurioMath)\
**Replies:** 3\
**Last updated:** [October 22, 2022, 9:05am UTC](https://discourse.julialang.org/t/datadriven-approach-for-recovering-dae-system-of-governing-equations/88822 "2022-10-22T09:05:55Z")

</div>

Can I know if data driven recovery of governing equations that can be a DAE system is possible with DMD or SINDy approach in DataDrivenDiffEq.jl? I have referred the examples in the documentation of DataDrivenDiffEq.jl b…

---

## [Sparse matrix and sparse subarray subtraction returns full arrays](https://discourse.julialang.org/t/sparse-matrix-and-sparse-subarray-subtraction-returns-full-arrays/88239)

<div class="topic-metadata">

**Author:** [@vivian-rogers](https://discourse.julialang.org/u/vivian-rogers)\
**Replies:** 6\
**Last updated:** [October 11, 2022, 12:24am UTC](https://discourse.julialang.org/t/sparse-matrix-and-sparse-subarray-subtraction-returns-full-arrays/88239 "2022-10-11T00:24:49Z")

</div>

Hi! So, I am writing a routine to recursively invert a big, sparse matrix which is known to be nice and reasonably invertible with this recursive method. Specifically, this pertains to the green’s function of a sparse ha…

---

## [Block Sparse Matrix](https://discourse.julialang.org/t/block-sparse-matrix/81465)

<div class="topic-metadata">

**Author:** [@00shiv](https://discourse.julialang.org/u/00shiv)\
**Replies:** 2\
**Last updated:** [September 27, 2022, 3:02pm UTC](https://discourse.julialang.org/t/block-sparse-matrix/81465 "2022-09-27T15:02:54Z")

</div>

I would like to deal with very large sparse matrices with dense sub-blocks; for example, block arrow-head matrices, or a block periodic tridiagonal matrices. I know about the BlockArrays package. That supports blocking …

---

## [Threaded loop shows error when using sparse matrix, but not with dense matrices](https://discourse.julialang.org/t/threaded-loop-shows-error-when-using-sparse-matrix-but-not-with-dense-matrices/87292)

<div class="topic-metadata">

**Author:** [@andresdrenik](https://discourse.julialang.org/u/andresdrenik)\
**Replies:** 3\
**Last updated:** [September 15, 2022, 7:15am UTC](https://discourse.julialang.org/t/threaded-loop-shows-error-when-using-sparse-matrix-but-not-with-dense-matrices/87292 "2022-09-15T07:15:34Z")

</div>

I’m having trouble with a parallelized for loop that replaces the values of a sparse matrix. Here is a simple example that reproduces the error: using SparseArrays function test(θ,Ŵ\_prime,Ŵ) value, index = findmax…

---

## [Best way to parallelize](https://discourse.julialang.org/t/best-way-to-parallelize/85992)

<div class="topic-metadata">

**Author:** [@Dario-Rosa85](https://discourse.julialang.org/u/Dario-Rosa85)\
**Replies:** 12\
**Last updated:** [August 25, 2022, 2:01pm UTC](https://discourse.julialang.org/t/best-way-to-parallelize/85992 "2022-08-25T14:01:33Z")

</div>

Hi all, I have a large sparse matrix (dimension of order 10^5) which I have to multiply with a matrix of vectors many times. such a matrix of vectors is made out of, say, 500 vectors each of dimension equal to the dimen…

---

## [Sparse syrk() routine using Transducers.jl](https://discourse.julialang.org/t/sparse-syrk-routine-using-transducers-jl/86218)

<div class="topic-metadata">

**Author:** [@josuagrw](https://discourse.julialang.org/u/josuagrw)\
**Replies:** 0\
**Last updated:** [August 23, 2022, 7:09pm UTC](https://discourse.julialang.org/t/sparse-syrk-routine-using-transducers-jl/86218 "2022-08-23T19:09:07Z")

</div>

Hi, I implemented a sparse syrk routine to see if I could get something faster than the naive implementation: using SparseArrays using LinearAlgebra using Transducers using Combinatorics naive\_spsyrk(s) = Symmetric(s …

---

## [Best way to use CuSparseMatrixBSR](https://discourse.julialang.org/t/best-way-to-use-cusparsematrixbsr/86075)

<div class="topic-metadata">

**Author:** [@April-Hannah-Lena](https://discourse.julialang.org/u/April-Hannah-Lena)\
**Replies:** 7\
**Last updated:** [August 21, 2022, 9:42am UTC](https://discourse.julialang.org/t/best-way-to-use-cusparsematrixbsr/86075 "2022-08-21T09:42:12Z")

</div>

I’ve been writing a set of kernels in which I calculate many small (mostly on the order of ~10x10) square matrices column by column, like in this toy example using CUDA # each slice L\[:, :, j\] is a matrix of interest L…

---

## [Splitting and Summing Sparse Arrays](https://discourse.julialang.org/t/splitting-and-summing-sparse-arrays/85903)

<div class="topic-metadata">

**Author:** [@bmit](https://discourse.julialang.org/u/bmit)\
**Replies:** 5\
**Last updated:** [August 18, 2022, 7:29pm UTC](https://discourse.julialang.org/t/splitting-and-summing-sparse-arrays/85903 "2022-08-18T19:29:16Z")

</div>

In my application I need to split a sparse array into columns then pass each column to a separate function and sum them independently. x = sprand(1000, 1000, 0.01) cols = eachcol(x) function foo(x) s = sum(x) #…

---

## [Faster matrix product with a specifically structured matrix](https://discourse.julialang.org/t/faster-matrix-product-with-a-specifically-structured-matrix/67355)

<div class="topic-metadata">

**Author:** [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Replies:** 26\
**Last updated:** [August 7, 2022, 8:47pm UTC](https://discourse.julialang.org/t/faster-matrix-product-with-a-specifically-structured-matrix/67355 "2022-08-07T20:47:56Z")

</div>

Hi, I have a sparse matrix P that turns out to have only equal values (or zeros) on each line: julia\> all(\[sum(unique(P\[i,:\]).!=0)\<=1 for i in 1:size(P,1)\]) true julia\> Where I used \<=1 since some lines are complete…

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

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