# HG changeset patch
# User Volker Braun <vbraun@stp.dias.ie>
# Date 1317075226 -7200
# Node ID 586b3e95fe15f83dcab64854f5300c4edaad921e
# Parent 18829af747d0b29525feb685cfd9fb611eca466b
Trac #11115: Reviewer patch
Just removed out-of-date commented-out code and typos in docstrings.
diff --git a/sage/misc/cachefunc.pyx b/sage/misc/cachefunc.pyx
|
a
|
b
|
|
| 181 | 181 | sage: e.element_via_parent_test() is e.element_via_parent_test() |
| 182 | 182 | True |
| 183 | 183 | |
| 184 | | The other element class can only inherit a `cached_in_parent_method`, since |
| | 184 | The other element class can only inherit a ``cached_in_parent_method``, since |
| 185 | 185 | the cache is stored in the parent. In fact, equal elements share the cache, |
| 186 | 186 | even if they are of different types:: |
| 187 | 187 | |
| … |
… |
|
| 235 | 235 | |
| 236 | 236 | It is a very common special case to cache a method that has no |
| 237 | 237 | arguments. In that special case, the time needed to access the cache |
| 238 | | can be drastically reduced by using a special implmentation. The |
| | 238 | can be drastically reduced by using a special implementation. The |
| 239 | 239 | cached method decorator automatically determines which implementation |
| 240 | 240 | ought to be chosen. A typical example is |
| 241 | 241 | :meth:`sage.rings.polynomial.multi_polynomial_ideal.MPolynomialIdeal.gens` |
| … |
… |
|
| 738 | 738 | sage: R.<x, y, z> = PolynomialRing(QQ, 3) |
| 739 | 739 | sage: I = R*(x^3 + y^3 + z^3,x^4-y^4) |
| 740 | 740 | sage: I.groebner_basis() |
| 741 | | [y^5*z^3 - 1/4*x^2*z^6 + 1/2*x*y*z^6 + 1/4*y^2*z^6, x^2*y*z^3 - x*y^2*z^3 + 2*y^3*z^3 + z^6, x*y^3 + y^4 + x*z^3, x^3 + y^3 + z^3] |
| | 741 | [y^5*z^3 - 1/4*x^2*z^6 + 1/2*x*y*z^6 + 1/4*y^2*z^6, |
| | 742 | x^2*y*z^3 - x*y^2*z^3 + 2*y^3*z^3 + z^6, |
| | 743 | x*y^3 + y^4 + x*z^3, x^3 + y^3 + z^3] |
| 742 | 744 | sage: I.groebner_basis |
| 743 | 745 | Cached version of <function groebner_basis at 0x...> |
| 744 | 746 | |
| … |
… |
|
| 1584 | 1586 | |
| 1585 | 1587 | The example shows that the actual computation |
| 1586 | 1588 | takes place only once, and that the result is |
| 1587 | | identic for equivalent input:: |
| | 1589 | identical for equivalent input:: |
| 1588 | 1590 | |
| 1589 | 1591 | sage: res = a.f(3, 2); res |
| 1590 | 1592 | computing |
diff --git a/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py b/sage/schemes/hyperelliptic_curves/hyperelliptic_finite_field.py
|
a
|
b
|
|
| 579 | 579 | if E!=self: |
| 580 | 580 | self._Cartier_matrix_cached.clear_cache() |
| 581 | 581 | M, Coeffs,g, Fq, p, E= self._Cartier_matrix_cached() |
| 582 | | # A=self._Cartier_matrix_cached.get_cache() |
| 583 | | # if len(A) !=0: |
| 584 | | # if A.items()[-1][-1][-1]==self: |
| 585 | | # M,Coeffs,g, Fq, p,E = A.items()[-1][1]; |
| 586 | | # else: |
| 587 | | # A.clear() |
| 588 | | # M, Coeffs,g, Fq, p, E= self._Cartier_matrix_cached() |
| 589 | | # else: |
| 590 | | # A.clear() |
| 591 | | # M, Coeffs,g, Fq, p, E = self._Cartier_matrix_cached() |
| 592 | 582 | return M |
| 593 | 583 | |
| 594 | 584 | #This where Hasse_Witt is actually computed. This is either called by E.Hasse_Witt or p_rank |
| … |
… |
|
| 665 | 655 | self._Cartier_matrix_cached.clear_cache() |
| 666 | 656 | M, Coeffs,g, Fq, p, E= self._Cartier_matrix_cached() |
| 667 | 657 | |
| 668 | | # A=self._Cartier_matrix_cached.get_cache() |
| 669 | | # if len(A) !=0: |
| 670 | | # if A.items()[-1][-1][-1]==self: |
| 671 | | # M,Coeffs,g, Fq, p,E = A.items()[-1][1]; |
| 672 | | # else: |
| 673 | | # A.clear() |
| 674 | | # M, Coeffs,g, Fq, p, E= self._Cartier_matrix_cached() |
| 675 | | # else: |
| 676 | | # A.clear() |
| 677 | | # M, Coeffs,g, Fq, p, E = self._Cartier_matrix_cached() |
| 678 | | |
| 679 | 658 | #This compute the action of p^kth Frobenius on list of coefficients |
| 680 | 659 | def frob_mat(Coeffs, k): |
| 681 | 660 | a = p**k |
| … |
… |
|
| 686 | 665 | mat.append(H); |
| 687 | 666 | return matrix(Fq,mat) |
| 688 | 667 | |
| 689 | | |
| 690 | | |
| 691 | 668 | #Computes all the different possible action of frobenius on matrix M and stores in list Mall |
| 692 | 669 | Mall = [M] + [frob_mat(Coeffs,k) for k in range(1,g)] |
| 693 | 670 | |
| … |
… |
|
| 759 | 736 | self._Hasse_Witt_cached.clear_cache() |
| 760 | 737 | N, E= self._Hasse_Witt_cached() |
| 761 | 738 | return N |
| 762 | | # A=self._Hasse_Witt_cached.get_cache() |
| 763 | | # if len(A) !=0: |
| 764 | | # if A.items()[-1][-1][-1]==self: |
| 765 | | # N, E = A.items()[-1][1]; |
| 766 | | # else: |
| 767 | | # A.clear() |
| 768 | | # N, E= self._Hasse_Witt_cached() |
| 769 | | # else: |
| 770 | | # A.clear() |
| 771 | | # N, E= self._Hasse_Witt_cached() |
| 772 | | # return N |
| 773 | 739 | |
| 774 | 740 | def a_number(self): |
| 775 | 741 | r""" |
| … |
… |
|
| 810 | 776 | # Since Trac Ticket #11115, there is a special cache for methods |
| 811 | 777 | # that don't accept arguments. The easiest is: Call the cached |
| 812 | 778 | # method, and test whether the last entry is self. |
| 813 | | |
| 814 | | # A=self._Cartier_matrix_cached.get_cache() |
| 815 | | # if len(A) !=0: |
| 816 | | # if A.items()[-1][-1][-1]==self: |
| 817 | | # M,Coeffs,g, Fq, p,E = A.items()[-1][1]; |
| 818 | | # else: |
| 819 | | # A.clear() |
| 820 | | # M,Coeffs,g, Fq, p,E= self._Cartier_matrix_cached() |
| 821 | | # else: |
| 822 | | # A.clear() |
| 823 | | # M,Coeffs,g, Fq, p,E= self._Cartier_matrix_cached() |
| 824 | 779 | M,Coeffs,g, Fq, p,E= self._Cartier_matrix_cached() |
| 825 | 780 | if E != self: |
| 826 | 781 | self._Cartier_matrix_cached.clear_cache() |
| … |
… |
|
| 855 | 810 | sage: E=HyperellipticCurve(x^29+1,0) |
| 856 | 811 | sage: E.p_rank() |
| 857 | 812 | 0 |
| 858 | | |
| 859 | | |
| 860 | | |
| 861 | | |
| 862 | 813 | """ |
| 863 | 814 | #We use caching here since Hasse Witt is needed to compute p_rank. So if the Hasse Witt |
| 864 | 815 | #is already computed it is stored in list A. If it was not cached (i.e. A is empty), we simply |
| … |
… |
|
| 867 | 818 | #the last entry in A. If it does not match, clear A and compute Hasse Witt. |
| 868 | 819 | # However, it seems a waste of time to manually analyse the cache |
| 869 | 820 | # -- See Trac Ticket #11115 |
| 870 | | |
| 871 | 821 | N,E= self._Hasse_Witt_cached() |
| 872 | 822 | if E!=self: |
| 873 | 823 | self._Hasse_Witt_cached.clear_cache() |
| 874 | 824 | N,E= self._Hasse_Witt_cached() |
| 875 | | # A=self._Hasse_Witt_cached.get_cache() |
| 876 | | # if len(A) !=0: |
| 877 | | # if A.items()[-1][-1][-1]==self: |
| 878 | | # N,E = A.items()[-1][1]; |
| 879 | | # else: |
| 880 | | # A.clear() |
| 881 | | # N,E= self._Hasse_Witt_cached() |
| 882 | | # else: |
| 883 | | # A.clear() |
| 884 | | # N,E= self._Hasse_Witt_cached() |
| 885 | 825 | pr=rank(N); |
| 886 | 826 | return pr |
| 887 | 827 | |