Skip to content

should use broadcast for vector space calculations? #187

Open
@vpuri3

Description

@vpuri3

# vector space calculations
@inferred x+5
@inferred 5+x
@inferred x-5
@inferred 5-x

What's the use case for the vector space interface? using broadcast, rather than overloading +,- would be consistent with AbstractArray interface.

julia> 2 + rand(2)
ERROR: MethodError: no method matching +(::Int64, ::Vector{Float64})
For element-wise addition, use broadcasting with dot syntax: scalar .+ array


julia> 2 .+ rand(2)
2-element Vector{Float64}:
 2.50859350057021
 2.7682555961902384

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