@@ -586,17 +586,17 @@ def assmus_mattson_designs(self, t, mode=None):
586
586
if mode == "verbose" :
587
587
for w in nonzerowts :
588
588
print ("The weight w={} codewords of C* form a t-(v,k,lambda) design, where\n \
589
- t={}, v={}, k={}, lambda={}. \n There are {} block of this design." .format (\
590
- w ,t ,n ,w ,wts [w ]* binomial (w ,t )// binomial (n ,t ),wts [w ]))
589
+ t={}, v={}, k={}, lambda={}. \n There are {} block of this design." .format (
590
+ w ,t ,n ,w ,wts [w ]* binomial (w ,t )// binomial (n ,t ),wts [w ]))
591
591
wtsp = Cp .weight_distribution ()
592
592
dp = min ([i for i in range (1 ,len (wtsp )) if wtsp [i ]!= 0 ])
593
593
nonzerowtsp = [i for i in range (len (wtsp )) if wtsp [i ]!= 0 and i <= n - t and i >= dp ]
594
594
s = len ([i for i in range (1 ,n ) if wtsp [i ]!= 0 and i <= n - t and i > 0 ])
595
595
if mode == "verbose" :
596
596
for w in nonzerowtsp :
597
597
print ("The weight w={} codewords of C* form a t-(v,k,lambda) design, where\n \
598
- t={}, v={}, k={}, lambda={}. \n There are {} block of this design." .format (\
599
- w ,t ,n ,w ,wts [w ]* binomial (w ,t )// binomial (n ,t ),wts [w ]))
598
+ t={}, v={}, k={}, lambda={}. \n There are {} block of this design." .format (
599
+ w ,t ,n ,w ,wts [w ]* binomial (w ,t )// binomial (n ,t ),wts [w ]))
600
600
if s <= d - t :
601
601
des = [[t ,(n ,w ,wts [w ]* binomial (w ,t )// binomial (n ,t ))] for w in nonzerowts ]
602
602
ans = ans + ["weights from C: " ,nonzerowts ,"designs from C: " ,des ]
@@ -1370,7 +1370,7 @@ def minimum_distance(self, algorithm=None):
1370
1370
# This is done only if algorithm is None.
1371
1371
if algorithm not in (None , "gap" , "guava" ):
1372
1372
raise ValueError ("The algorithm argument must be one of None, "
1373
- "'gap' or 'guava'; got '{0}'" .format (algorithm ))
1373
+ "'gap' or 'guava'; got '{0}'" .format (algorithm ))
1374
1374
1375
1375
F = self .base_ring ()
1376
1376
q = F .order ()
@@ -1380,14 +1380,14 @@ def minimum_distance(self, algorithm=None):
1380
1380
"of size at most 256" )
1381
1381
1382
1382
G = self .generator_matrix ()
1383
- if (q == 2 or q == 3 ) and algorithm == "guava" :
1383
+ if (q == 2 or q == 3 ) and algorithm == "guava" :
1384
1384
gap .load_package ("guava" )
1385
1385
C = gap (G ).GeneratorMatCode (gap (F ))
1386
1386
d = C .MinimumWeight ()
1387
1387
return ZZ (d )
1388
1388
return self ._minimum_weight_codeword (algorithm ).hamming_weight ()
1389
1389
1390
- def _minimum_weight_codeword (self , algorithm = None ):
1390
+ def _minimum_weight_codeword (self , algorithm = None ):
1391
1391
r"""
1392
1392
Return a minimum weight codeword of ``self``.
1393
1393
@@ -1431,7 +1431,7 @@ def _minimum_weight_codeword(self, algorithm = None):
1431
1431
1432
1432
current_randstate ().set_seed_gap ()
1433
1433
1434
- if algorithm == "guava" :
1434
+ if algorithm == "guava" :
1435
1435
GapPackage ("guava" , spkg = "gap_packages" ).require ()
1436
1436
gap .load_package ("guava" )
1437
1437
from sage .interfaces .gap import gfq_gap_to_sage
@@ -1464,34 +1464,41 @@ def _minimum_weight_codeword(self, algorithm = None):
1464
1464
1465
1465
def module_composition_factors (self , gp ):
1466
1466
r"""
1467
- Prints the GAP record of the Meataxe composition factors module in
1468
- Meataxe notation. This uses GAP but not Guava.
1467
+ Print the GAP record of the Meataxe composition factors module.
1468
+
1469
+ This is displayed in Meataxe notation.
1470
+
1471
+ This uses GAP but not Guava.
1469
1472
1470
1473
EXAMPLES::
1471
1474
1472
1475
sage: MS = MatrixSpace(GF(2),4,8)
1473
1476
sage: G = MS([[1,0,0,0,1,1,1,0],[0,1,1,1,0,0,0,0],[0,0,0,0,0,0,0,1],[0,0,0,0,0,1,0,0]])
1474
1477
sage: C = LinearCode(G)
1475
1478
sage: gp = C.permutation_automorphism_group()
1476
-
1477
- Now type "C.module_composition_factors(gp)" to get the record printed.
1479
+ sage: C.module_composition_factors(gp)
1480
+ [ rec(
1481
+ IsIrreducible := true,
1482
+ IsOverFiniteField := true,
1483
+ ...) ]
1478
1484
"""
1485
+ from sage .libs .gap .libgap import libgap
1479
1486
F = self .base_ring ()
1480
- q = F .order ()
1481
1487
gens = gp .gens ()
1482
1488
G = self .generator_matrix ()
1483
1489
n = len (G .columns ())
1484
- MS = MatrixSpace (F ,n , n )
1485
- mats = [] # initializing list of mats by which the gens act on self
1490
+ MS = MatrixSpace (F , n , n )
1491
+ mats = [] # initializing list of mats by which the gens act on self
1486
1492
Fn = VectorSpace (F , n )
1487
- W = Fn .subspace_with_basis (G .rows ()) # this is self
1493
+ W = Fn .subspace_with_basis (G .rows ()) # this is self
1488
1494
for g in gens :
1489
1495
p = MS (g .matrix ())
1490
- m = [W .coordinate_vector (r * p ) for r in G .rows ()]
1496
+ m = [W .coordinate_vector (r * p ) for r in G .rows ()]
1491
1497
mats .append (m )
1492
- mats_str = str (gap ([[list (r ) for r in m ] for m in mats ]))
1493
- gap .eval ("M:=GModuleByMats(" + mats_str + ", GF(" + str (q )+ "))" )
1494
- print (gap ("MTX.CompositionFactors( M )" ))
1498
+ mats_gap = libgap (mats )
1499
+ M_gap = mats_gap .GModuleByMats (F )
1500
+ compo = libgap .function_factory ('MTX.CompositionFactors' )
1501
+ print (compo (M_gap ))
1495
1502
1496
1503
def permutation_automorphism_group (self , algorithm = "partition" ):
1497
1504
r"""
@@ -1619,7 +1626,7 @@ def permutation_automorphism_group(self, algorithm="partition"):
1619
1626
gap .eval ("matCwt:=List(Cwt,c->VectorCodeword(c))" ) # for each i until stop = 1)
1620
1627
if gap ("Length(matCwt)" ) > 0 :
1621
1628
A = gap ("MatrixAutomorphisms(matCwt)" )
1622
- G2 = gap ("Intersection2(%s,%s)" % (str (A ).replace ("\n " ,"" ),str (Gp ).replace ("\n " ,"" ))) # bottleneck 3
1629
+ G2 = gap ("Intersection2(%s,%s)" % (str (A ).replace ("\n " ,"" ),str (Gp ).replace ("\n " ,"" ))) # bottleneck 3
1623
1630
Gp = G2
1624
1631
if Gp .Size ()== 1 :
1625
1632
return PermutationGroup ([()])
@@ -1830,7 +1837,7 @@ def weight_distribution(self, algorithm=None):
1830
1837
q = self .base_ring ().order ()
1831
1838
z = 'Z(%s)*%s' % (q , [0 ]* self .length ()) # GAP zero vector as a string
1832
1839
_ = gap .eval ("w:=DistancesDistributionMatFFEVecFFE(" + Gmat + ", GF(" + str (q )+ ")," + z + ")" )
1833
- v = [eval (gap .eval ("w[" + str (i )+ "]" )) for i in range (1 ,self .length ()+ 2 )] # because GAP returns vectors in compressed form
1840
+ v = [eval (gap .eval ("w[" + str (i )+ "]" )) for i in range (1 ,self .length ()+ 2 )] # because GAP returns vectors in compressed form
1834
1841
return v
1835
1842
elif algorithm == "binary" :
1836
1843
from sage .coding .binary_code import weight_dist
@@ -2144,7 +2151,7 @@ def e(i):
2144
2151
return G
2145
2152
2146
2153
2147
- ############################ linear codes python class ########################
2154
+ # ########################### linear codes python class ########################
2148
2155
2149
2156
class LinearCode (AbstractLinearCode ):
2150
2157
r"""
@@ -2773,7 +2780,7 @@ def _build_lookup_table(self):
2773
2780
# distance 1 gracefully
2774
2781
zero_syndrome = vector (F ,[F .zero ()]* (n - k ))
2775
2782
zero_syndrome .set_immutable ()
2776
- lookup = { zero_syndrome : vector (F ,[F .zero ()]* n ) }
2783
+ lookup = {zero_syndrome : vector (F ,[F .zero ()]* n )}
2777
2784
error_position_tables = [cartesian_product ([l ]* i ) for i in range (1 , t + 1 )]
2778
2785
first_collision = True
2779
2786
#Filling the lookup table
@@ -2814,15 +2821,14 @@ def _build_lookup_table(self):
2814
2821
# Update decoder types depending on whether we are decoding beyond d/2
2815
2822
if self ._code_minimum_distance :
2816
2823
if self ._maximum_error_weight == (self ._code_minimum_distance - 1 )// 2 :
2817
- self ._decoder_type .update ({"minimum-distance" ,"always-succeed" })
2824
+ self ._decoder_type .update ({"minimum-distance" , "always-succeed" })
2818
2825
else :
2819
2826
# then t > (d-1)/2
2820
2827
self ._decoder_type .add ("might-error" )
2821
2828
else :
2822
2829
self ._decoder_type .add ("always-succeed" )
2823
2830
return lookup
2824
2831
2825
-
2826
2832
def decode_to_code (self , r ):
2827
2833
r"""
2828
2834
Corrects the errors in ``word`` and returns a codeword.
0 commit comments