Status: Accepted
Owner: [email protected]
Labels: Type-Enhancement Priority-Medium Matrices

New issue 2221 by [email protected]: hstack() and vstack() methods for Matrix
http://code.google.com/p/sympy/issues/detail?id=2221

After the fix for issue 2212, Matrix(...) is able to stack its arguments vertically. This raises interesting additional points:
* it should be possible to stack things horizontally as well
* this feels like too much complexity for a constructor

So, I think that Matrix should get 2 more constructors (i.e. classmethods returning instances of Matrix): Matrix.hstack and Matrix.vstack. These can be implemented quite simply for now:

@classmethod
def vstack(cls, *args):
    return Matrix(args)

@classmethod
def hstack(cls, *args):
transpose = lambda arg: arg.transpose() if isinstance(arg, Matrix) else arg
    return Matrix(map(transpose, args)).transpose()

but ultimately, the actual logic for the operations should be transferred from Matrix.__init__. The new class methods will also deprecate .col_join() and .row_join().


--
You received this message because you are subscribed to the Google Groups 
"sympy-issues" 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-issues?hl=en.

Reply via email to