Skip to content

Array constructors using StaticInt as dimensions #70

Description

@chriselrod
julia> zeros(static(4))
ERROR: MethodError: no method matching zeros(::StaticInt{4})
Closest candidates are:
  zeros(::Tuple{Vararg{Union{Integer, AbstractUnitRange}}}) at array.jl:582
  zeros(::Type{StaticArrays.MVector{N}}) where N at ~/.julia/packages/StaticArrays/0T5rI/src/MVector.jl:20
  zeros(::Type{StaticArrays.SVector{N}}) where N at ~/.julia/packages/StaticArrays/0T5rI/src/SVector.jl:19
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[13]:1

julia> Array{Int}(undef, static(4))
ERROR: MethodError: no method matching (Array{Int64})(::UndefInitializer, ::StaticInt{4})
Closest candidates are:
  (Array{T})(::Nothing, ::Any...) where T at baseext.jl:45
  (Array{T})(::UndefInitializer, ::Tuple{Vararg{Int64, N}}) where {T, N} at boot.jl:478
  (Array{T})(::UndefInitializer, ::Tuple{Vararg{Integer, N}}) where {T, N} at baseext.jl:35
  ...
Stacktrace:
 [1] top-level scope
   @ REPL[14]:1

But it may be nice to pick a blessed package like StrideArraysCore for some of these (e.g. zeros, ones) to construct arrays with statically sized dimensions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions