[mlpack-git] [mlpack/mlpack] Spill trees (#747)

Ryan Curtin notifications at github.com
Wed Aug 17 00:11:01 EDT 2016

> +         typename MatType,
> +         template<typename HyperplaneMetricType> class HyperplaneType,
> +         template<typename SplitBoundT, typename SplitMatT> class SplitType>
> +void SpillSearch<MetricType, MatType, HyperplaneType, SplitType>::
> +Search(const MatType& querySet,
> +       const size_t k,
> +       arma::Mat<size_t>& neighbors,
> +       arma::mat& distances)
> +{
> +  if (Naive() || SingleMode())
> +    neighborSearch.Search(querySet, k, neighbors, distances);
> +  else
> +  {
> +    // For Dual Tree Search on SpillTrees, the queryTree must be built with non
> +    // overlapping (tau = 0).
> +    Tree queryTree(querySet, 0 /* tau */, leafSize, rho);

Ok, in this case, it is a lot of work to duplicate the entire class.  Instead I think we should use template specialization, but we can't specialize only a single member of a template class, so instead you'll need to write an auxiliary method kinda like:

template<typename TreeType>
TreeType* BuildQueryTree(arma::mat& dataset, boost::disable_if<IsSpillTree<TreeType>>::value*)
  return new TreeType(dataset);

template<typename TreeType>
TreeType* BuildQueryTree(const arma::mat& dataset, boost::enable_if<IsSpillTree<TreeType>>::value)
  return new TreeType(dataset, 0, leafSize, rho);

I've omitted a lot of details and there are probably syntax errors but the basic idea is to just use SFINAE in a standalone helper function.  I guess maybe it would have been easier for me to just say "check out `BuildTree()` at the top of neighbor_search_impl.hpp"...! :)

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.cc.gatech.edu/pipermail/mlpack-git/attachments/20160816/f67fa072/attachment.html>

More information about the mlpack-git mailing list