Hi,

I wrote some code for solving general linear systems.
Of course solve can do this too, but the output format of
solve is very unhandy for further use within algorithms.

There are several methods in the Matrix class that can solve
linear systems but I could find none which works with rectangular
systems or when the matrix is not invertible. There seems to
be no method for providing a parametric solution like in the
following example:

-----------------------------------------------------------
In [3]: M = Matrix([[1,2,3],[4,5,6],[7,8,9]])

In [4]: M.det()
Out[4]: 0

In [5]: v = Matrix([3,6,9])

In [6]: v
Out[6]: 
Matrix([
[3],
[6],
[9]])

In [7]: M
Out[7]: 
Matrix([
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])

In [8]: solve_general_linear(M, v)
Out[8]:
(Matrix([
[   _t_0 - 1],
[-2*_t_0 + 2],
[       _t_0]]), Matrix([[_t_0]]))

In [9]: pprint(_)
⎛⎡ t₀ - 1  ⎤, [t₀]⎞
⎜⎢         ⎥      ⎟
⎜⎢-2⋅t₀ + 2⎥      ⎟
⎜⎢         ⎥      ⎟
⎝⎣   t₀    ⎦      ⎠
-----------------------------------------------------------

For the moment it's a new file "linear.py" in sympy/solvers.
I'm not sure where exactly it belongs. I'll need a helping hand
for integrating this into the general solver landscape anyway.

Here is the PR:

  https://github.com/sympy/sympy/pull/2580


-- Raoul

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sympy.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to