Skip to content

Error during SArray initialization with array comprehension containing two SVector iterates #76

Closed
@wsshin

Description

@wsshin

Consider two SVector objects with 2 and 3 entries:

julia> vec2 = @SVector [1,2]
2-element StaticArrays.SVector{2,Int64}:
 1
 2

julia> vec3 = @SVector [1,2,3]
3-element StaticArrays.SVector{3,Int64}:
 1
 2
 3

I can use one of these two SVector objects as iterates in array comprehension to initialize SArray. For example,

julia> @SArray [1 for x = vec3, y = vec3]
3×3 StaticArrays.SArray{(3,3),Int64,2,9}:
 1  1  1
 1  1  1
 1  1  1

However, as soon as I mix two SVector objects, an error is generated:

julia> @SArray [1 for x = vec2, y = vec3]
ERROR: The size of type `StaticArrays.SVector{S,Int64}` is not known.

If you were trying to construct (or `convert` to) a `StaticArray` you
may need to add the size explicitly as a type parameter so its size is
inferrable to the Julia compiler (or performance would be terrible). For
example, you might try

    m = zeros(3,3)
    SMatrix(m)      # this error
    SMatrix{3,3}(m) # correct - size is inferrable

Is this an expected behavior?

Here is the versioninfo() output:

julia> versioninfo()
Julia Version 0.5.1-pre+4
Commit 887ad05* (2016-10-28 19:39 UTC)
Platform Info:
  System: Darwin (x86_64-apple-darwin16.0.0)
  CPU: Intel(R) Core(TM)2 Duo CPU     T9900  @ 3.06GHz
  WORD_SIZE: 64
  BLAS: libopenblas (USE64BITINT DYNAMIC_ARCH NO_AFFINITY Penryn)
  LAPACK: libopenblas64_
  LIBM: libopenlibm
  LLVM: libLLVM-3.7.1 (ORCJIT, penryn)

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