GitHub PullRequestReviewCommentEvent at 2014-08-07 17:11:20
Repository: csympy
Actor: certik
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/sympy/csympy/pulls/comments/15948958","id":15948958,"diff_hunk":"@@ -2135,6 +2135,184 @@ RCP<const Basic> ACoth::create(const RCP<const Basic> &arg) const\n     return acoth(arg);\n }\n \n+KroneckerDelta::KroneckerDelta(const RCP<const Basic> &i, const RCP<const Basic> &j)\n+    :i_{i}, j_{j}\n+{\n+    CSYMPY_ASSERT(is_canonical(i_, j_))\n+}\n+\n+bool KroneckerDelta::is_canonical(const RCP<const Basic> &i, const RCP<const Basic> &j)\n+{\n+    RCP<const Basic> diff = expand(sub(i, j));\n+    if (eq(diff, zero)) {\n+        return false;\n+    } else if (is_a_Number(*diff)) {\n+        return false;\n+    } else {\n+        // TODO: SymPy uses default key sorting to return in order\n+        return true;\n+    }\n+}\n+\n+bool KroneckerDelta::__eq__(const Basic &o) const\n+{\n+    if (is_a<KroneckerDelta>(o) &&\n+        eq(i_, static_cast<const KroneckerDelta &>(o).i_) &&\n+        eq(j_, static_cast<const KroneckerDelta &>(o).j_))\n+        return true;\n+    else\n+        return false;\n+}\n+\n+int KroneckerDelta::compare(const Basic &o) const\n+{\n+    CSYMPY_ASSERT(is_a<KroneckerDelta>(o))\n+    const KroneckerDelta &s = static_cast<const KroneckerDelta &>(o);\n+    return i_->__cmp__(*(s.i_));\n+}\n+\n+std::size_t KroneckerDelta::__hash__() const\n+{\n+    std::size_t seed = 0;\n+    hash_combine<Basic>(seed, *i_);\n+    hash_combine<Basic>(seed, *j_);\n+    return seed;\n+}\n+\n+std::string KroneckerDelta::__str__() const\n+{\n+    std::ostringstream o;\n+    o << \"KroneckerDelta(\" << *i_ << \", \" << *j_ << \")\";\n+    return o.str();\n+}\n+\n+RCP<const Basic> kronecker_delta(const RCP<const Basic> &i, const RCP<const Basic> &j)\n+{\n+    RCP<const Basic> diff = expand(sub(i, j));\n+    if (eq(diff, zero)) {\n+        return one;\n+    } else if (is_a_Number(*diff)) {\n+        return zero;\n+    } else {\n+        // SymPy uses default key sorting to return in order\n+        return rcp(new KroneckerDelta(i, j));\n+    }\n+}\n+\n+bool has_dup(const vec_basic &arg)\n+{\n+    map_basic_basic d;\n+    auto it = d.end();\n+    for (auto &p: arg) {\n+        it = d.find(p);\n+        if (it == d.end()) {\n+            insert(d, p, one);\n+        } else {\n+            return true;\n+        }\n+    }\n+    return false;\n+}\n+\n+LeviCivita::LeviCivita(vec_basic&& arg)\n+    :arg_{std::move(arg)}\n+{\n+    CSYMPY_ASSERT(is_canonical(arg_))\n+}\n+\n+bool LeviCivita::is_canonical(const vec_basic &arg)\n+{\n+    bool are_int = true;\n+    for (auto &p: arg) {\n+        if (!(is_a_Number(*p))) {\n+            are_int = false;\n+            break;\n+        }\n+    }\n+    if (are_int) {\n+        return false;\n+    } else if (has_dup(arg)) {\n+        return false;\n+    } else {\n+        return true;\n+    }\n+}\n+\n+bool LeviCivita::__eq__(const Basic &o) const\n+{\n+    if (is_a<LeviCivita>(o) &&\n+        vec_basic_eq(arg_, static_cast<const LeviCivita &>(o).arg_))\n+        return true;\n+    else\n+        return false;\n+}\n+\n+int LeviCivita::compare(const Basic &o) const\n+{\n+    CSYMPY_ASSERT(is_a<LeviCivita>(o))\n+    const LeviCivita &s = static_cast<const LeviCivita &>(o);\n+    // # of elements\n+    if (arg_.size() != s.arg_.size())\n+        return (arg_.size() < s.arg_.size()) ? -1 : 1;\n+    return vec_basic_compare(arg_, s.arg_);\n+}\n+\n+std::size_t LeviCivita::__hash__() const\n+{\n+    std::size_t seed = 0;\n+    for (auto &p: arg_) {\n+        hash_combine<Basic>(seed, *p);\n+    }\n+    return seed;\n+}\n+\n+std::string LeviCivita::__str__() const\n+{\n+    std::ostringstream o;\n+    o << \"LeviCivita(\";\n+    for (auto &p: arg_) {\n+        o << *p << \", \";\n+    }\n+    std::string s = o.str();\n+    s = s.substr(0, s.size()-2);\n+    s.append(\")\");\n+    return s;\n+}\n+\n+RCP<const Basic> eval_levicivita(vec_basic arg, int len)","path":"src/functions.cpp","position":148,"original_position":148,"commit_id":"10da35b13fd5c3e19ff16870fa4c1e8c3533ebcd","original_commit_id":"10da35b13fd5c3e19ff16870fa4c1e8c3533ebcd","user":{"login":"certik","id":20568,"avatar_url":"https://avatars.githubusercontent.com/u/20568?v=2","gravatar_id":"29d62e4d73bf4a16a7755f6862a6031f","url":"https://api.github.com/users/certik","html_url":"https://github.com/certik","followers_url":"https://api.github.com/users/certik/followers","following_url":"https://api.github.com/users/certik/following{/other_user}","gists_url":"https://api.github.com/users/certik/gists{/gist_id}","starred_url":"https://api.github.com/users/certik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/certik/subscriptions","organizations_url":"https://api.github.com/users/certik/orgs","repos_url":"https://api.github.com/users/certik/repos","events_url":"https://api.github.com/users/certik/events{/privacy}","received_events_url":"https://api.github.com/users/certik/received_events","type":"User","site_admin":false},"body":"Use `const vec_basic &arg`.","created_at":"2014-08-07T17:11:20Z","updated_at":"2014-08-07T17:11:20Z","html_url":"https://github.com/sympy/csympy/pull/267#discussion_r15948958","pull_request_url":"https://api.github.com/repos/sympy/csympy/pulls/267","_links":{"self":{"href":"https://api.github.com/repos/sympy/csympy/pulls/comments/15948958"},"html":{"href":"https://github.com/sympy/csympy/pull/267#discussion_r15948958"},"pull_request":{"href":"https://api.github.com/repos/sympy/csympy/pulls/267"}}},"pull_request":{"url":"https://api.github.com/repos/sympy/csympy/pulls/267","id":19258604,"html_url":"https://github.com/sympy/csympy/pull/267","diff_url":"https://github.com/sympy/csympy/pull/267.diff","patch_url":"https://github.com/sympy/csympy/pull/267.patch","issue_url":"https://api.github.com/repos/sympy/csympy/issues/267","number":267,"state":"open","title":"Tensor Module","user":{"login":"sushant-hiray","id":2182581,"avatar_url":"https://avatars.githubusercontent.com/u/2182581?v=2","gravatar_id":"03db473da44b1eb6d892a71846a59b45","url":"https://api.github.com/users/sushant-hiray","html_url":"https://github.com/sushant-hiray","followers_url":"https://api.github.com/users/sushant-hiray/followers","following_url":"https://api.github.com/users/sushant-hiray/following{/other_user}","gists_url":"https://api.github.com/users/sushant-hiray/gists{/gist_id}","starred_url":"https://api.github.com/users/sushant-hiray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sushant-hiray/subscriptions","organizations_url":"https://api.github.com/users/sushant-hiray/orgs","repos_url":"https://api.github.com/users/sushant-hiray/repos","events_url":"https://api.github.com/users/sushant-hiray/events{/privacy}","received_events_url":"https://api.github.com/users/sushant-hiray/received_events","type":"User","site_admin":false},"body":"This will comprise:\r\n- [x] KroneckerDelta\r\n- [x] LeviCivita\r\n\r\n`KroneckerDelta` makes uses of the Assumptions Module to define some more properties such as `is_above_fermi` `is_below_fermi`. These will currenly not be implemented.\r\n\r\n`LeviCivita` comprises of variable number of arguments. There is an answer for this [SO Question](http://stackoverflow.com/questions/1579719/variable-number-of-parameters-in-function-in-c) which deals with the variable arguments case. This will be implemented after further discussion.","created_at":"2014-08-03T19:41:44Z","updated_at":"2014-08-07T17:11:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6633a89e7aa70f6c02c41a18daa6ab6fdb1053c1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sympy/csympy/pulls/267/commits","review_comments_url":"https://api.github.com/repos/sympy/csympy/pulls/267/comments","review_comment_url":"https://api.github.com/repos/sympy/csympy/pulls/comments/{number}","comments_url":"https://api.github.com/repos/sympy/csympy/issues/267/comments","statuses_url":"https://api.github.com/repos/sympy/csympy/statuses/10da35b13fd5c3e19ff16870fa4c1e8c3533ebcd","head":{"label":"sushant-hiray:tensor","ref":"tensor","sha":"10da35b13fd5c3e19ff16870fa4c1e8c3533ebcd","user":{"login":"sushant-hiray","id":2182581,"avatar_url":"https://avatars.githubusercontent.com/u/2182581?v=2","gravatar_id":"03db473da44b1eb6d892a71846a59b45","url":"https://api.github.com/users/sushant-hiray","html_url":"https://github.com/sushant-hiray","followers_url":"https://api.github.com/users/sushant-hiray/followers","following_url":"https://api.github.com/users/sushant-hiray/following{/other_user}","gists_url":"https://api.github.com/users/sushant-hiray/gists{/gist_id}","starred_url":"https://api.github.com/users/sushant-hiray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sushant-hiray/subscriptions","organizations_url":"https://api.github.com/users/sushant-hiray/orgs","repos_url":"https://api.github.com/users/sushant-hiray/repos","events_url":"https://api.github.com/users/sushant-hiray/events{/privacy}","received_events_url":"https://api.github.com/users/sushant-hiray/received_events","type":"User","site_admin":false},"repo":{"id":17418292,"name":"csympy","full_name":"sushant-hiray/csympy","owner":{"login":"sushant-hiray","id":2182581,"avatar_url":"https://avatars.githubusercontent.com/u/2182581?v=2","gravatar_id":"03db473da44b1eb6d892a71846a59b45","url":"https://api.github.com/users/sushant-hiray","html_url":"https://github.com/sushant-hiray","followers_url":"https://api.github.com/users/sushant-hiray/followers","following_url":"https://api.github.com/users/sushant-hiray/following{/other_user}","gists_url":"https://api.github.com/users/sushant-hiray/gists{/gist_id}","starred_url":"https://api.github.com/users/sushant-hiray/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sushant-hiray/subscriptions","organizations_url":"https://api.github.com/users/sushant-hiray/orgs","repos_url":"https://api.github.com/users/sushant-hiray/repos","events_url":"https://api.github.com/users/sushant-hiray/events{/privacy}","received_events_url":"https://api.github.com/users/sushant-hiray/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sushant-hiray/csympy","description":"Fast symbolic manipulation library, written in C++","fork":true,"url":"https://api.github.com/repos/sushant-hiray/csympy","forks_url":"https://api.github.com/repos/sushant-hiray/csympy/forks","keys_url":"https://api.github.com/repos/sushant-hiray/csympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sushant-hiray/csympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sushant-hiray/csympy/teams","hooks_url":"https://api.github.com/repos/sushant-hiray/csympy/hooks","issue_events_url":"https://api.github.com/repos/sushant-hiray/csympy/issues/events{/number}","events_url":"https://api.github.com/repos/sushant-hiray/csympy/events","assignees_url":"https://api.github.com/repos/sushant-hiray/csympy/assignees{/user}","branches_url":"https://api.github.com/repos/sushant-hiray/csympy/branches{/branch}","tags_url":"https://api.github.com/repos/sushant-hiray/csympy/tags","blobs_url":"https://api.github.com/repos/sushant-hiray/csympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sushant-hiray/csympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sushant-hiray/csympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/sushant-hiray/csympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sushant-hiray/csympy/statuses/{sha}","languages_url":"https://api.github.com/repos/sushant-hiray/csympy/languages","stargazers_url":"https://api.github.com/repos/sushant-hiray/csympy/stargazers","contributors_url":"https://api.github.com/repos/sushant-hiray/csympy/contributors","subscribers_url":"https://api.github.com/repos/sushant-hiray/csympy/subscribers","subscription_url":"https://api.github.com/repos/sushant-hiray/csympy/subscription","commits_url":"https://api.github.com/repos/sushant-hiray/csympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/sushant-hiray/csympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/sushant-hiray/csympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/sushant-hiray/csympy/issues/comments/{number}","contents_url":"https://api.github.com/repos/sushant-hiray/csympy/contents/{+path}","compare_url":"https://api.github.com/repos/sushant-hiray/csympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sushant-hiray/csympy/merges","archive_url":"https://api.github.com/repos/sushant-hiray/csympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sushant-hiray/csympy/downloads","issues_url":"https://api.github.com/repos/sushant-hiray/csympy/issues{/number}","pulls_url":"https://api.github.com/repos/sushant-hiray/csympy/pulls{/number}","milestones_url":"https://api.github.com/repos/sushant-hiray/csympy/milestones{/number}","notifications_url":"https://api.github.com/repos/sushant-hiray/csympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sushant-hiray/csympy/labels{/name}","releases_url":"https://api.github.com/repos/sushant-hiray/csympy/releases{/id}","created_at":"2014-03-04T21:47:08Z","updated_at":"2014-06-25T06:07:36Z","pushed_at":"2014-08-06T06:36:56Z","git_url":"git://github.com/sushant-hiray/csympy.git","ssh_url":"git@github.com:sushant-hiray/csympy.git","clone_url":"https://github.com/sushant-hiray/csympy.git","svn_url":"https://github.com/sushant-hiray/csympy","homepage":"http://sympy.org","size":3318,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"sympy:master","ref":"master","sha":"fcefa914305dfc451edb64e72cc52be6413a0d07","user":{"login":"sympy","id":260832,"avatar_url":"https://avatars.githubusercontent.com/u/260832?v=2","gravatar_id":"cbddfebe00a15f38108875eaafa827de","url":"https://api.github.com/users/sympy","html_url":"https://github.com/sympy","followers_url":"https://api.github.com/users/sympy/followers","following_url":"https://api.github.com/users/sympy/following{/other_user}","gists_url":"https://api.github.com/users/sympy/gists{/gist_id}","starred_url":"https://api.github.com/users/sympy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sympy/subscriptions","organizations_url":"https://api.github.com/users/sympy/orgs","repos_url":"https://api.github.com/users/sympy/repos","events_url":"https://api.github.com/users/sympy/events{/privacy}","received_events_url":"https://api.github.com/users/sympy/received_events","type":"Organization","site_admin":false},"repo":{"id":42376,"name":"csympy","full_name":"sympy/csympy","owner":{"login":"sympy","id":260832,"avatar_url":"https://avatars.githubusercontent.com/u/260832?v=2","gravatar_id":"cbddfebe00a15f38108875eaafa827de","url":"https://api.github.com/users/sympy","html_url":"https://github.com/sympy","followers_url":"https://api.github.com/users/sympy/followers","following_url":"https://api.github.com/users/sympy/following{/other_user}","gists_url":"https://api.github.com/users/sympy/gists{/gist_id}","starred_url":"https://api.github.com/users/sympy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sympy/subscriptions","organizations_url":"https://api.github.com/users/sympy/orgs","repos_url":"https://api.github.com/users/sympy/repos","events_url":"https://api.github.com/users/sympy/events{/privacy}","received_events_url":"https://api.github.com/users/sympy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sympy/csympy","description":"Fast symbolic manipulation library, written in C++","fork":false,"url":"https://api.github.com/repos/sympy/csympy","forks_url":"https://api.github.com/repos/sympy/csympy/forks","keys_url":"https://api.github.com/repos/sympy/csympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sympy/csympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sympy/csympy/teams","hooks_url":"https://api.github.com/repos/sympy/csympy/hooks","issue_events_url":"https://api.github.com/repos/sympy/csympy/issues/events{/number}","events_url":"https://api.github.com/repos/sympy/csympy/events","assignees_url":"https://api.github.com/repos/sympy/csympy/assignees{/user}","branches_url":"https://api.github.com/repos/sympy/csympy/branches{/branch}","tags_url":"https://api.github.com/repos/sympy/csympy/tags","blobs_url":"https://api.github.com/repos/sympy/csympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sympy/csympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sympy/csympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/sympy/csympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sympy/csympy/statuses/{sha}","languages_url":"https://api.github.com/repos/sympy/csympy/languages","stargazers_url":"https://api.github.com/repos/sympy/csympy/stargazers","contributors_url":"https://api.github.com/repos/sympy/csympy/contributors","subscribers_url":"https://api.github.com/repos/sympy/csympy/subscribers","subscription_url":"https://api.github.com/repos/sympy/csympy/subscription","commits_url":"https://api.github.com/repos/sympy/csympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/sympy/csympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/sympy/csympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/sympy/csympy/issues/comments/{number}","contents_url":"https://api.github.com/repos/sympy/csympy/contents/{+path}","compare_url":"https://api.github.com/repos/sympy/csympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sympy/csympy/merges","archive_url":"https://api.github.com/repos/sympy/csympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sympy/csympy/downloads","issues_url":"https://api.github.com/repos/sympy/csympy/issues{/number}","pulls_url":"https://api.github.com/repos/sympy/csympy/pulls{/number}","milestones_url":"https://api.github.com/repos/sympy/csympy/milestones{/number}","notifications_url":"https://api.github.com/repos/sympy/csympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sympy/csympy/labels{/name}","releases_url":"https://api.github.com/repos/sympy/csympy/releases{/id}","created_at":"2008-08-13T18:40:14Z","updated_at":"2014-08-01T23:04:04Z","pushed_at":"2014-08-07T17:05:48Z","git_url":"git://github.com/sympy/csympy.git","ssh_url":"git@github.com:sympy/csympy.git","clone_url":"https://github.com/sympy/csympy.git","svn_url":"https://github.com/sympy/csympy","homepage":"http://sympy.org","size":5947,"stargazers_count":30,"watchers_count":30,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"forks_count":28,"mirror_url":null,"open_issues_count":52,"forks":28,"open_issues":52,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sympy/csympy/pulls/267"},"html":{"href":"https://github.com/sympy/csympy/pull/267"},"issue":{"href":"https://api.github.com/repos/sympy/csympy/issues/267"},"comments":{"href":"https://api.github.com/repos/sympy/csympy/issues/267/comments"},"review_comments":{"href":"https://api.github.com/repos/sympy/csympy/pulls/267/comments"},"review_comment":{"href":"https://api.github.com/repos/sympy/csympy/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/sympy/csympy/pulls/267/commits"},"statuses":{"href":"https://api.github.com/repos/sympy/csympy/statuses/10da35b13fd5c3e19ff16870fa4c1e8c3533ebcd"}}}}