@@ -20,12 +20,15 @@ julia> A[Block(1, 1)]
20
20
struct Block{N, T}
21
21
n:: NTuple{N, T}
22
22
Block {N, T} (n:: NTuple{N, T} ) where {N, T} = new {N, T} (n)
23
+ Block {1, T} (n:: Tuple{T} ) where T = new {1, T} (n)
23
24
end
24
25
25
-
26
- Block {N, T} (n:: Vararg{T , N} ) where {N,T} = Block {N, T} (n)
26
+ Block {N, T} (n :: Tuple{Vararg{Any, N}} ) where {N,T} = Block {N, T} ( convert (NTuple{N,T}, n))
27
+ Block {N, T} (n:: Vararg{Any , N} ) where {N,T} = Block {N, T} (n)
27
28
Block {N} (n:: Vararg{T, N} ) where {N,T} = Block {N, T} (n)
28
- Block () = Block {0,Int} ()
29
+ Block {1, T} (n:: Tuple{Any} ) where {N,T} = Block {1, T} (convert (Tuple{T}, n))
30
+ Block {0} () = Block {0,Int} ()
31
+ Block () = Block {0} ()
29
32
Block (n:: Vararg{T, N} ) where {N,T} = Block {N, T} (n)
30
33
Block {1} (n:: Tuple{T} ) where {T} = Block {1, T} (n)
31
34
Block {N} (n:: NTuple{N, T} ) where {N,T} = Block {N, T} (n)
77
80
_isless (ret, :: Tuple{} , :: Tuple{} ) = ifelse (ret== 1 , true , false )
78
81
icmp (a, b) = ifelse (isless (a,b), 1 , ifelse (a== b, 0 , - 1 ))
79
82
@inline isless (I1:: Block{N} , I2:: Block{N} ) where {N} = _isless (0 , I1. n, I2. n)
83
+ @inline isless (I1:: Block{1} , I2:: Block{1} ) = isless (Integer (I1), Integer (I2))
80
84
81
85
# conversions
82
86
convert (:: Type{T} , index:: Block{1} ) where {T<: Number } = convert (T, index. n[1 ])
0 commit comments