diff --git a/base/linalg/triangular.jl b/base/linalg/triangular.jl index 85392cbea8fab..271727a1d93f5 100644 --- a/base/linalg/triangular.jl +++ b/base/linalg/triangular.jl @@ -7,6 +7,11 @@ function Triangular{T}(A::AbstractMatrix{T}, uplo::Symbol, isunit::Bool=false) return Triangular{T,typeof(A),uplo,isunit}(A) end ++{T, MT, uplo}(A::Triangular{T, MT, uplo}, B::Triangular{T, MT, uplo}) = Triangular(A.data + B.data, uplo) ++{T, MT, uplo1, uplo2}(A::Triangular{T, MT, uplo1}, B::Triangular{T, MT, uplo2}) = full(A) + full(B) +-{T, MT, uplo}(A::Triangular{T, MT, uplo}, B::Triangular{T, MT, uplo}) = Triangular(A.data - B.data, uplo) +-{T, MT, uplo1, uplo2}(A::Triangular{T, MT, uplo1}, B::Triangular{T, MT, uplo2}) = full(A) - full(B) + ###################### # BlasFloat routines # ###################### diff --git a/test/linalg4.jl b/test/linalg4.jl index 3b77e9b47850c..f9d18b6b53318 100644 --- a/test/linalg4.jl +++ b/test/linalg4.jl @@ -66,7 +66,7 @@ for relty in (Float32, Float64, BigFloat), elty in (relty, Complex{relty}) #Binary operations B = convert(Matrix{elty}, randn(n, n)) for (M2, TM2) in ((triu(B), Triangular(B, :U)), (tril(B), Triangular(B, :L))) - for op in (*,) #+, - not implemented + for op in (*, +, -) @test_approx_eq full(op(TM, TM2)) op(M, M2) @test_approx_eq full(op(TM, M2)) op(M, M2) @test_approx_eq full(op(M, TM2)) op(M, M2)