2424```
2525
2626DevNotes
27- - See IIF Project to consolidate CCW, CF, FMD, CPT
27+ - Follow the Github project in IIF to better consolidate CCW FMD CPT CF CFM
2828
2929Related
3030
31- [`CommonConvWrapper`](@ref), [`FactorMetadata`](@ref), [`ConvPerThread`](@ref)
31+ [`CalcFactorMahalanobis`](@ref), [` CommonConvWrapper`](@ref), [`FactorMetadata`](@ref), [`ConvPerThread`](@ref)
3232"""
3333struct CalcFactor{T <: AbstractFactor , M, P <: Union{<:Tuple,Nothing} , X <: AbstractVector }
3434 # the interface compliant user object functor containing the data and logic
@@ -46,6 +46,23 @@ struct CalcFactor{T <: AbstractFactor, M, P <: Union{<:Tuple,Nothing}, X <: Abst
4646end
4747
4848
49+ """
50+ $TYPEDEF
51+
52+ Internal parametric extension to [`CalcFactor`](@ref) used for buffering measurement and calculating Mahalanobis distance
53+
54+ Related
55+
56+ [`CalcFactor`](@ref)
57+ """
58+ struct CalcFactorMahalanobis{CF<: CalcFactor , S, N}
59+ calcfactor!:: CF
60+ varOrder:: Vector{Symbol}
61+ meas:: NTuple{N, <:AbstractVector{Float64}}
62+ iΣ:: NTuple{N, Matrix{Float64}}
63+ specialAlg:: S
64+ end
65+
4966
5067abstract type _AbstractThreadModel end
5168
7087
7188DevNotes
7289- TODO why not just a NamedTuple? Perhaps part of #467
73- - TODO better consolidate with CCW, CPT, CalcFactor
90+ - Follow the Github project in IIF to better consolidate CCW FMD CPT CF CFM
7491- TODO standardize -- #927, #1025, #784, #692, #640
7592- TODO make immutable #825
7693"""
@@ -121,30 +138,25 @@ mutable struct ConvPerThread{R,F<:FactorMetadata,P}
121138end
122139
123140
124- function ConvPerThread ( X:: AbstractVector{P} ,
125- zDim:: Int ,
126- factormetadata:: FactorMetadata ;
127- particleidx:: Int = 1 ,
128- activehypo= 1 : length (params),
129- p:: AbstractVector{<:Integer} = collect (1 : 1 ),
130- perturb= zeros (zDim),
131- res= zeros (zDim),
132- thrid_ = 0 ) where P
133- #
134- return ConvPerThread {typeof(res), typeof(factormetadata), Any} ( thrid_,
135- particleidx,
136- factormetadata,
137- Int[activehypo;],
138- Int[p... ;],
139- perturb,
140- X,
141- res )
142- end
143-
144-
145141
146142"""
147143$(TYPEDEF)
144+
145+ Main factor memory container used during inference operations.
146+
147+ Notes
148+ - CCW does not get serialized / persisted
149+ - At writing, the assumption is there is just one CCW per factor
150+ - Any multithreaded design needs to happens as sub-constainers inside CCW or otherwise, to carry separate memory.
151+ - Since #467, `CalcFactor` is the only type 'seen by user' during `getSample` or function residual calculations `(cf::CalcFactor{<:MyFactor})`, s.t. `MyFactor <: AbstractRelative___`
152+ - There also exists a `CalcFactorMahalanobis` for parameteric computations using as much of the same mechanics as possible.
153+
154+ DevNotes
155+ - Follow the Github project in IIF to better consolidate CCW FMD CPT CF CFM
156+
157+ Related
158+
159+ [`CalcFactor`](@ref), [`CalcFactorMahalanobis`](@ref), [`FactorMetadata`](@ref), [`ConvPerThread`](@ref)
148160"""
149161mutable struct CommonConvWrapper{ T<: FunctorInferenceType ,
150162 H<: Union{Nothing, Distributions.Categorical} ,
@@ -186,50 +198,5 @@ mutable struct CommonConvWrapper{ T<:FunctorInferenceType,
186198end
187199
188200
189- function CommonConvWrapper ( fnc:: T ,
190- X:: AbstractVector{P} ,
191- zDim:: Int ,
192- params:: AbstractVector{<:AbstractVector{Q}} ,
193- factormetadata:: FactorMetadata ;
194- specialzDim:: Bool = false ,
195- partial:: Bool = false ,
196- hypotheses:: H = nothing ,
197- certainhypo= nothing ,
198- activehypo= 1 : length (params),
199- nullhypo:: Real = 0 ,
200- varidx:: Int = 1 ,
201- measurement:: Tuple = (Vector {Vector{Float64}} (),), # FIXME should not be a Matrix
202- particleidx:: Int = 1 ,
203- xDim:: Int = size (X,1 ),
204- partialDims:: AbstractVector{<:Integer} = collect (1 : size (X,1 )), # TODO make this SVector, and name partialDims
205- perturb= zeros (zDim),
206- res:: AbstractVector{<:Real} = zeros (zDim),
207- threadmodel:: Type{<:_AbstractThreadModel} = MultiThreaded,
208- inflation:: Real = 3.0 ,
209- vartypes= typeof .(getVariableType .(factormetadata. fullvariables)),
210- gradients= nothing ) where {T<: FunctorInferenceType ,P,H,Q}
211- #
212- return CommonConvWrapper (fnc,
213- xDim,
214- zDim,
215- specialzDim,
216- partial,
217- hypotheses,
218- certainhypo,
219- Float64 (nullhypo),
220- params,
221- varidx,
222- measurement,
223- threadmodel,
224- (i-> ConvPerThread (X, zDim,factormetadata, particleidx= particleidx,
225- activehypo= activehypo, p= partialDims,
226- perturb= perturb, res= res )). (1 : Threads. nthreads ()),
227- inflation,
228- partialDims, # SVector(Int32.()...)
229- DataType[vartypes... ],
230- gradients)
231- end
232-
233-
234201
235202#
0 commit comments