Skip to content

mul! with Symmetric does not check sizes are compatible #45572

Closed

Description

Here we define matrices A, B, and C with incompatible sizes for multiplication:

julia> using LinearAlgebra

julia> A = Symmetric(randn(5, 5));

julia> B = randn(10, 5);

julia> C = zeros(5, 5);

julia> mul!(C, A, B)
5×5 Array{Float64,2}:
  0.98847    1.64837    0.00974132  -4.00331    0.138057
 -2.00759   -1.08226   -0.240299     1.32073   -0.144493
  0.535827   0.125398  -0.53018     -0.385373  -0.146108
 -3.96372   -2.00857   -1.01928      4.40731    1.87013 
 -2.91995   -1.37546   -1.09736      4.79497    1.76239 
 
julia> A * B
5×5 Array{Float64,2}:
  0.98847    1.64837    0.00974132  -4.00331    0.138057
 -2.00759   -1.08226   -0.240299     1.32073   -0.144493
  0.535827   0.125398  -0.53018     -0.385373  -0.146108
 -3.96372   -2.00857   -1.01928      4.40731    1.87013 
 -2.91995   -1.37546   -1.09736      4.79497    1.76239 

Yet mul! (and *) works! I have confirmed that this has been the behavior since Julia 1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    backport 1.6Change should be backported to release-1.6backport 1.8Change should be backported to release-1.8bugIndicates an unexpected problem or unintended behaviorlinear algebraLinear algebra

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions