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

Fix infinite recursion in CorrBijector/VecCorrBijector #355

Merged
merged 1 commit into from
Nov 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Bijectors"
uuid = "76274a88-744f-5084-9051-94815aaf08c4"
version = "0.15.1"
version = "0.15.2"

[deps]
ArgCheck = "dce04be8-c92d-5529-be00-80e4d2c0e197"
Expand Down
12 changes: 6 additions & 6 deletions src/bijectors/corr.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ struct CorrBijector <: Bijector end

with_logabsdet_jacobian(b::CorrBijector, x) = transform(b, x), logabsdetjac(b, x)

function transform(b::CorrBijector, X::AbstractMatrix{<:Real})
function transform(b::CorrBijector, X)
w = cholesky_upper(X)
r = _link_chol_lkj(w)
return r
end

function with_logabsdet_jacobian(ib::Inverse{CorrBijector}, y::AbstractMatrix{<:Real})
function with_logabsdet_jacobian(ib::Inverse{CorrBijector}, y)
U, logJ = _inv_link_chol_lkj(y)
K = size(U, 1)
for j in 2:(K - 1)
Expand All @@ -80,8 +80,8 @@ function with_logabsdet_jacobian(ib::Inverse{CorrBijector}, y::AbstractMatrix{<:
return pd_from_upper(U), logJ
end

logabsdetjac(::Inverse{CorrBijector}, Y::AbstractMatrix{<:Real}) = _logabsdetjac_inv_corr(Y)
function logabsdetjac(b::CorrBijector, X::AbstractMatrix{<:Real})
logabsdetjac(::Inverse{CorrBijector}, Y) = _logabsdetjac_inv_corr(Y)
function logabsdetjac(b::CorrBijector, X)
#=
It may be more efficient if we can use un-contraint value to prevent call of b
It's recommended to directly call
Expand Down Expand Up @@ -135,7 +135,7 @@ function logabsdetjac(b::VecCorrBijector, x)
return -logabsdetjac(inverse(b), b(x))
end

function with_logabsdet_jacobian(::Inverse{VecCorrBijector}, y::AbstractVector{<:Real})
function with_logabsdet_jacobian(::Inverse{VecCorrBijector}, y)
U_logJ = _inv_link_chol_lkj(y)
# workaround for `Tracker.TrackedTuple` not supporting iteration
U, logJ = U_logJ[1], U_logJ[2]
Expand All @@ -146,7 +146,7 @@ function with_logabsdet_jacobian(::Inverse{VecCorrBijector}, y::AbstractVector{<
return pd_from_upper(U), logJ
end

function logabsdetjac(::Inverse{VecCorrBijector}, y::AbstractVector{<:Real})
function logabsdetjac(::Inverse{VecCorrBijector}, y)
return _logabsdetjac_inv_corr(y)
end

Expand Down
Loading