Skip to content

Multiplying Adjoint with Symmetric uses slow generic matmul #850

Closed
@olof3

Description

@olof3

Multiplying an Adjoint with a Symmetric matrix falls back to a very slow generic matmul.

n = 500
A = randn(n, n)
Q = Symmetric(randn(n,n))

@btime $A'*$Q
277.406 ms (2 allocations: 1.91 MiB)

Converting A' to Matrix makes it a lot faster

@btime Matrix($A')*$Q
  4.281 ms (4 allocations: 3.81 MiB)

The break-even poirnt for when converting A' to Matrix is faster is n = 5.

This seems a bit slow? Should this be fixed in Base or should one convert to Matrix explicitly?

Perhaps fallback conversion to Matrix should be used more widely when eltype(A) <: BlasFloat ?

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