GitHub PullRequestReviewCommentEvent at 2014-07-02 16:53:01
Repository: csympy
Actor: certik
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/sympy/csympy/pulls/comments/14468779","id":14468779,"diff_hunk":"@@ -98,26 +98,37 @@ RCP<const Basic> pow(const RCP<const Basic> &a, const RCP<const Basic> &b)\n     if (eq(a, one)) return one;\n     if (eq(a, minus_one) && is_a<Integer>(*b))\n         return is_a<Integer>(*div(b, integer(2))) ? one : minus_one;\n+\n     if (is_a_Number(*a) && is_a_Number(*b)) {\n         if (is_a<Rational>(*a)) {\n             RCP<const Rational> exp_new = rcp_static_cast<const Rational>(a);\n-            if (abs(exp_new->i.get_num()) < abs(exp_new->i.get_den())) {\n-                // Rational is not of form num > den. Make it first and then return.\n-                if (is_a<Integer>(*b)) {\n-                    return pownum(exp_new->rdiv(*rcp_static_cast<const Number>(one)),\n-                                    rcp_static_cast<const Integer>(b)->mul(*rcp_static_cast<const Number>(minus_one)));\n-                } else {\n-                    // eval pow directly is not implemented in case of rational power\n-                    return rcp(new Pow(exp_new->rdiv(*rcp_static_cast<const Number>(one)), b));\n-                }\n+\n+            if (is_a<Integer>(*b)) {\n+                return pownum(exp_new, rcp_static_cast<const Integer>(b));\n             } else {\n-                // Rational is of form num > den\n-                if (is_a<Integer>(*b)) {\n-                    return pownum(exp_new, rcp_static_cast<const Integer>(b));\n-                } else {\n-                    // eval pow directly is not implemented in case of rational power\n-                    return rcp(new Pow(exp_new, b));\n+                // b is a Rational\n+                mpz_class q, r, num, den;\n+                num = rcp_static_cast<const Rational>(b)->i.get_num();\n+                den = rcp_static_cast<const Rational>(b)->i.get_den();\n+\n+                if (abs(num) > den) {\n+                    mpz_cdiv_qr(q.get_mpz_t(), r.get_mpz_t(), num.get_mpz_t(),\n+                        den.get_mpz_t());\n+\n+                    if (r < 0) {\n+                        r += den;\n+                        q -= 1;\n+                    }","path":"src/pow.cpp","position":53,"original_position":39,"commit_id":"0f3b988dab77105c39f365f5b016aa12b94110ca","original_commit_id":"68649ca7c36cbcd3e23169314f8e9cba727d7215","user":{"login":"certik","id":20568,"avatar_url":"https://avatars.githubusercontent.com/u/20568?","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":"Perfect.","created_at":"2014-07-02T16:53:01Z","updated_at":"2014-07-02T16:53:01Z","html_url":"https://github.com/sympy/csympy/pull/227#discussion_r14468779","pull_request_url":"https://api.github.com/repos/sympy/csympy/pulls/227","_links":{"self":{"href":"https://api.github.com/repos/sympy/csympy/pulls/comments/14468779"},"html":{"href":"https://github.com/sympy/csympy/pull/227#discussion_r14468779"},"pull_request":{"href":"https://api.github.com/repos/sympy/csympy/pulls/227"}}},"pull_request":{"url":"https://api.github.com/repos/sympy/csympy/pulls/227","id":17869017,"html_url":"https://github.com/sympy/csympy/pull/227","diff_url":"https://github.com/sympy/csympy/pull/227.diff","patch_url":"https://github.com/sympy/csympy/pull/227.patch","issue_url":"https://api.github.com/repos/sympy/csympy/issues/227","number":227,"state":"open","title":"Fix for #224: Fractional radical simplification","user":{"login":"thilinarmtb","id":1346780,"avatar_url":"https://avatars.githubusercontent.com/u/1346780?","gravatar_id":"8ccd21c14794d3d064b60a91526687f0","url":"https://api.github.com/users/thilinarmtb","html_url":"https://github.com/thilinarmtb","followers_url":"https://api.github.com/users/thilinarmtb/followers","following_url":"https://api.github.com/users/thilinarmtb/following{/other_user}","gists_url":"https://api.github.com/users/thilinarmtb/gists{/gist_id}","starred_url":"https://api.github.com/users/thilinarmtb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thilinarmtb/subscriptions","organizations_url":"https://api.github.com/users/thilinarmtb/orgs","repos_url":"https://api.github.com/users/thilinarmtb/repos","events_url":"https://api.github.com/users/thilinarmtb/events{/privacy}","received_events_url":"https://api.github.com/users/thilinarmtb/received_events","type":"User","site_admin":false},"body":"Fix for issue #224.","created_at":"2014-07-02T05:58:50Z","updated_at":"2014-07-02T16:53:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"17ab1a16ab959ab3c1f5bbddb9f4d871849d394f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sympy/csympy/pulls/227/commits","review_comments_url":"https://api.github.com/repos/sympy/csympy/pulls/227/comments","review_comment_url":"https://api.github.com/repos/sympy/csympy/pulls/comments/{number}","comments_url":"https://api.github.com/repos/sympy/csympy/issues/227/comments","statuses_url":"https://api.github.com/repos/sympy/csympy/statuses/0f3b988dab77105c39f365f5b016aa12b94110ca","head":{"label":"thilinarmtb:pow_simplification","ref":"pow_simplification","sha":"0f3b988dab77105c39f365f5b016aa12b94110ca","user":{"login":"thilinarmtb","id":1346780,"avatar_url":"https://avatars.githubusercontent.com/u/1346780?","gravatar_id":"8ccd21c14794d3d064b60a91526687f0","url":"https://api.github.com/users/thilinarmtb","html_url":"https://github.com/thilinarmtb","followers_url":"https://api.github.com/users/thilinarmtb/followers","following_url":"https://api.github.com/users/thilinarmtb/following{/other_user}","gists_url":"https://api.github.com/users/thilinarmtb/gists{/gist_id}","starred_url":"https://api.github.com/users/thilinarmtb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thilinarmtb/subscriptions","organizations_url":"https://api.github.com/users/thilinarmtb/orgs","repos_url":"https://api.github.com/users/thilinarmtb/repos","events_url":"https://api.github.com/users/thilinarmtb/events{/privacy}","received_events_url":"https://api.github.com/users/thilinarmtb/received_events","type":"User","site_admin":false},"repo":{"id":12099700,"name":"csympy","full_name":"thilinarmtb/csympy","owner":{"login":"thilinarmtb","id":1346780,"avatar_url":"https://avatars.githubusercontent.com/u/1346780?","gravatar_id":"8ccd21c14794d3d064b60a91526687f0","url":"https://api.github.com/users/thilinarmtb","html_url":"https://github.com/thilinarmtb","followers_url":"https://api.github.com/users/thilinarmtb/followers","following_url":"https://api.github.com/users/thilinarmtb/following{/other_user}","gists_url":"https://api.github.com/users/thilinarmtb/gists{/gist_id}","starred_url":"https://api.github.com/users/thilinarmtb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thilinarmtb/subscriptions","organizations_url":"https://api.github.com/users/thilinarmtb/orgs","repos_url":"https://api.github.com/users/thilinarmtb/repos","events_url":"https://api.github.com/users/thilinarmtb/events{/privacy}","received_events_url":"https://api.github.com/users/thilinarmtb/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/thilinarmtb/csympy","description":"Experimental SymPy core written in C++","fork":true,"url":"https://api.github.com/repos/thilinarmtb/csympy","forks_url":"https://api.github.com/repos/thilinarmtb/csympy/forks","keys_url":"https://api.github.com/repos/thilinarmtb/csympy/keys{/key_id}","collaborators_url":"https://api.github.com/repos/thilinarmtb/csympy/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/thilinarmtb/csympy/teams","hooks_url":"https://api.github.com/repos/thilinarmtb/csympy/hooks","issue_events_url":"https://api.github.com/repos/thilinarmtb/csympy/issues/events{/number}","events_url":"https://api.github.com/repos/thilinarmtb/csympy/events","assignees_url":"https://api.github.com/repos/thilinarmtb/csympy/assignees{/user}","branches_url":"https://api.github.com/repos/thilinarmtb/csympy/branches{/branch}","tags_url":"https://api.github.com/repos/thilinarmtb/csympy/tags","blobs_url":"https://api.github.com/repos/thilinarmtb/csympy/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/thilinarmtb/csympy/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/thilinarmtb/csympy/git/refs{/sha}","trees_url":"https://api.github.com/repos/thilinarmtb/csympy/git/trees{/sha}","statuses_url":"https://api.github.com/repos/thilinarmtb/csympy/statuses/{sha}","languages_url":"https://api.github.com/repos/thilinarmtb/csympy/languages","stargazers_url":"https://api.github.com/repos/thilinarmtb/csympy/stargazers","contributors_url":"https://api.github.com/repos/thilinarmtb/csympy/contributors","subscribers_url":"https://api.github.com/repos/thilinarmtb/csympy/subscribers","subscription_url":"https://api.github.com/repos/thilinarmtb/csympy/subscription","commits_url":"https://api.github.com/repos/thilinarmtb/csympy/commits{/sha}","git_commits_url":"https://api.github.com/repos/thilinarmtb/csympy/git/commits{/sha}","comments_url":"https://api.github.com/repos/thilinarmtb/csympy/comments{/number}","issue_comment_url":"https://api.github.com/repos/thilinarmtb/csympy/issues/comments/{number}","contents_url":"https://api.github.com/repos/thilinarmtb/csympy/contents/{+path}","compare_url":"https://api.github.com/repos/thilinarmtb/csympy/compare/{base}...{head}","merges_url":"https://api.github.com/repos/thilinarmtb/csympy/merges","archive_url":"https://api.github.com/repos/thilinarmtb/csympy/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/thilinarmtb/csympy/downloads","issues_url":"https://api.github.com/repos/thilinarmtb/csympy/issues{/number}","pulls_url":"https://api.github.com/repos/thilinarmtb/csympy/pulls{/number}","milestones_url":"https://api.github.com/repos/thilinarmtb/csympy/milestones{/number}","notifications_url":"https://api.github.com/repos/thilinarmtb/csympy/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/thilinarmtb/csympy/labels{/name}","releases_url":"https://api.github.com/repos/thilinarmtb/csympy/releases{/id}","created_at":"2013-08-14T04:11:44Z","updated_at":"2014-06-25T08:28:23Z","pushed_at":"2014-07-02T16:37:22Z","git_url":"git://github.com/thilinarmtb/csympy.git","ssh_url":"git@github.com:thilinarmtb/csympy.git","clone_url":"https://github.com/thilinarmtb/csympy.git","svn_url":"https://github.com/thilinarmtb/csympy","homepage":"http://sympy.org","size":2080,"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":"9a41fabd3f91b594e009c2b61189eb8a02588b60","user":{"login":"sympy","id":260832,"avatar_url":"https://avatars.githubusercontent.com/u/260832?","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?","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-06-29T23:14:14Z","pushed_at":"2014-07-02T14:13:06Z","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":5006,"stargazers_count":26,"watchers_count":26,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":false,"forks_count":26,"mirror_url":null,"open_issues_count":49,"forks":26,"open_issues":49,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sympy/csympy/pulls/227"},"html":{"href":"https://github.com/sympy/csympy/pull/227"},"issue":{"href":"https://api.github.com/repos/sympy/csympy/issues/227"},"comments":{"href":"https://api.github.com/repos/sympy/csympy/issues/227/comments"},"review_comments":{"href":"https://api.github.com/repos/sympy/csympy/pulls/227/comments"},"review_comment":{"href":"https://api.github.com/repos/sympy/csympy/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/sympy/csympy/pulls/227/commits"},"statuses":{"href":"https://api.github.com/repos/sympy/csympy/statuses/0f3b988dab77105c39f365f5b016aa12b94110ca"}}}}