@@ -62,9 +62,9 @@ cdef inline int min(int a, int b) noexcept:
6262 else :
6363 return a
6464
65- # # NOTE - Since most of the functions are used from within the module, cdef'd
66- # # functions come without an underscore, and the def'd equivalents, which are
67- # # essentially only for doctesting and debugging, have underscores.
65+ # NOTE - Since most of the functions are used from within the module, cdef'd
66+ # functions come without an underscore, and the def'd equivalents, which are
67+ # essentially only for doctesting and debugging, have underscores.
6868
6969cdef int * hamming_weights() noexcept:
7070 cdef int * ham_wts
@@ -1279,25 +1279,34 @@ cdef class OrbitPartition:
12791279 nwords = (1 << nrows)
12801280 self .nwords = nwords
12811281 self .ncols = ncols
1282- self .wd_parent = < int * > sig_malloc( nwords * sizeof(int ) )
1283- self .wd_rank = < int * > sig_malloc( nwords * sizeof(int ) )
1284- self .wd_min_cell_rep = < int * > sig_malloc( nwords * sizeof(int ) )
1285- self .wd_size = < int * > sig_malloc( nwords * sizeof(int ) )
1286- self .col_parent = < int * > sig_malloc( ncols * sizeof(int ) )
1287- self .col_rank = < int * > sig_malloc( ncols * sizeof(int ) )
1288- self .col_min_cell_rep = < int * > sig_malloc( ncols * sizeof(int ) )
1289- self .col_size = < int * > sig_malloc( ncols * sizeof(int ) )
1290- if self .wd_parent is NULL or self .wd_rank is NULL or self .wd_min_cell_rep is NULL \
1291- or self .wd_size is NULL or self .col_parent is NULL or self .col_rank is NULL \
1292- or self .col_min_cell_rep is NULL or self .col_size is NULL :
1293- if self .wd_parent is not NULL : sig_free(self .wd_parent)
1294- if self .wd_rank is not NULL : sig_free(self .wd_rank)
1295- if self .wd_min_cell_rep is not NULL : sig_free(self .wd_min_cell_rep)
1296- if self .wd_size is not NULL : sig_free(self .wd_size)
1297- if self .col_parent is not NULL : sig_free(self .col_parent)
1298- if self .col_rank is not NULL : sig_free(self .col_rank)
1299- if self .col_min_cell_rep is not NULL : sig_free(self .col_min_cell_rep)
1300- if self .col_size is not NULL : sig_free(self .col_size)
1282+ self .wd_parent = < int * > sig_malloc(nwords * sizeof(int ))
1283+ self .wd_rank = < int * > sig_malloc(nwords * sizeof(int ))
1284+ self .wd_min_cell_rep = < int * > sig_malloc(nwords * sizeof(int ))
1285+ self .wd_size = < int * > sig_malloc(nwords * sizeof(int ))
1286+ self .col_parent = < int * > sig_malloc(ncols * sizeof(int ))
1287+ self .col_rank = < int * > sig_malloc(ncols * sizeof(int ))
1288+ self .col_min_cell_rep = < int * > sig_malloc(ncols * sizeof(int ))
1289+ self .col_size = < int * > sig_malloc(ncols * sizeof(int ))
1290+ if (self .wd_parent is NULL or self .wd_rank is NULL
1291+ or self .wd_min_cell_rep is NULL or self .wd_size is NULL
1292+ or self .col_parent is NULL or self .col_rank is NULL
1293+ or self .col_min_cell_rep is NULL or self .col_size is NULL ):
1294+ if self .wd_parent is not NULL :
1295+ sig_free(self .wd_parent)
1296+ if self .wd_rank is not NULL :
1297+ sig_free(self .wd_rank)
1298+ if self .wd_min_cell_rep is not NULL :
1299+ sig_free(self .wd_min_cell_rep)
1300+ if self .wd_size is not NULL :
1301+ sig_free(self .wd_size)
1302+ if self .col_parent is not NULL :
1303+ sig_free(self .col_parent)
1304+ if self .col_rank is not NULL :
1305+ sig_free(self .col_rank)
1306+ if self .col_min_cell_rep is not NULL :
1307+ sig_free(self .col_min_cell_rep)
1308+ if self .col_size is not NULL :
1309+ sig_free(self .col_size)
13011310 raise MemoryError (" Memory." )
13021311 for word from 0 <= word < nwords:
13031312 self .wd_parent[word] = word
@@ -1605,33 +1614,43 @@ cdef class PartitionStack:
16051614 self .flag = (1 << (self .radix- 1 ))
16061615
16071616 # data
1608- self .wd_ents = < int * > sig_malloc( self .nwords * sizeof_int )
1609- self .wd_lvls = < int * > sig_malloc( self .nwords * sizeof_int )
1610- self .col_ents = < int * > sig_malloc( self .ncols * sizeof_int )
1611- self .col_lvls = < int * > sig_malloc( self .ncols * sizeof_int )
1617+ self .wd_ents = < int * > sig_malloc(self .nwords * sizeof_int)
1618+ self .wd_lvls = < int * > sig_malloc(self .nwords * sizeof_int)
1619+ self .col_ents = < int * > sig_malloc(self .ncols * sizeof_int)
1620+ self .col_lvls = < int * > sig_malloc(self .ncols * sizeof_int)
16121621
16131622 # scratch space
1614- self .col_degs = < int * > sig_malloc( self .ncols * sizeof_int )
1623+ self .col_degs = < int * > sig_malloc( self .ncols * sizeof_int )
16151624 self .col_counts = < int * > sig_malloc( self .nwords * sizeof_int )
16161625 self .col_output = < int * > sig_malloc( self .ncols * sizeof_int )
1617- self .wd_degs = < int * > sig_malloc( self .nwords * sizeof_int )
1618- self .wd_counts = < int * > sig_malloc( (self .ncols+ 1 ) * sizeof_int )
1619- self .wd_output = < int * > sig_malloc( self .nwords * sizeof_int )
1626+ self .wd_degs = < int * > sig_malloc( self .nwords * sizeof_int )
1627+ self .wd_counts = < int * > sig_malloc( (self .ncols+ 1 ) * sizeof_int )
1628+ self .wd_output = < int * > sig_malloc( self .nwords * sizeof_int )
16201629
16211630 if self .wd_ents is NULL or self .wd_lvls is NULL or self .col_ents is NULL \
16221631 or self .col_lvls is NULL or self .col_degs is NULL or self .col_counts is NULL \
16231632 or self .col_output is NULL or self .wd_degs is NULL or self .wd_counts is NULL \
16241633 or self .wd_output is NULL :
1625- if self .wd_ents is not NULL : sig_free(self .wd_ents)
1626- if self .wd_lvls is not NULL : sig_free(self .wd_lvls)
1627- if self .col_ents is not NULL : sig_free(self .col_ents)
1628- if self .col_lvls is not NULL : sig_free(self .col_lvls)
1629- if self .col_degs is not NULL : sig_free(self .col_degs)
1630- if self .col_counts is not NULL : sig_free(self .col_counts)
1631- if self .col_output is not NULL : sig_free(self .col_output)
1632- if self .wd_degs is not NULL : sig_free(self .wd_degs)
1633- if self .wd_counts is not NULL : sig_free(self .wd_counts)
1634- if self .wd_output is not NULL : sig_free(self .wd_output)
1634+ if self .wd_ents is not NULL :
1635+ sig_free(self .wd_ents)
1636+ if self .wd_lvls is not NULL :
1637+ sig_free(self .wd_lvls)
1638+ if self .col_ents is not NULL :
1639+ sig_free(self .col_ents)
1640+ if self .col_lvls is not NULL :
1641+ sig_free(self .col_lvls)
1642+ if self .col_degs is not NULL :
1643+ sig_free(self .col_degs)
1644+ if self .col_counts is not NULL :
1645+ sig_free(self .col_counts)
1646+ if self .col_output is not NULL :
1647+ sig_free(self .col_output)
1648+ if self .wd_degs is not NULL :
1649+ sig_free(self .wd_degs)
1650+ if self .wd_counts is not NULL :
1651+ sig_free(self .wd_counts)
1652+ if self .wd_output is not NULL :
1653+ sig_free(self .wd_output)
16351654 raise MemoryError (" Memory." )
16361655
16371656 nwords = self .nwords
@@ -3073,40 +3092,54 @@ cdef class BinaryCodeClassifier:
30733092 self .alpha_size = self .w_gamma_size + self .radix
30743093 self .Phi_size = self .w_gamma_size/ self .radix + 1
30753094
3076- self .w_gamma = < int * > sig_malloc( self .w_gamma_size * sizeof(int ) )
3077- self .alpha = < int * > sig_malloc( self .alpha_size * sizeof(int ) )
3078- self .Phi = < unsigned int * > sig_malloc( self .Phi_size * (self .L+ 1 ) * sizeof(unsigned int ) )
3079- self .Omega = < unsigned int * > sig_malloc( self .Phi_size * self .L * sizeof(unsigned int ) )
3080- self .W = < unsigned int * > sig_malloc( self .Phi_size * self .radix * 2 * sizeof(unsigned int ) )
3095+ self .w_gamma = < int * > sig_malloc( self .w_gamma_size * sizeof(int ) )
3096+ self .alpha = < int * > sig_malloc( self .alpha_size * sizeof(int ) )
3097+ self .Phi = < unsigned int * > sig_malloc( self .Phi_size * (self .L+ 1 ) * sizeof(unsigned int ) )
3098+ self .Omega = < unsigned int * > sig_malloc( self .Phi_size * self .L * sizeof(unsigned int ) )
3099+ self .W = < unsigned int * > sig_malloc( self .Phi_size * self .radix * 2 * sizeof(unsigned int ) )
30813100
3082- self .base = < int * > sig_malloc( self .radix * sizeof(int ) )
3101+ self .base = < int * > sig_malloc( self .radix * sizeof(int ) )
30833102 self .aut_gp_gens = < int * > sig_malloc( self .aut_gens_size * sizeof(int ) )
3084- self .c_gamma = < int * > sig_malloc( self .radix * sizeof(int ) )
3085- self .labeling = < int * > sig_malloc( self .radix * 3 * sizeof(int ) )
3086- self .Lambda1 = < int * > sig_malloc( self .radix * 2 * sizeof(int ) )
3087- self .Lambda2 = < int * > sig_malloc( self .radix * 2 * sizeof(int ) )
3088- self .Lambda3 = < int * > sig_malloc( self .radix * 2 * sizeof(int ) )
3089- self .v = < int * > sig_malloc( self .radix * 2 * sizeof(int ) )
3090- self .e = < int * > sig_malloc( self .radix * 2 * sizeof(int ) )
3103+ self .c_gamma = < int * > sig_malloc( self .radix * sizeof(int ) )
3104+ self .labeling = < int * > sig_malloc( self .radix * 3 * sizeof(int ) )
3105+ self .Lambda1 = < int * > sig_malloc( self .radix * 2 * sizeof(int ) )
3106+ self .Lambda2 = < int * > sig_malloc( self .radix * 2 * sizeof(int ) )
3107+ self .Lambda3 = < int * > sig_malloc( self .radix * 2 * sizeof(int ) )
3108+ self .v = < int * > sig_malloc( self .radix * 2 * sizeof(int ) )
3109+ self .e = < int * > sig_malloc( self .radix * 2 * sizeof(int ) )
30913110
30923111 if self .Phi is NULL or self .Omega is NULL or self .W is NULL or self .Lambda1 is NULL \
30933112 or self .Lambda2 is NULL or self .Lambda3 is NULL or self .w_gamma is NULL \
30943113 or self .c_gamma is NULL or self .alpha is NULL or self .v is NULL or self .e is NULL \
30953114 or self .aut_gp_gens is NULL or self .labeling is NULL or self .base is NULL :
3096- if self .Phi is not NULL : sig_free(self .Phi)
3097- if self .Omega is not NULL : sig_free(self .Omega)
3098- if self .W is not NULL : sig_free(self .W)
3099- if self .Lambda1 is not NULL : sig_free(self .Lambda1)
3100- if self .Lambda2 is not NULL : sig_free(self .Lambda2)
3101- if self .Lambda3 is not NULL : sig_free(self .Lambda3)
3102- if self .w_gamma is not NULL : sig_free(self .w_gamma)
3103- if self .c_gamma is not NULL : sig_free(self .c_gamma)
3104- if self .alpha is not NULL : sig_free(self .alpha)
3105- if self .v is not NULL : sig_free(self .v)
3106- if self .e is not NULL : sig_free(self .e)
3107- if self .aut_gp_gens is not NULL : sig_free(self .aut_gp_gens)
3108- if self .labeling is not NULL : sig_free(self .labeling)
3109- if self .base is not NULL : sig_free(self .base)
3115+ if self .Phi is not NULL :
3116+ sig_free(self .Phi)
3117+ if self .Omega is not NULL :
3118+ sig_free(self .Omega)
3119+ if self .W is not NULL :
3120+ sig_free(self .W)
3121+ if self .Lambda1 is not NULL :
3122+ sig_free(self .Lambda1)
3123+ if self .Lambda2 is not NULL :
3124+ sig_free(self .Lambda2)
3125+ if self .Lambda3 is not NULL :
3126+ sig_free(self .Lambda3)
3127+ if self .w_gamma is not NULL :
3128+ sig_free(self .w_gamma)
3129+ if self .c_gamma is not NULL :
3130+ sig_free(self .c_gamma)
3131+ if self .alpha is not NULL :
3132+ sig_free(self .alpha)
3133+ if self .v is not NULL :
3134+ sig_free(self .v)
3135+ if self .e is not NULL :
3136+ sig_free(self .e)
3137+ if self .aut_gp_gens is not NULL :
3138+ sig_free(self .aut_gp_gens)
3139+ if self .labeling is not NULL :
3140+ sig_free(self .labeling)
3141+ if self .base is not NULL :
3142+ sig_free(self .base)
31103143 raise MemoryError (" Memory." )
31113144
31123145 def __dealloc__ (self ):
@@ -3371,27 +3404,32 @@ cdef class BinaryCodeClassifier:
33713404 self .w_gamma_size *= 2
33723405 self .alpha_size = self .w_gamma_size + self .radix
33733406 self .Phi_size = self .w_gamma_size/ self .radix + 1
3374- self .w_gamma = < int * > sig_realloc(self .w_gamma, self .w_gamma_size * sizeof(int ) )
3375- self .alpha = < int * > sig_realloc(self .alpha, self .alpha_size * sizeof(int ) )
3376- self .Phi = < unsigned int * > sig_realloc(self .Phi, self .Phi_size * self .L * sizeof(int ) )
3377- self .Omega = < unsigned int * > sig_realloc(self .Omega, self .Phi_size * self .L * sizeof(int ) )
3378- self .W = < unsigned int * > sig_realloc(self .W, self .Phi_size * self .radix * 2 * sizeof(int ) )
3407+ self .w_gamma = < int * > sig_realloc(self .w_gamma, self .w_gamma_size * sizeof(int ))
3408+ self .alpha = < int * > sig_realloc(self .alpha, self .alpha_size * sizeof(int ))
3409+ self .Phi = < unsigned int * > sig_realloc(self .Phi, self .Phi_size * self .L * sizeof(int ))
3410+ self .Omega = < unsigned int * > sig_realloc(self .Omega, self .Phi_size * self .L * sizeof(int ))
3411+ self .W = < unsigned int * > sig_realloc(self .W, self .Phi_size * self .radix * 2 * sizeof(int ))
33793412 if self .w_gamma is NULL or self .alpha is NULL or self .Phi is NULL or self .Omega is NULL or self .W is NULL :
3380- if self .w_gamma is not NULL : sig_free(self .w_gamma)
3381- if self .alpha is not NULL : sig_free(self .alpha)
3382- if self .Phi is not NULL : sig_free(self .Phi)
3383- if self .Omega is not NULL : sig_free(self .Omega)
3384- if self .W is not NULL : sig_free(self .W)
3413+ if self .w_gamma is not NULL :
3414+ sig_free(self .w_gamma)
3415+ if self .alpha is not NULL :
3416+ sig_free(self .alpha)
3417+ if self .Phi is not NULL :
3418+ sig_free(self .Phi)
3419+ if self .Omega is not NULL :
3420+ sig_free(self .Omega)
3421+ if self .W is not NULL :
3422+ sig_free(self .W)
33853423 raise MemoryError (" Memory." )
33863424 for i from 0 <= i < self .Phi_size * self .L:
33873425 self .Omega[i] = 0
33883426 word_gamma = self .w_gamma
33893427 alpha = self .alpha # think of alpha as of length exactly nwords + ncols
3390- Phi = self .Phi
3428+ Phi = self .Phi
33913429 Omega = self .Omega
3392- W = self .W
3393- e = self .e
3394- nu = PartitionStack(nrows, ncols)
3430+ W = self .W
3431+ e = self .e
3432+ nu = PartitionStack(nrows, ncols)
33953433 Theta = OrbitPartition(nrows, ncols)
33963434
33973435 # trivial case
0 commit comments