Skip to content

Commit

Permalink
Support mixed type constructors.
Browse files Browse the repository at this point in the history
  • Loading branch information
maleadt committed Sep 1, 2023
1 parent 10ffc98 commit 2332533
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/array.jl
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,23 @@ const oneVecOrMat{T} = Union{oneVector{T},oneMatrix{T}}
oneArray{T,N}(::UndefInitializer, dims::Dims{N}) where {T,N} =
oneArray{T,N,oneL0.DeviceBuffer}(undef, dims)

# type and dimensionality specified, accepting dims as series of Ints
oneArray{T,N,B}(::UndefInitializer, dims::Integer...) where {T,N,B} =
# buffer, type and dimensionality specified
oneArray{T,N,B}(::UndefInitializer, dims::NTuple{N,Integer}) where {T,N,B} =
oneArray{T,N,B}(undef, convert(Tuple{Vararg{Int}}, dims))
oneArray{T,N}(::UndefInitializer, dims::Integer...) where {T,N} =
oneArray{T,N,B}(::UndefInitializer, dims::Vararg{Integer,N}) where {T,N,B} =
oneArray{T,N,B}(undef, convert(Tuple{Vararg{Int}}, dims))

# type and dimensionality specified
oneArray{T,N}(::UndefInitializer, dims::NTuple{N,Integer}) where {T,N} =
oneArray{T,N}(undef, convert(Tuple{Vararg{Int}}, dims))
oneArray{T,N}(::UndefInitializer, dims::Vararg{Integer,N}) where {T,N} =
oneArray{T,N}(undef, convert(Tuple{Vararg{Int}}, dims))

# type but not dimensionality specified
oneArray{T}(::UndefInitializer, dims::Dims{N}) where {T,N} =
oneArray{T,N}(undef, dims)
oneArray{T}(::UndefInitializer, dims::Integer...) where {T} =
oneArray{T}(undef, convert(Tuple{Vararg{Int}}, dims))
# only type specified
oneArray{T}(::UndefInitializer, dims::NTuple{N,Integer}) where {T,N} =
oneArray{T,N}(undef, convert(Tuple{Vararg{Int}}, dims))
oneArray{T}(::UndefInitializer, dims::Vararg{Integer,N}) where {T,N} =
oneArray{T,N}(undef, convert(Tuple{Vararg{Int}}, dims))

# empty vector constructor
oneArray{T,1,B}() where {T,B} = oneArray{T,1,B}(undef, 0)
Expand Down

0 comments on commit 2332533

Please sign in to comment.