@@ -35,28 +35,6 @@ parameterless_type(x::Type) = __parameterless_type(x)
35
35
const VecAdjTrans{T,V<: AbstractVector{T} } = Union{Transpose{T,V},Adjoint{T,V}}
36
36
const MatAdjTrans{T,M<: AbstractMatrix{T} } = Union{Transpose{T,M},Adjoint{T,M}}
37
37
38
- """
39
- length(A) -> Union{Int,StaticInt}
40
-
41
- Returns the length of `A`. If the length is known at compile time, it is
42
- returned as `Static` number. Otherwise, `ArrayInterfaceCore.length(A)` is identical
43
- to `Base.length(A)`.
44
-
45
- ```julia
46
- julia> using StaticArrays, ArrayInterface
47
-
48
- julia> A = @SMatrix rand(3,4);
49
-
50
- julia> ArrayInterfaceCore.length(A)
51
- static(12)
52
- ```
53
- """
54
- @inline length (a:: UnitRange{T} ) where {T} = last (a) - first (a) + oneunit (T)
55
- @inline length (x) = Static. maybe_static (known_length, Base. length, x)
56
-
57
- # Alias to to-be-depreciated internal function
58
- const static_length = length
59
-
60
38
@inline static_first (x) = Static. maybe_static (known_first, first, x)
61
39
@inline static_last (x) = Static. maybe_static (known_last, last, x)
62
40
@inline static_step (x) = Static. maybe_static (known_step, step, x)
@@ -101,43 +79,6 @@ buffer(x) = parent(x)
101
79
buffer (x:: SparseMatrixCSC ) = getfield (x, :nzval )
102
80
buffer (x:: SparseVector ) = getfield (x, :nzval )
103
81
104
- """
105
- known_length(::Type{T}) -> Union{Int,Nothing}
106
-
107
- If `length` of an instance of type `T` is known at compile time, return it.
108
- Otherwise, return `nothing`.
109
- """
110
- known_length (x) = known_length (typeof (x))
111
- known_length (:: Type{<:NamedTuple{L}} ) where {L} = length (L)
112
- known_length (:: Type{T} ) where {T<: Slice } = known_length (parent_type (T))
113
- known_length (:: Type{<:Tuple{Vararg{Any,N}}} ) where {N} = N
114
- known_length (:: Type{<:Number} ) = 1
115
- known_length (:: Type{<:AbstractCartesianIndex{N}} ) where {N} = N
116
- known_length (:: Type{T} ) where {T} = _maybe_known_length (Base. IteratorSize (T), T)
117
-
118
- @generated function _prod_or_nothing (x:: Tuple )
119
- p = 1
120
- for i in eachindex (x. parameters)
121
- x. parameters[i] === Nothing && return nothing
122
- p *= x. parameters[i]. parameters[1 ]
123
- end
124
- StaticInt (p)
125
- end
126
-
127
- function _maybe_known_length (:: Base.HasShape , :: Type{T} ) where {T}
128
- t = map (_static_or_nothing, known_size (T))
129
- _int_or_nothing (_prod_or_nothing (t))
130
- end
131
-
132
- _maybe_known_length (:: Base.IteratorSize , :: Type ) = nothing
133
- _static_or_nothing (:: Nothing ) = nothing
134
- @inline _static_or_nothing (x:: Int ) = StaticInt {x} ()
135
- _int_or_nothing (:: StaticInt{N} ) where {N} = N
136
- _int_or_nothing (:: Nothing ) = nothing
137
- function known_length (:: Type{<:Iterators.Flatten{I}} ) where {I}
138
- _int_or_nothing (_prod_or_nothing ((_static_or_nothing (known_length (I)),_static_or_nothing (known_length (eltype (I))))))
139
- end
140
-
141
82
"""
142
83
can_change_size(::Type{T}) -> Bool
143
84
@@ -478,22 +419,6 @@ _not_pointer(x) = x
478
419
_device (:: False , :: Type{T} ) where {T<: DenseArray } = CPUPointer ()
479
420
_device (:: False , :: Type{T} ) where {T} = CPUIndex ()
480
421
481
- """
482
- defines_strides(::Type{T}) -> Bool
483
-
484
- Is strides(::T) defined? It is assumed that types returning `true` also return a valid
485
- pointer on `pointer(::T)`.
486
- """
487
- defines_strides (x) = defines_strides (typeof (x))
488
- _defines_strides (:: Type{T} , :: Type{T} ) where {T} = false
489
- _defines_strides (:: Type{P} , :: Type{T} ) where {P,T} = defines_strides (P)
490
- defines_strides (:: Type{T} ) where {T} = _defines_strides (parent_type (T), T)
491
- defines_strides (:: Type{<:StridedArray} ) = true
492
- function defines_strides (:: Type{<:SubArray{T,N,P,I}} ) where {T,N,P,I}
493
- return stride_preserving_index (I) === True ()
494
- end
495
- defines_strides (:: Type{<:BitArray} ) = true
496
-
497
422
"""
498
423
can_avx(f) -> Bool
499
424
0 commit comments