@@ -14,6 +14,9 @@ For `(y, ladj) = with_logabsdet_jacobian(f, x)`, the following must hold true:
1414`with_logabsdet_jacobian` comes with support for broadcasted/mapped functions
1515(via `Base.Fix1`) and (Julia >=v1.6 only) `ComposedFunction`.
1616
17+ If no volume element is defined/applicable, `with_logabsdet_jacobian(f, x)` returns
18+ [`NoLogAbsDetJacobian(f)`](@ref).
19+
1720# Examples
1821
1922```jldoctest a
@@ -67,6 +70,32 @@ Implementations of with_logabsdet_jacobian can be tested (as a
6770function with_logabsdet_jacobian end
6871export with_logabsdet_jacobian
6972
73+
74+
75+ """
76+ struct NoLogAbsDetJacobian{F,T}
77+
78+ An instance `NoLogAbsDetJacobian{F,T}(f)` signifies that
79+ `with_logabsdet_jacobian(f, ::T)` is not defined.
80+ """
81+ struct NoLogAbsDetJacobian{F,T}
82+ f:: F
83+ end
84+ export NoLogAbsDetJacobian
85+
86+ function _no_ladj_errmsg (@nospecialize noladj:: NoLogAbsDetJacobian{F,T} ) where {F,T}
87+ (" with_logabsdet_jacobian(" , noladj. f, " , ::" , T, " is not defined " )
88+ end
89+
90+ Base. getindex (@nospecialize (noladj:: NoLogAbsDetJacobian ), args... ) = error (_no_ladj_errmsg (noladj)... )
91+ Base. iterate (@nospecialize (noladj:: NoLogAbsDetJacobian )) = error (_no_ladj_errmsg (noladj)... )
92+ Base. firstindex (@nospecialize (noladj:: NoLogAbsDetJacobian )) = error (_no_ladj_errmsg (noladj)... )
93+ Base. lastindex (@nospecialize (noladj:: NoLogAbsDetJacobian )) = error (_no_ladj_errmsg (noladj)... )
94+
95+ with_logabsdet_jacobian (f:: F , :: T ) where {F,T} = NoLogAbsDetJacobian {F,T} (f, )
96+
97+
98+
7099@static if VERSION >= v " 1.6"
71100 function with_logabsdet_jacobian (f:: Base.ComposedFunction , x)
72101 y_inner, ladj_inner = with_logabsdet_jacobian (f. inner, x)
0 commit comments