o
    8Va                     @   s   d Z ddlmZmZmZmZmZmZ ddlm	Z	 ddl
mZ ddlmZmZmZmZmZmZmZmZmZmZmZ ddlmZmZmZ dd Zd	d
 Zdd Zdd Zdd Z dd Z!dd Z"dd Z#dS )z<Tests for functions for generating interesting polynomials.     )PolyZZsymbolssqrtprimeAdd)permute_signs)raises)swinnerton_dyer_polycyclotomic_polysymmetric_polyrandom_polyinterpolating_polyfateman_poly_F_1dmp_fateman_poly_F_1fateman_poly_F_2dmp_fateman_poly_F_2fateman_poly_F_3dmp_fateman_poly_F_3)xyzc                  C   s  t tdd  tdtddttd d ksJ tdttd d ks%J tdttd dtd   d ks8J td	ttd
 dtd   dtd   dtd   d ksWJ dd tddD } tdd tddd D ttdd t	| D ksJ d S )Nc                   S   
   t dtS Nr   )r
   r    r   r   E/usr/lib/python3/dist-packages/sympy/polys/tests/test_specialpolys.py<lambda>      
 z+test_swinnerton_dyer_poly.<locals>.<lambda>   TZpolys      
         (      i`  i  i@  c                 S   s   g | ]}t t|qS r   )r   r   .0ir   r   r   
<listcomp>#   s    z-test_swinnerton_dyer_poly.<locals>.<listcomp>   c                 S   s   g | ]}| d qS r#   )nr'   r   r   r   r*   $   s    c                 S   s   g | ]	}t | d qS r,   )r   r-   r'   r   r   r   r*   &   s    )
r	   
ValueErrorr
   r   r   rangestrZ	all_rootssortedr   )pr   r   r   test_swinnerton_dyer_poly   s   "&.r3   c                   C   s   t tdd  tdtddttd ksJ tdttd ks!J tdttd ks,J tdttd t d ks;J tdttd d ksHJ td	ttd td  td  t d ks_J td
ttd t d ksnJ d S )Nc                   S   r   r   )r   r   r   r   r   r   r   *   r   z&test_cyclotomic_poly.<locals>.<lambda>r   Tr   r    r#   r!   r+   r&   )r	   r.   r   r   r   r   r   r   r   test_cyclotomic_poly)   s   ."r4   c                   C   s   t tdd  t tdd  tdtttddttt t ks!J tdtttfddttt t ks5J tdtttdks@J tdttttt t ksOJ tdttttt tt  tt  ksdJ td	ttttt t kssJ d S )
Nc                   S      t dtttS )Nr   r   r   r   r   r   r   r   r   7       z%test_symmetric_poly.<locals>.<lambda>c                   S   r5   )Nr+   r7   r   r   r   r   r   8   r8   r   Tr   r   r    r#   )r	   r.   r   r   r   r   r   r   r   r   r   test_symmetric_poly6   s   &(*"r9   c                  C   s   t tddddd} t|  dksJ tdd t|  D du s$J t tddddd} |  dks5J td	d |  D du sDJ d S )
Nr"   d   Fr   c                 s   (    | ]}d |  kodkn  V  qdS r:   r;   Nr   r(   Zcoeffr   r   r   	<genexpr>G      & z#test_random_poly.<locals>.<genexpr>Tc                 s   r<   r=   r   r>   r   r   r   r?   L   r@   )r   r   r   ZdegreeallZcoeffs)Zpolyr   r   r   test_random_polyC   s   ""rB   c                  C   s`  t d\} }}}}}}}tdtdksJ tdt|ksJ tdt|t|  | |  |t|   ||    ks9J tdt|t|  t|  | | | |   |t|   t|  ||  ||    |t|   t|  ||  ||    ksvJ tdt|t|  t|  t|  | | | |  | |   |t|   t|  t|  ||  ||  ||    |t|   t|  t|  ||  ||  ||    |t|   t|  t|  ||  ||  ||    ksJ ttdd  ttd	d  ttd
d  ttdd  ttdd  tdtdddksJ tdtdddks J tdtddtd ks.J d S )Nzx:4, y:4r   r   r    r#   r!   c                   S   s   t dttdfdS Nr    )r   r#   )r   r   r   r   r   r   r   c   s   z)test_interpolating_poly.<locals>.<lambda>c                   S   s   t dttt dfdS rC   r   r   r   r   r   r   r   r   e      c                   S   s   t dtt tdfdS rC   rD   r   r   r   r   r   g   rE   c                   S      t ddddS )Nr    r#   r!   r+   )r&      r   r   r   r   r   r   i      c                   S   rF   )Nr    r#   rG   )r&   rH   r$   rI   r   r   r   r   r   k   rJ   )r   r    )r#   r!   )r   r   r   r	   r.   )Zx0Zx1Zx2Zx3Zy0Zy1Zy2Zy3r   r   r   test_interpolating_polyO   s<   &"""2222 rK   c                  C      t d\} }}tdt\}}}dd | ||fD |||gks J t d\} }}tdt\}}}dd | ||fD |||gks@J d S )Nr   c                 S      g | ]}|j j qS r   Zrepr(   tr   r   r   r*   v       z)test_fateman_poly_F_1.<locals>.<listcomp>r#   c                 S   rM   r   rN   rO   r   r   r   r*   {   rQ   )r   r   r   fghFGHr   r   r   test_fateman_poly_F_1r      "&rY   c                  C   rL   )Nr   c                 S   rM   r   rN   rO   r   r   r   r*      rQ   z)test_fateman_poly_F_2.<locals>.<listcomp>r#   c                 S   rM   r   rN   rO   r   r   r   r*      rQ   )r   r   r   rR   r   r   r   test_fateman_poly_F_2~   rZ   r[   c                  C   rL   )Nr   c                 S   rM   r   rN   rO   r   r   r   r*      rQ   z)test_fateman_poly_F_3.<locals>.<listcomp>r#   c                 S   rM   r   rN   rO   r   r   r   r*      rQ   )r   r   r   rR   r   r   r   test_fateman_poly_F_3   rZ   r\   N)$__doc__Zsympyr   r   r   r   r   r   Zsympy.utilities.iterablesr   Zsympy.testing.pytestr	   Zsympy.polys.specialpolysr
   r   r   r   r   r   r   r   r   r   r   Z	sympy.abcr   r   r   r3   r4   r9   rB   rK   rY   r[   r\   r   r   r   r   <module>   s     4#