From 04c1aecc80e6523fe67ca93c30ea5ef12492fd10 Mon Sep 17 00:00:00 2001 From: Frames Catherine White Date: Tue, 12 Apr 2022 07:08:31 +0200 Subject: [PATCH] use ProjectTo in rules for constructors of triangular matrixes --- src/rulesets/LinearAlgebra/structured.jl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rulesets/LinearAlgebra/structured.jl b/src/rulesets/LinearAlgebra/structured.jl index 1a5a4bcd0..b50ec08eb 100644 --- a/src/rulesets/LinearAlgebra/structured.jl +++ b/src/rulesets/LinearAlgebra/structured.jl @@ -208,15 +208,17 @@ end ##### function rrule(::Type{<:UpperTriangular}, A::AbstractMatrix) + project = ProjectTo(A) function UpperTriangular_pullback(ȳ) - return (NoTangent(), Matrix(ȳ)) + return (NoTangent(), project(ȳ)) end return UpperTriangular(A), UpperTriangular_pullback end function rrule(::Type{<:LowerTriangular}, A::AbstractMatrix) + project = ProjectTo(A) function LowerTriangular_pullback(ȳ) - return (NoTangent(), Matrix(ȳ)) + return (NoTangent(), project(ȳ)) end return LowerTriangular(A), LowerTriangular_pullback end