Skip to content

Commit

Permalink
Merge pull request #26 from JuliaRobotics/feature/addfunctoreval
Browse files Browse the repository at this point in the history
adding functor evaluation style
  • Loading branch information
dehann committed Jul 17, 2018
2 parents f20761c + d0c49dd commit 6a66742
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/DualTree01.jl
Expand Up @@ -354,6 +354,7 @@ function evaluateDualTree(bd::BallTreeDensity, pos::Array{Float64,2}, lvFlag::Bo
end
# should make this be the Union again TODO ??
function evaluateDualTree(bd::BallTreeDensity, pos::AbstractArray{Float64,1}, lvFlag::Bool=false, errTol::Float64=1e-3)
warn("evaluateDualTree vector evaluation API is changing for single point evaluation across multiple dimensions rather than assuming multiple points on a univariate kde.")
pos2 = zeros(1,length(pos))
pos2[1,:] = pos[:]
return evaluateDualTree(bd, pos2, lvFlag, errTol)
Expand All @@ -368,6 +369,13 @@ function makeDualTree(bd::BallTreeDensity, errTol::Float64)
return pRes
end

function (bd::BallTreeDensity)(pos::Array{Float64,2}, lvFlag::Bool=false, errTol::Float64=1e-3)
evaluateDualTree(bd, pos, lvFlag, errTol)
end

function (bd::BallTreeDensity)(pos::Array{Float64,1}, lvFlag::Bool=false, errTol::Float64=1e-3)
evaluateDualTree(bd, reshape(pos,:,1), lvFlag, errTol)
end

function evaluateDualTree(bd::BallTreeDensity, pos::BallTreeDensity, lvFlag::Bool=false, errTol::Float64=1e-3)
if (bd.bt.dims != pos.bt.dims) error("bd and pos must have the same dimension") end
Expand Down

0 comments on commit 6a66742

Please sign in to comment.