Skip to content

Commit

Permalink
Making '_count_diagonal_entries(P)' work for arbitrary matrices.
Browse files Browse the repository at this point in the history
  • Loading branch information
mipals committed Dec 11, 2024
1 parent dd709aa commit 7c2fe97
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/utils/csc_assembly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,11 @@ end


function _count_diagonal_entries(P)

count = 0
for i = 1:P.n

#compare last entry in each column with
#its row number to identify diagonal entries
if((P.colptr[i+1] != P.colptr[i]) && #nonempty column
(P.rowval[P.colptr[i+1]-1] == i) ) #last element is on diagonal
count += 1
#Check if the ith column contain ith row
if (i in P.rowval[P.colptr[i]:P.colptr[i+1]-1])
count += 1
end
end
return count
Expand Down

0 comments on commit 7c2fe97

Please sign in to comment.