Google Summer of Code Week 10: Matrix Wildcard Redux

Posted on August 6, 2019 by Ankit Pandey

For this week, I’ve made some more minor changes to the Indexed pull request from last week, in addition to filing a new matrix wildcard pull request.

Matrix Wildcards (again)

Since #17223 was merged this week, I started with an implementation of matrix wildcards that takes advantage of the functionality included in the pull request. I thought that this would be relatively straightforward, with an implementation of the matches method for the MatrixWild subclass being enough. There was one problem though: the underlying matching implementation assumes that all powers in the expression are an instance of the Pow class. However, this isn’t true for matrix expressions: the MatPow class, which represents matrix powers, is a subclass of its own. I’m not exactly sure what the reason for this is, since a quick change of MatPow to inherit from Pow doesn’t seem to break anything. I’ll probably look into this a bit more, since I think this might have something to do with the fact that Matrix exponents can also include other matrices.

My solution for this was to allow temporarily allow expansion of powers by recursing through the expression tree and setting the is_Pow field of each matrix power to True and later reverting these states later. It doesn’t look pretty, but it does seem to work (you can see the code here).

Next Steps

I’ll try to get started with some optimizations that utilize this wildcard class once the pull request gets merged.