@@ -14,6 +14,9 @@ For `(y, ladj) = with_logabsdet_jacobian(f, x)`, the following must hold true:
14
14
`with_logabsdet_jacobian` comes with support for broadcasted/mapped functions
15
15
(via `Base.Fix1`) and (Julia >=v1.6 only) `ComposedFunction`.
16
16
17
+ If no volume element is defined/applicable, `with_logabsdet_jacobian(f, x)` returns
18
+ [`NoLogAbsDetJacobian(f)`](@ref).
19
+
17
20
# Examples
18
21
19
22
```jldoctest a
@@ -67,6 +70,32 @@ Implementations of with_logabsdet_jacobian can be tested (as a
67
70
function with_logabsdet_jacobian end
68
71
export with_logabsdet_jacobian
69
72
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
+
70
99
@static if VERSION >= v " 1.6"
71
100
function with_logabsdet_jacobian (f:: Base.ComposedFunction , x)
72
101
y_inner, ladj_inner = with_logabsdet_jacobian (f. inner, x)
0 commit comments