<commit_before>/**
 * @file rectangle_tree_impl.hpp
 *
 * Implementation of generalized rectangle tree.
 */
#ifndef __MLPACK_CORE_TREE_RECTANGLE_TREE_RECTANGLE_TREE_IMPL_HPP
#define __MLPACK_CORE_TREE_RECTANGLE_TREE_RECTANGLE_TREE_IMPL_HPP

// In case it wasn't included already for some reason.
#include "rectangle_tree.hpp"

#include <mlpack/core/util/cli.hpp>
#include <mlpack/core/util/log.hpp>
#include <mlpack/core/util/string_util.hpp>

namespace mlpack {
namespace tree {

template<typename StatisticType,
	 typename MatType,
	 typename SplitType>
RectangleTree<StatisticType, MatType, SplitType>::RectangleTree(
    MatType& data,
    const size_t leafSize):

{
  //Do the actual stuff here

}

/**
 * Deletes this node, deallocating the memory for the children and calling
 * their destructors in turn.  This will invalidate any pointers or references
 * to any nodes which are children of this one.
 */
template<typename StatisticType,
	   typename MatType,
	   typename SplitType>
RectangleTree<BoundType, StatisticType, MatType, SplitType>::
  ~RectangleTree()
{
  for(int i = 0; i < numOfChildren; i++) {
    delete children[i];
  }
}

template<typename StatisticType,
	 typename MatType,
	 typename SplitType>
size_t RectangleTree<StatisticType, MatType, SplitType>::
    TreeSize() const
{
  int n = 0;
  for(int i = 0; i < numOfChildren; i++) {
    n += children[i].TreeSize();
  }
  return n + 1; // we add one for this node
}



template<typename StatisticType,
	 typename MatType,
	 typename SplitType>
size_t RectangleTree<StatisticType, MatType, SplitType>::
    TreeDepth() const
{
  // Recursively count the depth of each subtree.  The plus one is
  // because we have to count this node, too.
  int maxSubDepth = 0;
  for(int i = 0; i < numOfChildren; i++) {
    int d = children[i].depth();
    if(d > maxSubDepth)
      maxSubDepth = d;
  }
  return maxSubDepth + 1;
}

template<typename StatisticType,
         	typename MatType,
         	typename SplitType>
inline bool BinarySpaceTree<StatisticType, MatType, SplitType>::
    IsLeaf() const
{
  return numOfChildren == 0;
}

/**
 * Return the last point in the tree.  SINCE THE TREE STORES DATA SEPARATELY IN EACH LEAF
 * THIS IS CURRENTLY MEANINGLESS.
 */
template<typename StatisticType,
	 typename MatType,
	 typename SplitType>
inline size_t RectangleTree<StatisticType, MatType, SplitType>::End() const
{
  if(numOfChildren)
    return begin + count;
  return children[numOfChildren-1].End();
}

  //have functions for returning the list of modified indices if we end up doing it that way.

/**
 * Split the tree.  This moves up the tree recursively.<commit_msg>more R tree stuff.  Still no build<commit_after>/**
 * @file rectangle_tree_impl.hpp
 *
 * Implementation of generalized rectangle tree.
 */
#ifndef __MLPACK_CORE_TREE_RECTANGLE_TREE_RECTANGLE_TREE_IMPL_HPP
#define __MLPACK_CORE_TREE_RECTANGLE_TREE_RECTANGLE_TREE_IMPL_HPP

// In case it wasn't included already for some reason.
#include "rectangle_tree.hpp"

#include <mlpack/core/util/cli.hpp>
#include <mlpack/core/util/log.hpp>
#include <mlpack/core/util/string_util.hpp>

namespace mlpack {
namespace tree {

template<typename StatisticType,
	 typename MatType,
	 typename SplitType>
RectangleTree<StatisticType, MatType, SplitType>::RectangleTree(
    MatType& data,
    const size_t leafSize):

{
  //Do the actual stuff here

}

/**
 * Deletes this node, deallocating the memory for the children and calling
 * their destructors in turn.  This will invalidate any pointers or references
 * to any nodes which are children of this one.
 */
template<typename StatisticType,
	   typename MatType,
	   typename SplitType>
RectangleTree<BoundType, StatisticType, MatType, SplitType>::
  ~RectangleTree()
{
  for(int i = 0; i < numOfChildren; i++) {
    delete children[i];
  }
}

template<typename StatisticType,
	 typename MatType,
	 typename SplitType>
size_t RectangleTree<StatisticType, MatType, SplitType>::
    TreeSize() const
{
  int n = 0;
  for(int i = 0; i < numOfChildren; i++) {
    n += children[i].TreeSize();
  }
  return n + 1; // we add one for this node
}



template<typename StatisticType,
	 typename MatType,
	 typename SplitType>
size_t RectangleTree<StatisticType, MatType, SplitType>::
    TreeDepth() const
{
  // Recursively count the depth of each subtree.  The plus one is
  // because we have to count this node, too.
  int maxSubDepth = 0;
  for(int i = 0; i < numOfChildren; i++) {
    int d = children[i].depth();
    if(d > maxSubDepth)
      maxSubDepth = d;
  }
  return maxSubDepth + 1;
}

template<typename StatisticType,
         typename MatType,
         typename SplitType>
inline bool BinarySpaceTree<StatisticType, MatType, SplitType>::
    IsLeaf() const
{
  return numOfChildren == 0;
}

/**
 * Returns the number of children in this node.
 */
template<typename StatisticType,
	 typename MatType,
	 typename SplitType>
inline size_t RectangleTree<StatisticType, MatType, SplitType>::
    NumChildren() const
{
  return NumChildren;
}

/**
 * Return a bound on the furthest point in the node form the centroid.
 * This returns 0 unless the node is a leaf.
 */
template<typename StatisticType,
         typename MatType,
         typename SplitType>
inline double RectangleTree<StatisticType, MatType, SplitType>::
FurthestPointDistance() const
{
  if(!IsLeaf())
    return 0.0;

  // Otherwise return the distance from the centroid to a corner of the bound.
  return 0.5 * bound.Diameter();
}

/**
 * Return the furthest possible descendant distance.  This returns the maximum
 * distance from the centroid to the edge of the bound and not the empirical
 * quantity which is the actual furthest descendant distance.  So the actual
 * furthest descendant distance may be less than what this method returns (but
 * it will never be greater than this).
 */
template<typename StatisiticType,
	 typename MatType,
	 typename SplitType>
inline double RectangleTree<StatisticType, MatType, SplitType>::
    FurthestDescendantDistance() const
{
  return furthestDescendantDistance;
}

/**
 * Return the specified child.
 */
template<typename StatisticType,
	 typename MatType,
	 typename SplitType>
inline RectangleTree<StatisticType, MatType, SplitType>&
    RectangleTree<StatisticType, MatType, SplitType>::
        Child(const size_t child) const
{
  return children[child];
}

/**
 * Return the number of points contained in this node.  Zero if it is not a leaf.
 */
template<typename StatisticType,
	 typename MatType,
	 typename SplitType>
inline size_t RectangleTree<StatisticType, MatType, SplitType>::
    NumPoints() const
{
  if(numChildren == 0)
    return 0;

  return count;
}

/**
 * Return the number of descendants contained in this node.  MEANINIGLESS AS IT CURRENTLY STANDS.
 */
template<typename StatisticType,
	 typename MatType,
	 typename SplitType>
inline size_t RectangleTree<StatisticType, MatType, SplitType>::
    NumDescendants() const
{
  return count;
}

/**
 * Return the index of a particular descendant contained in this node.  SEE OTHER WARNINGS
 */
template<typename StatisticType,
	 typename MatType,
	 typename SplitType>
inline size_t RectangleTree<StatisticType, MatType, SplitType>::
    Descendant(const size_t index> const
{
  return (begin + index);
}

/**
 * Return the index of a particular point contained in this node.  SEE OTHER WARNINGS
 */
template<typename StatisticType,
	 typename MatType,
	 typename SplitType>
inline size_t RectangleTree<StatisticType, MatType, SplitType>::
    Point(const size_t index> const
{
  return (begin + index);
}

/**
 * Return the last point in the tree.  SINCE THE TREE STORES DATA SEPARATELY IN EACH LEAF
 * THIS IS CURRENTLY MEANINGLESS.
 */
template<typename StatisticType,
	 typename MatType,
	 typename SplitType>
inline size_t RectangleTree<StatisticType, MatType, SplitType>::End() const
{
  if(numOfChildren)
    return begin + count;
  return children[numOfChildren-1].End();
}

  //have functions for returning the list of modified indices if we end up doing it that way.

/**
 * Split the tree.  This moves up the tree recursively.
{'fraction_non_alphanumeric': 0.08920650566781665, 'fraction_numerical': 0.0030803351404632825, 'mean_word_length': 4.124368686868687, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5393963', 'n_tokens_mistral': 2619, 'n_tokens_neox': 2457, 'n_words': 830}