@@ -176,6 +176,12 @@ issymmetric(S::SymTridiagonal) = true
176176
177177tr (S:: SymTridiagonal ) = sum (S. dv)
178178
179+ @noinline function throw_diag_outofboundserror (n, sz)
180+ sz1, sz2 = sz
181+ throw (ArgumentError (LazyString (lazy " requested diagonal, $n, must be at least $(-sz1) " ,
182+ lazy " and at most $sz2 for an $(sz1)-by-$(sz2) matrix" )))
183+ end
184+
179185function diag (M:: SymTridiagonal{T} , n:: Integer = 0 ) where T<: Number
180186 # every branch call similar(..., ::Int) to make sure the
181187 # same vector type is returned independent of n
@@ -187,8 +193,7 @@ function diag(M::SymTridiagonal{T}, n::Integer=0) where T<:Number
187193 elseif absn <= size (M,1 )
188194 return fill! (similar (M. dv, size (M,1 )- absn), zero (T))
189195 else
190- throw (ArgumentError (string (lazy " requested diagonal, $n, must be at least $(-size(M, 1)) " ,
191- lazy " and at most $(size(M, 2)) for an $(size(M, 1))-by-$(size(M, 2)) matrix" )))
196+ throw_diag_outofboundserror (n, size (M))
192197 end
193198end
194199function diag (M:: SymTridiagonal , n:: Integer = 0 )
@@ -203,8 +208,7 @@ function diag(M::SymTridiagonal, n::Integer=0)
203208 elseif n <= size (M,1 )
204209 throw (ArgumentError (" requested diagonal contains undefined zeros of an array type" ))
205210 else
206- throw (ArgumentError (string (lazy " requested diagonal, $n, must be at least $(-size(M, 1)) " ,
207- lazy " and at most $(size(M, 2)) for an $(size(M, 1))-by-$(size(M, 2)) matrix" )))
211+ throw_diag_outofboundserror (n, size (M))
208212 end
209213end
210214
@@ -346,7 +350,7 @@ isdiag(M::SymTridiagonal) = iszero(_evview(M))
346350function tril! (M:: SymTridiagonal{T} , k:: Integer = 0 ) where T
347351 n = length (M. dv)
348352 if ! (- n - 1 <= k <= n - 1 )
349- throw (ArgumentError (string (lazy " the requested diagonal, $k, must be at least " ,
353+ throw (ArgumentError (LazyString (lazy " the requested diagonal, $k, must be at least " ,
350354 lazy " $(-n - 1) and at most $(n - 1) in an $n-by-$n matrix" )))
351355 elseif k < - 1
352356 fill! (M. ev, zero (T))
365369function triu! (M:: SymTridiagonal{T} , k:: Integer = 0 ) where T
366370 n = length (M. dv)
367371 if ! (- n + 1 <= k <= n + 1 )
368- throw (ArgumentError (string (lazy " the requested diagonal, $k, must be at least " ,
372+ throw (ArgumentError (LazyString (lazy " the requested diagonal, $k, must be at least " ,
369373 lazy " $(-n + 1) and at most $(n + 1) in an $n-by-$n matrix" )))
370374 elseif k > 1
371375 fill! (M. ev, zero (T))
@@ -474,7 +478,7 @@ struct Tridiagonal{T,V<:AbstractVector{T}} <: AbstractMatrix{T}
474478 require_one_based_indexing (dl, d, du)
475479 n = length (d)
476480 if (length (dl) != n- 1 || length (du) != n- 1 ) && ! (length (d) == 0 && length (dl) == 0 && length (du) == 0 )
477- throw (ArgumentError (string (" cannot construct Tridiagonal from incompatible " ,
481+ throw (ArgumentError (LazyString (" cannot construct Tridiagonal from incompatible " ,
478482 " lengths of subdiagonal, diagonal and superdiagonal: " ,
479483 lazy " ($(length(dl)), $(length(d)), $(length(du)))" )))
480484 end
@@ -642,7 +646,7 @@ function diag(M::Tridiagonal{T}, n::Integer=0) where T
642646 elseif abs (n) <= size (M,1 )
643647 return fill! (similar (M. d, size (M,1 )- abs (n)), zero (T))
644648 else
645- throw (ArgumentError (string (lazy " requested diagonal, $n, must be at least $(-size(M, 1)) " ,
649+ throw (ArgumentError (LazyString (lazy " requested diagonal, $n, must be at least $(-size(M, 1)) " ,
646650 lazy " and at most $(size(M, 2)) for an $(size(M, 1))-by-$(size(M, 2)) matrix" )))
647651 end
648652end
695699 elseif j - i == 1
696700 @inbounds A. du[i] = x
697701 elseif ! iszero (x)
698- throw (ArgumentError (string (lazy " cannot set entry ($i, $j) off " ,
702+ throw (ArgumentError (LazyString (lazy " cannot set entry ($i, $j) off " ,
699703 lazy " the tridiagonal band to a nonzero value ($x)" )))
700704 end
701705 return x
@@ -738,7 +742,7 @@ isdiag(M::Tridiagonal) = iszero(M.dl) && iszero(M.du)
738742function tril! (M:: Tridiagonal{T} , k:: Integer = 0 ) where T
739743 n = length (M. d)
740744 if ! (- n - 1 <= k <= n - 1 )
741- throw (ArgumentError (string (lazy " the requested diagonal, $k, must be at least " ,
745+ throw (ArgumentError (LazyString (lazy " the requested diagonal, $k, must be at least " ,
742746 lazy " $(-n - 1) and at most $(n - 1) in an $n-by-$n matrix" )))
743747 elseif k < - 1
744748 fill! (M. dl, zero (T))
756760function triu! (M:: Tridiagonal{T} , k:: Integer = 0 ) where T
757761 n = length (M. d)
758762 if ! (- n + 1 <= k <= n + 1 )
759- throw (ArgumentError (string (lazy " the requested diagonal, $k, must be at least " ,
763+ throw (ArgumentError (LazyString (lazy " the requested diagonal, $k, must be at least " ,
760764 lazy " $(-n + 1) and at most $(n + 1) in an $n-by-$n matrix" )))
761765 elseif k > 1
762766 fill! (M. dl, zero (T))
0 commit comments