@@ -30,12 +30,6 @@ See also [`mbind`](@ref).
30
30
function mkernel end
31
31
export mkernel
32
32
33
- @inline mkernel (f_β:: MKernel ) = f_β
34
- @inline mkernel (f_β, f_c = secondarg) = _generic_mkernel_impl (f_β, f_c)
35
-
36
- @inline _generic_mkernel_impl (f_β, f_c) = MKernel (f_β, f_c)
37
- @inline _generic_mkernel_impl (f_β:: MKernel , :: typeof (secondarg)) = f_β
38
-
39
33
40
34
"""
41
35
struct MeasureBase.MKernel <: Function
@@ -45,12 +39,20 @@ Represents a generalized monatic transition kernel.
45
39
User code should not create instances of `MKernel` directly, but should call
46
40
[`mkernel`](@ref) instead.
47
41
"""
48
- struct MKernel
49
- f_β:: FK
42
+ struct MKernel{FT,FC} <: Function
43
+ f_β:: FT
50
44
f_c:: FC
51
45
end
52
46
53
47
48
+ @inline mkernel (f_β:: MKernel ) = f_β
49
+ @inline mkernel (f_β, f_c = secondarg) = _generic_mkernel_impl (f_β, f_c)
50
+
51
+ @inline _generic_mkernel_impl (f_β, f_c) = MKernel (f_β, f_c)
52
+ @inline _generic_mkernel_impl (f_β:: MKernel , :: typeof (secondarg)) = f_β
53
+
54
+
55
+
54
56
@doc raw """
55
57
mbind(f_β, α::AbstractMeasure, f_c = OneTwoMany.secondarg)
56
58
mbind(f_β::MeasureBase.MKernel, α::AbstractMeasure)
@@ -102,7 +104,7 @@ The measure `α` that went into the bind can be retrieved via
102
104
103
105
Densities on hierarchical measures can only be evaluated if `ab = f_c(a, b)`
104
106
can be unambiguously split into `a` and `b` again, knowing `α`. This is
105
- currently implemented for `f_c` that is either tuple or `=>`/`Pair` (these
107
+ currently implemented for `f_c` that is either ` tuple` or `=>`/`Pair` (these
106
108
work for any combination of variate types), `vcat` (for tuple- or vector-like
107
109
variates) and `merge` (`NamedTuple` variates).
108
110
[`MeasureBase.split_point(::typeof(f_c), α)`](@ref) can be specialized to
@@ -152,19 +154,20 @@ export mbind
152
154
153
155
@inline mbind (f_β) = Base. Fix1 (mbind, f_β)
154
156
155
- @inline mbind (f_k:: MKernel , α:: AbstractMeasure ) = mbind (f_k. f_β, α, f_k. f_c)
156
-
157
- # @inline mbind(f_β, α::AbstractMeasure, f_c = getsecond) = _generic_mbind_impl(f_β, α, f_c) --- temporary ---
158
- @inline mbind (f_β, α:: AbstractMeasure , f_c = secondarg) = _generic_mbind_impl (f_β, α, f_c)
157
+ @inline mbind (f_β, α:: AbstractMeasure , f_c = secondarg) = _generic_mbind_impl (f_β, asmeasure (α), f_c)
159
158
160
159
@inline function _generic_mbind_impl (f_β, α:: AbstractMeasure , f_c)
161
160
F, M, G = Core. Typeof (f_β), Core. Typeof (α), Core. Typeof (f_c)
162
161
Bind {F,M,G} (f_β, α, f_c)
163
162
end
164
163
165
- function _generic_mbind_impl (f_β, α:: Dirac , f_c)
166
- mcombine (f_c, α, f_β (α. x))
167
- end
164
+ @inline _generic_mbind_impl (f_β, α:: Dirac , f_c) = mcombine (f_c, α, f_β (α. x))
165
+
166
+ @inline _generic_mbind_impl (@nospecialize (f_β), α:: AbstractMeasure , :: typeof (firstarg)) = α
167
+ @inline _generic_mbind_impl (@nospecialize (f_β), α:: Dirac , :: typeof (firstarg)) = α
168
+
169
+ @inline _generic_mbind_impl (f_k:: MKernel , α:: AbstractMeasure , :: typeof (secondarg)) = mbind (f_k. f_β, α, f_k. f_c)
170
+ @inline _generic_mbind_impl (f_k:: MKernel , α:: Dirac , :: typeof (secondarg)) = mbind (f_k. f_β, α, f_k. f_c)
168
171
169
172
170
173
"""
@@ -175,8 +178,8 @@ Represents a monatic bind resp. a mbind in general.
175
178
User code should not create instances of `Bind` directly, but should call
176
179
[`mbind`](@ref) instead.
177
180
"""
178
- struct Bind{FK ,M<: AbstractMeasure ,FC} <: AbstractMeasure
179
- f_β:: FK
181
+ struct Bind{FT ,M<: AbstractMeasure ,FC} <: AbstractMeasure
182
+ f_β:: FT
180
183
α:: M
181
184
f_c:: FC
182
185
end
0 commit comments