# Updating a row in sparse cholesky factorisation using CHOLMOD

**URL:** <https://discourse.julialang.org/t/updating-a-row-in-sparse-cholesky-factorisation-using-cholmod/126683>\
**Category:** General Usage\
**Tags:** linearalgebra\
**Created:** [March 7, 2025, 3:51pm UTC](https://discourse.julialang.org/t/updating-a-row-in-sparse-cholesky-factorisation-using-cholmod/126683 "2025-03-07T15:51:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wvanroos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wvanroos/32/215654_2.png) [@wvanroos](https://discourse.julialang.org/u/wvanroos)\
**Post date:** [March 7, 2025, 3:51pm UTC](https://discourse.julialang.org/t/updating-a-row-in-sparse-cholesky-factorisation-using-cholmod/126683/1 "2025-03-07T15:51:36Z")

</div>

CHOLMOD allows the modification of a row of a sparse matrix and updates the factorisation, accordingly. There is a function `ldlrowmod` in Matlab that interfaces to `rowadd` and `rowdel` from CHOLMOD ([SuiteSparse/CHOLMOD/MATLAB/ldlrowmod.m at dev · DrTimothyAldenDavis/SuiteSparse · GitHub](https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/dev/CHOLMOD/MATLAB/ldlrowmod.m))

Currently, SparseArray.CHOLMOD only offers an interface to `SparseArrays.CHOLMOD.lowrankupdowndate` for updates to the factorization. But this only allows updates to A of the form A + CC’ which is very limited.

A use case of updates of a row is in active set methods, where the active set is updated one item at a time. We then need to update a row (and column) of the Cholesky factorisation of the reduced Hessian. I am sure there are many other use cases where a cholesky factorisation is update one row at a time.

In Matlab and example of code would be

```julia
n= 20
H = speye(n)
LD = ldlchol(H)
LD3 = ldlrowmod (LD, 10,sparse(rand(n,1)))
[L,D] = ldlsplit(LD3)
figure; spy(L)
figure; spy(abs(L*D*L')>0.01)

```

Is a similar thing possible currently in Julia? I was not able to do this. Any advice?

I would be happy to contribute.

---

<div class="post-metadata">

**Author:** ![wvanroos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wvanroos/32/215654_2.png) [@wvanroos](https://discourse.julialang.org/u/wvanroos)\
**Post date:** [March 12, 2025, 6:19pm UTC](https://discourse.julialang.org/t/updating-a-row-in-sparse-cholesky-factorisation-using-cholmod/126683/2 "2025-03-12T18:19:04Z")

</div>

I am able to access the desired functions using `ccall` using this example. I still have to test in the real application. But it works for this example.  
[test\_add\_delete\_row.jl](https://discourse.julialang.org/uploads/short-url/wu6NC9W6Rx2kvyhjMwPPbZOd6pJ.jl) (1.5 KB)

---

<div class="post-metadata">

**Author:** ![wvanroos](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wvanroos/32/215654_2.png) [@wvanroos](https://discourse.julialang.org/u/wvanroos)\
**Post date:** [March 15, 2025, 9:34am UTC](https://discourse.julialang.org/t/updating-a-row-in-sparse-cholesky-factorisation-using-cholmod/126683/3 "2025-03-15T09:34:52Z")

</div>

Note that this example does not deal with the possible permutations that might appear.
