Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow construction of 0x0 Tridiagonal matrix (fixes #26377) #33275

Merged
merged 1 commit into from
Sep 16, 2019

Conversation

goggle
Copy link
Contributor

@goggle goggle commented Sep 16, 2019

This PR solves the last remaining issue of #26377. Prior to this PR it was not possible to display a Bunch-Kaufmann decomposition of an empty matrix, because we could not construct empty tridiagonal matrices:

julia> bunchkaufman(ones(0,0))
BunchKaufman{Float64,Array{Float64,2}}
D factor:
Error showing value of type BunchKaufman{Float64,Array{Float64,2}}:
ERROR: ArgumentError: cannot construct Tridiagonal from incompatible lengths of subdiagonal, diagonal and superdiagonal: (0, 0, 0)
Stacktrace:
 [1] Type at /build/julia/src/julia-1.2.0/usr/share/julia/stdlib/v1.2/LinearAlgebra/src/tridiag.jl:384 [inlined]
 [2] Type at /build/julia/src/julia-1.2.0/usr/share/julia/stdlib/v1.2/LinearAlgebra/src/tridiag.jl:423 [inlined]
 [3] getproperty(::BunchKaufman{Float64,Array{Float64,2}}, ::Symbol) at /build/julia/src/julia-1.2.0/usr/share/julia/stdlib/v1.2/LinearAlgebra/src/bunchkaufman.jl:231
 [4] show(::IOContext{REPL.Terminals.TTYTerminal}, ::MIME{Symbol("text/plain")}, ::BunchKaufman{Float64,Array{Float64,2}}) at /build/julia/src/julia-1.2.0/usr/share/julia/stdlib/v1.2/LinearAlgebra/src/bunchkaufman.jl:260
 [5] #invokelatest#1 at ./essentials.jl:790 [inlined]
 [6] invokelatest at ./essentials.jl:789 [inlined]
 [7] print_response(::IO, ::Any, ::Bool, ::Bool, ::Any) at /build/julia/src/julia-1.2.0/usr/share/julia/stdlib/v1.2/REPL/src/REPL.jl:156

After this PR:

julia> bunchkaufman(ones(0,0))
BunchKaufman{Float64,Array{Float64,2}}
D factor:
0×0 Tridiagonal{Float64,Array{Float64,1}}
U factor:
0×0 UnitUpperTriangular{Float64,Array{Float64,2}}
permutation:
0-element Array{Int64,1}

Furthermore, I have added tests for LU and Bunch-Kaufmann decompositions of 0x0 matrices.

All the other mentioned issues in #26377 seem to be solved:

julia> lu(ones(0,0))
LU{Float64,Array{Float64,2}}
L factor:
0×0 Array{Float64,2}
U factor:
0×0 Array{Float64,2}

julia> tril(ones(0,0), -1)
0×0 Array{Float64,2}

julia> tril(ones(0,0), 0)
0×0 Array{Float64,2}

julia> triu(ones(0,0), 1)
0×0 Array{Float64,2}

julia> triu(ones(0,0), 0)
0×0 Array{Float64,2}

@andreasnoack andreasnoack changed the title Allow construction of 0x0 Triangular matrix (fixes #26377) Allow construction of 0x0 Tridiagonal matrix (fixes #26377) Sep 16, 2019
@andreasnoack andreasnoack added the domain:linear algebra Linear algebra label Sep 16, 2019
@andreasnoack andreasnoack merged commit ad475e3 into JuliaLang:master Sep 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants