{"action":"created","issue":{"url":"https://api.github.com/repos/sympy/sympy/issues/9314","labels_url":"https://api.github.com/repos/sympy/sympy/issues/9314/labels{/name}","comments_url":"https://api.github.com/repos/sympy/sympy/issues/9314/comments","events_url":"https://api.github.com/repos/sympy/sympy/issues/9314/events","html_url":"https://github.com/sympy/sympy/pull/9314","id":69274238,"number":9314,"title":"tensor: Added EinsteinSum function for implicit sums with Indexed","user":{"login":"joshburkart","id":3888181,"avatar_url":"https://avatars.githubusercontent.com/u/3888181?v=3","gravatar_id":"","url":"https://api.github.com/users/joshburkart","html_url":"https://github.com/joshburkart","followers_url":"https://api.github.com/users/joshburkart/followers","following_url":"https://api.github.com/users/joshburkart/following{/other_user}","gists_url":"https://api.github.com/users/joshburkart/gists{/gist_id}","starred_url":"https://api.github.com/users/joshburkart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshburkart/subscriptions","organizations_url":"https://api.github.com/users/joshburkart/orgs","repos_url":"https://api.github.com/users/joshburkart/repos","events_url":"https://api.github.com/users/joshburkart/events{/privacy}","received_events_url":"https://api.github.com/users/joshburkart/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/sympy/sympy/labels/PR:%20author's%20turn","name":"PR: author's turn","color":"eb6420"},{"url":"https://api.github.com/repos/sympy/sympy/labels/tensor","name":"tensor","color":"0000FF"},{"url":"https://api.github.com/repos/sympy/sympy/labels/utilities.codegen","name":"utilities.codegen","color":"0000FF"},{"url":"https://api.github.com/repos/sympy/sympy/labels/utilities.lambdify","name":"utilities.lambdify","color":"0000FF"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":46,"created_at":"2015-04-18T06:13:42Z","updated_at":"2015-09-04T13:59:02Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/sympy/sympy/pulls/9314","html_url":"https://github.com/sympy/sympy/pull/9314","diff_url":"https://github.com/sympy/sympy/pull/9314.diff","patch_url":"https://github.com/sympy/sympy/pull/9314.patch"},"body":"Previously expressions with ``tensor.Indexed`` objects involving repeated indices automatically implied summation. This commit now requires wrapping an expression in the new ``EinsteinSum`` function for summation to be implied.\r\n\r\nIssues: #9284, #9185.\r\n\r\nEinsteinSum also has the following additional functionality:\r\n\r\n* Automatic generation of Python functions taking NumPy arrays:\r\n``EinsteinSum.numpify``.\r\n* Allows differentiation wrt other Indexed objects; e.g. now\r\n  ``h[i].diff(h[j]) = delta[i, j]`` instead of ``0``.\r\n* Correctly implements Einstein summation convention; e.g.\r\n  ``EinsteinSum(h[i]*h[i])`` *does* imply a sum over ``i`` (previously didn't).\r\n* Support for simplification: evaluation of trivial contractions with Kronecker delta tensors and renaming/reordering of contraction indices; e.g. ``EinsteinSum(x[i]*delta[i, j]*x[j] + x[k]*x[k]).simplify()`` produces ``EinsteinSum(2*x[i]*x[i])``.\r\n\r\nOther changes in the PR:\r\n\r\n* Added ``DeltaIndexedBase`` subclass of ``IndexedBase`` for Kronecker delta tensors.\r\n* Deprecated ``tensor.index_methods``.\r\n* Updated and improved tensor module's documentation.\r\n* Updated code printers to use ``EinsteinSum``.\r\n\r\nPotential issues with this commit:\r\n\r\n* In order to allow differentiation like ``h[i].diff(h[j]) = delta[i, j]``,\r\n  added hack to differentiation code in ``core.function``. Should be scrutinized.\r\n* No deprecation of former way of calling code generation routines (sans\r\n  ``EinsteinSum``). Not sure how best to do this.\r\n* Name = ``EinsteinSum``? ``ImplicitSum``? ``IndexedSum``?\r\n* Name = ``DeltaIndexedBase``?"},"comment":{"url":"https://api.github.com/repos/sympy/sympy/issues/comments/137744761","html_url":"https://github.com/sympy/sympy/pull/9314#issuecomment-137744761","issue_url":"https://api.github.com/repos/sympy/sympy/issues/9314","id":137744761,"user":{"login":"Upabjojr","id":4128856,"avatar_url":"https://avatars.githubusercontent.com/u/4128856?v=3","gravatar_id":"","url":"https://api.github.com/users/Upabjojr","html_url":"https://github.com/Upabjojr","followers_url":"https://api.github.com/users/Upabjojr/followers","following_url":"https://api.github.com/users/Upabjojr/following{/other_user}","gists_url":"https://api.github.com/users/Upabjojr/gists{/gist_id}","starred_url":"https://api.github.com/users/Upabjojr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Upabjojr/subscriptions","organizations_url":"https://api.github.com/users/Upabjojr/orgs","repos_url":"https://api.github.com/users/Upabjojr/repos","events_url":"https://api.github.com/users/Upabjojr/events{/privacy}","received_events_url":"https://api.github.com/users/Upabjojr/received_events","type":"User","site_admin":false},"created_at":"2015-09-04T13:59:02Z","updated_at":"2015-09-04T13:59:02Z","body":"I have an idea to reduce the amount of work to merge this PR:\r\n\r\ncreate a separate PR and add a dummy `EinsteinSum` object, e.g.:\r\n```\r\nclass EinsteinSum(object):\r\n    def __new__(arg):\r\n        return arg\r\n```\r\nPut a warning that `EinsteinSum` will become mandatory for the repeated-summation convention.\r\n\r\nWith this alternative modification, wait for a new version of SymPy, after whose release merge this PR."}}