public void subDivide ( ) { MemoryWorkspace workspace = workspaceMode == WorkspaceMode . NONE ? new DummyWorkspace ( ) : Nd4j . getWorkspaceManager ( ) . getWorkspaceForCurrentThread ( workspaceConfigurationExternal , workspaceExternal ) ; try ( MemoryWorkspace ws = workspace . notifyScopeEntered ( ) ) { INDArray newCorner = Nd4j . create ( D ) ; INDArray newWidth = Nd4j . create ( D ) ; for ( int i = 0 ; i < numChildren ; i ++ ) { int div = 1 ; for ( int d = 0 ; d < D ; d ++ ) { newWidth . putScalar ( d , .5 * boundary . width ( d ) ) ; if ( ( i / div ) % 2 == 1 ) newCorner . putScalar ( d , boundary . corner ( d ) - .5 * boundary . width ( d ) ) ; else newCorner . putScalar ( d , boundary . corner ( d ) + .5 * boundary . width ( d ) ) ; div *= 2 ; } children [ i ] = new SpTree ( this , data , newCorner , newWidth , indices ) ; } // Move existing points to correct children for ( int i = 0 ; i < size ; i ++ ) { boolean success = false ; for ( int j = 0 ; j < this . numChildren ; j ++ ) if ( ! success ) success = children [ j ] . insert ( index [ i ] ) ; index [ i ] = - 1 ; } // Empty parent node size = 0 ; isLeaf = false ; } }
Subdivide the node in to 4 children