From ea79109b298615599a149cb74ceb09329e1b8a53 Mon Sep 17 00:00:00 2001 From: Tony Kelman Date: Mon, 2 Feb 2015 17:50:57 -0800 Subject: [PATCH] Fix conversion from Bidiagonal to Tridiagonal these were backwards --- base/linalg/bidiag.jl | 2 +- test/linalg4.jl | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/base/linalg/bidiag.jl b/base/linalg/bidiag.jl index af6b3ccde19e4..2de4d08b712dc 100644 --- a/base/linalg/bidiag.jl +++ b/base/linalg/bidiag.jl @@ -43,7 +43,7 @@ promote_rule{T,S}(::Type{Matrix{T}}, ::Type{Bidiagonal{S}})=Matrix{promote_type( Tridiagonal{T}(M::Bidiagonal{T}) = convert(Tridiagonal{T}, M) function convert{T}(::Type{Tridiagonal{T}}, A::Bidiagonal{T}) z = zeros(T, size(A)[1]-1) - A.isupper ? Tridiagonal(A.ev, A.dv, z) : Tridiagonal(z, A.dv, A.ev) + A.isupper ? Tridiagonal(z, A.dv, A.ev) : Tridiagonal(A.ev, A.dv, z) end promote_rule{T,S}(::Type{Tridiagonal{T}}, ::Type{Bidiagonal{S}})=Tridiagonal{promote_type(T,S)} diff --git a/test/linalg4.jl b/test/linalg4.jl index 8ecde3b09b062..72fb375d52085 100644 --- a/test/linalg4.jl +++ b/test/linalg4.jl @@ -175,11 +175,13 @@ for isupper in (true, false) for newtype in [Bidiagonal, Tridiagonal, isupper ? UpperTriangular : LowerTriangular, Matrix] debug && println("newtype is $(newtype)") @test full(convert(newtype, A)) == full(A) + @test full(newtype(A)) == full(A) end A=Bidiagonal(a, zeros(n-1), isupper) #morally Diagonal for newtype in [Diagonal, Bidiagonal, SymTridiagonal, Tridiagonal, isupper ? UpperTriangular : LowerTriangular, Matrix] debug && println("newtype is $(newtype)") @test full(convert(newtype, A)) == full(A) + @test full(newtype(A)) == full(A) end end