@@ -183,6 +183,12 @@ issymmetric(S::SymTridiagonal) = true
183
183
184
184
tr (S:: SymTridiagonal ) = sum (S. dv)
185
185
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
+
186
192
function diag (M:: SymTridiagonal{T} , n:: Integer = 0 ) where T<: Number
187
193
# every branch call similar(..., ::Int) to make sure the
188
194
# same vector type is returned independent of n
@@ -194,8 +200,7 @@ function diag(M::SymTridiagonal{T}, n::Integer=0) where T<:Number
194
200
elseif absn <= size (M,1 )
195
201
return fill! (similar (M. dv, size (M,1 )- absn), zero (T))
196
202
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))
199
204
end
200
205
end
201
206
function diag (M:: SymTridiagonal , n:: Integer = 0 )
@@ -210,8 +215,7 @@ function diag(M::SymTridiagonal, n::Integer=0)
210
215
elseif n <= size (M,1 )
211
216
throw (ArgumentError (" requested diagonal contains undefined zeros of an array type" ))
212
217
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))
215
219
end
216
220
end
217
221
@@ -353,7 +357,7 @@ isdiag(M::SymTridiagonal) = iszero(_evview(M))
353
357
function tril! (M:: SymTridiagonal{T} , k:: Integer = 0 ) where T
354
358
n = length (M. dv)
355
359
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 " ,
357
361
lazy " $(-n - 1) and at most $(n - 1) in an $n-by-$n matrix" )))
358
362
elseif k < - 1
359
363
fill! (M. ev, zero (T))
372
376
function triu! (M:: SymTridiagonal{T} , k:: Integer = 0 ) where T
373
377
n = length (M. dv)
374
378
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 " ,
376
380
lazy " $(-n + 1) and at most $(n + 1) in an $n-by-$n matrix" )))
377
381
elseif k > 1
378
382
fill! (M. ev, zero (T))
@@ -485,7 +489,7 @@ struct Tridiagonal{T,V<:AbstractVector{T}} <: AbstractMatrix{T}
485
489
require_one_based_indexing (dl, d, du)
486
490
n = length (d)
487
491
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 " ,
489
493
" lengths of subdiagonal, diagonal and superdiagonal: " ,
490
494
lazy " ($(length(dl)), $(length(d)), $(length(du)))" )))
491
495
end
@@ -658,7 +662,7 @@ function diag(M::Tridiagonal{T}, n::Integer=0) where T
658
662
elseif abs (n) <= size (M,1 )
659
663
return fill! (similar (M. d, size (M,1 )- abs (n)), zero (T))
660
664
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)) " ,
662
666
lazy " and at most $(size(M, 2)) for an $(size(M, 1))-by-$(size(M, 2)) matrix" )))
663
667
end
664
668
end
724
728
elseif j - i == 1
725
729
@inbounds A. du[i] = x
726
730
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 " ,
728
732
lazy " the tridiagonal band to a nonzero value ($x)" )))
729
733
end
730
734
return x
@@ -780,7 +784,7 @@ isdiag(M::Tridiagonal) = iszero(M.dl) && iszero(M.du)
780
784
function tril! (M:: Tridiagonal{T} , k:: Integer = 0 ) where T
781
785
n = length (M. d)
782
786
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 " ,
784
788
lazy " $(-n - 1) and at most $(n - 1) in an $n-by-$n matrix" )))
785
789
elseif k < - 1
786
790
fill! (M. dl, zero (T))
798
802
function triu! (M:: Tridiagonal{T} , k:: Integer = 0 ) where T
799
803
n = length (M. d)
800
804
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 " ,
802
806
lazy " $(-n + 1) and at most $(n + 1) in an $n-by-$n matrix" )))
803
807
elseif k > 1
804
808
fill! (M. dl, zero (T))
0 commit comments