Subclassing Expr has some issues as well. This is what Brian was referring
to. Within all of our code we use Add and Mul and don't check if instead we
should use some subclass of Add or subclass of Mul. If I feed a matrix
expression into these objects then the special matrix structure is lost.
This happens if, for example, you call simplify on a matrix expression.

I think I can get around this though with a few well placed "matrixify"
functions. Matrixify is a function which goes through the expression tree
and makes appropriate fixes. I've had good success so far with a very very
basic Matrixify function.

Brian, did you have particular horror stories trying to subclass Expr? I'm
enthusiastic about my approach but you seemed to have a bad experience. Can
you suggest difficult test cases that I should think about?



On Fri, Jul 8, 2011 at 3:22 PM, Aaron Meurer <[email protected]> wrote:

> On Fri, Jul 8, 2011 at 4:00 AM, SherjilOzair <[email protected]>
> wrote:
> > There is something I'm doing as part of my project which maybe be
> > useful. I'm implementing a Matrix_ wrapper class which will wrap over
> > low-level matrices. Its being written to replace the current Matrix
> > class. Algorithmic code and user-level code is being separated into
> > different classes. Currently, we have three internal matrices, the
> > DenseMatrix( a modified form of the current Matrix class), DOKMatrix
> > and LILMatrix. These three are essentially Data internal matrices.
> > The MatrixSymbol can be another object that Matrix_ (later Matrix)
> > would use as internal.
> >
> > Of what I understand from this discussion about the Matrix Symbol, we
> > need to have an object that will be treated like a Matrix everywhere,
> > but without the internal data. Space is being made in the Matrix
> > module for such an object, but for it work nicely it needs to interact
> > nicely with Expr objects. If its a problem subclassing Expr and
> > friends, I'm +1 about making a separate codebase for matrix
> > expressions. It is, after all, a different algebra.
> >
> > I'm not very familiar with Expr, Add, etc. but I think a separate
> > algebra MatrixExpr, MatrixAdd, etc. could be developed by copy-pasting
> > some code from Expr, Add, and modifying according to need. I say 'copy-
> > paste' and not subclassing as the code would be need to be modified
> > much before it can work on matrices.
>
> As has been discussed before, this is a bad idea. Just subclass Expr.
>
> Aaron Meurer
>
> >
> > Presently, I'm quite busy with this new encapsulation class Matrix_
> > and can only think of working fulltime on MatrixSymbol after I've
> > merged in my work on DOKMatrix, LILMatrix and the ongoing work on
> > Matrix_.
> >
> > Matthew, you could set up a wiki page on 'matrix expressions' with
> > some example code in it. 'symbolic matrices' can mean a few number of
> > things, and is somewhat vague. It would be good if everyone could see
> > what sort of concrete things are expected from matrix expressions.
> > Approaches to implement Matrix Algebra, with pros and cons listed,
> > could be added there for discussion, suggestion and improvement.
> >
> > Regards,
> > Sherjil Ozair
> >
> > --
> > 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.
> >
> >
>
> --
> 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.
>
>

-- 
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.

Reply via email to