Skip to content

3-arg dot is type-unstable for matrices with eltype Bool #1430

@dkarrasch

Description

@dkarrasch

This is due to the fact that when we initialize the zero value, we use the eltypes or, alternatively, the first values, before we start to add up further dot products. We also have this inconsistency:

julia> using LinearAlgebra

julia> dot(true, true)
true

julia> dot([true], [true])
1

A minimal fix would be to define

dot(x::Bool, y::Bool) = x*y + false

which changes the return type for scalar arguments, but renders the matrix cases (both 2-arg and 3-arg) type-stable. What do you think?

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