# Update matrix block inplace from a sparse array

**URL:** <https://discourse.julialang.org/t/update-matrix-block-inplace-from-a-sparse-array/36360>\
**Category:** General Usage\
**Tags:** sparse\
**Created:** [March 22, 2020, 8:51pm UTC](https://discourse.julialang.org/t/update-matrix-block-inplace-from-a-sparse-array/36360 "2020-03-22T20:51:18Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jlchan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlchan/32/10958_2.png) [@jlchan](https://discourse.julialang.org/u/jlchan)\
**Post date:** [April 7, 2020, 8:19pm UTC](https://discourse.julialang.org/t/update-matrix-block-inplace-from-a-sparse-array/36360/2 "2020-04-07T20:19:34Z")

</div>

I’ve been looking for this as well, and it looks like there’s some [related work](https://github.com/JuliaDiff/FiniteDiff.jl/issues/29) and [interest from others](https://discourse.julialang.org/t/a-version-of-sparse-that-updates-a-previously-existing-sparsematrixcsc/31943). There is a related feature `SparseArrays.sparse!` (not exported) which allows you to get halfway there by specifying some pre-allocated arrays for the construction of sparse matrices.

I haven’t found a good solution for full in-place updates, however. As far as I can tell, it’s possible to do fully in-place sparse matrix updates by directly modifying `rowptr,colptr,nzval`, but more complicated when accounting for general sparse matrix functionality like combining repeated entries and sorted/unsorted representations.

---

_[View the full topic](https://discourse.julialang.org/t/update-matrix-block-inplace-from-a-sparse-array/36360)._
