Skip to content

Commit

Permalink
Update deps (#12)
Browse files Browse the repository at this point in the history
* update to ID 0.4

* bump version
  • Loading branch information
mohamed82008 committed May 19, 2023
1 parent 69313bd commit 09e7836
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "DifferentiableFactorizations"
uuid = "f7876f94-e99c-4755-b0c6-59dc4ff4934d"
authors = ["Mohamed Tarek <mohamed82008@gmail.com> and contributors"]
version = "0.1.0"
version = "0.2.0"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand All @@ -12,7 +12,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
[compat]
ChainRulesCore = "1"
ComponentArrays = "0.11, 0.12"
ImplicitDifferentiation = "0.2"
ImplicitDifferentiation = "0.4"
julia = "1"

[extras]
Expand Down
44 changes: 22 additions & 22 deletions src/DifferentiableFactorizations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using LinearAlgebra, ImplicitDifferentiation, ComponentArrays, ChainRulesCore

# QR

function qr_conditions(A, x)
function qr_conditions(A, x, _)
(; Q, R) = x
return vcat(
vec(UpperTriangular(Q' * Q) + LowerTriangular(R) - I - Diagonal(R)),
Expand All @@ -17,32 +17,32 @@ function qr_forward(A)
qr_res = qr(A)
Q = copy(qr_res.Q[:, 1:size(A, 2)])
(; R) = qr_res
return ComponentVector(; Q, R)
return ComponentVector(; Q, R), 0
end
const _diff_qr = ImplicitFunction(qr_forward, qr_conditions)
function diff_qr(A)
(; Q, R) = _diff_qr(A)
(; Q, R) = _diff_qr(A)[1]
return (; Q, R)
end

# Cholesky

function cholesky_conditions(A, U)
function cholesky_conditions(A, U, _)
return vec(UpperTriangular(U' * U) + LowerTriangular(U) - UpperTriangular(A) - Diagonal(U))
end
function cholesky_forward(A)
ch_res = cholesky(A)
return ch_res.U
return ch_res.U, 0
end
const _diff_cholesky = ImplicitFunction(cholesky_forward, cholesky_conditions)
function diff_cholesky(A)
U = _diff_cholesky(A)
U = _diff_cholesky(A)[1]
return (; L = U', U)
end

# LU

function lu_conditions(A, LU)
function lu_conditions(A, LU, _)
(; L, U, p) = LU
pint = convert(Vector{Int}, p)
return vcat(
Expand All @@ -54,11 +54,11 @@ end
function lu_forward(A)
lu_res = lu(A)
(; L, U, p) = lu_res
return ComponentVector(; L, U, p)
return ComponentVector(; L, U, p), 0
end
const _diff_lu = ImplicitFunction(lu_forward, lu_conditions)
function diff_lu(A)
temp = _diff_lu(A)
temp = _diff_lu(A)[1]
(; L, U, p) = temp
return (; L, U, p = convert(Vector{Int}, p))
end
Expand All @@ -84,7 +84,7 @@ function ChainRulesCore.rrule(::typeof(comp_vec), A, B)
end
end

function eigen_conditions(AB, sV)
function eigen_conditions(AB, sV, _)
(; s, V) = sV
(; A) = AB
if hasproperty(AB, :B)
Expand All @@ -107,20 +107,20 @@ function eigen_forward(AB)
end
s = eig_res.values
V = eig_res.vectors
return ComponentVector(; s, V)
return ComponentVector(; s, V), 0
end

const _diff_eigen = ImplicitFunction(eigen_forward, eigen_conditions)
function diff_eigen(A)
(; s, V) = _diff_eigen(comp_vec(A))
(; s, V) = _diff_eigen(comp_vec(A))[1]
return (; s , V)
end
function diff_eigen(A, B)
(; s, V) = _diff_eigen(comp_vec(A, B))
(; s, V) = _diff_eigen(comp_vec(A, B))[1]
return (; s , V)
end

function schur_conditions(A, Z_T)
function schur_conditions(A, Z_T, _)
(; Z, T) = Z_T
return vcat(
vec(Z' * A * Z - T),
Expand All @@ -130,7 +130,7 @@ end
function schur_forward(A)
schur_res = schur(A)
(; Z, T) = schur_res
return ComponentVector(; Z, T)
return ComponentVector(; Z, T), 0
end
const _diff_schur = ImplicitFunction(schur_forward, schur_conditions)

Expand All @@ -143,7 +143,7 @@ function ChainRulesCore.rrule(::typeof(bidiag), v1, v2)
end
end

function gen_schur_conditions(AB, left_right_S_T)
function gen_schur_conditions(AB, left_right_S_T, _)
(; left, right, S, T) = left_right_S_T
(; A, B) = AB
return vcat(
Expand All @@ -157,22 +157,22 @@ function gen_schur_forward(AB)
(; A, B) = AB
schur_res = schur(A, B)
(; left, right, S, T) = schur_res
return ComponentVector(; left, right, S, T)
return ComponentVector(; left, right, S, T), 0
end
const _diff_gen_schur = ImplicitFunction(gen_schur_forward, gen_schur_conditions)

function diff_schur(A, B)
(; left, right, S, T) = _diff_gen_schur(comp_vec(A, B))
(; left, right, S, T) = _diff_gen_schur(comp_vec(A, B))[1]
return (; left, right, S, T)
end
function diff_schur(A)
(; Z, T) = _diff_schur(A)
(; Z, T) = _diff_schur(A)[1]
return (; Z, T)
end

# SVD

function svd_conditions(A, USV)
function svd_conditions(A, USV, _)
(; U, S, V) = USV
VtV = V' * V
return vcat(
Expand All @@ -184,12 +184,12 @@ end
function svd_forward(A)
svd_res = svd(A)
(; U, S, V) = svd_res
return ComponentVector(; U, S, V)
return ComponentVector(; U, S, V), 0
end

const _diff_svd = ImplicitFunction(svd_forward, svd_conditions)
function diff_svd(A)
(; U, S, V) = _diff_svd(A)
(; U, S, V) = _diff_svd(A)[1]
return (; U, S , V)
end

Expand Down

2 comments on commit 09e7836

@mohamed82008
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/83899

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.2.0 -m "<description of version>" 09e78362e33bee106f670791e55321d5be2f78f1
git push origin v0.2.0

Please sign in to comment.