Skip to content

Commit 213b31d

Browse files
JeffBezansonViralBShahjishnub
authored andcommitted
improve type stability of structural zero error for triangular (#1413)
Co-authored-by: Viral B. Shah <[email protected]> Co-authored-by: Jishnu Bhattacharya <[email protected]>
1 parent 9941132 commit 213b31d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/triangular.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,15 @@ Base.@constprop :aggressive @propagate_inbounds function getindex(A::Union{Lower
248248
_shouldforwardindex(A, b) ? A.data[b] : diagzero(A.data, b)
249249
end
250250

251-
_zero_triangular_half_str(::Type{<:UpperOrUnitUpperTriangular}) = "lower"
252-
_zero_triangular_half_str(::Type{<:LowerOrUnitLowerTriangular}) = "upper"
251+
_zero_triangular_half_str(T::Type) = T <: UpperOrUnitUpperTriangular ? "lower" : "upper"
253252

254-
@noinline function throw_nonzeroerror(T, @nospecialize(x), i, j)
253+
@noinline function throw_nonzeroerror(T::DataType, @nospecialize(x), i, j)
255254
Ts = _zero_triangular_half_str(T)
256255
Tn = nameof(T)
257256
throw(ArgumentError(
258257
lazy"cannot set index in the $Ts triangular part ($i, $j) of an $Tn matrix to a nonzero value ($x)"))
259258
end
260-
@noinline function throw_nononeerror(T, @nospecialize(x), i, j)
259+
@noinline function throw_nononeerror(T::DataType, @nospecialize(x), i, j)
261260
Tn = nameof(T)
262261
throw(ArgumentError(
263262
lazy"cannot set index on the diagonal ($i, $j) of an $Tn matrix to a non-unit value ($x)"))
@@ -303,7 +302,7 @@ end
303302
return A
304303
end
305304

306-
@noinline function throw_setindex_structuralzero_error(T, @nospecialize(x))
305+
@noinline function throw_setindex_structuralzero_error(T::DataType, @nospecialize(x))
307306
Ts = _zero_triangular_half_str(T)
308307
Tn = nameof(T)
309308
throw(ArgumentError(

0 commit comments

Comments
 (0)