Skip to content

Commit aad49cf

Browse files
committed
Check for diagonal in unittriangular indexing
1 parent 70a23a6 commit aad49cf

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/triangular.jl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,10 @@ end
316316
# however, the converted value is unused, and the compiler is free to remove
317317
# the conversion if the call is guaranteed to succeed
318318
convert(eltype(A), x)
319-
if i > j
320-
iszero(x) || throw_nonzeroerror(nameof(typeof(A)), x, i, j)
321-
else
319+
if i == j # diagonal
322320
x == oneunit(eltype(A)) || throw_nonuniterror(nameof(typeof(A)), x, i, j)
321+
else
322+
iszero(x) || throw_nonzeroerror(nameof(typeof(A)), x, i, j)
323323
end
324324
end
325325
return A
@@ -348,10 +348,10 @@ end
348348
# however, the converted value is unused, and the compiler is free to remove
349349
# the conversion if the call is guaranteed to succeed
350350
convert(eltype(A), x)
351-
if i < j
352-
iszero(x) || throw_nonzeroerror(nameof(typeof(A)), x, i, j)
353-
else
351+
if i == j # diagonal
354352
x == oneunit(eltype(A)) || throw_nonuniterror(nameof(typeof(A)), x, i, j)
353+
else
354+
iszero(x) || throw_nonzeroerror(nameof(typeof(A)), x, i, j)
355355
end
356356
end
357357
return A

0 commit comments

Comments
 (0)