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

Add Tridiagonal construction rule #758

Merged
merged 10 commits into from
Jun 10, 2024
13 changes: 13 additions & 0 deletions src/rulesets/LinearAlgebra/structured.jl
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,16 @@ function rrule(::typeof(logdet), X::Union{Diagonal, AbstractTriangular})
end
return y, logdet_pullback
end

#####
##### Tridiagonal
#####

function rrule(::Type{Tridiagonal}, dl, d, du)
y = Tridiagonal(dl, d, du)
@views function ∇Tridiagonal(∂y)
return (NoTangent(), diag(∂y[2:end, 1:(end - 1)]), diag(∂y),
diag(∂y[1:(end - 1), 2:end]))
ChrisRackauckas marked this conversation as resolved.
Show resolved Hide resolved
end
return y, ∇Tridiagonal
end
Loading