ó
¡¼™\c           @  sa   d  Z  d d l m Z m Z d d l m Z m Z d e f d „  ƒ  YZ d „  Z e	 d „ Z
 d S(	   s!   Low-level linear systems solver. iÿÿÿÿ(   t   print_functiont   division(   t   Matrixt   zerost	   RawMatrixc           B  s   e  Z e d  „  ƒ Z RS(   c         C  s   |  S(   N(    (   t   x(    (    s2   lib/python2.7/site-packages/sympy/polys/solvers.pyt   <lambda>   t    (   t   __name__t
   __module__t   staticmethodt   _sympify(    (    (    s2   lib/python2.7/site-packages/sympy/polys/solvers.pyR      s   c         C  sŸ   | j  } t t |  ƒ t | ƒ d d t ƒ} xj t |  ƒ D]\ \ } } x3 t | ƒ D]% \ } } | j | ƒ | | | f <qT W| j d ƒ | | d f <q; W| S(   s)   Transform from equations to matrix form. i   t   clsiÿÿÿÿ(   t   gensR   t   lenR   t	   enumeratet   coeff(   t   eqst   ringt   xst   Mt   jt   e_jt   it   x_i(    (    s2   lib/python2.7/site-packages/sympy/polys/solvers.pyt   eqs_to_matrix
   s    	%c         C  s¹  | } | j  j s t ‚ t |  | ƒ } | j d d „  d d „  ƒ \ } } | r[ | j n | j } | d t | ƒ k r~ d St | ƒ t | ƒ k rg  } xO | d d … d f D]7 }	 | j	 |	 ƒ }
 | rÝ |
 j
 ƒ  }
 n  | j |
 ƒ q³ Wt t | | ƒ ƒ } n¯ i  } | j } g  | D] } | g ^ q} x€ t | ƒ D]r \ } } t | | d | j g g ƒ } | | | d d … f | d } | r£| j
 ƒ  } n  | | | | <q?W| S(	   s%  Solve a system of linear equations.

    If ``_raw`` is False, the keys and values in the returned dictionary
    will be of type Expr (and the unit of the field will be removed from
    the keys) otherwise the low-level polys types will be returned, e.g.
    PolyElement: PythonRational.
    t
   iszerofuncc         S  s   |  S(   N(    (   R   (    (    s2   lib/python2.7/site-packages/sympy/polys/solvers.pyR   &   R   t   simplifyc         S  s   |  S(   N(    (   R   (    (    s2   lib/python2.7/site-packages/sympy/polys/solvers.pyR   &   R   iÿÿÿÿNi   i    (   t   domaint   is_Fieldt   AssertionErrorR   t   rreft   symbolsR   R   t   Nonet
   ground_newt   as_exprt   appendt   dictt   zipR   R   t   one(   R   R   t   _rawR#   t   matrixt   echelont   pivotst   keyst   solt   st   at   solst   gR   t   _gt   pt   vectt   v(    (    s2   lib/python2.7/site-packages/sympy/polys/solvers.pyt   solve_lin_sys   s2    $	!"N(   t   __doc__t
   __future__R    R   t   sympy.matricesR   R   R   R   t   TrueR6   (    (    (    s2   lib/python2.7/site-packages/sympy/polys/solvers.pyt   <module>   s
   	