Skip to content

make linear algebra math functions work for scalars #763

Closed
@SamChill

Description

@SamChill

I was writing an optimization algorithm and wanted it to work with scalars and vectors. I noticed that norm and dot aren't defined for scalar numbers.

julia> norm(1.0)
no method norm(Float64,)
 in method_missing at base.jl:60

julia> dot(1.0,2.0)
no method dot(Float64,Float64)
 in method_missing at base.jl:60

The definitions would be simple:

norm(x::Number) = x                                                                                                                     
dot(x::Number, y::Number) = x*y

There might be more functions to consider defining for scalars as well.

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