{"action":"created","comment":{"url":"https://api.github.com/repos/gonum/integrate/pulls/comments/66179338","id":66179338,"diff_hunk":"@@ -0,0 +1,383 @@\n+// Copyright ©2016 The gonum Authors. All rights reserved.\n+// Use of this source code is governed by a BSD-style\n+// license that can be found in the LICENSE file.\n+\n+package quad\n+\n+import (\n+\t\"math\"\n+\t\"math/cmplx\"\n+\n+\t\"github.com/gonum/floats\"\n+\t\"github.com/gonum/mathext/airy\"\n+)\n+\n+// Hermite integrates a function over the whole real line with negative\n+// squared exponential weight\n+//  int_-inf^inf e^-x^2 f(x) dx .\n+type Hermite struct{}\n+\n+func (h Hermite) FixedLocations(x, weight []float64, min, max float64) {\n+\t// TODO(btracey): Implement the case where x > 20, x < 200 so that we don't\n+\t// need to store all of that data.\n+\n+\t// References:\n+\t// Algorithm:\n+\t// G. H. Golub and J. A. Welsch, \"Calculation of Gauss quadrature rules\",\n+\t// Math. Comp. 23:221-230, 1969.\n+\t// A. Glaser, X. Liu and V. Rokhlin, \"A fast algorithm for the\n+\t// calculation of the roots of special functions\", SIAM Journal\n+\t// on Scientific Computing\", 29(4):1420-1438:, 2007.\n+\t// A. Townsend, T. Trogdon and S. Olver, Fast computation of Gauss\n+\t// nodes and weights on the whole real line, submitted, 2014.\n+\t//\n+\t// Algorithm adapted from Chubfun http://www.chebfun.org/.\n+\n+\tif len(x) != len(weight) {\n+\t\tpanic(\"hermite: slice length mismatch\")\n+\t}\n+\tif min >= max {\n+\t\tpanic(\"hermite: min >= max\")\n+\t}\n+\tif !math.IsInf(min, -1) || !math.IsInf(max, 1) {\n+\t\tpanic(\"hermite: non-infinite bound\")\n+\t}\n+\th.locations(x, weight)\n+}\n+\n+func (h Hermite) locations(x, weights []float64) {\n+\tn := len(x)\n+\tswitch {\n+\tdefault:\n+\t\tpanic(\"n<0\")\n+\tcase n <= 200:\n+\t\tcopy(x, xCacheHermite[n-1])\n+\t\tcopy(weights, wCacheHermite[n-1])\n+\tcase n > 200:\n+\t\txasy, weightsasy := h.locationsAsy(n)\n+\t\tcopy(x, xasy)\n+\t\tcopy(weights, weightsasy)\n+\t}\n+\treturn\n+}\n+\n+// Algorithm adapted from Chebfun http://www.chebfun.org/. Specific code\n+// https://github.com/chebfun/chebfun/blob/development/hermpts.m.\n+\n+// Original Copyright Notice:\n+\n+/*\n+Copyright (c) 2015, The Chancellor, Masters and Scholars of the University\n+of Oxford, and the Chebfun Developers. All rights reserved.\n+\n+Redistribution and use in source and binary forms, with or without\n+modification, are permitted provided that the following conditions are met:\n+    * Redistributions of source code must retain the above copyright\n+      notice, this list of conditions and the following disclaimer.\n+    * Redistributions in binary form must reproduce the above copyright\n+      notice, this list of conditions and the following disclaimer in the\n+      documentation and/or other materials provided with the distribution.\n+    * Neither the name of the University of Oxford nor the names of its\n+      contributors may be used to endorse or promote products derived from\n+      this software without specific prior written permission.\n+\n+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR\n+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n+*/\n+\n+func (h Hermite) locationsAsy(n int) (x, w []float64) {\n+\t// A. Townsend, T. Trogdon and S. Olver, Fast computation of Gauss\n+\t// nodes and weights on the whole real line, submitted, 2014.\n+\txa, wa := h.locationsAsy0(n)\n+\tif n%2 == 1 {\n+\t\tfor i := len(xa) - 1; i >= 0; i-- {\n+\t\t\tx = append(x, -xa[i])\n+\t\t\tw = append(w, wa[i])\n+\t\t}\n+\t\tfor i := 1; i < len(xa); i++ {\n+\t\t\tx = append(x, xa[i])\n+\t\t\tw = append(w, wa[i])\n+\t\t}\n+\t} else {\n+\t\tlxa := len(xa)\n+\t\tx = make([]float64, 2*lxa)\n+\t\tfor i, v := range xa {\n+\t\t\tx[lxa-1-i] = -v\n+\t\t\tx[lxa+i] = v\n+\t\t}\n+\t\tlwa := len(wa)\n+\t\tw = make([]float64, 2*lwa)\n+\t\tfor i, v := range wa {\n+\t\t\tw[lwa-1-i] = v\n+\t\t\tw[lwa+i] = v\n+\t\t}\n+\t}\n+\tsumW := floats.Sum(w)\n+\tc := math.SqrtPi / sumW\n+\tfloats.Scale(c, w)\n+\treturn x, w\n+}\n+\n+func (h Hermite) locationsAsy0(n int) (x, w []float64) {\n+\teps := math.Nextafter(1, math.Inf(1)) - 1\n+\t// Compute Hermite nodes and weights using asymptotic formula.\n+\tx0pts := h.hermiteInitialGuesses(n)\n+\ttheta0 := x0pts\n+\tfor i, x0 := range theta0 {\n+\t\tt0 := x0 / math.Sqrt(2*float64(n)+1)\n+\t\ttheta0[i] = math.Acos(t0)\n+\t}\n+\tdts := make([]float64, len(theta0))\n+\tvar val, dval []float64\n+\tfor k := 0; k < 20; k++ {\n+\t\tval, dval = h.hermpolyAsyAiry(n, theta0)\n+\t\tfor i, t0 := range theta0 {\n+\t\t\tdt := -val[i] / (math.Sqrt2 * math.Sqrt(2*float64(n)+1) * dval[i] * math.Sin(t0))\n+\t\t\ttheta0[i] = t0 - dt\n+\t\t\tdts[i] = dt\n+\t\t}\n+\t\tif floats.Norm(dts, math.Inf(1)) < math.Sqrt(eps)/10 {\n+\t\t\tbreak\n+\t\t}\n+\t}\n+\n+\tx = make([]float64, len(theta0))\n+\tw = make([]float64, len(theta0))\n+\tfor i, t := range theta0 {\n+\t\tt0 := math.Cos(t)\n+\t\txi := math.Sqrt(2*float64(n)+1) * t0\n+\t\tx[i] = xi\n+\t\tders := xi*val[i] + math.Sqrt2*dval[i]\n+\t\tw[i] = math.Exp(-xi*xi) / (ders * ders)\n+\t}\n+\treturn x, w\n+}\n+\n+// hermpolyAsyAiry evaluates the hermite polynomials using the Airy asymptotic","path":"hermite.go","position":164,"original_position":164,"commit_id":"91eefde6c2667106d784698dd30e1b500fabfd06","original_commit_id":"91eefde6c2667106d784698dd30e1b500fabfd06","user":{"login":"vladimir-ch","id":1837502,"avatar_url":"https://avatars.githubusercontent.com/u/1837502?v=3","gravatar_id":"","url":"https://api.github.com/users/vladimir-ch","html_url":"https://github.com/vladimir-ch","followers_url":"https://api.github.com/users/vladimir-ch/followers","following_url":"https://api.github.com/users/vladimir-ch/following{/other_user}","gists_url":"https://api.github.com/users/vladimir-ch/gists{/gist_id}","starred_url":"https://api.github.com/users/vladimir-ch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vladimir-ch/subscriptions","organizations_url":"https://api.github.com/users/vladimir-ch/orgs","repos_url":"https://api.github.com/users/vladimir-ch/repos","events_url":"https://api.github.com/users/vladimir-ch/events{/privacy}","received_events_url":"https://api.github.com/users/vladimir-ch/received_events","type":"User","site_admin":false},"body":"Hermite","created_at":"2016-06-08T01:06:52Z","updated_at":"2016-06-08T01:06:52Z","html_url":"https://github.com/gonum/integrate/pull/13#discussion_r66179338","pull_request_url":"https://api.github.com/repos/gonum/integrate/pulls/13","_links":{"self":{"href":"https://api.github.com/repos/gonum/integrate/pulls/comments/66179338"},"html":{"href":"https://github.com/gonum/integrate/pull/13#discussion_r66179338"},"pull_request":{"href":"https://api.github.com/repos/gonum/integrate/pulls/13"}}},"pull_request":{"url":"https://api.github.com/repos/gonum/integrate/pulls/13","id":64692645,"html_url":"https://github.com/gonum/integrate/pull/13","diff_url":"https://github.com/gonum/integrate/pull/13.diff","patch_url":"https://github.com/gonum/integrate/pull/13.patch","issue_url":"https://api.github.com/repos/gonum/integrate/issues/13","number":13,"state":"open","locked":false,"title":"Add Hermitian Quadrature","user":{"login":"btracey","id":3680859,"avatar_url":"https://avatars.githubusercontent.com/u/3680859?v=3","gravatar_id":"","url":"https://api.github.com/users/btracey","html_url":"https://github.com/btracey","followers_url":"https://api.github.com/users/btracey/followers","following_url":"https://api.github.com/users/btracey/following{/other_user}","gists_url":"https://api.github.com/users/btracey/gists{/gist_id}","starred_url":"https://api.github.com/users/btracey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/btracey/subscriptions","organizations_url":"https://api.github.com/users/btracey/orgs","repos_url":"https://api.github.com/users/btracey/repos","events_url":"https://api.github.com/users/btracey/events{/privacy}","received_events_url":"https://api.github.com/users/btracey/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-03-30T20:35:51Z","updated_at":"2016-06-08T01:06:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7750eee7d28172742ad7a813678267db85cefead","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/gonum/integrate/pulls/13/commits","review_comments_url":"https://api.github.com/repos/gonum/integrate/pulls/13/comments","review_comment_url":"https://api.github.com/repos/gonum/integrate/pulls/comments{/number}","comments_url":"https://api.github.com/repos/gonum/integrate/issues/13/comments","statuses_url":"https://api.github.com/repos/gonum/integrate/statuses/91eefde6c2667106d784698dd30e1b500fabfd06","head":{"label":"gonum:addhermite","ref":"addhermite","sha":"91eefde6c2667106d784698dd30e1b500fabfd06","user":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"repo":{"id":45565768,"name":"integrate","full_name":"gonum/integrate","owner":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gonum/integrate","description":"integrate implements routines for numerical integration for the Go language","fork":false,"url":"https://api.github.com/repos/gonum/integrate","forks_url":"https://api.github.com/repos/gonum/integrate/forks","keys_url":"https://api.github.com/repos/gonum/integrate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gonum/integrate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gonum/integrate/teams","hooks_url":"https://api.github.com/repos/gonum/integrate/hooks","issue_events_url":"https://api.github.com/repos/gonum/integrate/issues/events{/number}","events_url":"https://api.github.com/repos/gonum/integrate/events","assignees_url":"https://api.github.com/repos/gonum/integrate/assignees{/user}","branches_url":"https://api.github.com/repos/gonum/integrate/branches{/branch}","tags_url":"https://api.github.com/repos/gonum/integrate/tags","blobs_url":"https://api.github.com/repos/gonum/integrate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gonum/integrate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gonum/integrate/git/refs{/sha}","trees_url":"https://api.github.com/repos/gonum/integrate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gonum/integrate/statuses/{sha}","languages_url":"https://api.github.com/repos/gonum/integrate/languages","stargazers_url":"https://api.github.com/repos/gonum/integrate/stargazers","contributors_url":"https://api.github.com/repos/gonum/integrate/contributors","subscribers_url":"https://api.github.com/repos/gonum/integrate/subscribers","subscription_url":"https://api.github.com/repos/gonum/integrate/subscription","commits_url":"https://api.github.com/repos/gonum/integrate/commits{/sha}","git_commits_url":"https://api.github.com/repos/gonum/integrate/git/commits{/sha}","comments_url":"https://api.github.com/repos/gonum/integrate/comments{/number}","issue_comment_url":"https://api.github.com/repos/gonum/integrate/issues/comments{/number}","contents_url":"https://api.github.com/repos/gonum/integrate/contents/{+path}","compare_url":"https://api.github.com/repos/gonum/integrate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gonum/integrate/merges","archive_url":"https://api.github.com/repos/gonum/integrate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gonum/integrate/downloads","issues_url":"https://api.github.com/repos/gonum/integrate/issues{/number}","pulls_url":"https://api.github.com/repos/gonum/integrate/pulls{/number}","milestones_url":"https://api.github.com/repos/gonum/integrate/milestones{/number}","notifications_url":"https://api.github.com/repos/gonum/integrate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gonum/integrate/labels{/name}","releases_url":"https://api.github.com/repos/gonum/integrate/releases{/id}","deployments_url":"https://api.github.com/repos/gonum/integrate/deployments","created_at":"2015-11-04T20:34:34Z","updated_at":"2016-06-02T14:29:10Z","pushed_at":"2016-06-02T14:53:57Z","git_url":"git://github.com/gonum/integrate.git","ssh_url":"git@github.com:gonum/integrate.git","clone_url":"https://github.com/gonum/integrate.git","svn_url":"https://github.com/gonum/integrate","homepage":"","size":453,"stargazers_count":6,"watchers_count":6,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":6,"default_branch":"master"}},"base":{"label":"gonum:master","ref":"master","sha":"82caf9bae5c210bf5348863ea59473d295a15898","user":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"repo":{"id":45565768,"name":"integrate","full_name":"gonum/integrate","owner":{"login":"gonum","id":3771091,"avatar_url":"https://avatars.githubusercontent.com/u/3771091?v=3","gravatar_id":"","url":"https://api.github.com/users/gonum","html_url":"https://github.com/gonum","followers_url":"https://api.github.com/users/gonum/followers","following_url":"https://api.github.com/users/gonum/following{/other_user}","gists_url":"https://api.github.com/users/gonum/gists{/gist_id}","starred_url":"https://api.github.com/users/gonum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gonum/subscriptions","organizations_url":"https://api.github.com/users/gonum/orgs","repos_url":"https://api.github.com/users/gonum/repos","events_url":"https://api.github.com/users/gonum/events{/privacy}","received_events_url":"https://api.github.com/users/gonum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/gonum/integrate","description":"integrate implements routines for numerical integration for the Go language","fork":false,"url":"https://api.github.com/repos/gonum/integrate","forks_url":"https://api.github.com/repos/gonum/integrate/forks","keys_url":"https://api.github.com/repos/gonum/integrate/keys{/key_id}","collaborators_url":"https://api.github.com/repos/gonum/integrate/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/gonum/integrate/teams","hooks_url":"https://api.github.com/repos/gonum/integrate/hooks","issue_events_url":"https://api.github.com/repos/gonum/integrate/issues/events{/number}","events_url":"https://api.github.com/repos/gonum/integrate/events","assignees_url":"https://api.github.com/repos/gonum/integrate/assignees{/user}","branches_url":"https://api.github.com/repos/gonum/integrate/branches{/branch}","tags_url":"https://api.github.com/repos/gonum/integrate/tags","blobs_url":"https://api.github.com/repos/gonum/integrate/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/gonum/integrate/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/gonum/integrate/git/refs{/sha}","trees_url":"https://api.github.com/repos/gonum/integrate/git/trees{/sha}","statuses_url":"https://api.github.com/repos/gonum/integrate/statuses/{sha}","languages_url":"https://api.github.com/repos/gonum/integrate/languages","stargazers_url":"https://api.github.com/repos/gonum/integrate/stargazers","contributors_url":"https://api.github.com/repos/gonum/integrate/contributors","subscribers_url":"https://api.github.com/repos/gonum/integrate/subscribers","subscription_url":"https://api.github.com/repos/gonum/integrate/subscription","commits_url":"https://api.github.com/repos/gonum/integrate/commits{/sha}","git_commits_url":"https://api.github.com/repos/gonum/integrate/git/commits{/sha}","comments_url":"https://api.github.com/repos/gonum/integrate/comments{/number}","issue_comment_url":"https://api.github.com/repos/gonum/integrate/issues/comments{/number}","contents_url":"https://api.github.com/repos/gonum/integrate/contents/{+path}","compare_url":"https://api.github.com/repos/gonum/integrate/compare/{base}...{head}","merges_url":"https://api.github.com/repos/gonum/integrate/merges","archive_url":"https://api.github.com/repos/gonum/integrate/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/gonum/integrate/downloads","issues_url":"https://api.github.com/repos/gonum/integrate/issues{/number}","pulls_url":"https://api.github.com/repos/gonum/integrate/pulls{/number}","milestones_url":"https://api.github.com/repos/gonum/integrate/milestones{/number}","notifications_url":"https://api.github.com/repos/gonum/integrate/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/gonum/integrate/labels{/name}","releases_url":"https://api.github.com/repos/gonum/integrate/releases{/id}","deployments_url":"https://api.github.com/repos/gonum/integrate/deployments","created_at":"2015-11-04T20:34:34Z","updated_at":"2016-06-02T14:29:10Z","pushed_at":"2016-06-02T14:53:57Z","git_url":"git://github.com/gonum/integrate.git","ssh_url":"git@github.com:gonum/integrate.git","clone_url":"https://github.com/gonum/integrate.git","svn_url":"https://github.com/gonum/integrate","homepage":"","size":453,"stargazers_count":6,"watchers_count":6,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":2,"forks":2,"open_issues":2,"watchers":6,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/gonum/integrate/pulls/13"},"html":{"href":"https://github.com/gonum/integrate/pull/13"},"issue":{"href":"https://api.github.com/repos/gonum/integrate/issues/13"},"comments":{"href":"https://api.github.com/repos/gonum/integrate/issues/13/comments"},"review_comments":{"href":"https://api.github.com/repos/gonum/integrate/pulls/13/comments"},"review_comment":{"href":"https://api.github.com/repos/gonum/integrate/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/gonum/integrate/pulls/13/commits"},"statuses":{"href":"https://api.github.com/repos/gonum/integrate/statuses/91eefde6c2667106d784698dd30e1b500fabfd06"}}}}
{"actor":{"display_login":"vladimir-ch"}}