Why didn't anyone think of this before ?! Q : What benefits does groundtypes give ? A : Operations are faster, as one does not have to type-check. Each groundtype has its own __add__, __mul__ installed, and global Add, Mul are avoided. The Matrix doesn't have to worry about the zero- equivalence. x belong to type MYTYPE for example, the question x == 0, should be solved by the groundtype and not by the Matrix class.
Q : So, all the elements have to be of the same groundtype ? How do you plan to do it ? A : Simple. Instead of sympify-ing the vals before putting it in the matrix, I typify them, typify being a variable function, which the user/caller will provide, like this A = Matrix(..., typify = sympify) or A = Matrix(..., typify = poly). The Matrix constructor would then use A[i,j] = typify(val). Q : So the matrix just needs to have a typify function ? A : Well, It could have another variable which says "This Matrix belongs to the Poly domain !". But Its just for the user. The matrix doesn't need to know which domain it is in (there are exceptions, keep reading). The Matrix shouldn't care what A[6,5] and A[7,8] types are. When they need to be multiplied or added, A[6,5] * A[7,8] will automatically the right __mul__ and similarly for addition. Q : That easy ?! :O A : No, this can only work for 'domain-preserving algorithms'. An algorithm which for example employs the division or the square root, shouldn't/wouldn't operate on Polys. It should return an Error, complaining about the bad groundtype. OR We could have type-conversion. For division-employing algorithms, we could convert the groundtype to RationalFunction, for squareroot- employing algorithms, we could convert to the Expr. Q : So the user has to be smart enough to know why typify function to use for what ? A : Maybe or maybe not. We can always have automatic identification added in later. Q : What do you need from Polys for this ? A : Basically, I need an exhaustive set of groundtypes which in essence have the fundamental operators coded along with __eq__ for the zero-equivalence check. If someone (mattpap ?) could help me compile a list of groundtypes which I can extract from Polys with description of each and what operations it supports and, equally important, what it does not suuport. I may have used the terms 'ground type' to mean both 'ground domain' and 'ground type'. But I think my meaning is clear. This is just a simple idea that came in my mind which made me think 'why not ?'. Did I leave out/forget anything ? What does this idea lack ? Am I completely wrong ? I think, this idea is good enough to iterate over and build on, and would love to see the communities' modifications and suggestions. Cheers, Sherjil Ozair -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to sympy@googlegroups.com. To unsubscribe from this group, send email to sympy+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.