{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/79796809","id":79796809,"diff_hunk":"@@ -496,20 +498,71 @@ for (f,T) in ((:f32,Float32),(:f16,Float16))\n     end\n end\n \n-zeta(s::Integer, z::Number) = zeta(Int(s), f64(z))\n-zeta(s::Number, z::Number) = zeta(f64(s), f64(z))\n-for f in (:digamma, :trigamma)\n+\n+function zeta(s::Integer, z::Number) \n+    x = float(z)\n+    t = Int(s)\n+    if typeof(x) === typeof(z) && typeof(t) === typeof(s)\n+        throw MethodError(zeta,(s,t))\n+    end\n+    oftype(x, zeta(t, x))\n+end\n+\n+function zeta(s::Number, z::Number) \n+    x = float(z)\n+    t = float(s)\n+    if typeof(x) === typeof(z) && typeof(t) === typeof(s)\n+        throw MethodError(zeta,(s,t))\n+    end\n+    oftype(x, zeta(t, x))\n+end\n+\n+\n+function polygamma(m::Integer, z::Number)\n+    x = float(z)\n+    typeof(x) == typeof(z) && throw(MethodError(polygamma, (m,z))\n+    oftype(x,polygamma(m, x))\n+end\n+\n+\n+for f in (:digamma, :trigamma, :zeta, :eta, invdigamma)\n     @eval begin\n-        $f(z::Number) = $f(f64(z))\n+        $f(z::Base.BitInteger) = $f(Float64(z))\n+        $f(z::Float32) = Float32($f(Float64(z)))\n+        $f(z::Float16) = Float16($f(Float64(z)))\n+\n+        function $f(z::Number)\n+            x = float(z)\n+            typeof(x) == typeof(z) && throw(MethodError($f, (z,)))\n+            oftype(x, $f(x))\n+        end\n     end\n end\n-polygamma(m::Integer, z::Number) = polygamma(m, f64(z))\n \n-# Inverse digamma function:\n-# Implementation of fixed point algorithm described in\n-#  \"Estimating a Dirichlet distribution\" by Thomas P. Minka, 2000\n+for f in (:zeta, :eta)\n+    @eval begin\n+        $f{T<:Union{Base.BitInteger,Float32,Float16}}(x::t) = oftype(float(x), $f(Complex128(z)))","path":"base/special/gamma.jl","position":64,"original_position":64,"commit_id":"0254e89e9ae6f86ce185f635bc40e9be292ffa57","original_commit_id":"0254e89e9ae6f86ce185f635bc40e9be292ffa57","user":{"login":"CarloLucibello","id":7014210,"avatar_url":"https://avatars.githubusercontent.com/u/7014210?v=3","gravatar_id":"","url":"https://api.github.com/users/CarloLucibello","html_url":"https://github.com/CarloLucibello","followers_url":"https://api.github.com/users/CarloLucibello/followers","following_url":"https://api.github.com/users/CarloLucibello/following{/other_user}","gists_url":"https://api.github.com/users/CarloLucibello/gists{/gist_id}","starred_url":"https://api.github.com/users/CarloLucibello/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CarloLucibello/subscriptions","organizations_url":"https://api.github.com/users/CarloLucibello/orgs","repos_url":"https://api.github.com/users/CarloLucibello/repos","events_url":"https://api.github.com/users/CarloLucibello/events{/privacy}","received_events_url":"https://api.github.com/users/CarloLucibello/received_events","type":"User","site_admin":false},"body":"Complex128(x) ?","created_at":"2016-09-21T09:48:32Z","updated_at":"2016-09-21T09:48:32Z","html_url":"https://github.com/JuliaLang/julia/pull/18584#discussion_r79796809","pull_request_url":"https://api.github.com/repos/JuliaLang/julia/pulls/18584","_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/79796809"},"html":{"href":"https://github.com/JuliaLang/julia/pull/18584#discussion_r79796809"},"pull_request":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/18584"}}},"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/18584","id":85821644,"html_url":"https://github.com/JuliaLang/julia/pull/18584","diff_url":"https://github.com/JuliaLang/julia/pull/18584.diff","patch_url":"https://github.com/JuliaLang/julia/pull/18584.patch","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/18584","number":18584,"state":"open","locked":false,"title":"[WIP] Improve the Type consistency of Special Functions (Fixes #17474)","user":{"login":"oxinabox","id":5127634,"avatar_url":"https://avatars.githubusercontent.com/u/5127634?v=3","gravatar_id":"","url":"https://api.github.com/users/oxinabox","html_url":"https://github.com/oxinabox","followers_url":"https://api.github.com/users/oxinabox/followers","following_url":"https://api.github.com/users/oxinabox/following{/other_user}","gists_url":"https://api.github.com/users/oxinabox/gists{/gist_id}","starred_url":"https://api.github.com/users/oxinabox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oxinabox/subscriptions","organizations_url":"https://api.github.com/users/oxinabox/orgs","repos_url":"https://api.github.com/users/oxinabox/repos","events_url":"https://api.github.com/users/oxinabox/events{/privacy}","received_events_url":"https://api.github.com/users/oxinabox/received_events","type":"User","site_admin":false},"body":"As I found in #17474,\r\nthe various special functions tend to just blindly cast everything to Float64.\r\nRegardless of if it makes sense.\r\nThis is my attempt to fix that.\r\nAnd while I am at it, to make the return types also a little more consistent across the functions.\r\n\r\nThis is WIP, I'm not actually sure my tests pass, but I would like feedback as to if I am going about this in a sane way. \r\n\r\n\r\nThough these do need to move to SpecialFunctions.jl\r\n(cf: https://github.com/JuliaMath/SpecialFunctions.jl/issues/12)","created_at":"2016-09-19T16:02:57Z","updated_at":"2016-09-21T09:48:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2fccc61441eeb32be881676cd715549d8225e826","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/JuliaLang/julia/pulls/18584/commits","review_comments_url":"https://api.github.com/repos/JuliaLang/julia/pulls/18584/comments","review_comment_url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/18584/comments","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/0254e89e9ae6f86ce185f635bc40e9be292ffa57","head":{"label":"oxinabox:master","ref":"master","sha":"0254e89e9ae6f86ce185f635bc40e9be292ffa57","user":{"login":"oxinabox","id":5127634,"avatar_url":"https://avatars.githubusercontent.com/u/5127634?v=3","gravatar_id":"","url":"https://api.github.com/users/oxinabox","html_url":"https://github.com/oxinabox","followers_url":"https://api.github.com/users/oxinabox/followers","following_url":"https://api.github.com/users/oxinabox/following{/other_user}","gists_url":"https://api.github.com/users/oxinabox/gists{/gist_id}","starred_url":"https://api.github.com/users/oxinabox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oxinabox/subscriptions","organizations_url":"https://api.github.com/users/oxinabox/orgs","repos_url":"https://api.github.com/users/oxinabox/repos","events_url":"https://api.github.com/users/oxinabox/events{/privacy}","received_events_url":"https://api.github.com/users/oxinabox/received_events","type":"User","site_admin":false},"repo":{"id":68599240,"name":"julia","full_name":"oxinabox/julia","owner":{"login":"oxinabox","id":5127634,"avatar_url":"https://avatars.githubusercontent.com/u/5127634?v=3","gravatar_id":"","url":"https://api.github.com/users/oxinabox","html_url":"https://github.com/oxinabox","followers_url":"https://api.github.com/users/oxinabox/followers","following_url":"https://api.github.com/users/oxinabox/following{/other_user}","gists_url":"https://api.github.com/users/oxinabox/gists{/gist_id}","starred_url":"https://api.github.com/users/oxinabox/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oxinabox/subscriptions","organizations_url":"https://api.github.com/users/oxinabox/orgs","repos_url":"https://api.github.com/users/oxinabox/repos","events_url":"https://api.github.com/users/oxinabox/events{/privacy}","received_events_url":"https://api.github.com/users/oxinabox/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/oxinabox/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":true,"url":"https://api.github.com/repos/oxinabox/julia","forks_url":"https://api.github.com/repos/oxinabox/julia/forks","keys_url":"https://api.github.com/repos/oxinabox/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/oxinabox/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/oxinabox/julia/teams","hooks_url":"https://api.github.com/repos/oxinabox/julia/hooks","issue_events_url":"https://api.github.com/repos/oxinabox/julia/issues/events{/number}","events_url":"https://api.github.com/repos/oxinabox/julia/events","assignees_url":"https://api.github.com/repos/oxinabox/julia/assignees{/user}","branches_url":"https://api.github.com/repos/oxinabox/julia/branches{/branch}","tags_url":"https://api.github.com/repos/oxinabox/julia/tags","blobs_url":"https://api.github.com/repos/oxinabox/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/oxinabox/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/oxinabox/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/oxinabox/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/oxinabox/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/oxinabox/julia/languages","stargazers_url":"https://api.github.com/repos/oxinabox/julia/stargazers","contributors_url":"https://api.github.com/repos/oxinabox/julia/contributors","subscribers_url":"https://api.github.com/repos/oxinabox/julia/subscribers","subscription_url":"https://api.github.com/repos/oxinabox/julia/subscription","commits_url":"https://api.github.com/repos/oxinabox/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/oxinabox/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/oxinabox/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/oxinabox/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/oxinabox/julia/contents/{+path}","compare_url":"https://api.github.com/repos/oxinabox/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/oxinabox/julia/merges","archive_url":"https://api.github.com/repos/oxinabox/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/oxinabox/julia/downloads","issues_url":"https://api.github.com/repos/oxinabox/julia/issues{/number}","pulls_url":"https://api.github.com/repos/oxinabox/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/oxinabox/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/oxinabox/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/oxinabox/julia/labels{/name}","releases_url":"https://api.github.com/repos/oxinabox/julia/releases{/id}","deployments_url":"https://api.github.com/repos/oxinabox/julia/deployments","created_at":"2016-09-19T11:27:35Z","updated_at":"2016-09-19T11:27:44Z","pushed_at":"2016-09-19T15:55:38Z","git_url":"git://github.com/oxinabox/julia.git","ssh_url":"git@github.com:oxinabox/julia.git","clone_url":"https://github.com/oxinabox/julia.git","svn_url":"https://github.com/oxinabox/julia","homepage":"http://julialang.org/","size":98790,"stargazers_count":0,"watchers_count":0,"language":"Julia","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"JuliaLang:master","ref":"master","sha":"21936384b5d896aae4459e6859cbb8a1701dcd5f","user":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"repo":{"id":1644196,"name":"julia","full_name":"JuliaLang/julia","owner":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JuliaLang/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":false,"url":"https://api.github.com/repos/JuliaLang/julia","forks_url":"https://api.github.com/repos/JuliaLang/julia/forks","keys_url":"https://api.github.com/repos/JuliaLang/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JuliaLang/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JuliaLang/julia/teams","hooks_url":"https://api.github.com/repos/JuliaLang/julia/hooks","issue_events_url":"https://api.github.com/repos/JuliaLang/julia/issues/events{/number}","events_url":"https://api.github.com/repos/JuliaLang/julia/events","assignees_url":"https://api.github.com/repos/JuliaLang/julia/assignees{/user}","branches_url":"https://api.github.com/repos/JuliaLang/julia/branches{/branch}","tags_url":"https://api.github.com/repos/JuliaLang/julia/tags","blobs_url":"https://api.github.com/repos/JuliaLang/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JuliaLang/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JuliaLang/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/JuliaLang/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/JuliaLang/julia/languages","stargazers_url":"https://api.github.com/repos/JuliaLang/julia/stargazers","contributors_url":"https://api.github.com/repos/JuliaLang/julia/contributors","subscribers_url":"https://api.github.com/repos/JuliaLang/julia/subscribers","subscription_url":"https://api.github.com/repos/JuliaLang/julia/subscription","commits_url":"https://api.github.com/repos/JuliaLang/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/JuliaLang/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/JuliaLang/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/JuliaLang/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/JuliaLang/julia/contents/{+path}","compare_url":"https://api.github.com/repos/JuliaLang/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JuliaLang/julia/merges","archive_url":"https://api.github.com/repos/JuliaLang/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JuliaLang/julia/downloads","issues_url":"https://api.github.com/repos/JuliaLang/julia/issues{/number}","pulls_url":"https://api.github.com/repos/JuliaLang/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/JuliaLang/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/JuliaLang/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JuliaLang/julia/labels{/name}","releases_url":"https://api.github.com/repos/JuliaLang/julia/releases{/id}","deployments_url":"https://api.github.com/repos/JuliaLang/julia/deployments","created_at":"2011-04-21T07:01:50Z","updated_at":"2016-09-21T05:51:15Z","pushed_at":"2016-09-21T09:40:31Z","git_url":"git://github.com/JuliaLang/julia.git","ssh_url":"git@github.com:JuliaLang/julia.git","clone_url":"https://github.com/JuliaLang/julia.git","svn_url":"https://github.com/JuliaLang/julia","homepage":"http://julialang.org/","size":423201,"stargazers_count":7577,"watchers_count":7577,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1772,"mirror_url":null,"open_issues_count":1981,"forks":1772,"open_issues":1981,"watchers":7577,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/18584"},"html":{"href":"https://github.com/JuliaLang/julia/pull/18584"},"issue":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/18584"},"comments":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/18584/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/18584/comments"},"review_comment":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/18584/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaLang/julia/statuses/0254e89e9ae6f86ce185f635bc40e9be292ffa57"}}}}
{"actor":{"display_login":"CarloLucibello"}}