Skip to content

Commit 104c061

Browse files
authored
Merge pull request #1705 from JuliaRobotics/23Q3/perf/bitstypes
Towards StaticArrays Support
2 parents 6f617fb + 65d3305 commit 104c061

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/ManifoldSampling.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ end
6666
function samplePoint(
6767
M::AbstractDecoratorManifold,
6868
sbelief::ManifoldKernelDensity,
69-
p = identity_element(M, mean(sbelief)),
69+
# p = identity_element(M, mean(sbelief)), # 8.671254 seconds (82.64 M allocations: 3.668 GiB, 7.50% gc time)
70+
p = getPointIdentity(M), #6.713209 seconds (66.42 M allocations: 3.141 GiB, 7.52% gc time)
7071
retraction_method::AbstractRetractionMethod = ExponentialRetraction(),
7172
)
7273
X = sampleTangent(M, sbelief, p)

src/services/EvalFactor.jl

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ function addEntropyOnManifold!(
102102
# preallocate
103103
T = number_eltype(points[1])
104104
Xc = zeros(T, manifold_dimension(M))
105-
X = get_vector(M, points[1], Xc, DefaultOrthogonalBasis())
105+
#allocate to change SMatrix to MMatrix
106+
X = allocate(get_vector(M, points[1], Xc, DefaultOrthogonalBasis()))
106107

107108
for idx = 1:length(points)
108109
# build tangent coordinate random
@@ -115,8 +116,8 @@ function addEntropyOnManifold!(
115116
get_vector!(M, X, points[idx], Xc, DefaultOrthogonalBasis())
116117
#update point
117118
# exp!(M, points[idx], points[idx], X)
118-
retract!(M, points[idx], points[idx], X)
119-
# points[idx] = exp(M, points[idx], X)
119+
# retract!(M, points[idx], points[idx], X)
120+
points[idx] = retract(M, points[idx], X)
120121

121122
end
122123
#
@@ -369,6 +370,16 @@ function evalPotentialSpecific(
369370
return ccwl.varValsAll[ccwl.varidx[]], ipc
370371
end
371372

373+
374+
#TODO workaround for supporting bitstypes, need rewrite, can do with `PowerManifoldNestedReplacing` or similar
375+
function AMP.setPointsMani!(dest::AbstractArray{T}, src::AbstractArray{U}, destIdx, srcIdx=destIdx) where {T<:AbstractArray,U<:AbstractArray}
376+
if isbitstype(T)
377+
dest[destIdx] = src[srcIdx]
378+
else
379+
setPointsMani!(dest[destIdx],src[srcIdx])
380+
end
381+
end
382+
372383
# TODO `measurement` might not be properly wired up yet
373384
# TODO consider 1051 here to inflate proposals as general behaviour
374385
function evalPotentialSpecific(
@@ -436,7 +447,7 @@ function evalPotentialSpecific(
436447
for m in (1:length(addEntr))[ahmask]
437448
# FIXME, selection for all measurement::Tuple elements
438449
# @info "check broadcast" ccwl.usrfnc! addEntr[m] ccwl.measurement[1][m]
439-
setPointsMani!(addEntr[m], ccwl.measurement[m])
450+
setPointsMani!(addEntr, ccwl.measurement, m)
440451
# addEntr[m] = ccwl.measurement[m][1]
441452
end
442453
# ongoing part of RoME.jl #244

src/services/NumericalCalculations.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ function _solveCCWNumeric!(
385385
## using CalcFactor legacy path inside (::CalcFactor)
386386
# _hypoObj = (x) -> (target.=x; unrollHypo!())
387387
function _hypoObj(x)
388-
target[] .= x
388+
target[] = x
389389
return unrollHypo!()
390390
end
391391

@@ -413,7 +413,7 @@ function _solveCCWNumeric!(
413413
# end
414414

415415
# FIXME insert result back at the correct variable element location
416-
ccwl.varValsAll[sfidx][smpid] .= retval
416+
ccwl.varValsAll[sfidx][smpid] = retval
417417

418418
return nothing
419419
end

0 commit comments

Comments
 (0)