Skip to content

Commit 12e99db

Browse files
authored
Remove redundant subtyping in type tuples (#321)
1 parent 6a81c01 commit 12e99db

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

src/generic/broadcast.jl

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ function _banded_broadcast!(dest::AbstractMatrix, f, A::AbstractMatrix{T}, ::Ban
215215
dest
216216
end
217217

218-
function copyto!(dest::AbstractArray, bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{<:AbstractMatrix}})
218+
function copyto!(dest::AbstractArray, bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{AbstractMatrix}})
219219
(A,) = bc.args
220220
_banded_broadcast!(dest, bc.f, A, MemoryLayout(typeof(dest)), MemoryLayout(typeof(A)))
221221
end
@@ -362,12 +362,12 @@ function _banded_broadcast!(dest::AbstractMatrix, f, (x, src)::Tuple{Number,Abst
362362
dest
363363
end
364364

365-
function copyto!(dest::AbstractArray, bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{<:AbstractMatrix,<:Number}})
365+
function copyto!(dest::AbstractArray, bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{AbstractMatrix,Number}})
366366
(A,x) = bc.args
367367
_banded_broadcast!(dest, bc.f, (A, x), MemoryLayout(typeof(dest)), MemoryLayout(typeof(A)))
368368
end
369369

370-
function copyto!(dest::AbstractArray, bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{<:Number,<:AbstractMatrix}})
370+
function copyto!(dest::AbstractArray, bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{Number,AbstractMatrix}})
371371
(x,A) = bc.args
372372
_banded_broadcast!(dest, bc.f, (x,A), MemoryLayout(typeof(dest)), MemoryLayout(typeof(A)))
373373
end
@@ -605,11 +605,11 @@ function _right_rowvec_banded_broadcast!(dest::AbstractMatrix, f, (A,B)::Tuple{A
605605
end
606606

607607

608-
copyto!(dest::AbstractArray, bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{<:AbstractVector,<:AbstractMatrix}}) =
608+
copyto!(dest::AbstractArray, bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{AbstractVector,AbstractMatrix}}) =
609609
_banded_broadcast!(dest, bc.f, bc.args, MemoryLayout(dest), MemoryLayout.(bc.args))
610610

611611

612-
copyto!(dest::AbstractArray, bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{<:AbstractMatrix,<:AbstractVector}}) =
612+
copyto!(dest::AbstractArray, bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{AbstractMatrix,AbstractVector}}) =
613613
_banded_broadcast!(dest, bc.f, bc.args, MemoryLayout(dest), MemoryLayout.(bc.args))
614614

615615

@@ -676,7 +676,7 @@ function __banded_broadcast!(dest::AbstractMatrix, f, (A,B)::Tuple{AbstractMatri
676676
dest
677677
end
678678

679-
function checkzerobands(dest, f, (A,B)::Tuple{AbstractMatrix,AbstractMatrix})
679+
function checkzerobands(dest, f, (A,B)::NTuple{2,AbstractMatrix})
680680
m,n = size(A)
681681
d_l, d_u = bandwidths(dest)
682682
A_l, A_u = bandwidths(A)
@@ -696,7 +696,7 @@ function checkzerobands(dest, f, (A,B)::Tuple{AbstractMatrix,AbstractMatrix})
696696
end
697697

698698

699-
function _banded_broadcast!(dest::AbstractMatrix, f, (A,B)::Tuple{AbstractMatrix,AbstractMatrix}, Mdest::BandedColumns, MAB::NTuple{2,BandedColumns})
699+
function _banded_broadcast!(dest::AbstractMatrix, f, (A,B)::NTuple{2,AbstractMatrix}, Mdest::BandedColumns, MAB::NTuple{2,BandedColumns})
700700
z = f(zero(eltype(A)), zero(eltype(B)))
701701
bc = broadcasted(f, A, B)
702702
l, u = bandwidths(bc)
@@ -769,7 +769,7 @@ function _banded_broadcast!(dest::AbstractMatrix, f, (A,B)::Tuple{AbstractMatrix
769769
end
770770

771771

772-
copyto!(dest::AbstractArray, bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{<:AbstractMatrix,<:AbstractMatrix}}) =
772+
copyto!(dest::AbstractArray, bc::Broadcasted{BandedStyle, <:Any, <:Any, <:NTuple{2,AbstractMatrix}}) =
773773
_banded_broadcast!(dest, bc.f, bc.args, MemoryLayout(typeof(dest)), map(MemoryLayout,bc.args))
774774

775775
# override copy in case data has special broadcast
@@ -798,24 +798,24 @@ function _banded_broadcast(f, (x, src)::Tuple{Number,AbstractMatrix{T}}, ::Bande
798798
_BandedMatrix(Bdata_new, axes(src,1), bandwidths(src)...)
799799
end
800800

801-
function copy(bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{<:AbstractMatrix}})
801+
function copy(bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{AbstractMatrix}})
802802
(A,) = bc.args
803803
_banded_broadcast(bc.f, A, MemoryLayout(typeof(A)))
804804
end
805805

806-
function copy(bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{<:AbstractMatrix,<:Number}})
806+
function copy(bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{AbstractMatrix,Number}})
807807
(A,x) = bc.args
808808
_banded_broadcast(bc.f, (A, x), MemoryLayout(typeof(A)))
809809
end
810810

811811

812-
function copy(bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{<:Number,<:AbstractMatrix}})
812+
function copy(bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{Number,AbstractMatrix}})
813813
(x,A) = bc.args
814814
_banded_broadcast(bc.f, (x,A), MemoryLayout(typeof(A)))
815815
end
816816

817817

818-
function copy(bc::Broadcasted{BandedStyle, <:Any, <:Any, <:Tuple{<:AbstractMatrix,<:AbstractMatrix}})
818+
function copy(bc::Broadcasted{BandedStyle, <:Any, <:Any, <:NTuple{2,AbstractMatrix}})
819819
_banded_broadcast(bc.f, bc.args, MemoryLayout.(typeof.(bc.args)))
820820
end
821821

@@ -1005,17 +1005,19 @@ end
10051005
# Should be made more general.
10061006
##
10071007
function copyto!(dest::AbstractArray{T}, bc::Broadcasted{BandedStyle, <:Any, typeof(+),
1008-
<:Tuple{<:Broadcasted{BandedStyle,<:Any,typeof(*),<:Tuple{<:Number,<:AbstractMatrix}},
1009-
<:AbstractMatrix}}) where T
1008+
<:Tuple{
1009+
Broadcasted{BandedStyle,<:Any,typeof(*),<:Tuple{Number,AbstractMatrix}},
1010+
AbstractMatrix}}) where T
10101011
αA,B = bc.args
10111012
α,A = αA.args
10121013
dest B || (dest .= B)
10131014
banded_axpy!(α, A, dest)
10141015
end
10151016

10161017
function similar(bc::Broadcasted{BandedStyle, <:Any, typeof(+),
1017-
<:Tuple{<:Broadcasted{BandedStyle,<:Any,typeof(*),<:Tuple{<:Number,<:AbstractMatrix}},
1018-
<:AbstractMatrix}}, ::Type{T}) where T
1018+
<:Tuple{
1019+
Broadcasted{BandedStyle,<:Any,typeof(*),<:Tuple{Number,AbstractMatrix}},
1020+
AbstractMatrix}}, ::Type{T}) where T
10191021
αA,B = bc.args
10201022
α,A = αA.args
10211023
n,m = size(A)

0 commit comments

Comments
 (0)