Skip to content

Commit 7e647cf

Browse files
JeffBezansonViralBShahjishnub
authored
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 aaa7688 commit 7e647cf

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
@@ -256,16 +256,15 @@ Base.@constprop :aggressive @propagate_inbounds function getindex(A::Union{Lower
256256
_shouldforwardindex(A, b) ? A.data[b] : diagzero(A.data, b)
257257
end
258258

259-
_zero_triangular_half_str(::Type{<:UpperOrUnitUpperTriangular}) = "lower"
260-
_zero_triangular_half_str(::Type{<:LowerOrUnitLowerTriangular}) = "upper"
259+
_zero_triangular_half_str(T::Type) = T <: UpperOrUnitUpperTriangular ? "lower" : "upper"
261260

262-
@noinline function throw_nonzeroerror(T, @nospecialize(x), i, j)
261+
@noinline function throw_nonzeroerror(T::DataType, @nospecialize(x), i, j)
263262
Ts = _zero_triangular_half_str(T)
264263
Tn = nameof(T)
265264
throw(ArgumentError(
266265
lazy"cannot set index in the $Ts triangular part ($i, $j) of an $Tn matrix to a nonzero value ($x)"))
267266
end
268-
@noinline function throw_nononeerror(T, @nospecialize(x), i, j)
267+
@noinline function throw_nononeerror(T::DataType, @nospecialize(x), i, j)
269268
Tn = nameof(T)
270269
throw(ArgumentError(
271270
lazy"cannot set index on the diagonal ($i, $j) of an $Tn matrix to a non-unit value ($x)"))
@@ -311,7 +310,7 @@ end
311310
return A
312311
end
313312

314-
@noinline function throw_setindex_structuralzero_error(T, @nospecialize(x))
313+
@noinline function throw_setindex_structuralzero_error(T::DataType, @nospecialize(x))
315314
Ts = _zero_triangular_half_str(T)
316315
Tn = nameof(T)
317316
throw(ArgumentError(

0 commit comments

Comments
 (0)