Comment #13 on issue 3742 by matt...@gmail.com: rref very slow
http://code.google.com/p/sympy/issues/detail?id=3742

In [1]: from sympy.polys.solvers import RawMatrix

In [2]: from sympy.polys.fields import vfield

In [3]: var("a_(1:5)(1:5)")
Out[3]: (a₁₁, a₁₂, a₁₃, a₁₄, a₂₁, a₂₂, a₂₃, a₂₄, a₃₁, a₃₂, a₃₃, a₃₄, a₄₁, a₄₂, a₄₃, a₄₄)

In [4]: M = Matrix([[a_11*a_12, a_21*a_22, 1], [a_31*a_32, a_41*a_42, 0]])

In [5]: M
Out[5]:
⎡a₁₁⋅a₁₂  a₂₁⋅a₂₂  1⎤
⎢                   ⎥
⎣a₃₁⋅a₃₂  a₄₁⋅a₄₂  0⎦

In [6]: M.applyfunc(type)
Out[6]:
⎡<class 'sympy.core.mul.Mul'> <class 'sympy.core.mul.Mul'> <class 'sympy.core.numbers.One'> ⎤ ⎣<class 'sympy.core.mul.Mul'> <class 'sympy.core.mul.Mul'> <class 'sympy.core.numbers.Zero'>⎦

In [7]: F = vfield("a_(1:5)(1:5)", ZZ)

In [8]: N = RawMatrix(M.rows, M.cols, map(F.to_domain().convert, M))

In [9]: N
Out[9]:
⎡a_11*a_12  a_21*a_22  1⎤
⎢                       ⎥
⎣a_31*a_32  a_41*a_42  0⎦

In [10]: N.applyfunc(type)
Out[10]:
⎡<class 'sympy.polys.fields.FracElement'> <class 'sympy.polys.fields.FracElement'> <class 'sympy.polys.fields.FracElement'>⎤ ⎣<class 'sympy.polys.fields.FracElement'> <class 'sympy.polys.fields.FracElement'> <class 'sympy.polys.fields.FracElement'>⎦

This is verbose to show you how to check if conversions went OK. The conversion happens in [8]. Note that step [7] overrides a_ij defined with var(). If you don't want that, use F = field("a_(1:5)(1:5)", ZZ)[0] or F, _ = xfield("a_(1:5)(1:5)", ZZ). What we show you here is all experimental code, so be warned that things will most likely work differently in the final version (and will be much simpler to use).

--
You received this message because this project is configured to send all issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy-issues+unsubscr...@googlegroups.com.
To post to this group, send email to sympy-issues@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy-issues?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to