@@ -33,29 +33,33 @@ struct CompoundDimensions{N} <: AbstractDimensions{N}
3333 to:: SVector{N,AbstractSpace} # space acting on the left
3434 from:: SVector{N,AbstractSpace} # space acting on the right
3535end
36- function CompoundDimensions (
37- to:: Union{AbstractVector{T},NTuple{N1,T}} ,
38- from:: Union{AbstractVector{T},NTuple{N2,T}} ,
39- ) where {T<: Integer ,N1,N2}
40- _non_static_array_warning (" dims" , to)
41- _non_static_array_warning (" dims" , from)
42-
43- L1 = length (to)
44- L2 = length (from)
36+ function CompoundDimensions (dims:: Union{AbstractVector{T},NTuple{N,T}} ) where {T<: Union{AbstractVector,NTuple} ,N}
37+ (length (dims) != 2 ) && throw (ArgumentError (" Invalid dims = $dims " ))
38+
39+ _non_static_array_warning (" dims[1]" , dims[1 ])
40+ _non_static_array_warning (" dims[2]" , dims[2 ])
41+
42+ L1 = length (dims[1 ])
43+ L2 = length (dims[2 ])
4544 ((L1 > 0 ) && (L1 == L2)) || throw (
4645 DomainError (
4746 (L1, L2),
48- " The length of the arguments `to ` and `from ` must be in the same length and have at least one element." ,
47+ " The length of the arguments `dims[1] ` and `dims[2] ` must be in the same length and have at least one element." ,
4948 ),
5049 )
5150
52- return CompoundDimensions {L1} (SVector {L1,AbstractSpace} (Space .(to)), SVector {L1,AbstractSpace} (Space .(from)))
51+ return CompoundDimensions {L1} (
52+ SVector {L1,AbstractSpace} (Space .(dims[1 ])),
53+ SVector {L1,AbstractSpace} (Space .(dims[2 ])),
54+ )
5355end
54- CompoundDimensions (to:: Int , from:: Int ) = CompoundDimensions (SVector {1,Int} (to), SVector {1,Int} (from))
5556
5657Base. show (io:: IO , D:: CompoundDimensions ) = print (io, " [" , D. to, " , " , D. from, " ]" )
5758
5859_gen_dims (dims:: AbstractDimensions ) = dims
60+ _gen_dims (dims:: Union{AbstractVector{T},NTuple{N,T}} ) where {T<: Integer ,N} = Dimensions (dims)
61+ _gen_dims (dims:: Union{AbstractVector{T},NTuple{N,T}} ) where {T<: Union{AbstractVector,NTuple} ,N} =
62+ CompoundDimensions (dims)
5963_gen_dims (dims:: Any ) = Dimensions (dims)
6064
6165# obtain dims in the type of SVector with integers
0 commit comments