> @Matthew Rocklin: would you try to generalize your multiple dispatch module to pattern dispatch?
The multipledispatch package will only be about dispatch against types. This package is intended for general programming and so efficiently covers the common case. However a long time ago though I was on a pattern matching and logic programming kick. There are old/derelict unify and strategies modules in SymPy as a result. Most development was eventually transferred to the LogPy project, an implementation of miniKanren. Among other things it held a basic unification/reification system, a dispatch system for those functions, and a less basic though still inefficient associative-commutative unification/reification system. In a SymPy branch I built up LogPy/SymPy integration and played with a simplification system that defined itself based on (source-pattern, target-pattern, boolean condition patterns) a la Abs(x) -> x if x is positive It worked fine but was slow in the case of associative-commutative operators. I'll throw up some links below. I suggest that if we want to continue this conversation we do it on a separate issue. https://github.com/logpy/logpy -- a logic programming system based on miniKanren https://github.com/mrocklin/sympy/tree/matrix-cookbook-logpy/sympy/logpy -- SymPy-LogPy interaction code https://github.com/mrocklin/sympy/blob/matrix-cookbook-logpy/sympy/matrices/expressions/simplifydata.py-- Example rewrite rules for Matrix Expressions The trick behind efficient pattern matching in our case is to match an input expression against all of the patterns at once. The patterns should be stored in a data structure like a Trie. This is relatively straightforward in the non-associative-commutative case but a mess in the associative-commutative case. Separating out matching from SymPy was nice. I was also targeting Theano simplifications at the same time. On Sat, Mar 22, 2014 at 7:03 AM, F. B. <[email protected]> wrote: > Please also take care of this bug: > > > https://github.com/sympy/sympy/blob/master/sympy/physics/hep/gamma_matrices.py#L8 > > DiracSpinorIndex is the index for the Dirac matrices, its dimension is > fixed to 4, it is a TensorIndexType, i.e. the class used to generate the > actual indices to be placed into tensor expressions. The Lorentz index > instead is contained inside a container class, which stores many Lorentz > index type objects, based on their dimension. > > The problem is that the gamma matrix dimension should be given by the > spinor index dimension, not by the Lorentz index dimension, which should > always be 4. Originally gamma matrices were meant to be tensors with a > single index, so the trick was to put their dimension into the Lorentz > index. Afterwards I decided to switch to a (Lorentz, Spinor, Spinor) type > tensor, in order to avoid dealing with the complications of having a tensor > of matrices. Unfortunately the dimensional marked remained on the Lorentz > index. > > Possible solutions: > > 1. get rid of the _LorentzContainer class and replace it with a global > LorentzIndex object. > 2. devise a better way to store the GammaMatrix dimension information. > > Unfortunately this is not a very easy task. > > -- > 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. > To view this discussion on the web visit > https://groups.google.com/d/msgid/sympy/2355c999-683b-43fe-90d2-7afd20e2e8ce%40googlegroups.com<https://groups.google.com/d/msgid/sympy/2355c999-683b-43fe-90d2-7afd20e2e8ce%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAJ8oX-Fws7i%2B5C4Q9DvU-F1%2BGkq%2BH_zNKDSkvTVg5PK-T%3Dw-tw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
