Skip to content

quadtree_children

quadtree_children(CH)

"Leaf nodes of a quadtree

Builds a list of indeces to the child cells of the quadtree

Parameters:

Name Type Description Default
CH numpy int array

Matrix of child indeces (-1 if leaf node)

required

Returns:

Name Type Description
child_indeces list

Indeces into CH and A of leaf node cells

See Also

initialize_quadtree, quadtree_boundary.

Examples:

# Create a random point cloud
P = 2*np.random.rand(100,2) - 1
# Initialize the quadtree
C,W,CH,PAR,D,A = gpytoolbox.initialize_quadtree(P,graded=True,max_depth=8)
# Get the children
children = gpytoolbox.quadtree_children(CH)
Source code in src/gpytoolbox/quadtree_children.py
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def quadtree_children(CH):
    """"Leaf nodes of a quadtree

    Builds a list of indeces to the child cells of the quadtree

    Parameters
    ----------
    CH : numpy int array
        Matrix of child indeces (-1 if leaf node)

    Returns
    -------
    child_indeces : list
        Indeces into CH and A of leaf node cells

    See Also
    --------
    initialize_quadtree, quadtree_boundary.

    Examples
    --------
    ```python
    # Create a random point cloud
    P = 2*np.random.rand(100,2) - 1
    # Initialize the quadtree
    C,W,CH,PAR,D,A = gpytoolbox.initialize_quadtree(P,graded=True,max_depth=8)
    # Get the children
    children = gpytoolbox.quadtree_children(CH)
    ```  
    """
    # Builds a list of indeces to the child cells of the quadtree
    #
    # Inputs:
    #   CH #nodes by 4 matrix of child indeces (-1 if leaf node)
    #
    # Outputs:
    #   child_indeces list of child indeces

    return (CH[:,0]<0).nonzero()[0]