Hi Riccardo, On Tue, Jun 17, 2008 at 10:29 AM, goric <[EMAIL PROTECTED]> wrote: > > Hello, > I need some methods that permit to add a line or a column in a matrix > in that way: > > M = Matrix(3,3,lambda i,j: i+j) > M > ⎡0 1 2⎤ > ⎢1 2 3⎥ > ⎣2 3 4⎦ > V = Matrix(3,1,lambda i,j: 3+i+j) > V > ⎡3⎤ > ⎢4⎥ > ⎣5⎦ > M.append_col(V) > M > ⎡0 1 2 3⎤ > ⎢1 2 3 4⎥ > ⎣2 3 4 5⎦ > VL = [3,4,5,6] > M.append_line(VL) > M > ⎡0 1 2 3⎤ > ⎢1 2 3 4⎥ > ⎢2 3 4 5⎥ > ⎣3 4 5 6⎦ > > Can I implement them? The names I gave to them are good or do you > suggest any other name? I'll wait your opinion to start working.
Yes, please go ahead and implement them. I think the names are ok, and they can always be renamed. Note that you can use the matrix indexing to do what you want: In [3]: V = Matrix(3,1,lambda i,j: 3+i+j) In [4]: V Out[4]: ⎡3⎤ ⎢4⎥ ⎣5⎦ In [7]: M = zeronm(3, 4) In [8]: M Out[8]: ⎡0 0 0 0⎤ ⎢0 0 0 0⎥ ⎣0 0 0 0⎦ In [9]: M[:, :3] Out[9]: ⎡0 0 0⎤ ⎢0 0 0⎥ ⎣0 0 0⎦ In [10]: M[:, :3] = Matrix(3,3,lambda i,j: i+j) In [11]: M Out[11]: ⎡0 1 2 0⎤ ⎢1 2 3 0⎥ ⎣2 3 4 0⎦ In [12]: M[:, 3] = V In [13]: M Out[13]: ⎡0 1 2 3⎤ ⎢1 2 3 4⎥ ⎣2 3 4 5⎦ Ondrej --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sympy?hl=en -~----------~----~----~----~------~----~------~--~---
