Skip to content

Some operations do not ignore trailing dimensions equal to 1 #779

Open
@mateuszbaran

Description

@mateuszbaran

As in the title. Here is a small example:
addition in Base Julia arrays ignores trailing dimensions equal to 1:

julia> [1 2][:,1:1] + [1]
1×1 Array{Int64,2}:
 2

but in StaticArrays it does not:

julia> [1 2][:,1:1] +  SA[1]
ERROR: DimensionMismatch("Sizes ((1, 1), Size(1,)) of input arrays do not match")
Stacktrace:
 [1] _throw_size_mismatch(::Array{Int64,2}, ::Vararg{Any,N} where N) at /home/mateusz/.julia/dev/StaticArrays/src/traits.jl:198
 [2] same_size at /home/mateusz/.julia/dev/StaticArrays/src/traits.jl:192 [inlined]
 [3] macro expansion at /home/mateusz/.julia/dev/StaticArrays/src/mapreduce.jl:74 [inlined]
 [4] _map at /home/mateusz/.julia/dev/StaticArrays/src/mapreduce.jl:41 [inlined]
 [5] map at /home/mateusz/.julia/dev/StaticArrays/src/mapreduce.jl:34 [inlined]
 [6] +(::Array{Int64,2}, ::SArray{Tuple{1},Int64,1,1}) at /home/mateusz/.julia/dev/StaticArrays/src/linalg.jl:12
 [7] top-level scope at none:0

Do you think StaticArrays should have same_size modified to follow the behavior of Base?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions