Skip to content

Generic functions, not aliases, for unicode operators in LinearAlgebra #759

@epatters

Description

@epatters

The LinearAlgebra module exports two unicode operators, like this:

const  = dot
const × = cross

Would it be possible to change these to generic functions?

(u,v) = dot(u,v)
×(u,v) = cross(u,v)

The reason is that \cdot does not always have the interpretation of a dot product. For example, in Catlab we use it as a generic composition operator. Likewise, \times is not always a cross product; in many contexts it conventionally represents the cartesian product of sets or types. By using generic functions instead of aliases, it would at least be possible to override these operators for specific types when a different interpretation makes sense.

It would be better still to have typing, e.g.

×(u::AbstractVector, v::AbstractVector) = cross(u,v)

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