# HG changeset patch
# User J. H. Palmieri <palmieri@math.washington.edu>
# Date 1299898020 28800
# Node ID e791515a4dbbc38ade760caa0a01932cef096cda
# Parent 21b3641531b7c8f924587e0d500d5ddaaa62dade
#9370: delta from v3 to v4
diff -r 21b3641531b7 -r e791515a4dbb sage/algebras/steenrod/steenrod_algebra_misc.py
a
|
b
|
def is_valid_profile(profile, truncation |
246 | 246 | # p odd: |
247 | 247 | e = list(profile[0]) + [truncation_type]*len(profile[0]) |
248 | 248 | k = list(profile[1]) |
| 249 | if not set(k).issubset(set([1,2])): |
| 250 | return False |
249 | 251 | if truncation_type > 0: |
250 | 252 | k = k + [2] |
251 | 253 | else: |
… |
… |
def normalize_profile(profile, precision |
391 | 393 | sage: normalize_profile(([2,1], [2,2,2]), precision=84, p=13) |
392 | 394 | (((2, 1), (2, 2, 2)), 0) |
393 | 395 | sage: normalize_profile((lambda n: 0, lambda n: 2), precision=4, p=11) |
394 | | (((0, 0, 0), (2, 2, 2)), +Infinity) |
| 396 | (((0, 0, 0), ()), +Infinity) |
395 | 397 | |
396 | 398 | As at the prime 2, negative numbers in the first component are |
397 | | converted to zeroes. Numbers in the second component are forced |
398 | | to lie between 1 and 2: numbers larger than 2 get converted to 2, |
399 | | etc. :: |
| 399 | converted to zeroes. Numbers in the second component must be |
| 400 | either 1 and 2, or else an error is raised:: |
400 | 401 | |
401 | | sage: normalize_profile((lambda n: -n, lambda n: 2+n), precision=4, p=11) |
402 | | (((0, 0, 0), (2, 2, 2)), +Infinity) |
| 402 | sage: normalize_profile((lambda n: -n, lambda n: 1), precision=4, p=11) |
| 403 | (((0, 0, 0), (1, 1, 1)), +Infinity) |
| 404 | sage: normalize_profile([[0,0,0], [1,2,3,2,1]], p=11) |
| 405 | Traceback (most recent call last): |
| 406 | ... |
| 407 | ValueError: Invalid profile |
403 | 408 | """ |
404 | 409 | from inspect import isfunction |
405 | 410 | from sage.rings.infinity import Infinity |
… |
… |
def normalize_profile(profile, precision |
488 | 493 | k = tuple(k) |
489 | 494 | elif isfunction(k): |
490 | 495 | # k is a function: turn it into a tuple. |
491 | | k = [max(1, min(2, k(i))) for i in range(precision-1)] |
492 | | k = tuple(k) |
| 496 | k = tuple([k(i) for i in range(precision-1)]) |
| 497 | # Remove trailing ones from k if truncation_type is 'zero', |
| 498 | # remove trailing twos if truncation_type is 'Infinity'. |
| 499 | if truncation_type == 0: |
| 500 | while len(k) > 0 and k[-1] == 1: |
| 501 | k = k[:-1] |
| 502 | else: |
| 503 | while len(k) > 0 and k[-1] == 2: |
| 504 | k = k[:-1] |
493 | 505 | new_profile = (e, k) |
494 | 506 | if is_valid_profile(new_profile, truncation_type, p): |
495 | 507 | return new_profile, truncation_type |