@@ -10,9 +10,15 @@ using Static: Zero, One, nstatic, _get_tuple, eq, ne, gt, ge, lt, le, eachop, ea
10
10
using Base. Cartesian
11
11
12
12
using Base: @propagate_inbounds , tail, OneTo, LogicalIndex, Slice, ReinterpretArray,
13
- ReshapedArray
13
+ ReshapedArray, AbstractCartesianIndex
14
14
15
15
16
+ # # utilites for internal use only ##
17
+ _int_or_static_int (:: Nothing ) = Int
18
+ _int_or_static_int (x:: Int ) = StaticInt{x}
19
+ _int (i:: Integer ) = Int (i)
20
+ _int (i:: StaticInt ) = i
21
+
16
22
@static if VERSION >= v " 1.7.0-DEV.421"
17
23
using Base: @aggressive_constprop
18
24
else
21
27
end
22
28
end
23
29
30
+ static_ndims (x) = static (ndims (x))
31
+
24
32
if VERSION ≥ v " 1.6.0-DEV.1581"
25
33
_is_reshaped (:: Type{ReinterpretArray{T,N,S,A,true}} ) where {T,N,S,A} = true
26
34
_is_reshaped (:: Type{ReinterpretArray{T,N,S,A,false}} ) where {T,N,S,A} = false
@@ -34,6 +42,8 @@ parameterless_type(x::Type) = __parameterless_type(x)
34
42
35
43
const VecAdjTrans{T,V<: AbstractVector{T} } = Union{Transpose{T,V},Adjoint{T,V}}
36
44
const MatAdjTrans{T,M<: AbstractMatrix{T} } = Union{Transpose{T,M},Adjoint{T,M}}
45
+ const UpTri{T,M} = Union{UpperTriangular{T,M},UnitUpperTriangular{T,M}}
46
+ const LoTri{T,M} = Union{LowerTriangular{T,M},UnitLowerTriangular{T,M}}
37
47
38
48
@inline static_length (a:: UnitRange{T} ) where {T} = last (a) - first (a) + oneunit (T)
39
49
@inline static_length (x) = Static. maybe_static (known_length, length, x)
@@ -57,12 +67,15 @@ parent_type(::Type{<:PermutedDimsArray{T,N,I1,I2,A}}) where {T,N,I1,I2,A} = A
57
67
parent_type (:: Type{Slice{T}} ) where {T} = T
58
68
parent_type (:: Type{T} ) where {T} = T
59
69
parent_type (:: Type{R} ) where {S,T,A,N,R<: Base.ReinterpretArray{T,N,S,A} } = A
60
-
70
+ parent_type (:: Type{LoTri{T,M}} ) where {T,M} = M
71
+ parent_type (:: Type{UpTri{T,M}} ) where {T,M} = M
72
+ parent_type (:: Type{Diagonal{T,V}} ) where {T,V} = V
61
73
"""
62
74
has_parent(::Type{T}) -> StaticBool
63
75
64
76
Returns `True` if `parent_type(T)` a type unique to `T`.
65
77
"""
78
+ has_parent (x) = has_parent (typeof (x))
66
79
has_parent (:: Type{T} ) where {T} = _has_parent (parent_type (T), T)
67
80
_has_parent (:: Type{T} , :: Type{T} ) where {T} = False ()
68
81
_has_parent (:: Type{T1} , :: Type{T2} ) where {T1,T2} = True ()
786
799
end
787
800
end
788
801
789
- include (" ranges.jl" )
790
- include (" indexing.jl" )
791
- include (" dimensions.jl" )
792
- include (" axes.jl" )
793
- include (" size.jl" )
794
- include (" stridelayout.jl" )
795
- include (" broadcast.jl" )
796
-
797
-
798
802
abstract type AbstractArray2{T,N} <: AbstractArray{T,N} end
799
803
800
804
Base. size (A:: AbstractArray2 ) = map (Int, ArrayInterface. size (A))
836
840
return setindex! (A, val; kwargs... )
837
841
end
838
842
843
+ include (" ranges.jl" )
844
+ include (" indexing.jl" )
845
+ include (" dimensions.jl" )
846
+ include (" axes.jl" )
847
+ include (" size.jl" )
848
+ include (" stridelayout.jl" )
849
+ include (" broadcast.jl" )
850
+
839
851
function __init__ ()
840
852
841
853
@require SuiteSparse = " 4607b0f0-06f3-5cda-b6b1-a6196a1729e9" begin
0 commit comments