From b995ca4c081a86143fd52d8e9feb5cde154929ab Mon Sep 17 00:00:00 2001 From: Ioannis Filippidis Date: Mon, 19 Sep 2022 19:55:03 +0200 Subject: [PATCH] REF: abbreviate `DdNode *` as `DdRef` --- dd/cudd.pyx | 32 ++++++++++++++--------------- dd/cudd_zdd.pyx | 54 ++++++++++++++++++++++++------------------------- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/dd/cudd.pyx b/dd/cudd.pyx index 4f3f990b..8e747804 100644 --- a/dd/cudd.pyx +++ b/dd/cudd.pyx @@ -1331,13 +1331,13 @@ cdef class BDD: raise ValueError( '`f.manager != self.manager`') r: DdRef - cdef DdNode **x + cdef DdRef *x g: Function n_cudd_vars = self._number_of_cudd_vars() if n_cudd_vars <= 0: raise AssertionError(n_cudd_vars) - x = PyMem_Malloc( - n_cudd_vars *sizeof(DdNode *)) + x = PyMem_Malloc( + n_cudd_vars *sizeof(DdRef)) for var in self.vars: j = self._index_of_var[var] if var in var_sub: @@ -1460,10 +1460,10 @@ cdef class BDD: # # call swapping n = len(dvars) - cdef DdNode **x = PyMem_Malloc( - n * sizeof(DdNode *)) - cdef DdNode **y = PyMem_Malloc( - n * sizeof(DdNode *)) + cdef DdRef *x = PyMem_Malloc( + n * sizeof(DdRef)) + cdef DdRef *y = PyMem_Malloc( + n * sizeof(DdRef)) r: DdRef cdef DdManager *mgr = u.manager f: Function @@ -1862,7 +1862,7 @@ cdef class BDD: # invert `Function.__int__` if 2 <= i: i -= 2 - u = i + u = i return wrap(self, u) cpdef Function cube( @@ -1898,9 +1898,9 @@ cdef class BDD: n = len(dvars) # make cube cube: DdRef - cdef DdNode **x - x = PyMem_Malloc( - n * sizeof(DdNode *)) + cdef DdRef *x + x = PyMem_Malloc( + n * sizeof(DdRef)) for i, var in enumerate(dvars): f = self.var(var) x[i] = f.node @@ -1922,7 +1922,7 @@ cdef class BDD: n_cudd_vars = self._number_of_cudd_vars() cdef int *x x = PyMem_Malloc( - n_cudd_vars * sizeof(DdNode *)) + n_cudd_vars * sizeof(DdRef)) try: Cudd_BddToCubeArray( self.manager, f.node, x) @@ -2465,11 +2465,11 @@ cpdef int count_nodes( Sharing is taken into account. """ - cdef DdNode **x + cdef DdRef *x f: Function n = len(functions) - x = PyMem_Malloc( - n * sizeof(DdNode *)) + x = PyMem_Malloc( + n * sizeof(DdRef)) for i, f in enumerate(functions): x[i] = f.node try: @@ -2999,7 +2999,7 @@ cdef class Function: self ) -> int: # inverse is `BDD._add_int` - if sizeof(stdint.uintptr_t) != sizeof(DdNode *): + if sizeof(stdint.uintptr_t) != sizeof(DdRef): raise AssertionError( 'mismatch of sizes') i = self.node diff --git a/dd/cudd_zdd.pyx b/dd/cudd_zdd.pyx index 32be0b3f..1e673b63 100644 --- a/dd/cudd_zdd.pyx +++ b/dd/cudd_zdd.pyx @@ -1261,7 +1261,7 @@ cdef class ZDD: r: DdRef bdd = u.bdd u_ = bdd.copy(u, self) - r = u_.node + r = u_.node r = Cudd_zddPortFromBdd(self.manager, r) return wrap(self, r) @@ -2039,7 +2039,7 @@ cdef class ZDD: # invert `Function.__int__` if 2 <= i: i -= 2 - u = i + u = i return wrap(self, u) cpdef Function cube( @@ -2625,7 +2625,7 @@ cdef class ZDD: raise ValueError('`f.manager != self.manager`') n = self._number_of_cudd_vars() cdef int *x - x = PyMem_Malloc(n * sizeof(DdNode *)) + x = PyMem_Malloc(n * sizeof(DdRef)) try: Cudd_BddToCubeArray(self.manager, f.node, x) d = _cube_array_to_dict(x, self._index_of_var) @@ -2873,7 +2873,7 @@ cdef class Function: self ) -> int: # inverse is `ZDD._add_int` - if sizeof(stdint.uintptr_t) != sizeof(DdNode *): + if sizeof(stdint.uintptr_t) != sizeof(DdRef): raise RuntimeError( 'expected equal pointer sizes') i = self.node @@ -3542,7 +3542,7 @@ cpdef Function _c_forall( # changes to the function `_exist_root` # are copied here -cdef DdNode *_forall_root( +cdef DdRef _forall_root( DdManager *mgr, u: DdRef, @@ -3565,7 +3565,7 @@ cdef DdNode *_forall_root( return r -cdef DdNode *_forall_cache_id( +cdef DdRef _forall_cache_id( DdManager *mgr, u: DdRef, @@ -3584,7 +3584,7 @@ cdef DdNode *_forall_cache_id( # changes to the function `_exist` # are copied here -cdef DdNode *_forall( +cdef DdRef _forall( DdManager *mgr, level: _c_level, @@ -3681,7 +3681,7 @@ cpdef Function _c_exist( return wrap(u.bdd, r) -cdef DdNode *_exist_root( +cdef DdRef _exist_root( DdManager *mgr, u: DdRef, @@ -3704,7 +3704,7 @@ cdef DdNode *_exist_root( return r -cdef DdNode *_exist_cache_id( +cdef DdRef _exist_cache_id( DdManager *mgr, u: DdRef, @@ -3724,7 +3724,7 @@ cdef DdNode *_exist_cache_id( 'as cache key.') -cdef DdNode *_exist( +cdef DdRef _exist( DdManager *mgr, level: _c_level, @@ -3809,7 +3809,7 @@ cdef DdNode *_exist( return r -cdef DdNode *_find_or_add( +cdef DdRef _find_or_add( DdManager *mgr, index: _c_int, @@ -3866,7 +3866,7 @@ cpdef Function _c_disjoin( return wrap(u.bdd, r) -cdef DdNode *_disjoin_root( +cdef DdRef _disjoin_root( DdManager *mgr, u: DdRef, @@ -3900,7 +3900,7 @@ cdef DdNode *_disjoin_root( # in a way that passing `_disjoin_root()` # to the C function `cuddCacheLookup2Zdd()` # raises a Cython compilation error. -cdef DdNode *_disjoin_cache_id( +cdef DdRef _disjoin_cache_id( DdManager *mgr, u: DdRef, @@ -3924,7 +3924,7 @@ cdef DdNode *_disjoin_cache_id( # Those cases are due to reaching the point where # the tables need to be resized, and reordering # invoked. -cdef DdNode *_disjoin( +cdef DdRef _disjoin( DdManager *mgr, level: _c_level, @@ -4026,7 +4026,7 @@ cpdef Function _c_conjoin( return wrap(u.bdd, r) -cdef DdNode *_conjoin_root( +cdef DdRef _conjoin_root( DdManager *mgr, u: DdRef, @@ -4051,7 +4051,7 @@ cdef DdNode *_conjoin_root( # Similar to function `_disjoin_cache_id()`. # This function is used for the hash in cache. -cdef DdNode *_conjoin_cache_id( +cdef DdRef _conjoin_cache_id( DdManager *mgr, u: DdRef, @@ -4068,7 +4068,7 @@ cdef DdNode *_conjoin_cache_id( """ -cdef DdNode *_conjoin( +cdef DdRef _conjoin( DdManager *mgr, level: _c_level, @@ -4170,10 +4170,10 @@ cpdef Function _c_compose( contiguous = _utils.contiguous_levels( '_c_compose', zdd) raise AssertionError(f'{counts}\n{contiguous}') - # convert `dvars` to `DdNode **` - cdef DdNode **vector - vector = PyMem_Malloc( - n_cudd_vars * sizeof(DdNode *)) + # convert `dvars` to `DdRef *` + cdef DdRef *vector + vector = PyMem_Malloc( + n_cudd_vars * sizeof(DdRef)) for var in zdd.vars: i = zdd._index_of_var[var] if var in dvars: @@ -4203,11 +4203,11 @@ cpdef Function _c_compose( return wrap(u.bdd, r) -cdef DdNode *_compose_root( +cdef DdRef _compose_root( DdManager *mgr, u: DdRef, - DdNode **vector + DdRef *vector ) except NULL: """Root of recursive composition.""" if mgr is NULL: @@ -4236,7 +4236,7 @@ cdef DdNode *_compose_root( # cuddHashTableQuitZdd(table) for nd in table.values(): Cudd_RecursiveDerefZdd(mgr, - nd) + nd) if r is not NULL: cuddDeref(r) if r is NULL: @@ -4244,7 +4244,7 @@ cdef DdNode *_compose_root( return r -cdef DdNode *_compose( +cdef DdRef _compose( DdManager *mgr, level: _c_level, @@ -4253,7 +4253,7 @@ cdef DdNode *_compose( dict, u: DdRef, - DdNode **vector + DdRef *vector ) except? NULL: """Recursively compute composition. @@ -4280,7 +4280,7 @@ cdef DdNode *_compose( return r t = (u, level) if t in table: - return table[t] + return table[t] # r = cuddHashTableLookup1(table, u) # if r is not NULL: # return r