From 20f4889bdfaee992f6a75d1535b8f6fecadb3976 Mon Sep 17 00:00:00 2001 From: Alessio Date: Thu, 28 Nov 2024 17:32:28 +0100 Subject: [PATCH] added function to get sparse matrix --- src/util.jl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/util.jl b/src/util.jl index c90180b..c401216 100644 --- a/src/util.jl +++ b/src/util.jl @@ -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"