@@ -35,7 +35,7 @@ julia> indices(A,2)
35
35
Base.OneTo(6)
36
36
```
37
37
"""
38
- function indices {T,N} (A:: AbstractArray{T,N} , d)
38
+ function indices (A:: AbstractArray{T,N} , d) where {T,N}
39
39
@_inline_meta
40
40
d <= N ? indices (A)[d] : OneTo (1 )
41
41
end
@@ -901,7 +901,7 @@ function _getindex(::IndexLinear, A::AbstractArray, I::Int...)
901
901
end
902
902
_to_linear_index (A:: AbstractArray , i:: Int ) = i
903
903
_to_linear_index (A:: AbstractVector , i:: Int , I:: Int... ) = i # TODO : DEPRECATE FOR #14770
904
- _to_linear_index {T,N} (A:: AbstractArray{T,N} , I:: Vararg{Int,N} ) = (@_inline_meta ; sub2ind (A, I... ))
904
+ _to_linear_index (A:: AbstractArray{T,N} , I:: Vararg{Int,N} ) where {T,N} = (@_inline_meta ; sub2ind (A, I... ))
905
905
_to_linear_index (A:: AbstractArray ) = 1 # TODO : DEPRECATE FOR #14770
906
906
_to_linear_index (A:: AbstractArray , I:: Int... ) = (@_inline_meta ; sub2ind (A, I... )) # TODO : DEPRECATE FOR #14770
907
907
@@ -916,16 +916,16 @@ function _getindex(::IndexCartesian, A::AbstractArray, I::Int...)
916
916
@inbounds r = getindex (A, _to_subscript_indices (A, I... )... )
917
917
r
918
918
end
919
- function _getindex {T,N} (:: IndexCartesian , A:: AbstractArray{T,N} , I:: Vararg{Int, N} )
919
+ function _getindex (:: IndexCartesian , A:: AbstractArray{T,N} , I:: Vararg{Int, N} ) where {T,N}
920
920
@_propagate_inbounds_meta
921
921
getindex (A, I... )
922
922
end
923
923
_to_subscript_indices (A:: AbstractArray , i:: Int ) = (@_inline_meta ; _unsafe_ind2sub (A, i))
924
- _to_subscript_indices {T,N} (A:: AbstractArray{T,N} ) = (@_inline_meta ; fill_to_length ((), 1 , Val{N})) # TODO : DEPRECATE FOR #14770
925
- _to_subscript_indices {T} (A:: AbstractArray{T,0} ) = () # TODO : REMOVE FOR #14770
926
- _to_subscript_indices {T} (A:: AbstractArray{T,0} , i:: Int ) = () # TODO : REMOVE FOR #14770
927
- _to_subscript_indices {T} (A:: AbstractArray{T,0} , I:: Int... ) = () # TODO : DEPRECATE FOR #14770
928
- function _to_subscript_indices {T,N} (A:: AbstractArray{T,N} , I:: Int... ) # TODO : DEPRECATE FOR #14770
924
+ _to_subscript_indices (A:: AbstractArray{T,N} ) where {T,N} = (@_inline_meta ; fill_to_length ((), 1 , Val{N})) # TODO : DEPRECATE FOR #14770
925
+ _to_subscript_indices (A:: AbstractArray{T,0} ) where {T} = () # TODO : REMOVE FOR #14770
926
+ _to_subscript_indices (A:: AbstractArray{T,0} , i:: Int ) where {T} = () # TODO : REMOVE FOR #14770
927
+ _to_subscript_indices (A:: AbstractArray{T,0} , I:: Int... ) where {T} = () # TODO : DEPRECATE FOR #14770
928
+ function _to_subscript_indices (A:: AbstractArray{T,N} , I:: Int... ) where {T,N} # TODO : DEPRECATE FOR #14770
929
929
@_inline_meta
930
930
J, Jrem = IteratorsMD. split (I, Val{N})
931
931
_to_subscript_indices (A, J, Jrem)
@@ -946,7 +946,7 @@ function __to_subscript_indices(A::AbstractArray,
946
946
(J... , map (first, tail (_remaining_size (J, indices (A))))... )
947
947
end
948
948
_to_subscript_indices (A, J:: Tuple , Jrem:: Tuple ) = J # already bounds-checked, safe to drop
949
- _to_subscript_indices {T,N} (A:: AbstractArray{T,N} , I:: Vararg{Int,N} ) = I
949
+ _to_subscript_indices (A:: AbstractArray{T,N} , I:: Vararg{Int,N} ) where {T,N} = I
950
950
_remaining_size (:: Tuple{Any} , t:: Tuple ) = t
951
951
_remaining_size (h:: Tuple , t:: Tuple ) = (@_inline_meta ; _remaining_size (tail (h), tail (t)))
952
952
_unsafe_ind2sub (:: Tuple{} , i) = () # ind2sub may throw(BoundsError()) in this case
@@ -979,7 +979,7 @@ function _setindex!(::IndexLinear, A::AbstractArray, v, I::Int...)
979
979
end
980
980
981
981
# IndexCartesian Scalar indexing
982
- function _setindex! {T,N} (:: IndexCartesian , A:: AbstractArray{T,N} , v, I:: Vararg{Int, N} )
982
+ function _setindex! (:: IndexCartesian , A:: AbstractArray{T,N} , v, I:: Vararg{Int, N} ) where {T,N}
983
983
@_propagate_inbounds_meta
984
984
setindex! (A, v, I... )
985
985
end
@@ -1051,8 +1051,8 @@ promote_eltype(v1, vs...) = promote_type(eltype(v1), promote_eltype(vs...))
1051
1051
# TODO : ERROR CHECK
1052
1052
cat (catdim:: Integer ) = Array {Any,1} (0 )
1053
1053
1054
- typed_vcat {T} (:: Type{T} ) = Array {T,1} (0 )
1055
- typed_hcat {T} (:: Type{T} ) = Array {T,1} (0 )
1054
+ typed_vcat (:: Type{T} ) where {T} = Array {T,1} (0 )
1055
+ typed_hcat (:: Type{T} ) where {T} = Array {T,1} (0 )
1056
1056
1057
1057
# # cat: special cases
1058
1058
vcat (X:: T... ) where {T} = T[ X[i] for i= 1 : length (X) ]
@@ -1062,13 +1062,13 @@ hcat(X::T...) where {T<:Number} = T[ X[j] for i=1:1, j=1:length(X) ]
1062
1062
1063
1063
vcat (X:: Number... ) = hvcat_fill (Array {promote_typeof(X...)} (length (X)), X)
1064
1064
hcat (X:: Number... ) = hvcat_fill (Array {promote_typeof(X...)} (1 ,length (X)), X)
1065
- typed_vcat {T} (:: Type{T} , X:: Number... ) = hvcat_fill (Array {T,1} (length (X)), X)
1066
- typed_hcat {T} (:: Type{T} , X:: Number... ) = hvcat_fill (Array {T,2} (1 ,length (X)), X)
1065
+ typed_vcat (:: Type{T} , X:: Number... ) where {T} = hvcat_fill (Array {T,1} (length (X)), X)
1066
+ typed_hcat (:: Type{T} , X:: Number... ) where {T} = hvcat_fill (Array {T,2} (1 ,length (X)), X)
1067
1067
1068
1068
vcat (V:: AbstractVector... ) = typed_vcat (promote_eltype (V... ), V... )
1069
1069
vcat (V:: AbstractVector{T} ...) where {T} = typed_vcat (T, V... )
1070
1070
1071
- function typed_vcat {T} (:: Type{T} , V:: AbstractVector... )
1071
+ function typed_vcat (:: Type{T} , V:: AbstractVector... ) where T
1072
1072
n:: Int = 0
1073
1073
for Vk in V
1074
1074
n += length (Vk)
@@ -1087,7 +1087,7 @@ end
1087
1087
hcat (A:: AbstractVecOrMat... ) = typed_hcat (promote_eltype (A... ), A... )
1088
1088
hcat (A:: AbstractVecOrMat{T} ...) where {T} = typed_hcat (T, A... )
1089
1089
1090
- function typed_hcat {T} (:: Type{T} , A:: AbstractVecOrMat... )
1090
+ function typed_hcat (:: Type{T} , A:: AbstractVecOrMat... ) where T
1091
1091
nargs = length (A)
1092
1092
nrows = size (A[1 ], 1 )
1093
1093
ncols = 0
@@ -1124,7 +1124,7 @@ end
1124
1124
vcat (A:: AbstractMatrix... ) = typed_vcat (promote_eltype (A... ), A... )
1125
1125
vcat (A:: AbstractMatrix{T} ...) where {T} = typed_vcat (T, A... )
1126
1126
1127
- function typed_vcat {T} (:: Type{T} , A:: AbstractMatrix... )
1127
+ function typed_vcat (:: Type{T} , A:: AbstractMatrix... ) where T
1128
1128
nargs = length (A)
1129
1129
nrows = sum (a-> size (a, 1 ), A):: Int
1130
1130
ncols = size (A[1 ], 2 )
@@ -1200,7 +1200,7 @@ function cat_t(dims, T::Type, X...)
1200
1200
return _cat (A, shape, catdims, X... )
1201
1201
end
1202
1202
1203
- function _cat {N} (A, shape:: NTuple{N} , catdims, X... )
1203
+ function _cat (A, shape:: NTuple{N} , catdims, X... ) where N
1204
1204
offsets = zeros (Int, N)
1205
1205
inds = Vector {UnitRange{Int}} (N)
1206
1206
concat = copy! (zeros (Bool, N), catdims)
@@ -1295,7 +1295,7 @@ hcat(X...) = cat(Val{2}, X...)
1295
1295
typed_vcat (T:: Type , X... ) = cat_t (Val{1 }, T, X... )
1296
1296
typed_hcat (T:: Type , X... ) = cat_t (Val{2 }, T, X... )
1297
1297
1298
- cat {T} (catdims, A:: AbstractArray{T} ...) = cat_t (catdims, T, A... )
1298
+ cat (catdims, A:: AbstractArray{T} ...) where {T} = cat_t (catdims, T, A... )
1299
1299
1300
1300
# The specializations for 1 and 2 inputs are important
1301
1301
# especially when running with --inline=no, see #11158
@@ -1362,9 +1362,9 @@ If the first argument is a single integer `n`, then all block rows are assumed t
1362
1362
block columns.
1363
1363
"""
1364
1364
hvcat (rows:: Tuple{Vararg{Int}} , xs:: AbstractVecOrMat... ) = typed_hvcat (promote_eltype (xs... ), rows, xs... )
1365
- hvcat {T} (rows:: Tuple{Vararg{Int}} , xs:: AbstractVecOrMat{T} ...) = typed_hvcat (T, rows, xs... )
1365
+ hvcat (rows:: Tuple{Vararg{Int}} , xs:: AbstractVecOrMat{T} ...) where {T} = typed_hvcat (T, rows, xs... )
1366
1366
1367
- function typed_hvcat {T} (:: Type{T} , rows:: Tuple{Vararg{Int}} , as:: AbstractVecOrMat... )
1367
+ function typed_hvcat (:: Type{T} , rows:: Tuple{Vararg{Int}} , as:: AbstractVecOrMat... ) where T
1368
1368
nbr = length (rows) # number of block rows
1369
1369
1370
1370
nc = 0
@@ -1408,9 +1408,9 @@ function typed_hvcat{T}(::Type{T}, rows::Tuple{Vararg{Int}}, as::AbstractVecOrMa
1408
1408
end
1409
1409
1410
1410
hvcat (rows:: Tuple{Vararg{Int}} ) = []
1411
- typed_hvcat {T} (:: Type{T} , rows:: Tuple{Vararg{Int}} ) = Array {T,1} (0 )
1411
+ typed_hvcat (:: Type{T} , rows:: Tuple{Vararg{Int}} ) where {T} = Array {T,1} (0 )
1412
1412
1413
- function hvcat {T<:Number} (rows:: Tuple{Vararg{Int}} , xs:: T... )
1413
+ function hvcat (rows:: Tuple{Vararg{Int}} , xs:: T... ) where T <: Number
1414
1414
nr = length (rows)
1415
1415
nc = rows[1 ]
1416
1416
@@ -1445,7 +1445,7 @@ end
1445
1445
1446
1446
hvcat (rows:: Tuple{Vararg{Int}} , xs:: Number... ) = typed_hvcat (promote_typeof (xs... ), rows, xs... )
1447
1447
1448
- function typed_hvcat {T} (:: Type{T} , rows:: Tuple{Vararg{Int}} , xs:: Number... )
1448
+ function typed_hvcat (:: Type{T} , rows:: Tuple{Vararg{Int}} , xs:: Number... ) where T
1449
1449
nr = length (rows)
1450
1450
nc = rows[1 ]
1451
1451
for i = 2 : nr
@@ -1472,7 +1472,7 @@ function hvcat(rows::Tuple{Vararg{Int}}, as...)
1472
1472
vcat (rs... )
1473
1473
end
1474
1474
1475
- function typed_hvcat {T} (:: Type{T} , rows:: Tuple{Vararg{Int}} , as... )
1475
+ function typed_hvcat (:: Type{T} , rows:: Tuple{Vararg{Int}} , as... ) where T
1476
1476
nbr = length (rows) # number of block rows
1477
1477
rs = Array {Any,1} (nbr)
1478
1478
a = 1
0 commit comments