@@ -42,12 +42,13 @@ function calcVariableDistanceExpectedFractional(
4242 sfidx:: Integer ,
4343 certainidx:: AbstractVector{<:Integer} ;
4444 kappa:: Real = 3.0 ,
45- readonlyVarVals = ccwl. varValsAll[][sfidx]
45+ # readonlyVarVals = ccwl.varValsAll[][sfidx]
4646)
4747 #
48+ @assert sfidx == ccwl. varidx[] " ccwl.varidx[] is expected to be the same as sfidx"
4849 varTypes = getVariableType .(ccwl. fullvariables)
4950 if sfidx in certainidx
50- msst_ = calcStdBasicSpread (varTypes[sfidx], readonlyVarVals )
51+ msst_ = calcStdBasicSpread (varTypes[sfidx], ccwl . varValsAll[][sfidx] )
5152 return kappa * msst_
5253 end
5354 # @assert !(sfidx in certainidx) "null hypo distance does not work for sfidx in certainidx"
@@ -68,7 +69,7 @@ function calcVariableDistanceExpectedFractional(
6869
6970 refMean = getCoordinates (
7071 varTypes[sfidx],
71- mean (getManifold (varTypes[sfidx]), readonlyVarVals ),
72+ mean (getManifold (varTypes[sfidx]), ccwl . varValsAll[][sfidx] ),
7273 )
7374
7475 # calc for uncertain and certain
@@ -107,7 +108,7 @@ function addEntropyOnManifold!(
107108 # allocate to change SMatrix to MMatrix
108109 X = allocate (get_vector (M, points[1 ], Xc, DefaultOrthogonalBasis ()))
109110
110- for idx = 1 : length (points)
111+ for idx in 1 : length (points)
111112 # build tangent coordinate random
112113 for dim in dimIdx
113114 if (p === :) || dim in p
@@ -145,7 +146,7 @@ function computeAcrossHypothesis!(
145146 sfidx:: Int ,
146147 maxlen:: Int ,
147148 mani:: ManifoldsBase.AbstractManifold ; # maniAddOps::Tuple;
148- destinationVarVals = deepcopy ( ccwl. varValsAll[][sfidx]),
149+ # destinationVarVals = ccwl.varValsAll[][sfidx], # deepcopy
149150 spreadNH:: Real = 5.0 ,
150151 inflateCycles:: Int = 3 ,
151152 skipSolve:: Bool = false ,
@@ -159,6 +160,7 @@ function computeAcrossHypothesis!(
159160 activehypo = hyporecipe. activehypo
160161 certainidx = hyporecipe. certainidx
161162
163+ @assert ccwl. varidx[] == sfidx " duplicate registers for solve for index should be the same in ccw.varidx"
162164 @assert ccwl. hyporecipe. certainhypo == hyporecipe. certainidx " expected hyporecipe.certainidx to be the same as cached in ccw"
163165 for (hypoidx, vars) in activehypo
164166 count += 1
@@ -171,7 +173,8 @@ function computeAcrossHypothesis!(
171173 ccwl. hyporecipe. activehypo[:] = vars
172174 # end
173175
174- addEntr = view (destinationVarVals, allelements[count])
176+ # ccwl.varValsAll[][ccwl.varidx[]] should be an alternate/duplicate memory from getVal(variable; solveKey)
177+ addEntr = view (ccwl. varValsAll[][ccwl. varidx[]], allelements[count]) # destinationVarVals
175178
176179 # do proposal inflation step, see #1051
177180 # consider duplicate convolution approximations for inflation off-zero
@@ -183,7 +186,7 @@ function computeAcrossHypothesis!(
183186 sfidx,
184187 certainidx;
185188 kappa = ccwl. inflation,
186- readonlyVarVals = destinationVarVals ,
189+ # readonlyVarVals = ccwl.varValsAll[][ccwl.varidx[]] ,
187190 )
188191 addEntropyOnManifold! (
189192 mani,
@@ -197,7 +200,7 @@ function computeAcrossHypothesis!(
197200 if skipSolve
198201 @warn (" skipping numerical solve operation" )
199202 else
200- approxConvOnElements! (destinationVarVals , ccwl, allelements[count], _slack)
203+ approxConvOnElements! (ccwl . varValsAll[][ccwl . varidx[]] , ccwl, allelements[count], _slack)
201204 end
202205 end
203206 elseif hypoidx != sfidx && hypoidx != 0
@@ -206,22 +209,22 @@ function computeAcrossHypothesis!(
206209 # sfidx=2, hypoidx=3: 2 should take a value from 3
207210 # sfidx=3, hypoidx=2: 3 should take a value from 2
208211 # DEBUG sfidx=2, hypoidx=1 -- bad when do something like multihypo=[0.5;0.5] -- issue 424
209- # destinationVarVals [:,allelements[count]] = view(ccwl.varValsAll[hypoidx],:,allelements[count])
212+ # ccwl.varValsAll[][ccwl.varidx[]] [:,allelements[count]] = view(ccwl.varValsAll[hypoidx],:,allelements[count])
210213 # NOTE make alternative case only operate as null hypo
211- addEntr = view (destinationVarVals , allelements[count])
214+ addEntr = view (ccwl . varValsAll[][ccwl . varidx[]] , allelements[count])
212215 # dynamic estimate with user requested speadNH of how much noise to inject (inflation or nullhypo)
213216 spreadDist =
214- calcVariableDistanceExpectedFractional (ccwl, sfidx, certainidx; kappa = spreadNH,readonlyVarVals = destinationVarVals )
217+ calcVariableDistanceExpectedFractional (ccwl, sfidx, certainidx; kappa = spreadNH) # ,readonlyVarVals = ccwl.varValsAll[][ccwl.varidx[]] )
215218 addEntropyOnManifold! (mani, addEntr, 1 : getDimension (mani), spreadDist)
216219
217220 elseif hypoidx == 0
218221 # basically do nothing since the factor is not active for these allelements[count]
219222 # inject more entropy in nullhypo case
220223 # add noise (entropy) to spread out search in convolution proposals
221- addEntr = view (destinationVarVals , allelements[count])
224+ addEntr = view (ccwl . varValsAll[][ccwl . varidx[]] , allelements[count])
222225 # dynamic estimate with user requested speadNH of how much noise to inject (inflation or nullhypo)
223226 spreadDist =
224- calcVariableDistanceExpectedFractional (ccwl, sfidx, certainidx; kappa = spreadNH, readonlyVarVals = destinationVarVals )
227+ calcVariableDistanceExpectedFractional (ccwl, sfidx, certainidx; kappa = spreadNH) # , readonlyVarVals = ccwl.varValsAll[][ccwl.varidx[]] )
225228 # # make spread (1σ) equal to mean distance of other fractionals
226229 addEntropyOnManifold! (mani, addEntr, 1 : getDimension (mani), spreadDist)
227230 else
@@ -337,8 +340,7 @@ function evalPotentialSpecific(
337340 # add user desired measurement values if 0 < length
338341 # 2023Q2, ccwl.varValsAll always points at the variable.VND.val memory locations
339342 # remember when doing approxConv to make a deepcopy of the destination memory first.
340- destinationVarVals = deepcopy (ccwl. varValsAll[][sfidx])
341- maxlen = _beforeSolveCCW! (ccwl, variables, destinationVarVals, sfidx, N; solveKey, needFreshMeasurements, measurement)
343+ maxlen = _beforeSolveCCW! (ccwl, variables, sfidx, N; solveKey, needFreshMeasurements, measurement)
342344
343345 # Check which variables have been initialized
344346 isinit = map (x -> isInitialized (x), variables)
@@ -367,7 +369,7 @@ function evalPotentialSpecific(
367369 sfidx,
368370 maxlen,
369371 mani;
370- destinationVarVals,
372+ # destinationVarVals,
371373 spreadNH,
372374 inflateCycles,
373375 skipSolve,
@@ -415,8 +417,7 @@ function evalPotentialSpecific(
415417 #
416418
417419 # Prep computation variables
418- destinationVarVals = deepcopy (ccwl. varValsAll[][sfidx])
419- maxlen = _beforeSolveCCW! (ccwl, variables, destinationVarVals, sfidx, N; solveKey, needFreshMeasurements, measurement)
420+ maxlen = _beforeSolveCCW! (ccwl, variables, sfidx, N; solveKey, needFreshMeasurements, measurement)
420421
421422 # # FIXME , NEEDS TO BE CLEANED UP AND WORK ON MANIFOLDS PROPER
422423 fnc = ccwl. usrfnc!
@@ -622,7 +623,6 @@ function _evalFactorTemporary!(
622623 solveKey:: Symbol = :default ,
623624 newFactor:: Bool = true ,
624625 _slack = nothing ,
625- # FIXME ON FIRE ADD destinationVarVals,
626626 buildgraphkw... ,
627627)
628628 #
0 commit comments