| 2399 | |
| 2400 | def additive_order(self): |
| 2401 | """ |
| 2402 | Return the additive order of this finite field element. |
| 2403 | |
| 2404 | EXAMPLES: |
| 2405 | sage: k.<a> = FiniteField(2^12, 'a') |
| 2406 | sage: b = a^3 + a + 1 |
| 2407 | sage: b.additive_order() |
| 2408 | 2 |
| 2409 | sage: k(0).additive_order() |
| 2410 | 1 |
| 2411 | """ |
| 2412 | if self.is_zero(): |
| 2413 | from sage.rings.integer import Integer |
| 2414 | return Integer(1) |
| 2415 | return self.parent().characteristic() |
| 2416 | |
| 2417 | def pth_power(self, int k = 1): |
| 2418 | """ |
| 2419 | Return the $p^k$th power of self, where $p$ is the characteristic |
| 2420 | of the field. |
| 2421 | |
| 2422 | INPUT: |
| 2423 | k -- integer (default: 1, must fit in C int type) |
| 2424 | |
| 2425 | OUTPUT: |
| 2426 | The $p^k$th power of self. |
| 2427 | |
| 2428 | Note that if $k$ is negative, then this computes the appropriate root. |
| 2429 | |
| 2430 | EXAMPLES: |
| 2431 | sage: F.<a> = GF(29^2) |
| 2432 | sage: z = a^2 + 5*a + 1 |
| 2433 | sage: z.pth_power() |
| 2434 | 19*a + 20 |
| 2435 | sage: z.pth_power(10) |
| 2436 | 10*a + 28 |
| 2437 | sage: z.pth_power(-10) == z |
| 2438 | True |
| 2439 | sage: F.<b> = GF(2^12) |
| 2440 | sage: y = b^3 + b + 1 |
| 2441 | sage: y == (y.pth_power(-3))^(2^3) |
| 2442 | True |
| 2443 | sage: y.pth_power(2) |
| 2444 | b^7 + b^6 + b^5 + b^4 + b^3 + b |
| 2445 | """ |
| 2446 | p = self.additive_order() |
| 2447 | n = self.parent().order().factor()[0][1] |
| 2448 | return self**(p**(k % n)) |
| 2449 | |
| 2450 | frobenius = pth_power |
| 2451 | |
| 2452 | def pth_root(self, int k = 1): |
| 2453 | """ |
| 2454 | Return the $p^k$th root of self, where $p$ is the characteristic |
| 2455 | of the field. |
| 2456 | |
| 2457 | INPUT: |
| 2458 | k -- integer (default: 1, must fit in C int type) |
| 2459 | |
| 2460 | OUTPUT: |
| 2461 | The $p^k$th root of self. |
| 2462 | |
| 2463 | Note that if $k$ is negative, then this computes the appropriate power. |
| 2464 | |
| 2465 | EXAMPLES: |
| 2466 | sage: F.<b> = GF(2^12) |
| 2467 | sage: y = b^3 + b + 1 |
| 2468 | sage: y == (y.pth_root(3))^(2^3) |
| 2469 | True |
| 2470 | sage: y.pth_root(2) |
| 2471 | b^11 + b^10 + b^9 + b^7 + b^5 + b^4 + b^2 + b |
| 2472 | """ |
| 2473 | return self.pth_power(-k) |
| 2474 | |