@@ -5,75 +5,75 @@ like `OffsetArrays` or named indices
55(such as ITensors).
66"""
77function set_indstype (arraytype:: Type{<:AbstractArray} , dims:: Tuple )
8- return set_ndims (arraytype, NDims (length (dims)))
8+ return set_ndims (arraytype, NDims (length (dims)))
99end
1010
1111function similartype (arraytype:: Type{<:AbstractArray} , eltype:: Type , ndims:: NDims )
12- return similartype (similartype (arraytype, eltype), ndims)
12+ return similartype (similartype (arraytype, eltype), ndims)
1313end
1414
1515function similartype (arraytype:: Type{<:AbstractArray} , eltype:: Type , dims:: Tuple )
16- return similartype (similartype (arraytype, eltype), dims)
16+ return similartype (similartype (arraytype, eltype), dims)
1717end
1818
1919@traitfn function similartype (
20- arraytype:: Type{ArrayT}
21- ) where {ArrayT;! IsWrappedArray{ArrayT}}
22- return arraytype
20+ arraytype:: Type{ArrayT}
21+ ) where {{ ArrayT; ! IsWrappedArray{ArrayT} }}
22+ return arraytype
2323end
2424
2525@traitfn function similartype (
26- arraytype:: Type{ArrayT} , eltype:: Type
27- ) where {ArrayT;! IsWrappedArray{ArrayT}}
28- return set_eltype (arraytype, eltype)
26+ arraytype:: Type{ArrayT} , eltype:: Type
27+ ) where {{ ArrayT; ! IsWrappedArray{ArrayT} }}
28+ return set_eltype (arraytype, eltype)
2929end
3030
3131function similartype (arraytype:: Type{<:BitArray} , elt:: Type )
32- if is_parameter_specified (arraytype, ndims)
33- return Array{elt,ndims (arraytype)}
34- end
35- return Array{elt}
32+ if is_parameter_specified (arraytype, ndims)
33+ return Array{elt, ndims (arraytype)}
34+ end
35+ return Array{elt}
3636end
3737
3838@traitfn function similartype (
39- arraytype:: Type{ArrayT} , dims:: Tuple
40- ) where {ArrayT;! IsWrappedArray{ArrayT}}
41- return set_indstype (arraytype, dims)
39+ arraytype:: Type{ArrayT} , dims:: Tuple
40+ ) where {{ ArrayT; ! IsWrappedArray{ArrayT} }}
41+ return set_indstype (arraytype, dims)
4242end
4343
4444@traitfn function similartype (
45- arraytype:: Type{ArrayT} , ndims:: NDims
46- ) where {ArrayT;! IsWrappedArray{ArrayT}}
47- return set_ndims (arraytype, ndims)
45+ arraytype:: Type{ArrayT} , ndims:: NDims
46+ ) where {{ ArrayT; ! IsWrappedArray{ArrayT} }}
47+ return set_ndims (arraytype, ndims)
4848end
4949
5050function similartype (
51- arraytype:: Type{<:AbstractArray} , dim1:: Base.DimOrInd , dim_rest:: Base.DimOrInd...
52- )
53- return similartype (arraytype, (dim1, dim_rest... ))
51+ arraytype:: Type{<:AbstractArray} , dim1:: Base.DimOrInd , dim_rest:: Base.DimOrInd...
52+ )
53+ return similartype (arraytype, (dim1, dim_rest... ))
5454end
5555
5656# # Wrapped arrays
57- @traitfn function similartype (arraytype:: Type{ArrayT} ) where {ArrayT;IsWrappedArray{ArrayT}}
58- return similartype (unwrap_array_type (arraytype), NDims (arraytype))
57+ @traitfn function similartype (arraytype:: Type{ArrayT} ) where {{ ArrayT; IsWrappedArray{ArrayT} }}
58+ return similartype (unwrap_array_type (arraytype), NDims (arraytype))
5959end
6060
6161@traitfn function similartype (
62- arraytype:: Type{ArrayT} , eltype:: Type
63- ) where {ArrayT;IsWrappedArray{ArrayT}}
64- return similartype (unwrap_array_type (arraytype), eltype, NDims (arraytype))
62+ arraytype:: Type{ArrayT} , eltype:: Type
63+ ) where {{ ArrayT; IsWrappedArray{ArrayT} }}
64+ return similartype (unwrap_array_type (arraytype), eltype, NDims (arraytype))
6565end
6666
6767@traitfn function similartype (
68- arraytype:: Type{ArrayT} , dims:: Tuple
69- ) where {ArrayT;IsWrappedArray{ArrayT}}
70- return similartype (unwrap_array_type (arraytype), dims)
68+ arraytype:: Type{ArrayT} , dims:: Tuple
69+ ) where {{ ArrayT; IsWrappedArray{ArrayT} }}
70+ return similartype (unwrap_array_type (arraytype), dims)
7171end
7272
7373@traitfn function similartype (
74- arraytype:: Type{ArrayT} , ndims:: NDims
75- ) where {ArrayT;IsWrappedArray{ArrayT}}
76- return similartype (unwrap_array_type (arraytype), ndims)
74+ arraytype:: Type{ArrayT} , ndims:: NDims
75+ ) where {{ ArrayT; IsWrappedArray{ArrayT} }}
76+ return similartype (unwrap_array_type (arraytype), ndims)
7777end
7878
7979# This is for uniform `Diag` storage which uses
8282# `FillArray` instead. This is a stand-in
8383# to make things work with the current design.
8484function similartype (numbertype:: Type{<:Number} )
85- return numbertype
85+ return numbertype
8686end
8787
8888# Instances
8989function similartype (array:: AbstractArray , eltype:: Type , dims... )
90- return similartype (typeof (array), eltype, dims... )
90+ return similartype (typeof (array), eltype, dims... )
9191end
9292similartype (array:: AbstractArray , eltype:: Type ) = similartype (typeof (array), eltype)
9393similartype (array:: AbstractArray , dims... ) = similartype (typeof (array), dims... )
0 commit comments