Ticket #3634: sage-3634-referee.patch
| File sage-3634-referee.patch, 2.0 kB (added by was, 5 months ago) |
|---|
-
a/sage/rings/finite_field_ntl_gf2e.pyx
old new 1113 1113 C.append(GF2_conv_to_long(GF2X_coeff(r,i))) 1114 1114 return self._parent.polynomial_ring(name)(C) 1115 1115 1116 def charpoly(self, var='x'): 1117 r""" 1118 Return the characteristic polynomial of self as a polynomial 1119 in var over the prime subfield. 1120 1121 INPUT: 1122 var -- string (default: 'x') 1123 OUTPUT: 1124 polynomial 1125 1126 EXAMPLES: 1127 sage: k.<a> = GF(2^8) 1128 sage: b = a^3 + a 1129 sage: b.minpoly() 1130 x^4 + x^3 + x^2 + x + 1 1131 sage: b.charpoly() 1132 x^8 + x^6 + x^4 + x^2 + 1 1133 sage: b.charpoly().factor() 1134 (x^4 + x^3 + x^2 + x + 1)^2 1135 sage: b.charpoly('Z') 1136 Z^8 + Z^6 + Z^4 + Z^2 + 1 1137 """ 1138 f = self.minpoly(var) 1139 cdef int d = f.degree(), n = self.parent().degree() 1140 cdef int pow = n/d 1141 return f if pow == 1 else f**pow 1142 1143 1116 1144 def minpoly(self, var='x'): 1117 """ 1118 Return the minimal polynomial of self, which is 1119 the smallest degree polynomial $f \in \F_{2}[x]$ 1120 such that $f(self) = 0$. 1121 1145 r""" 1146 Return the minimal polynomial of self, which is the smallest 1147 degree polynomial $f \in \mathbf{F}_{2}[x]$ such that 1148 $f(self) = 0$. 1149 1150 INPUT: 1151 var -- string (default: 'x') 1152 OUTPUT: 1153 polynomial 1154 1122 1155 EXAMPLES: 1123 1156 sage: K.<a> = GF(2^100) 1124 1157 sage: f = a.minpoly(); f