Operators are the most urgent issue. The current arg-tree and internal structure of TensMul and TensAdd do not make it easy to add new objects containing tensor expressions. My current idea is to refactor both TensMul and TensAdd, and relocate all index and symmetry manipulation logic to either a TIDS object or to a new object (let's say TensorContainer).
The TensorContainer option would be the best one, so that TensMul and possible future operators would all inherit that object. All index symmetry operations and indices contractions would be handled by TensorContainer, so that TensMul is no longer be the only such container. TensAdd is then a collection of TensorContainer. A derivative operator would then contain the derivative variable and a TensMul object, but I still have to make up my mind on how to exactly represent operators.
What about not storing index symmetry information inside the arg-tree? I mean, it could work in a way similar to the new assumptions, with a global dictionary storing such info. I am currently proposing such an approach for components data in a PR.
from sympy.tensor.tensor import *
L = TensorIndexType('L')
i0, i1, i2 = tensor_indices('i0:3', L)
A = tensorhead('A', [L]*2, [[1]*2])
The arguments
>>> A(i0, i1).args
(1, (A(L,L),), (i0, i1))
>>> A(i0, -i0).args
(1, (A(L,L),), (dummy_index_0, -dummy_index_0))
>>> from sympy.unify import *
>>> list(unify(A(i0, i1), A(i0, i2), {}, variables=[i2]))
[{i2: i1}]
>>> list(unify(A(i0, -i0), A(i1, -i1), {}, variables=[i1]))
[{}]
--To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/0bcab04e-6d84-465e-8fa8-2592b28b8b3c%40googlegroups.com.
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 sy...@googlegroups.com.
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/CADDwiVC2dOYvobCDcjMBySQx8TS-j7peBsxk2NmqKBrMWqRBQQ%40mail.gmail.com.
--
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 sy...@googlegroups.com.
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/CAD8szLyr1qqFoKwUcOOCrcfs%2B%3DeretJ8g1bNAnb5CTJ0HrcY-w%40mail.gmail.com.
I don't know whether __eq__ overloading may be an issue to unify, as well as the standard __hash__ for tensor expressions.
The issue now is more about how to represent operators on tensors in a frozen state, eg partial derivative by an index or by a tensor.
Note that now some of the logic is also handled by an object called TIDS, whose purpose is just to contain the calculation data pertaining to TensMul.
And if you're not using .args then you don't adhere to the basic
invariants of SymPy.
PartialDerivative(A(i)*B(j, k)*A(-k) + C(-k, j, i)*A(k), A(h))D(-h)*PartialDerivative(A(i)*B(j, k)*A(-k) + C(-k, j, i)*A(k), A(h))
In any case, introducing operators requires some refactory of the current index algorithms. Fortunately there is now a separate TIDS class used to stored all such algorithms.
--
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 sy...@googlegroups.com.
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/eb0fdec5-18e6-47c3-b631-e3a791ab2f6e%40googlegroups.com.
Yeah, Wild subclasses from Expr, alas. The logpy solution is to have a dispatched isvar function.It seems to me that the all tensor indices are in some sense wild. Shouldn't A[i, -i] unify to A[j, -j] ?
--
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 sy...@googlegroups.com.
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/d7b6882e-d224-48b9-8261-bd5ff81cb84c%40googlegroups.com.
Right, but ideally A(i, -i, j) and A(j, -i, i) wouldn't unify. Actually in this sort of case I suppose that they would because it could be that i == j.
Generally speaking though unification variables do need match consistently within a term. (a, a) does not match to (1, 2). Perhaps we could consider all tensor indices on one side to be wild?
--
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 sy...@googlegroups.com.
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/CAD8szLxfMiWvhFxkELqSwFdJTauce8jr0%3DHz-AmiCA3UnGs%2BSw%40mail.gmail.com.
Yes, exactly. In Python, __eq__ really means equality, and things like sets and lists will assume objects that return True with __eq__ can be interchanged with one another. SymPy follows this convention. If a == b, any SymPy algorithm might interchange a with b and consider it to be valid.Also take a read of https://github.com/sympy/sympy/wiki/Automatic-Simplification. It's best to allow different things ways of writing mathematically the same thing to be written down differently, and deal with them being mathematically equal in algorithms.
--
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 sy...@googlegroups.com.
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/e9a07348-9bb1-48af-a93c-7e458bb5f0f2%40googlegroups.com.
There are probably little ways around these things, but nothing clean without dispatching in the core.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6L%2B0wx_h1YFT83swB90WwYq_fL3W6q-61frXxr-rUo0YQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6%2BOOW5iHNsOCbFW26A6zh7j%3DnCm57pNTu8hTCv8m81i5Q%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/CAKgW%3D6KynwwTuTnPtEzKL45vgUg5Q00zdxXc-jSQb9K_L8LtNA%40mail.gmail.com.