GLAMERDOC++
Gravitational Lensing Code Library
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
TreeSimple< PType > Class Template Reference

A C++ class wrapper for the bianary treeNB used in the Nbody force calculation, but also useful for general purpose searches. More...

#include <simpleTree.h>

Inheritance diagram for TreeSimple< PType >:
Inheritance graph
[legend]

Public Member Functions

 TreeSimple (PType *xp, IndexType Npoints, int bucket=5, int dimensions=2, bool median=true)
 
template<typename T >
void PointsWithinCircle (T center[2], float radius, std::list< unsigned long > &neighborkist)
 Finds the points within a circle around center and puts their index numbers in a list.
 
template<typename T >
void PointsWithinEllipse (T center[2], float a_max, float a_min, float posangle, std::list< unsigned long > &neighborkist)
 Finds the points within an ellipse around center and puts their index numbers in a list.
 
template<typename T >
NNDistance (T *ray, int Nneighbors) const
 Finds the nearest N neighbors and puts their index numbers in an array, also returns the distance to the Nth neighbor for calculating smoothing. More...
 
template<typename T >
void PointsWithinEllipse (T *ray, float rmax, float rmin, float posangle, std::list< unsigned long > &neighborlist)
 
template<typename T >
void PointsWithinCircle (T *ray, float rmax, std::list< unsigned long > &neighborlist)
 

Protected Member Functions

TreeNBStruct< PType > * BuildTreeNB (PType *xxp, IndexType Nparticles, IndexType *particles, int Ndimensions, PosType theta)
 
void _BuildTreeNB (TreeNBStruct< PType > *tree, IndexType nparticles, IndexType *particles)
 
template<typename T >
void _findleaf (T *ray, TreeSimple::iterator &it) const
 
template<typename T >
void _PointsWithin (T *ray, float *rmax, std::list< unsigned long > &neighborkist)
 
template<typename T >
void _NearestNeighbors (T *ray, int Nneighbors, unsigned long *neighbors, PosType *rneighbors)
 
BranchNBNewBranchNB (IndexType *particles, IndexType nparticles, PosType boundary_p1[], PosType boundary_p2[], PosType center[], int level, unsigned long branchNBnumber)
 
void FreeBranchNB (BranchNB *branchNB)
 
TreeNBStruct< PType > * NewTreeNB (IndexType *particles, IndexType nparticles, PosType boundary_p1[], PosType boundary_p2[], PosType center[], short Ndimensions)
 
void freeTreeNB (TreeNBStruct< PType > *tree)
 
short emptyTreeNB (TreeNBStruct< PType > *tree)
 
void _freeTreeNB (TreeNBStruct< PType > *tree, short child)
 
bool isEmptyNB (TreeNBStruct< PType > *tree)
 
bool atTopNB (TreeNBStruct< PType > *tree)
 
bool noChildNB (TreeNBStruct< PType > *tree)
 
bool offEndNB (TreeNBStruct< PType > *tree)
 
void getCurrentNB (TreeNBStruct< PType > *tree, IndexType *particles, IndexType *nparticles)
 
unsigned long getNbranchesNB (TreeNBStruct< PType > *tree)
 
void moveTopNB (TreeNBStruct< PType > *tree)
 
void moveUpNB (TreeNBStruct< PType > *tree)
 
void moveToChildNB (TreeNBStruct< PType > *tree, int child)
 
void insertChildToCurrentNB (TreeNBStruct< PType > *tree, IndexType *particles, IndexType nparticles, PosType boundary_p1[], PosType boundary_p2[], PosType center[], int child)
 
void attachChildToCurrentNB (TreeNBStruct< PType > *tree, BranchNB &data, int child)
 
bool TreeNBWalkStep (TreeNBStruct< PType > *tree, bool allowDescent)
 
bool atLeaf ()
 
template<typename T >
bool inbox (const T *center, PosType *p1, PosType *p2) const
 

Protected Attributes

int Ndim
 
int incell
 
TreeNBStruct< PType > * tree
 
IndexType * index
 
IndexType Nparticles
 
bool median_cut
 
int Nbucket
 
PosType realray [3]
 
PType * xxp
 

Detailed Description

template<typename PType>
class TreeSimple< PType >

A C++ class wrapper for the bianary treeNB used in the Nbody force calculation, but also useful for general purpose searches.

Most of the code in TreeNB.c and TreeDriverNB.c is duplicated here as private methods and a few public ones.

PType must have a dereferencing operator [] that gives the value to be sorterd. THIS CAN ONLY BE IN 2 OR 3 DIMENSIONS.

Member Function Documentation

◆ _NearestNeighbors()

template<typename PType >
template<typename T >
void TreeSimple< PType >::_NearestNeighbors ( T *  ray,
int  Nneighbors,
unsigned long *  neighbors,
PosType *  rneighbors 
)
protected

if ray found in second child go back to first to search for neighbors

◆ _PointsWithin()

template<typename PType >
template<typename T >
void TreeSimple< PType >::_PointsWithin ( T *  ray,
float *  rmax,
std::list< unsigned long > &  neighborlist 
)
protected

Used in PointsWithinKist() to walk tree.

◆ NewBranchNB()

template<typename PType >
BranchNB * TreeSimple< PType >::NewBranchNB ( IndexType *  particles,
IndexType  nparticles,
PosType  boundary_p1[],
PosType  boundary_p2[],
PosType  center[],
int  level,
unsigned long  branchNBnumber 
)
protected

visits every branch in tree to calculate two critical lengths rcrit_angle and rcrit_part and mark largest particle in each node subject to some conditions

if the sph[] are negative rcrit_part = 0

◆ NNDistance()

template<typename PType >
template<typename T >
T TreeSimple< PType >::NNDistance ( T *  ray,
int  Nneighbors 
) const

Finds the nearest N neighbors and puts their index numbers in an array, also returns the distance to the Nth neighbor for calculating smoothing.

Nearest neighbor distance.

Finds the distance to the Nth nearest neighbors in whatever dimensions tree is defined in.

walk tree from the top

Parameters
rayposition
Nneighborsnumber of neighbors to be found

◆ PointsWithinCircle()

template<typename PType >
template<typename T >
void TreeSimple< PType >::PointsWithinCircle ( T *  ray,
float  rmax,
std::list< unsigned long > &  neighborlist 
)
Parameters
raycenter of circle
rmaxradius of circle
neighborlistoutput neighbor list, will be emptied if it contains anything on entry

◆ PointsWithinEllipse()

template<typename PType >
template<typename T >
void TreeSimple< PType >::PointsWithinEllipse ( T *  ray,
float  rmax,
float  rmin,
float  posangle,
std::list< unsigned long > &  neighborlist 
)
Parameters
raycenter of ellipse
rmaxmajor axis
rminminor axis
posangleposition angle of major axis, smallest angle between the x-axis and the long axis
neighborlistoutput neighbor list, will be emptied if it contains anything on entry

The documentation for this class was generated from the following file: