{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/pulls/comments/126798047","pull_request_review_id":49318237,"id":126798047,"diff_hunk":"@@ -0,0 +1,96 @@\n+# A truncated version of Stiefel’s Conjugate Residual method\n+# cr(A, b, Δ, rtol, itmax, verbose) solves the linear system 'A * x = b' or the least-squares problem :\n+# 'min ‖b - A * x‖²' within a region of fixed radius Δ.\n+#\n+# Marie-Ange Dahito, <marie-ange.dahito@polymtl.ca>\n+# Montreal, QC, June 2017\n+\n+export cr\n+\n+\"\"\"A truncated version of Stiefel’s Conjugate Residual method to solve the symmetric linear system Ax=b.\n+The matrix A must be positive semi-definite\n+\"\"\"\n+function cr{T <: Number}(A :: AbstractLinearOperator, b :: Vector{T}, atol :: Float64=1.0e-8, rtol :: Float64=1.0e-6, itmax :: Int=0, radius :: Float64=0., verbose :: Bool=true)\n+\n+  n = size(b, 1) # size of the problem\n+  (size(A, 1) == n & size(A, 2) == n) || error(\"Inconsistent problem size\")\n+  verbose && @printf(\"CR: system of %d equations in %d variables\\n\", n, n)\n+\n+  # Initial state.\n+  x = zeros(T, n) # initial estimation x = 0\n+  r = copy(b) # initial residual r = b - Ax = b\n+  Ar = A * r\n+  ρ = @kdot(n, r, Ar)\n+  ρ == 0.0 && return (x, Krylov.SimpleStats(true, false, [0.0], [], \"x = 0 is a zero-residual solution\"))\n+  p = copy(r)\n+  q = copy(Ar)\n+\n+  iter = 0\n+  itmax == 0 && (itmax = 2 * n)\n+\n+  m = 0.0\n+  mvalues = [m] # values of the quadratic model\n+  xNorm = 0.0\n+  xNorms = [xNorm] # Values of ‖x‖\n+  rNorm = @knrm2(n, r) # ‖r‖\n+  rNorms = [rNorm] # Values of ‖r‖\n+  ArNorm = @knrm2(n, Ar) # ‖Ar‖\n+  ArNorms = [ArNorm]\n+  ε = atol + rtol * rNorm\n+  verbose && @printf(\"%5s %6s %10s %10s %10s %10s\\n\", \"Iter\", \"‖x‖\", \"‖r‖\", \"q\", \"α\", \"σ\")\n+  verbose && @printf(\"    %d  %8.1e    %8.1e    %8.1e\", iter, xNorm, rNorm, m)\n+\n+  solved = rNorm <= ε\n+  tired = iter >= itmax\n+  on_boundary = false\n+  status = \"unknown\"\n+\n+  while ! (solved || tired)\n+    α = ρ / @kdot(n, q, q) # step\n+\n+    # Compute step size to boundary if applicable.\n+    σ = radius > 0.0 ? to_boundary(x, p, radius) : α\n+\n+    verbose && @printf(\"  %7.1e   %7.1e\\n\", α, σ);\n+\n+    # Move along p from x to the boundary if either\n+    # the next step leads outside the trust region or\n+    # we have nonpositive curvature.\n+    if (radius > 0.0) & (α > σ)\n+      α = σ\n+      on_boundary = true\n+    end\n+\n+    @kaxpy!(n,  α,  p, x)\n+    xNorm = @knrm2(n, x)\n+    push!(xNorms, xNorm)\n+    Ax = A * x\n+    m = - @kdot(n, b, x) + 0.5 * @kdot(n, x, Ax)","path":"src/cr.jl","position":68,"original_position":68,"commit_id":"e9fc2fff4cf3fa80a72bf7e39ab256cbbfb5fdd2","original_commit_id":"e9fc2fff4cf3fa80a72bf7e39ab256cbbfb5fdd2","user":{"login":"dpo","id":38760,"avatar_url":"https://avatars2.githubusercontent.com/u/38760?v=3","gravatar_id":"","url":"https://api.github.com/users/dpo","html_url":"https://github.com/dpo","followers_url":"https://api.github.com/users/dpo/followers","following_url":"https://api.github.com/users/dpo/following{/other_user}","gists_url":"https://api.github.com/users/dpo/gists{/gist_id}","starred_url":"https://api.github.com/users/dpo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpo/subscriptions","organizations_url":"https://api.github.com/users/dpo/orgs","repos_url":"https://api.github.com/users/dpo/repos","events_url":"https://api.github.com/users/dpo/events{/privacy}","received_events_url":"https://api.github.com/users/dpo/received_events","type":"User","site_admin":false},"body":"Same comment about `xNorm`.","created_at":"2017-07-11T20:24:05Z","updated_at":"2017-07-11T20:24:05Z","html_url":"https://github.com/JuliaSmoothOptimizers/Krylov.jl/pull/29#discussion_r126798047","pull_request_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/pulls/29","_links":{"self":{"href":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/pulls/comments/126798047"},"html":{"href":"https://github.com/JuliaSmoothOptimizers/Krylov.jl/pull/29#discussion_r126798047"},"pull_request":{"href":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/pulls/29"}}},"pull_request":{"url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/pulls/29","id":129753516,"html_url":"https://github.com/JuliaSmoothOptimizers/Krylov.jl/pull/29","diff_url":"https://github.com/JuliaSmoothOptimizers/Krylov.jl/pull/29.diff","patch_url":"https://github.com/JuliaSmoothOptimizers/Krylov.jl/pull/29.patch","issue_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/issues/29","number":29,"state":"open","locked":false,"title":"An implementation of cr","user":{"login":"DahitoMA","id":28715812,"avatar_url":"https://avatars1.githubusercontent.com/u/28715812?v=3","gravatar_id":"","url":"https://api.github.com/users/DahitoMA","html_url":"https://github.com/DahitoMA","followers_url":"https://api.github.com/users/DahitoMA/followers","following_url":"https://api.github.com/users/DahitoMA/following{/other_user}","gists_url":"https://api.github.com/users/DahitoMA/gists{/gist_id}","starred_url":"https://api.github.com/users/DahitoMA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DahitoMA/subscriptions","organizations_url":"https://api.github.com/users/DahitoMA/orgs","repos_url":"https://api.github.com/users/DahitoMA/repos","events_url":"https://api.github.com/users/DahitoMA/events{/privacy}","received_events_url":"https://api.github.com/users/DahitoMA/received_events","type":"User","site_admin":false},"body":"add cr method\r\nadd cr tests","created_at":"2017-07-10T19:19:46Z","updated_at":"2017-07-11T20:24:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"27f1c5137dcba924eb0d5119a0b254282413dc24","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/pulls/29/commits","review_comments_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/pulls/29/comments","review_comment_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/issues/29/comments","statuses_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/statuses/e9fc2fff4cf3fa80a72bf7e39ab256cbbfb5fdd2","head":{"label":"DahitoMA:master","ref":"master","sha":"e9fc2fff4cf3fa80a72bf7e39ab256cbbfb5fdd2","user":{"login":"DahitoMA","id":28715812,"avatar_url":"https://avatars1.githubusercontent.com/u/28715812?v=3","gravatar_id":"","url":"https://api.github.com/users/DahitoMA","html_url":"https://github.com/DahitoMA","followers_url":"https://api.github.com/users/DahitoMA/followers","following_url":"https://api.github.com/users/DahitoMA/following{/other_user}","gists_url":"https://api.github.com/users/DahitoMA/gists{/gist_id}","starred_url":"https://api.github.com/users/DahitoMA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DahitoMA/subscriptions","organizations_url":"https://api.github.com/users/DahitoMA/orgs","repos_url":"https://api.github.com/users/DahitoMA/repos","events_url":"https://api.github.com/users/DahitoMA/events{/privacy}","received_events_url":"https://api.github.com/users/DahitoMA/received_events","type":"User","site_admin":false},"repo":{"id":93880291,"name":"Krylov.jl","full_name":"DahitoMA/Krylov.jl","owner":{"login":"DahitoMA","id":28715812,"avatar_url":"https://avatars1.githubusercontent.com/u/28715812?v=3","gravatar_id":"","url":"https://api.github.com/users/DahitoMA","html_url":"https://github.com/DahitoMA","followers_url":"https://api.github.com/users/DahitoMA/followers","following_url":"https://api.github.com/users/DahitoMA/following{/other_user}","gists_url":"https://api.github.com/users/DahitoMA/gists{/gist_id}","starred_url":"https://api.github.com/users/DahitoMA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DahitoMA/subscriptions","organizations_url":"https://api.github.com/users/DahitoMA/orgs","repos_url":"https://api.github.com/users/DahitoMA/repos","events_url":"https://api.github.com/users/DahitoMA/events{/privacy}","received_events_url":"https://api.github.com/users/DahitoMA/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DahitoMA/Krylov.jl","description":"A Julia Basket of Hand-Picked Krylov Methods","fork":true,"url":"https://api.github.com/repos/DahitoMA/Krylov.jl","forks_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/forks","keys_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/teams","hooks_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/hooks","issue_events_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/issues/events{/number}","events_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/events","assignees_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/assignees{/user}","branches_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/branches{/branch}","tags_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/tags","blobs_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/languages","stargazers_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/stargazers","contributors_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/contributors","subscribers_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/subscribers","subscription_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/subscription","commits_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/contents/{+path}","compare_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/merges","archive_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/downloads","issues_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/issues{/number}","pulls_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/labels{/name}","releases_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/releases{/id}","deployments_url":"https://api.github.com/repos/DahitoMA/Krylov.jl/deployments","created_at":"2017-06-09T17:08:22Z","updated_at":"2017-06-09T17:08:23Z","pushed_at":"2017-07-11T19:50:05Z","git_url":"git://github.com/DahitoMA/Krylov.jl.git","ssh_url":"git@github.com:DahitoMA/Krylov.jl.git","clone_url":"https://github.com/DahitoMA/Krylov.jl.git","svn_url":"https://github.com/DahitoMA/Krylov.jl","homepage":null,"size":321,"stargazers_count":0,"watchers_count":0,"language":"Julia","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"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":"JuliaSmoothOptimizers:master","ref":"master","sha":"20a5fa0364e248f0cbe15d8ce8ba218735f846a8","user":{"login":"JuliaSmoothOptimizers","id":15710294,"avatar_url":"https://avatars1.githubusercontent.com/u/15710294?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaSmoothOptimizers","html_url":"https://github.com/JuliaSmoothOptimizers","followers_url":"https://api.github.com/users/JuliaSmoothOptimizers/followers","following_url":"https://api.github.com/users/JuliaSmoothOptimizers/following{/other_user}","gists_url":"https://api.github.com/users/JuliaSmoothOptimizers/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaSmoothOptimizers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaSmoothOptimizers/subscriptions","organizations_url":"https://api.github.com/users/JuliaSmoothOptimizers/orgs","repos_url":"https://api.github.com/users/JuliaSmoothOptimizers/repos","events_url":"https://api.github.com/users/JuliaSmoothOptimizers/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaSmoothOptimizers/received_events","type":"Organization","site_admin":false},"repo":{"id":31977760,"name":"Krylov.jl","full_name":"JuliaSmoothOptimizers/Krylov.jl","owner":{"login":"JuliaSmoothOptimizers","id":15710294,"avatar_url":"https://avatars1.githubusercontent.com/u/15710294?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaSmoothOptimizers","html_url":"https://github.com/JuliaSmoothOptimizers","followers_url":"https://api.github.com/users/JuliaSmoothOptimizers/followers","following_url":"https://api.github.com/users/JuliaSmoothOptimizers/following{/other_user}","gists_url":"https://api.github.com/users/JuliaSmoothOptimizers/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaSmoothOptimizers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaSmoothOptimizers/subscriptions","organizations_url":"https://api.github.com/users/JuliaSmoothOptimizers/orgs","repos_url":"https://api.github.com/users/JuliaSmoothOptimizers/repos","events_url":"https://api.github.com/users/JuliaSmoothOptimizers/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaSmoothOptimizers/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JuliaSmoothOptimizers/Krylov.jl","description":"A Julia Basket of Hand-Picked Krylov Methods","fork":false,"url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl","forks_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/forks","keys_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/teams","hooks_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/hooks","issue_events_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/issues/events{/number}","events_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/events","assignees_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/assignees{/user}","branches_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/branches{/branch}","tags_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/tags","blobs_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/languages","stargazers_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/stargazers","contributors_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/contributors","subscribers_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/subscribers","subscription_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/subscription","commits_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/contents/{+path}","compare_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/merges","archive_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/downloads","issues_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/issues{/number}","pulls_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/labels{/name}","releases_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/releases{/id}","deployments_url":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/deployments","created_at":"2015-03-10T19:37:53Z","updated_at":"2017-01-21T23:03:17Z","pushed_at":"2017-07-11T19:50:07Z","git_url":"git://github.com/JuliaSmoothOptimizers/Krylov.jl.git","ssh_url":"git@github.com:JuliaSmoothOptimizers/Krylov.jl.git","clone_url":"https://github.com/JuliaSmoothOptimizers/Krylov.jl.git","svn_url":"https://github.com/JuliaSmoothOptimizers/Krylov.jl","homepage":null,"size":312,"stargazers_count":2,"watchers_count":2,"language":"Julia","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":3,"forks":6,"open_issues":3,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/pulls/29"},"html":{"href":"https://github.com/JuliaSmoothOptimizers/Krylov.jl/pull/29"},"issue":{"href":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/issues/29"},"comments":{"href":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/issues/29/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/pulls/29/comments"},"review_comment":{"href":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/pulls/29/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaSmoothOptimizers/Krylov.jl/statuses/e9fc2fff4cf3fa80a72bf7e39ab256cbbfb5fdd2"}}}}
{"actor":{"display_login":"dpo"}}