@@ -585,124 +585,22 @@ def BinaryGolayCode():
585
585
V = span(B, F)
586
586
return LinearCodeFromVectorSpace(V, d=7)
587
587
588
-
589
588
def CyclicCodeFromGeneratingPolynomial(n,g,ignore=True):
590
- r"""
591
- If g is a polynomial over GF(q) which divides `x^n-1` then
592
- this constructs the code "generated by g" (ie, the code associated
593
- with the principle ideal `gR` in the ring
594
- `R = GF(q)[x]/(x^n-1)` in the usual way).
595
-
596
- The option "ignore" says to ignore the condition that (a) the
597
- characteristic of the base field does not divide the length (the
598
- usual assumption in the theory of cyclic codes), and (b) `g`
599
- must divide `x^n-1`. If ignore=True, instead of returning
600
- an error, a code generated by `gcd(x^n-1,g)` is created.
601
-
602
- EXAMPLES::
603
-
604
- sage: P.<x> = PolynomialRing(GF(3),"x")
605
- sage: g = x-1
606
- sage: C = codes.CyclicCodeFromGeneratingPolynomial(4,g); C
607
- Linear code of length 4, dimension 3 over Finite Field of size 3
608
- sage: P.<x> = PolynomialRing(GF(4,"a"),"x")
609
- sage: g = x^3+1
610
- sage: C = codes.CyclicCodeFromGeneratingPolynomial(9,g); C
611
- Linear code of length 9, dimension 6 over Finite Field in a of size 2^2
612
- sage: P.<x> = PolynomialRing(GF(2),"x")
613
- sage: g = x^3+x+1
614
- sage: C = codes.CyclicCodeFromGeneratingPolynomial(7,g); C
615
- Linear code of length 7, dimension 4 over Finite Field of size 2
616
- sage: C.generator_matrix()
617
- [1 1 0 1 0 0 0]
618
- [0 1 1 0 1 0 0]
619
- [0 0 1 1 0 1 0]
620
- [0 0 0 1 1 0 1]
621
- sage: g = x+1
622
- sage: C = codes.CyclicCodeFromGeneratingPolynomial(4,g); C
623
- Linear code of length 4, dimension 3 over Finite Field of size 2
624
- sage: C.generator_matrix()
625
- [1 1 0 0]
626
- [0 1 1 0]
627
- [0 0 1 1]
628
-
629
- On the other hand, CyclicCodeFromPolynomial(4,x) will produce a
630
- ValueError including a traceback error message: "`x` must
631
- divide `x^4 - 1`". You will also get a ValueError if you
632
- type
633
-
634
- ::
635
-
636
- sage: P.<x> = PolynomialRing(GF(4,"a"),"x")
637
- sage: g = x^2+1
638
-
639
- followed by CyclicCodeFromGeneratingPolynomial(6,g). You will also
640
- get a ValueError if you type
641
-
642
- ::
643
-
644
- sage: P.<x> = PolynomialRing(GF(3),"x")
645
- sage: g = x^2-1
646
- sage: C = codes.CyclicCodeFromGeneratingPolynomial(5,g); C
647
- Linear code of length 5, dimension 4 over Finite Field of size 3
648
-
649
- followed by C = CyclicCodeFromGeneratingPolynomial(5,g,False), with
650
- a traceback message including "`x^2 + 2` must divide
651
- `x^5 - 1`".
652
- """
653
- P = g.parent()
654
- x = P.gen()
589
+ from sage.misc.superseded import deprecation
590
+ from sage.coding.cyclic_code import CyclicCode
591
+ deprecation(20100, "codes.CyclicCodeFromGeneratingPolynomial is now deprecated. Please use codes.CyclicCode instead.")
655
592
F = g.base_ring()
656
- p = F.characteristic()
657
- if not(ignore) and p.divides(n):
658
- raise ValueError('The characteristic %s must not divide %s'%(p,n))
659
- if not(ignore) and not(g.divides(x**n-1)):
660
- raise ValueError('%s must divide x^%s - 1'%(g,n))
661
- gn = GCD([g,x**n-1])
662
- d = gn.degree()
663
- coeffs = Sequence(gn.list())
664
- r1 = Sequence(coeffs+[0]*(n - d - 1))
665
- Sn = SymmetricGroup(n)
666
- s = Sn.gens()[0] # assumes 1st gen of S_n is (1,2,...,n)
667
- rows = [permutation_action(s**(-i),r1) for i in range(n-d)]
668
- MS = MatrixSpace(F,n-d,n)
669
- return LinearCode(MS(rows))
670
-
671
- CyclicCode = CyclicCodeFromGeneratingPolynomial
593
+ return CyclicCode(length = n, generator_pol = g, field = F)
672
594
673
595
def CyclicCodeFromCheckPolynomial(n,h,ignore=True):
674
- r"""
675
- If h is a polynomial over GF(q) which divides `x^n-1` then
676
- this constructs the code "generated by `g = (x^n-1)/h`"
677
- (ie, the code associated with the principle ideal `gR` in
678
- the ring `R = GF(q)[x]/(x^n-1)` in the usual way). The
679
- option "ignore" says to ignore the condition that the
680
- characteristic of the base field does not divide the length (the
681
- usual assumption in the theory of cyclic codes).
682
-
683
- EXAMPLES::
684
-
685
- sage: P.<x> = PolynomialRing(GF(3),"x")
686
- sage: C = codes.CyclicCodeFromCheckPolynomial(4,x + 1); C
687
- Linear code of length 4, dimension 1 over Finite Field of size 3
688
- sage: C = codes.CyclicCodeFromCheckPolynomial(4,x^3 + x^2 + x + 1); C
689
- Linear code of length 4, dimension 3 over Finite Field of size 3
690
- sage: C.generator_matrix()
691
- [2 1 0 0]
692
- [0 2 1 0]
693
- [0 0 2 1]
694
- """
596
+ from sage.misc.superseded import deprecation
597
+ from sage.coding.cyclic_code import CyclicCode
598
+ deprecation(20100, "codes.CyclicCodeFromCheckPolynomial is now deprecated. Please use codes.CyclicCode instead.")
695
599
P = h.parent()
696
600
x = P.gen()
697
- d = h.degree()
698
601
F = h.base_ring()
699
- p = F.characteristic()
700
- if not(ignore) and p.divides(n):
701
- raise ValueError('The characteristic %s must not divide %s'%(p,n))
702
- if not(h.divides(x**n-1)):
703
- raise ValueError('%s must divide x^%s - 1'%(h,n))
704
602
g = P((x**n-1)/h)
705
- return CyclicCodeFromGeneratingPolynomial(n,g )
603
+ return CyclicCode(length = n, generator_pol = g, field = F )
706
604
707
605
def DuadicCodeEvenPair(F,S1,S2):
708
606
r"""
0 commit comments