Skip to content

Instantly share code, notes, and snippets.

@KristofferC
Last active August 29, 2015 14:21
Show Gist options
  • Save KristofferC/36c760057b6e911e6258 to your computer and use it in GitHub Desktop.
Save KristofferC/36c760057b6e911e6258 to your computer and use it in GitHub Desktop.
function ishermitian_new(A::SparseMatrixCSC)
m, n = size(A)
if m != n; return false; end
colptr = A.colptr
rowval = A.rowval
nzval = A.nzval
start_indices = copy(A.colptr)
nrnzval = length(nzval)
@inbounds for col = 1 : A.n
# Step down until we hit the diagonal
diag_offset = 0
while rowval[colptr[col]+diag_offset] < col
diag_offset += 1
end
for j = colptr[col]+diag_offset : colptr[col+1]-1
row = rowval[j]
nz = nzval[j]
r1 = start_indices[row]
r2 = Int(A.colptr[row+1]-1)
r1 = searchsortedfirst(A.rowval, col, r1, r2, Forward)
start_indices[row] = r1
if r1 != r2 && nz != ctranspose(A.nzval[r1])
return false
end
end
end
true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment