Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
241852 views
�
eYc@s�ddlZddlZddlmZddlmZmZejZd�Zd�Z	d�Z
d�Zdd	�Zd
�Z
dd�Zdd�Zdd
�Zddd�Zdd�ZddlmZddlmZd�ZdS(i����N(tcputime(tIntegertZZcCsAtgtj|�j�D]\}}|dkr|^qg�S(Ni(tsumtFtideals_of_bdd_normt	iteritems(tBtntv((s%psage/modform/hilbert/sqrt5/tables.pytideals_of_bounded_normscCsxyt|�}Wn tk
r2t|�g}nXtjt|��}tg|D]}|dkrR||^qRg�S(Ni(tlistt	TypeErrorRRRtmaxR(R	tzR((s%psage/modform/hilbert/sqrt5/tables.pytideals_of_norm
s
cCsdyE|j�j|j��j�}t|�dks<t�|dSWntk
r_t|�SXdS(s�
    Return a canonical choice of generator for this ideal I (of a
    PID).

    The implementation computes the Hermite normal form (HNF) basis of
    the ideal, which is canonical, then finds a generator for the
    ideal it defines.

    EXAMPLES::

        sage: import psage.modform.hilbert.sqrt5.tables as tables
        sage: a = tables.F.gen()
        sage: z = a^30  * (-45*a+28); z
        -37284985*a - 23043388
        sage: tables.canonical_gen(tables.F.ideal(z))
        -45*a + 28
    iiN(tringtidealtbasistgens_reducedtlentAssertionErrortAttributeErrorR(tItg((s%psage/modform/hilbert/sqrt5/tables.pyt
canonical_gens!
cCst|j�j|��S(s}
    Return canonical generator for the ideal generated by z.  See the
    documentation for the canonical_gen function.
    (RtparentR(R((s%psage/modform/hilbert/sqrt5/tables.pyt
canonical_rep-si2cCsmtj�}d|d}gt||�D]}t|||�^q+}tt|��dksit�dS(Ni����ii(RtgentrangeRRtsetR(RtaRtiR	((s%psage/modform/hilbert/sqrt5/tables.pyttest_canonical_gen4s1cCst|�jdd�S(Nt t(tstrtreplace(ts((s%psage/modform/hilbert/sqrt5/tables.pytno_space;scCs�|rt|d�nd}x�t|�D]�}t�}tj|�}t|�}d|j�|j�tt	|��|f}|GH|r(|j
|d�|j�q(q(WdS(s�
    Compute dimensions of spaces of Hilbert modular forms for all the levels in v.
    The format is:

        Norm   dimension  generator  time
    Rs%s %s %s %ss
N(topentNoneRRt
sqrt5_fasttIcosiansModP1ModNtnormtcardinalityR'Rtwritetflush(R	tfilenameRtNtttHttmR&((s%psage/modform/hilbert/sqrt5/tables.pyt
dimensions>s	.cCs=|rt|d�nd}gt|�D]}|j�r(|^q(}x�t|�D]�}t�}tj|�}g|D]T}tt	|j
��t	|j
���dkrx|j�|j|�j
�f^qx}	t|�}
d|j
�tt|��|
t|	�f}|GH|rS|j|d�|j�qSqSWdS(s�
    Compute characteristic polynomials of T_P for primes P with norm <= B
    for spaces of Hilbert modular forms for all the levels in v.
    Ris%s %s %s %ss
N(R(R)R
tis_primeRRR*R+tgcdRR,tsmallest_integerthecke_matrixtfcpR'RR.R/(R	RR0RtptPR1R2R3tTR4R&((s%psage/modform/hilbert/sqrt5/tables.pyt	charpolysPs+	
T.c
Cs�|rt|d�nd}gtd�D]}|j�r(|^q(}x:t|�D],}t|j��}t�}tj	|�}t|�}	x3|D]+}t|j��j
|�dkr�Pq�q�Wt�}|j|�}
t|�}t�}|
j�}t|�}
d|j�t
t|��|j�t
t|��t
|�|	||
f}|GH|rS|j|d�|j�qSqSWdS(s�
    Compute and factor one characteristic polynomials for all the
    levels in v.  Always compute the charpoly of T_P where P is the
    smallest prime not dividing the level.
    Ridis%s	%s	%s	%s	%s	(%.1f,%.1f,%.1f)s
N(R(R)R
R6RRR,RR*R+R7R9R:R'RR8R.R/(R	R0RR;R<R1tNNR2R3tt0R=tt1tftt2R&((s%psage/modform/hilbert/sqrt5/tables.pytone_charpolycs.+	
!		!idcCs�ddlm}|r%t|d�nd}x�t|�D]�}||�}x�t|j��D]�\}}|j|�}d|j�t	t
|��|djg|D]}	t	|	�^q��f}
|
GH|r]|j|
d�|j
�q]q]Wq8WdS(Ni����(tHilbertModularFormsRs%s	%s	%s	%sR"s
(thmfRER(R)Rt	enumeratetelliptic_curve_factorstaplistR,R'RtjoinR.R/(R	RR0RERR1R3R tEtxR&((s%psage/modform/hilbert/sqrt5/tables.pytelliptic_curves�sJicsddlm�ddlm}m�ddl�||������fd��}x|t|��D]}|GHqlWdS(Ni����(RE(tparalleltset_random_seedc
s��d�tt|��jdd�jdd�}t�jj�d|�d�}�|�}tt|��}y�|j�}|jd|j�|t	|�f�|j
�x�t|�D]y\}}|j��}d	|j�||d
jg|D]}t|�^q��f}	|	GH|j|	d�|j
�q�WWn3t
k
rs}
|jd|j�||
f�nX|j�dS(
Nit*R#t-t_s%s.txttwscount %s %s %s
s%s	%s	%s	%sR"s
sexception %s %s "%s"
(R'RR%R(tpathRJRHR.R,RR/RGRIt	Exceptiontclose(R1tlevelRR3tDR RKR	RLR&tmsg(RREtdirtosRO(s%psage/modform/hilbert/sqrt5/tables.pyRB�s$
*"&
>$(RFREtsage.allRNROR[R(R	RRZtncpuRNRBtX((RRERZR[ROs%psage/modform/hilbert/sqrt5/tables.pytelliptic_curves_parallel�s'(tpari(tprimesc	Csng}tj�}x4t|d�D]"}|dkr\|jdtjd|d�f�q#|ddkr�||}||krE|j|tj|�f�qEq#td�j|�j�}td|dj	��}td|dj	��}|j||tj|||g�f�|j||tj|||g�f�q#W|j
�g|D]}|d^qZS(s
    Return the prime ideals of the integers of the field Q(sqrt(5)) of
    norm at most B, ordered first by norm, then by the image of the
    golden ratio mod the prime in GF(p)={0,1,...,p-1}.

    INPUT:

        - B -- integer

    OUTPUT:

        - list of prime ideals

    EXAMPLES::

        sage: import psage
        sage: psage.modform.hilbert.sqrt5.primes_of_bounded_norm(4)
        [Fractional ideal (2)]
        sage: len(psage.modform.hilbert.sqrt5.primes_of_bounded_norm(10^4))
        1233
        sage: v = psage.modform.hilbert.sqrt5.primes_of_bounded_norm(11); v
        [Fractional ideal (2), Fractional ideal (2*a - 1), Fractional ideal (3), Fractional ideal (3*a - 1), Fractional ideal (3*a - 2)]

    Check that the sort order is as claimed::
    
        sage: P0 = v[-2]; P1 = v[-1]
        sage: K = P0.number_field(); K
        Number Field in a with defining polynomial x^2 - x - 1
        sage: P0.residue_field()(K.gen())
        4
        sage: P1.residue_field()(K.gen())   # yep, 4 < 8
        8
    iiiii����(ii(RRRatappendRR`tModtsqrttinttlifttsort(	RR	RR;tNormR&RtbR((s%psage/modform/hilbert/sqrt5/tables.pytprimes_of_bounded_norm�s "'
")-
(tsqrt5R*t
sage.misc.allRtsage.rings.allRRRR
RRRR!R'R)R5R>RDRMR_t
sage.libs.allR`RaRj(((s%psage/modform/hilbert/sqrt5/tables.pyt<module>s"