contractSR

MainPage

Description: This method implements the subtractive rule for node contraction.

Constructor signature: MaxTreeAlpha.contractSR(to_keep)

Input:
  • to_keep, 1d-array bool. Array indicating which nodes should be preserved.

Output

C++ Aux Function

OK
OK

--------------------------------------------------------------------------------
    Fri Jul 22 12:39:31 2016
--------------------------------------------------------------------------------
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Found SWIG: /usr/bin/swig2.0 (found version "2.0.4")
-- Configuring done
-- Generating done
-- Build files have been written to: /net/awproxy<pkg_dir>/_build/_max_tree__contract_sr
[ 25%] Swig source
Scanning dependencies of target __max_tree__contract_sr
[ 50%] Building CXX object CMakeFiles/__max_tree__contract_sr.dir/_max_tree__contract_srPYTHON_wrap.o
[ 75%] Building CXX object CMakeFiles/__max_tree__contract_sr.dir/_max_tree__contract_sr.o
[100%] Building CXX object CMakeFiles/__max_tree__contract_sr.dir<pkg_dir>/_build/simple_arrays.o
Linking CXX shared module __max_tree__contract_sr.so
[100%] Built target __max_tree__contract_sr

Python Implementation

 1 def contractSR(self, to_keep):
 2     """
 3     Subtractive rule for contracting any max-tree nodes marked as False in 'to_keep'.
 4     This is a generic node removal procedure. Note that a node in the max-tree
 5     can represent many level components.
 6     """
 7 
 8     to_keep[0] = True # The root can never be removed
 9     N = self.node_array.shape[1]
10     lut = np.arange(N, dtype = np.int32)
11     self.contract_sr_aux(to_keep.astype(np.int32),lut,self.node_array[0,:])
12     self.compact(~to_keep,lut)
13     self.node_array[1,:] = 0
14     self.update_nchild_aux(self.node_array[0,:],self.node_array[1,:])
15     return self

Example