SlowDown Algorithmic Regularization (SDAR)
Algorithmic Regularization with slowdown method for integrating few-body motions
COMM::BinaryTree< Tptcl, Tbinary > Class Template Reference

Binary tree cell. More...

#include <binary_tree.h>

Inheritance diagram for COMM::BinaryTree< Tptcl, Tbinary >:
[legend]
Collaboration diagram for COMM::BinaryTree< Tptcl, Tbinary >:
[legend]

Public Types

template<class T >
using ProcessFunctionLeaf = void(*)(T &, Tptcl *&)
 iteratively leaf processing function template More...
 
template<class T >
using ProcessFunctionRoot = T(*)(T &, BinaryTreeLocal &)
 iteratively root processing function template More...
 
template<class T , class Tr >
using ProcessFunctionTree = Tr(*)(T &, const Tr &, const Tr &, BinaryTreeLocal &)
 iteratively tree processing function template More...
 

Public Member Functions

 BinaryTree ()
 
int isSameBranch (const BinaryTreeLocal &_bin) const
 check whether a given binarytree data is in the same branch More...
 
void getherBinaryTreeIter (BinaryTreeLocal _bin[])
 collect BinaryTree data iteratively and save to a BinaryTree array More...
 
void calcCenterOfMass ()
 calculate center-of-mass from members More...
 
void calcSemiEccPeriod (const Float &_G)
 calculate Kepler orbit semi, ecc and period only More...
 
void calcOrbit (const Float _G)
 calculate Kepler orbit from members More...
 
void calcParticles (const Float _G)
 calculate particles from orbit More...
 
int calcMemberN ()
 calc total number of members More...
 
int getMemberN () const
 get total number of members More...
 
int calcMemberNIter ()
 calc total number of members iteratively More...
 
template<class T >
void processLeafIter (T &_dat, ProcessFunctionLeaf< T > _f)
 Process (bottom) leaf data with extra dat iteratively (from left to right) More...
 
template<class T >
processRootIter (T &_dat, ProcessFunctionRoot< T > _f)
 Process root data and return result iteratively. More...
 
template<class Troot , class Tleaf >
Troot processRootLeafIter (Troot &_dat_root, ProcessFunctionRoot< Troot > _f_root, Tleaf &_dat_leaf, ProcessFunctionLeaf< Tleaf > _f_leaf)
 Process root and leaf data and return result iteratively. More...
 
template<class T , class Tr >
Tr processTreeIter (T &_dat, const Tr &_res1, const Tr &_res2, ProcessFunctionTree< T, Tr > _f)
 Process tree data with extra dat iteratively (from bottom to top) More...
 
int copyDataIter (BinaryTreeLocal _bin_out[], const int _i)
 copy a binary tree to a binaryTree array iteratively More...
 
void setMembers (Tptcl *_p1, Tptcl *_p2, const int _i1, const int _i2)
 set members More...
 
Tptcl * getMember (const size_t i) const
 get member More...
 
BinaryTreeLocalgetMemberAsTree (const size_t i) const
 get member as tree More...
 
int getMemberIndex (const size_t i) const
 get member index More...
 
bool isMemberTree (const size_t i) const
 
Tptcl * getLeftMember () const
 get left member More...
 
BinaryTreeLocalgetLeftMemberAsTree () const
 get left member as tree More...
 
Tptcl * getRightMember () const
 get right member More...
 
BinaryTreeLocalgetRightMemberAsTree () const
 get right member as tree More...
 
void printColumn (std::ostream &_fout, const int _width=20)
 print data of class members using column style More...
 
void writeAscii (std::ostream &_fout) const
 write class data to file with ASCII format More...
 
void readAscii (std::istream &_fin)
 read class data to file with ASCII format More...
 
void printBinaryTreeIter (std::ostream &_fout, const int _width=20)
 print binary and member information More...
 
void printBinaryIter (std::ostream &_fout, const int _width=20)
 print binary function More...
 

Static Public Member Functions

static FloatstableCheckIter (BinaryTreeLocal &_bin, const Float _t_crit)
 Three-body stability function for hierarchical binary tree. More...
 
static void generateLevelBranch (BinaryTreeLocal &_bin, const bool _reset)
 generate level and branch More...
 
static void generateBinaryTree (BinaryTreeLocal _bins[], int _ptcl_list[], const int _n, Tptcl *_ptcl, const Float _G)
 Generate kepler binary tree for a group of particles. More...
 
static void printColumnTitle (std::ostream &_fout, const int _width=20)
 print titles of class members using column style More...
 

Public Attributes

int level
 

member pointer

More...
 
int branch
 

binary tree level, start from zero for root tree. Then each subtree increase level by one.

More...
 

Detailed Description

template<class Tptcl, class Tbinary>
class COMM::BinaryTree< Tptcl, Tbinary >

Binary tree cell.

Member Typedef Documentation

◆ ProcessFunctionLeaf

template<class Tptcl , class Tbinary >
template<class T >
using COMM::BinaryTree< Tptcl, Tbinary >::ProcessFunctionLeaf = void (*) (T&, Tptcl* &)

iteratively leaf processing function template

◆ ProcessFunctionRoot

template<class Tptcl , class Tbinary >
template<class T >
using COMM::BinaryTree< Tptcl, Tbinary >::ProcessFunctionRoot = T (*) (T&, BinaryTreeLocal& )

iteratively root processing function template

◆ ProcessFunctionTree

template<class Tptcl , class Tbinary >
template<class T , class Tr >
using COMM::BinaryTree< Tptcl, Tbinary >::ProcessFunctionTree = Tr (*) (T&, const Tr&, const Tr&, BinaryTreeLocal& )

iteratively tree processing function template

Constructor & Destructor Documentation

◆ BinaryTree()

template<class Tptcl , class Tbinary >
COMM::BinaryTree< Tptcl, Tbinary >::BinaryTree ( )
inline

Member Function Documentation

◆ calcCenterOfMass()

template<class Tptcl , class Tbinary >
void COMM::BinaryTree< Tptcl, Tbinary >::calcCenterOfMass ( )
inline

calculate center-of-mass from members

Here is the caller graph for this function:

◆ calcMemberN()

template<class Tptcl , class Tbinary >
int COMM::BinaryTree< Tptcl, Tbinary >::calcMemberN ( )
inline

calc total number of members

Here is the caller graph for this function:

◆ calcMemberNIter()

template<class Tptcl , class Tbinary >
int COMM::BinaryTree< Tptcl, Tbinary >::calcMemberNIter ( )
inline

calc total number of members iteratively

Here is the caller graph for this function:

◆ calcOrbit()

template<class Tptcl , class Tbinary >
void COMM::BinaryTree< Tptcl, Tbinary >::calcOrbit ( const Float  _G)
inline

calculate Kepler orbit from members

Here is the caller graph for this function:

◆ calcParticles()

template<class Tptcl , class Tbinary >
void COMM::BinaryTree< Tptcl, Tbinary >::calcParticles ( const Float  _G)
inline

calculate particles from orbit

◆ calcSemiEccPeriod()

template<class Tptcl , class Tbinary >
void COMM::BinaryTree< Tptcl, Tbinary >::calcSemiEccPeriod ( const Float _G)
inline

calculate Kepler orbit semi, ecc and period only

◆ copyDataIter()

template<class Tptcl , class Tbinary >
int COMM::BinaryTree< Tptcl, Tbinary >::copyDataIter ( BinaryTreeLocal  _bin_out[],
const int  _i 
)
inline

copy a binary tree to a binaryTree array iteratively

Parameters
[in]_bin_outBinaryTree array to store the data
[in]_iindex in _bin_out for copying the current tree cell
Here is the caller graph for this function:

◆ generateBinaryTree()

template<class Tptcl , class Tbinary >
static void COMM::BinaryTree< Tptcl, Tbinary >::generateBinaryTree ( BinaryTreeLocal  _bins[],
int  _ptcl_list[],
const int  _n,
Tptcl *  _ptcl,
const Float  _G 
)
inlinestatic

Generate kepler binary tree for a group of particles.

Here is the caller graph for this function:

◆ generateLevelBranch()

template<class Tptcl , class Tbinary >
static void COMM::BinaryTree< Tptcl, Tbinary >::generateLevelBranch ( BinaryTreeLocal _bin,
const bool  _reset 
)
inlinestatic

generate level and branch

Parameters
[in]_binbinary tree
[in]_resetif true, set _bin as root tree (level=0, branch=0), otherwise use the stored values.
Here is the caller graph for this function:

◆ getherBinaryTreeIter()

template<class Tptcl , class Tbinary >
void COMM::BinaryTree< Tptcl, Tbinary >::getherBinaryTreeIter ( BinaryTreeLocal  _bin[])
inline

collect BinaryTree data iteratively and save to a BinaryTree array

The member number should be correct

Parameters
[out]_binbinarytree array to store the data (should be size of n_members-1), the root is put last (n_members-1)
Here is the caller graph for this function:

◆ getLeftMember()

template<class Tptcl , class Tbinary >
Tptcl* COMM::BinaryTree< Tptcl, Tbinary >::getLeftMember ( ) const
inline

get left member

Here is the caller graph for this function:

◆ getLeftMemberAsTree()

template<class Tptcl , class Tbinary >
BinaryTreeLocal* COMM::BinaryTree< Tptcl, Tbinary >::getLeftMemberAsTree ( ) const
inline

get left member as tree

◆ getMember()

template<class Tptcl , class Tbinary >
Tptcl* COMM::BinaryTree< Tptcl, Tbinary >::getMember ( const size_t  i) const
inline

get member

Here is the caller graph for this function:

◆ getMemberAsTree()

template<class Tptcl , class Tbinary >
BinaryTreeLocal* COMM::BinaryTree< Tptcl, Tbinary >::getMemberAsTree ( const size_t  i) const
inline

get member as tree

Here is the caller graph for this function:

◆ getMemberIndex()

template<class Tptcl , class Tbinary >
int COMM::BinaryTree< Tptcl, Tbinary >::getMemberIndex ( const size_t  i) const
inline

get member index

◆ getMemberN()

template<class Tptcl , class Tbinary >
int COMM::BinaryTree< Tptcl, Tbinary >::getMemberN ( ) const
inline

get total number of members

Here is the caller graph for this function:

◆ getRightMember()

template<class Tptcl , class Tbinary >
Tptcl* COMM::BinaryTree< Tptcl, Tbinary >::getRightMember ( ) const
inline

get right member

Here is the caller graph for this function:

◆ getRightMemberAsTree()

template<class Tptcl , class Tbinary >
BinaryTreeLocal* COMM::BinaryTree< Tptcl, Tbinary >::getRightMemberAsTree ( ) const
inline

get right member as tree

◆ isMemberTree()

template<class Tptcl , class Tbinary >
bool COMM::BinaryTree< Tptcl, Tbinary >::isMemberTree ( const size_t  i) const
inline
Here is the caller graph for this function:

◆ isSameBranch()

template<class Tptcl , class Tbinary >
int COMM::BinaryTree< Tptcl, Tbinary >::isSameBranch ( const BinaryTreeLocal _bin) const
inline

check whether a given binarytree data is in the same branch

Parameters
[in]_binbinary tree
Returns
0: no relation; 1: same binary; -2: the given _bin is in the upper root tree; 2: the given _bin is in the leaf tree

◆ printBinaryIter()

template<class Tptcl , class Tbinary >
void COMM::BinaryTree< Tptcl, Tbinary >::printBinaryIter ( std::ostream &  _fout,
const int  _width = 20 
)
inline

print binary function

◆ printBinaryTreeIter()

template<class Tptcl , class Tbinary >
void COMM::BinaryTree< Tptcl, Tbinary >::printBinaryTreeIter ( std::ostream &  _fout,
const int  _width = 20 
)
inline

print binary and member information

◆ printColumn()

template<class Tptcl , class Tbinary >
void COMM::BinaryTree< Tptcl, Tbinary >::printColumn ( std::ostream &  _fout,
const int  _width = 20 
)
inline

print data of class members using column style

print data of class members in one line for column style. Notice no newline is printed at the end

Parameters
[out]_foutstd::ostream output object
[in]_widthprint width (defaulted 20)
Here is the caller graph for this function:

◆ printColumnTitle()

template<class Tptcl , class Tbinary >
static void COMM::BinaryTree< Tptcl, Tbinary >::printColumnTitle ( std::ostream &  _fout,
const int  _width = 20 
)
inlinestatic

print titles of class members using column style

! copy operator = *! Copy the data and member address. If member address point to a particle (id>0), copy address; else if it is a binary tree, copy the address and also correct the address difference, this assume the whole BinaryTree is stored in a continuing array, thus correct address difference also make the new binary tree have consistent member address in new array.

print titles of class members in one line for column style

Parameters
[out]_foutstd::ostream output object
[in]_widthprint width (defaulted 20)

◆ processLeafIter()

template<class Tptcl , class Tbinary >
template<class T >
void COMM::BinaryTree< Tptcl, Tbinary >::processLeafIter ( T &  _dat,
ProcessFunctionLeaf< T >  _f 
)
inline

Process (bottom) leaf data with extra dat iteratively (from left to right)

Parameters
[in]_datdata for processing loop from left to right
[in]_ffunction to process leaf information
Returns
: new data generated by processing function

◆ processRootIter()

template<class Tptcl , class Tbinary >
template<class T >
T COMM::BinaryTree< Tptcl, Tbinary >::processRootIter ( T &  _dat,
ProcessFunctionRoot< T >  _f 
)
inline

Process root data and return result iteratively.

The process go from top root to leafs from left to right

Parameters
[in]_datdata return from upper level processing function
[in]_ffunction to process root information
Returns
: new data generated by processing function

◆ processRootLeafIter()

template<class Tptcl , class Tbinary >
template<class Troot , class Tleaf >
Troot COMM::BinaryTree< Tptcl, Tbinary >::processRootLeafIter ( Troot &  _dat_root,
ProcessFunctionRoot< Troot >  _f_root,
Tleaf &  _dat_leaf,
ProcessFunctionLeaf< Tleaf >  _f_leaf 
)
inline

Process root and leaf data and return result iteratively.

The process go from top root to leafs from left to right

Parameters
[in]_dat_rootdata return from upper root processing function
[in]_f_rootfunction to process root information
[in]_dat_leafdata for processing loop from left to right
[in]_f_leaffunction to process leaf information
Returns
: new data generated by processing function

◆ processTreeIter()

template<class Tptcl , class Tbinary >
template<class T , class Tr >
Tr COMM::BinaryTree< Tptcl, Tbinary >::processTreeIter ( T &  _dat,
const Tr &  _res1,
const Tr &  _res2,
ProcessFunctionTree< T, Tr >  _f 
)
inline

Process tree data with extra dat iteratively (from bottom to top)

Parameters
[in]_datgeneral data type for process using
[in]_res1return from branch 1
[in]_res2return from branch 2
[in]_ffunction to process root information
Returns
: new data generated by processing function

◆ readAscii()

template<class Tptcl , class Tbinary >
void COMM::BinaryTree< Tptcl, Tbinary >::readAscii ( std::istream &  _fin)
inline

read class data to file with ASCII format

Parameters
[in]_finstd::istream file for input

◆ setMembers()

template<class Tptcl , class Tbinary >
void COMM::BinaryTree< Tptcl, Tbinary >::setMembers ( Tptcl *  _p1,
Tptcl *  _p2,
const int  _i1,
const int  _i2 
)
inline

set members

Parameters
[in]_p1particle 1
[in]_p2particle 2
[in]_i1particle 1 index (should be >=0 if it is not binary tree)
[in]_i2particle 2 index (should be >=0 if it is not binary tree)
Here is the caller graph for this function:

◆ stableCheckIter()

template<class Tptcl , class Tbinary >
static Float& COMM::BinaryTree< Tptcl, Tbinary >::stableCheckIter ( BinaryTreeLocal _bin,
const Float  _t_crit 
)
inlinestatic

Three-body stability function for hierarchical binary tree.

Here is the caller graph for this function:

◆ writeAscii()

template<class Tptcl , class Tbinary >
void COMM::BinaryTree< Tptcl, Tbinary >::writeAscii ( std::ostream &  _fout) const
inline

write class data to file with ASCII format

Parameters
[in]_foutstd:osteram file for output

Member Data Documentation

◆ branch

template<class Tptcl , class Tbinary >
int COMM::BinaryTree< Tptcl, Tbinary >::branch

binary tree level, start from zero for root tree. Then each subtree increase level by one.

◆ level

template<class Tptcl , class Tbinary >
int COMM::BinaryTree< Tptcl, Tbinary >::level

member pointer


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