6565function mult_axes (a, b)
6666 Base. require_one_based_indexing (a, b)
6767 size (a, 2 ) ≠ size (b, 1 ) &&
68- throw (DimensionMismatch (" A has dimensions $( size (a)) but B has dimensions $( size (b))" ))
68+ throw (DimensionMismatch (LazyString ( " A has dimensions " , size (a), " but B has dimensions " , size (b))))
6969 return (axes (a, 1 ), axes (b)[2 : end ]. .. )
7070end
7171
@@ -115,11 +115,11 @@ function *(F::AbstractFillMatrix, v::AbstractVector)
115115end
116116
117117function lmul_diag (a:: Diagonal , b)
118- size (a,2 ) == size (b,1 ) || throw (DimensionMismatch (" A has dimensions $( size (a)) but B has dimensions $( size (b))" ))
118+ size (a,2 ) == size (b,1 ) || throw (DimensionMismatch (LazyString ( " A has dimensions " , size (a), " but B has dimensions " , size (b))))
119119 parent (a) .* b # use special broadcast
120120end
121121function rmul_diag (a, b:: Diagonal )
122- size (a,2 ) == size (b,1 ) || throw (DimensionMismatch (" A has dimensions $( size (a)) but B has dimensions $( size (b))" ))
122+ size (a,2 ) == size (b,1 ) || throw (DimensionMismatch (LazyString ( " A has dimensions " , size (a), " but B has dimensions " , size (b))))
123123 a .* permutedims (parent (b)) # use special broadcast
124124end
125125
@@ -132,26 +132,26 @@ end
132132@noinline function check_matmul_sizes (A:: AbstractMatrix , x:: AbstractVector )
133133 Base. require_one_based_indexing (A, x)
134134 size (A,2 ) == size (x,1 ) ||
135- throw (DimensionMismatch (" second dimension of A, $( size (A,2 )) does not match length of x $( length (x))" ))
135+ throw (DimensionMismatch (LazyString ( " second dimension of A, " , size (A,2 ), " , does not match length of x, " , length (x))))
136136end
137137@noinline function check_matmul_sizes (A:: AbstractMatrix , B:: AbstractMatrix )
138138 Base. require_one_based_indexing (A, B)
139139 size (A,2 ) == size (B,1 ) ||
140- throw (DimensionMismatch (" second dimension of A, $( size (A,2 )) does not match first dimension of B, $( size (B,1 ))" ))
140+ throw (DimensionMismatch (LazyString ( " second dimension of A, " , size (A,2 ), " , does not match first dimension of B, " , size (B,1 ))))
141141end
142142@noinline function check_matmul_sizes (y:: AbstractVector , A:: AbstractMatrix , x:: AbstractVector )
143143 Base. require_one_based_indexing (A, x, y)
144144 size (A,2 ) == size (x,1 ) ||
145- throw (DimensionMismatch (" second dimension of A, $( size (A,2 )) does not match length of x $( length (x))" ))
145+ throw (DimensionMismatch (LazyString ( " second dimension of A, " , size (A,2 ), " , does not match length of x, " , length (x))))
146146 size (y,1 ) == size (A,1 ) ||
147- throw (DimensionMismatch (" first dimension of A, $( size (A,1 )) does not match length of y $( length (y))" ))
147+ throw (DimensionMismatch (LazyString ( " first dimension of A, " , size (A,1 ), " , does not match length of y, " , length (y))))
148148end
149149@noinline function check_matmul_sizes (C:: AbstractMatrix , A:: AbstractMatrix , B:: AbstractMatrix )
150150 Base. require_one_based_indexing (A, B, C)
151151 size (A,2 ) == size (B,1 ) ||
152- throw (DimensionMismatch (" second dimension of A, $( size (A,2 )) does not match first dimension of B, $( size (B,1 ))" ))
152+ throw (DimensionMismatch (LazyString ( " second dimension of A, " , size (A,2 ), " , does not match first dimension of B, " , size (B,1 ))))
153153 size (C,1 ) == size (A,1 ) && size (C,2 ) == size (B,2 ) ||
154- throw (DimensionMismatch (" A has size $( size (A)) , B has size $( size (B)) , C has size $( size (C))" ))
154+ throw (DimensionMismatch (LazyString ( " A has size " , size (A), " , B has size " , size (B), " , C has size " , size (C))))
155155end
156156
157157function mul! (y:: AbstractVector , A:: AbstractFillMatrix , b:: AbstractFillVector , alpha:: Number , beta:: Number )
314314function _adjvec_mul_zeros (a, b)
315315 la, lb = length (a), length (b)
316316 if la ≠ lb
317- throw (DimensionMismatch (" dot product arguments have lengths $la and $lb " ))
317+ throw (DimensionMismatch (LazyString ( " dot product arguments have lengths " , la, " and " , lb) ))
318318 end
319319 # ensure that all the elements of `a` are of the same size,
320320 # so that ∑ᵢaᵢbᵢ = b₁∑ᵢaᵢ makes sense
@@ -324,7 +324,7 @@ function _adjvec_mul_zeros(a, b)
324324 end
325325 a1 = a[1 ]
326326 sza1 = size (a1)
327- all (x -> size (x) == sza1, a) || throw (DimensionMismatch (" not all elements of A are of size $sza1 " ))
327+ all (x -> size (x) == sza1, a) || throw (DimensionMismatch (LazyString ( " not all elements of A are of size " , sza1) ))
328328 # we replace b₁∑ᵢaᵢ by b₁a₁, as we know that b₁ is zero.
329329 # Each term in the summation is zero, so the sum is equal to the first term
330330 return a1 * b[1 ]
365365* (a:: TransposeAbsVec{<:Any,<:AbstractZerosVector} , D:: Diagonal ) = transpose (D* transpose (a))
366366function _triple_zeromul (x, D:: Diagonal , y)
367367 if ! (length (x) == length (D. diag) == length (y))
368- throw (DimensionMismatch (" x has length $( length (x)) , D has size $( size (D)) , and y has $( length (y))" ))
368+ throw (DimensionMismatch (LazyString ( " x has length " , length (x), " , D has size " , size (D), " , and y has " , length (y))))
369369 end
370370 zero (promote_type (eltype (x), eltype (D), eltype (y)))
371371end
381381function * (a:: Transpose{T, <:AbstractVector} , b:: AbstractZerosVector{T} ) where T<: Real
382382 la, lb = length (a), length (b)
383383 if la ≠ lb
384- throw (DimensionMismatch (" dot product arguments have lengths $la and $lb " ))
384+ throw (DimensionMismatch (LazyString ( " dot product arguments have lengths " , la, " and " , lb) ))
385385 end
386386 return zero (T)
387387end
@@ -391,12 +391,12 @@ end
391391# infinite cases should be supported in InfiniteArrays.jl
392392# type issues of Bool dot are ignored at present.
393393function _fill_dot (a:: AbstractFillVector{T} , b:: AbstractVector{V} ) where {T,V}
394- axes (a) == axes (b) || throw (DimensionMismatch (" dot product arguments have lengths $( length (a)) and $( length (b))" ))
394+ axes (a) == axes (b) || throw (DimensionMismatch (LazyString ( " dot product arguments have lengths " , length (a), " and " , length (b))))
395395 dot (getindex_value (a), sum (b))
396396end
397397
398398function _fill_dot_rev (a:: AbstractVector{T} , b:: AbstractFillVector{V} ) where {T,V}
399- axes (a) == axes (b) || throw (DimensionMismatch (" dot product arguments have lengths $( length (a)) and $( length (b))" ))
399+ axes (a) == axes (b) || throw (DimensionMismatch (LazyString ( " dot product arguments have lengths " , length (a), " and " , length (b))))
400400 dot (sum (a), getindex_value (b))
401401end
402402
@@ -406,21 +406,21 @@ dot(a::AbstractVector, b::AbstractFillVector) = _fill_dot_rev(a, b)
406406
407407function dot (u:: AbstractVector , E:: Eye , v:: AbstractVector )
408408 length (u) == size (E,1 ) && length (v) == size (E,2 ) ||
409- throw (DimensionMismatch (" dot product arguments have dimensions $( length (u)) × $( size (E)) × $( length (v))" ))
409+ throw (DimensionMismatch (LazyString ( " dot product arguments have dimensions " , length (u), " × " , size (E), " × " , length (v))))
410410 d = dot (u,v)
411411 T = typeof (one (eltype (E)) * d)
412412 convert (T, d)
413413end
414414
415415function dot (u:: AbstractVector , D:: Diagonal{<:Any,<:Fill} , v:: AbstractVector )
416416 length (u) == size (D,1 ) && length (v) == size (D,2 ) ||
417- throw (DimensionMismatch (" dot product arguments have dimensions $( length (u)) × $( size (D)) × $( length (v))" ))
417+ throw (DimensionMismatch (LazyString ( " dot product arguments have dimensions " , length (u), " × " , size (D), " × " , length (v))))
418418 D. diag. value* dot (u, v)
419419end
420420
421421function dot (u:: AbstractVector{T} , D:: Diagonal{U,<:Zeros} , v:: AbstractVector{V} ) where {T,U,V}
422422 length (u) == size (D,1 ) && length (v) == size (D,2 ) ||
423- throw (DimensionMismatch (" dot product arguments have dimensions $( length (u)) × $( size (D)) × $( length (v))" ))
423+ throw (DimensionMismatch (LazyString ( " dot product arguments have dimensions " , length (u), " × " , size (D), " × " , length (v))))
424424 zero (promote_type (T,U,V))
425425end
426426
@@ -516,21 +516,21 @@ function lmul!(x::Number, z::AbstractFill)
516516 λ = getindex_value (z)
517517 # Following check ensures consistency w/ lmul!(x, Array(z))
518518 # for, e.g., lmul!(NaN, z)
519- x* λ == λ || throw (ArgumentError (" Cannot scale by $x " ))
519+ x* λ == λ || throw (ArgumentError (LazyString ( " Cannot scale by " , x) ))
520520 z
521521end
522522
523523function rmul! (z:: AbstractFill , x:: Number )
524524 λ = getindex_value (z)
525525 # Following check ensures consistency w/ lmul!(x, Array(z))
526526 # for, e.g., lmul!(NaN, z)
527- λ* x == λ || throw (ArgumentError (" Cannot scale by $x " ))
527+ λ* x == λ || throw (ArgumentError (LazyString ( " Cannot scale by " , x) ))
528528 z
529529end
530530
531531fillzero (:: Type{Fill{T,N,AXIS}} , n, m) where {T,N,AXIS} = Fill {T,N,AXIS} (zero (T), (n, m))
532532fillzero (:: Type{<:AbstractZeros{T,N,AXIS}} , n, m) where {T,N,AXIS} = Zeros {T,N,AXIS} ((n, m))
533- fillzero (:: Type{F} , n, m) where F = throw (ArgumentError (" Cannot create a zero array of type $F " ))
533+ fillzero (:: Type{F} , n, m) where F = throw (ArgumentError (LazyString ( " Cannot create a zero array of type " , F) ))
534534
535535diagzero (D:: Diagonal{F} , i, j) where F<: AbstractFill = fillzero (F, axes (D. diag[i], 1 ), axes (D. diag[j], 2 ))
536536
0 commit comments