408
408
# so that we can re-use this code for sparse-matrix hcat etcetera.
409
409
promote_to_arrays_ (n:: Int , :: Type , a:: Number ) = a
410
410
promote_to_arrays_ (n:: Int , :: Type{Matrix} , J:: UniformScaling{T} ) where {T} = Matrix (J, n, n)
411
- promote_to_arrays_ (n:: Int , :: Type , A:: AbstractVecOrMat ) = A
411
+ promote_to_arrays_ (n:: Int , :: Type , A:: AbstractArray ) = A
412
412
promote_to_arrays (n,k, :: Type ) = ()
413
413
promote_to_arrays (n,k, :: Type{T} , A) where {T} = (promote_to_arrays_ (n[k], T, A),)
414
414
promote_to_arrays (n,k, :: Type{T} , A, B) where {T} =
@@ -417,17 +417,16 @@ promote_to_arrays(n,k, ::Type{T}, A, B, C) where {T} =
417
417
(promote_to_arrays_ (n[k], T, A), promote_to_arrays_ (n[k+ 1 ], T, B), promote_to_arrays_ (n[k+ 2 ], T, C))
418
418
promote_to_arrays (n,k, :: Type{T} , A, B, Cs... ) where {T} =
419
419
(promote_to_arrays_ (n[k], T, A), promote_to_arrays_ (n[k+ 1 ], T, B), promote_to_arrays (n,k+ 2 , T, Cs... )... )
420
- promote_to_array_type (A:: Tuple{Vararg{Union{AbstractVecOrMat,UniformScaling,Number}}} ) = Matrix
421
420
422
421
_us2number (A) = A
423
422
_us2number (J:: UniformScaling ) = J. λ
424
423
425
424
for (f, _f, dim, name) in ((:hcat , :_hcat , 1 , " rows" ), (:vcat , :_vcat , 2 , " cols" ))
426
425
@eval begin
427
- @inline $ f (A:: Union{AbstractVecOrMat ,UniformScaling} ...) = $ _f (A... )
426
+ @inline $ f (A:: Union{AbstractArray ,UniformScaling} ...) = $ _f (A... )
428
427
# if there's a Number present, J::UniformScaling must be 1x1-dimensional
429
- @inline $ f (A:: Union{AbstractVecOrMat ,UniformScaling,Number} ...) = $ f (map (_us2number, A)... )
430
- function $_f (A:: Union{AbstractVecOrMat ,UniformScaling,Number} ...; array_type = promote_to_array_type (A))
428
+ @inline $ f (A:: Union{AbstractArray ,UniformScaling,Number} ...) = $ f (map (_us2number, A)... )
429
+ function $_f (A:: Union{AbstractArray ,UniformScaling,Number} ...; array_type = promote_to_array_type (A))
431
430
n = - 1
432
431
for a in A
433
432
if ! isa (a, UniformScaling)
@@ -445,9 +444,8 @@ for (f, _f, dim, name) in ((:hcat, :_hcat, 1, "rows"), (:vcat, :_vcat, 2, "cols"
445
444
end
446
445
end
447
446
448
- hvcat (rows:: Tuple{Vararg{Int}} , A:: Union{AbstractVecOrMat,UniformScaling} ...) = _hvcat (rows, A... )
449
- hvcat (rows:: Tuple{Vararg{Int}} , A:: Union{AbstractVecOrMat,UniformScaling,Number} ...) = _hvcat (rows, A... )
450
- function _hvcat (rows:: Tuple{Vararg{Int}} , A:: Union{AbstractVecOrMat,UniformScaling,Number} ...; array_type = promote_to_array_type (A))
447
+ hvcat (rows:: Tuple{Vararg{Int}} , A:: Union{AbstractArray,UniformScaling,Number} ...) = _hvcat (rows, A... )
448
+ function _hvcat (rows:: Tuple{Vararg{Int}} , A:: Union{AbstractArray,UniformScaling,Number} ...; array_type = promote_to_array_type (A))
451
449
require_one_based_indexing (A... )
452
450
nr = length (rows)
453
451
sum (rows) == length (A) || throw (ArgumentError (" mismatch between row sizes and number of arguments" ))
0 commit comments