Skip to content

Type piracy in defining qr for Tridiagonal #495

@jishnub

Description

@jishnub

qr(A::Tridiagonal{T}) where T = qr!(BandedMatrix{float(T)}(A, (1,2)))

This is an egregious example of type piracy. Do we really need this here? Loading BandedMatrices changes the type of the result.

julia> A = Tridiagonal([1:2;], [1:3;], [1:2;])
3×3 Tridiagonal{Int64, Vector{Int64}}:
 1  1  
 1  2  2
   2  3

julia> qr(A)
LinearAlgebra.QRCompactWY{Float64, Matrix{Float64}, Matrix{Float64}}
Q factor: 3×3 LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}}
R factor:
3×3 Matrix{Float64}:
 -1.41421  -2.12132  -1.41421
  0.0      -2.12132  -3.29983
  0.0       0.0      -0.333333

julia> using BandedMatrices

julia> qr(A)
QR{Float64, BandedMatrix{Float64, Matrix{Float64}, Base.OneTo{Int64}}, Vector{Float64}}
Q factor: 3×3 LinearAlgebra.QRPackedQ{Float64, BandedMatrix{Float64, Matrix{Float64}, Base.OneTo{Int64}}, Vector{Float64}}
R factor:
3×3 BandedMatrix{Float64} with bandwidths (1, 2):
 -1.41421  -2.12132  -1.41421
  0.0      -2.12132  -3.29983
           0.0      -0.333333

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions