Skip to content

Commit

Permalink
added function to get sparse matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
aquaresima committed Nov 28, 2024
1 parent 1164779 commit 20f4889
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/util.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
function connect!(c, j, i, μ = 1e-6)
W = sparse(c.I, c.J, c.W, length(c.rowptr) - 1, length(c.colptr) - 1)
W = matrix(c)
W[i, j] = μ * randn(Float32)
replace_sparse_matrix!(c, W)
return nothing
end

function matrix(c)
return sparse(c.I, c.J, c.W, length(c.rowptr) - 1, length(c.colptr) - 1)
end

function replace_sparse_matrix!(c::S, W::SparseMatrixCSC) where S <: AbstractConnection
rowptr, colptr, I, J, index, W = dsparse(W)
@assert length(rowptr) == length(c.rowptr) "Rowptr length mismatch"
Expand Down

0 comments on commit 20f4889

Please sign in to comment.