Feel free to update me on an incomplete implementation as well. I'm happy to provide feedback on a half-complete pull request. That will probably save you some work.
On Thu, Jul 25, 2013 at 5:35 AM, Sreeraj Rajendran <[email protected]>wrote: > Hi Matthew, > > Thank you for the crystal clear explanation. Will update you once my > implementation is complete. > > -Sreeraj > > > On Wednesday, July 24, 2013 7:15:31 PM UTC+5:30, Matthew wrote: > >> Hi Sreeraj >> >> Stefan is correct that you should not expect operations from >> sympy.physics to interoperate smoothly with operations from >> sympy.matrices.expressions. They have different designs. >> >> sympy.matrix.expressions doesn't have a kronecker product operation but >> it could if you're willing to build it. We'd love the contribution and I'd >> be happy to support you if you're willing to do some development work. >> You could also build whatever matrix functionality you need into the >> sympy.physics family of operations; I'm less able to help here but it's an >> equally valid approach and presumably other members of the sympy community >> could help out. >> >> If you wanted to get started with a KroneckerProduct operator in >> sympy.matrices.expressions I would take a look at our Development >> Workflow <https://github.com/sympy/sympy/wiki/Development-workflow> wiki >> page. I would then take a look at the following files to serve as examples >> >> sympy/matrices/expressions/**transpose.py >> sympy/matrices/expressions/**hadamard.py >> sympy/matrices/expressions/**fourier.py >> >> Each of them are decent examples of how to add simple operations to >> matrix expressions. Hadamard is probably the closest/simplest to what >> you're looking for. The minimum you need to do is to implement the shape >> property. You might also want to implement _entry for indexing into the >> kronecker product or any of the methods like _eval_transpose for any of the >> simplifications you want to be done. For example your example above >> of KP(X,Y).T = KP(X.T, Y.T) can be implemented as follows >> >> def _eval_transpose(self): >> return KroneckerProduct(*[arg.T for arg in self.args]) >> >> _eval_transpose will be called automatically whenever anyone uses the .T >> property of a matrix expression. >> >> In recent memory this is the second time this operation has come up. >> Sounds like it would be a meaningful contribution. >> >> Best, >> -Matthew >> >> >> On Wed, Jul 24, 2013 at 7:42 AM, Stefan Krastanov >> <[email protected]>wrote: >> >>> I guess you will have to implement the Kroenecker product yourself. >>> Matthew Rocklin might have more details (he did most of the matrix symbols >>> stuff). >>> >>> >>> On 24 July 2013 13:44, Sreeraj Rajendran <[email protected]> wrote: >>> >>>> Let me explain my needs. MatrixSymbol supports basic matrix operations >>>> like >>>> >>>> With >>>> X = MatrixSymbol('X', 3, 3) >>>> Y = MatrixSymbol('Y', 3, 3) >>>> >>>> (X*Y).T will give me >>>> >>>> T T >>>> Y ⋅X >>>> >>>> I just wanted to try similar properties of "kronecker product" i.e >>>> KP(X,Y).T = KP(X.T, Y.T). What is the best way to implement these? >>>> What if I want to try some basic decompositions, say KP(X,Y) = >>>> KP(X,I_m) KP(X,I_n)? >>>> >>>> I am just a beginner in to sympy. Should I implement some new methods >>>> to work on kronecker product (http://en.wikipedia.org/wiki/** >>>> Kronecker_product <http://en.wikipedia.org/wiki/Kronecker_product>) on >>>> matrix symbols? >>>> >>>> Thank you for your previous comments. >>>> >>>> >>>> >>>> On Wednesday, July 24, 2013 2:05:53 PM UTC+5:30, Stefan Krastanov wrote: >>>> >>>>> Well, these two modules do not have anything in common, they are not >>>>> meant to be inter-operable. >>>>> >>>>> The matrixexpr do not have a notion of basis, vector space or linear >>>>> operator. `MatrixSymbol` is meant to represent a matrix, not an operator >>>>> (though if you wish, you can make the mental assumption that you are >>>>> working in certain basis and just consider all matrices to be operators). >>>>> >>>>> The quantum module has all this (different bases, Hilbert spaces, >>>>> operators, etc). If that is what you need just use it. >>>>> >>>>> There is also the `diffgeom` module for differential geometry which >>>>> you might find useful depending on what exactly you want to do. >>>>> >>>>> >>>>> On 24 July 2013 10:22, Sreeraj Rajendran <[email protected]> wrote: >>>>> >>>>>> Stefan, >>>>>> >>>>>> My imports >>>>>> from sympy.physics.quantum import TensorProduct >>>>>> from sympy import MatrixSymbol >>>>>> >>>>>> >>>>>> On Wednesday, July 24, 2013 1:35:38 PM UTC+5:30, Stefan Krastanov >>>>>> wrote: >>>>>> >>>>>>> From what submodules of sympy are you importing these classes? >>>>>>> >>>>>>> >>>>>>> On 24 July 2013 09:38, Sreeraj Rajendran <[email protected]> wrote: >>>>>>> >>>>>>>> >>>>>>>> Hi, >>>>>>>> >>>>>>>> With >>>>>>>> X = MatrixSymbol('X', 3, 3) >>>>>>>> Y = MatrixSymbol('Y', 3, 3) >>>>>>>> >>>>>>>> TensorProduct(X,Y) throws me the following error >>>>>>>> AttributeError: 'MatrixSymbol' object has no attribute 'args_cnc' >>>>>>>> >>>>>>>> TensorProduct(Matrix(X),**Matrix****(Y)) works fine. >>>>>>>> Is tensorproduct over matrixsymbols is currently under development >>>>>>>> or am I doing something terribly wrong? >>>>>>>> >>>>>>>> -- >>>>>>>> Regards >>>>>>>> Sreeraj Rajendran >>>>>>>> http://home.iitb.ac.in/~**rsreer****aj<http://home.iitb.ac.in/%7Ersreeraj> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> 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 sympy+un...@**googlegroups.com. >>>>>>>> To post to this group, send email to [email protected]. >>>>>>>> >>>>>>>> Visit this group at >>>>>>>> http://groups.google.com/**group****/sympy<http://groups.google.com/group/sympy> >>>>>>>> . >>>>>>>> For more options, visit https://groups.google.com/**grou**** >>>>>>>> ps/opt_out <https://groups.google.com/groups/opt_out>. >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> -- >>>>>> 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 sympy+un...@**googlegroups.com. >>>>>> To post to this group, send email to [email protected]. >>>>>> Visit this group at >>>>>> http://groups.google.com/**group**/sympy<http://groups.google.com/group/sympy> >>>>>> . >>>>>> For more options, visit >>>>>> https://groups.google.com/**grou**ps/opt_out<https://groups.google.com/groups/opt_out> >>>>>> . >>>>>> >>>>>> >>>>>> >>>>> >>>>> -- >>>> 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 sympy+un...@**googlegroups.com. >>>> To post to this group, send email to [email protected]. >>>> Visit this group at >>>> http://groups.google.com/**group/sympy<http://groups.google.com/group/sympy> >>>> . >>>> For more options, visit >>>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>>> . >>>> >>>> >>>> >>> >>> -- >>> 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 sympy+un...@**googlegroups.com. >>> To post to this group, send email to [email protected]. >>> Visit this group at >>> http://groups.google.com/**group/sympy<http://groups.google.com/group/sympy> >>> . >>> For more options, visit >>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out> >>> . >>> >>> >>> >> >> -- > 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. > > > -- 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.
