@@ -183,6 +183,12 @@ issymmetric(S::SymTridiagonal) = true
183183
184184tr (S:: SymTridiagonal ) = sum (S. dv)
185185
186+ @noinline function throw_diag_outofboundserror (n, sz)
187+ sz1, sz2 = sz
188+ throw (ArgumentError (LazyString (lazy " requested diagonal, $n, must be at least $(-sz1) " ,
189+ lazy " and at most $sz2 for an $(sz1)-by-$(sz2) matrix" )))
190+ end
191+
186192function diag (M:: SymTridiagonal{T} , n:: Integer = 0 ) where T<: Number
187193 # every branch call similar(..., ::Int) to make sure the
188194 # same vector type is returned independent of n
@@ -194,8 +200,7 @@ function diag(M::SymTridiagonal{T}, n::Integer=0) where T<:Number
194200 elseif absn <= size (M,1 )
195201 return fill! (similar (M. dv, size (M,1 )- absn), zero (T))
196202 else
197- throw (ArgumentError (string (lazy " requested diagonal, $n, must be at least $(-size(M, 1)) " ,
198- lazy " and at most $(size(M, 2)) for an $(size(M, 1))-by-$(size(M, 2)) matrix" )))
203+ throw_diag_outofboundserror (n, size (M))
199204 end
200205end
201206function diag (M:: SymTridiagonal , n:: Integer = 0 )
@@ -210,8 +215,7 @@ function diag(M::SymTridiagonal, n::Integer=0)
210215 elseif n <= size (M,1 )
211216 throw (ArgumentError (" requested diagonal contains undefined zeros of an array type" ))
212217 else
213- throw (ArgumentError (string (lazy " requested diagonal, $n, must be at least $(-size(M, 1)) " ,
214- lazy " and at most $(size(M, 2)) for an $(size(M, 1))-by-$(size(M, 2)) matrix" )))
218+ throw_diag_outofboundserror (n, size (M))
215219 end
216220end
217221
@@ -353,7 +357,7 @@ isdiag(M::SymTridiagonal) = iszero(_evview(M))
353357function tril! (M:: SymTridiagonal{T} , k:: Integer = 0 ) where T
354358 n = length (M. dv)
355359 if ! (- n - 1 <= k <= n - 1 )
356- throw (ArgumentError (string (lazy " the requested diagonal, $k, must be at least " ,
360+ throw (ArgumentError (LazyString (lazy " the requested diagonal, $k, must be at least " ,
357361 lazy " $(-n - 1) and at most $(n - 1) in an $n-by-$n matrix" )))
358362 elseif k < - 1
359363 fill! (M. ev, zero (T))
372376function triu! (M:: SymTridiagonal{T} , k:: Integer = 0 ) where T
373377 n = length (M. dv)
374378 if ! (- n + 1 <= k <= n + 1 )
375- throw (ArgumentError (string (lazy " the requested diagonal, $k, must be at least " ,
379+ throw (ArgumentError (LazyString (lazy " the requested diagonal, $k, must be at least " ,
376380 lazy " $(-n + 1) and at most $(n + 1) in an $n-by-$n matrix" )))
377381 elseif k > 1
378382 fill! (M. ev, zero (T))
@@ -485,7 +489,7 @@ struct Tridiagonal{T,V<:AbstractVector{T}} <: AbstractMatrix{T}
485489 require_one_based_indexing (dl, d, du)
486490 n = length (d)
487491 if (length (dl) != n- 1 || length (du) != n- 1 ) && ! (length (d) == 0 && length (dl) == 0 && length (du) == 0 )
488- throw (ArgumentError (string (" cannot construct Tridiagonal from incompatible " ,
492+ throw (ArgumentError (LazyString (" cannot construct Tridiagonal from incompatible " ,
489493 " lengths of subdiagonal, diagonal and superdiagonal: " ,
490494 lazy " ($(length(dl)), $(length(d)), $(length(du)))" )))
491495 end
@@ -658,7 +662,7 @@ function diag(M::Tridiagonal{T}, n::Integer=0) where T
658662 elseif abs (n) <= size (M,1 )
659663 return fill! (similar (M. d, size (M,1 )- abs (n)), zero (T))
660664 else
661- throw (ArgumentError (string (lazy " requested diagonal, $n, must be at least $(-size(M, 1)) " ,
665+ throw (ArgumentError (LazyString (lazy " requested diagonal, $n, must be at least $(-size(M, 1)) " ,
662666 lazy " and at most $(size(M, 2)) for an $(size(M, 1))-by-$(size(M, 2)) matrix" )))
663667 end
664668end
724728 elseif j - i == 1
725729 @inbounds A. du[i] = x
726730 elseif ! iszero (x)
727- throw (ArgumentError (string (lazy " cannot set entry ($i, $j) off " ,
731+ throw (ArgumentError (LazyString (lazy " cannot set entry ($i, $j) off " ,
728732 lazy " the tridiagonal band to a nonzero value ($x)" )))
729733 end
730734 return x
@@ -780,7 +784,7 @@ isdiag(M::Tridiagonal) = iszero(M.dl) && iszero(M.du)
780784function tril! (M:: Tridiagonal{T} , k:: Integer = 0 ) where T
781785 n = length (M. d)
782786 if ! (- n - 1 <= k <= n - 1 )
783- throw (ArgumentError (string (lazy " the requested diagonal, $k, must be at least " ,
787+ throw (ArgumentError (LazyString (lazy " the requested diagonal, $k, must be at least " ,
784788 lazy " $(-n - 1) and at most $(n - 1) in an $n-by-$n matrix" )))
785789 elseif k < - 1
786790 fill! (M. dl, zero (T))
798802function triu! (M:: Tridiagonal{T} , k:: Integer = 0 ) where T
799803 n = length (M. d)
800804 if ! (- n + 1 <= k <= n + 1 )
801- throw (ArgumentError (string (lazy " the requested diagonal, $k, must be at least " ,
805+ throw (ArgumentError (LazyString (lazy " the requested diagonal, $k, must be at least " ,
802806 lazy " $(-n + 1) and at most $(n + 1) in an $n-by-$n matrix" )))
803807 elseif k > 1
804808 fill! (M. dl, zero (T))
0 commit comments