{"action":"created","comment":{"url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/pulls/comments/102005770","pull_request_review_id":22747918,"id":102005770,"diff_hunk":"@@ -158,4 +158,54 @@ Nmax (optional)\n \"\"\"\n groundstate(H::Union{DenseOperator, SparseOperator}) = eigenstates_hermitian(H; Nmax=1)[1]\n \n+\n+\"\"\"\n+Simultaneously diagonalize commuting Hermitian operators.\n+\n+This is done by diagonalizing the sum of the operators.\n+The eigenvalues are computed by :math:`a = \\\\langle \\\\psi |A|\\\\psi\\\\rangle` and\n+it is checked whether the eigenvectors fulfill the equation\n+:math:`A|\\\\psi\\\\rangle = a|\\\\psi\\\\rangle`.\n+\n+Arguments\n+---------\n+\n+Ops\n+  Vector of operators (sparse or dense).\n+\n+Keyword arguments\n+-----------------\n+\n+atol (optional)\n+  kwarg of Base.isapprox specifying the tolerance of the approximate check\n+  Default is 1e-14.\n+\n+rtol (optional)\n+  kwarg of Base.isapprox specifying the tolerance of the approximate check\n+  Default is 1e-14.\n+\"\"\"\n+\n+function simdiag{T <: DenseOperator}(Ops::Vector{T}; atol::Real=1e-14, rtol::Real=1e-14)\n+\n+  # Check input\n+  for A=Ops\n+    A == dagger(A) ? nothing : error(\"Non-hermitian operator given!\")\n+  end\n+\n+  d, v = eig(sum(Ops).data)\n+\n+  evals = [Vector{Complex128}(length(d)) for i=1:length(Ops)]\n+  for i=1:length(Ops), j=1:length(d)\n+    evals[i][j] = (v[:, j]'*Ops[i].data*v[:, j])[1]\n+    check_eval = isapprox(Ops[i].data*v[:, j] - evals[i][j]*v[:, j], zeros(length(d)); atol=atol, rtol=rtol)\n+    check_eval ? nothing : error(\"Simultaneous diagonalization failed!\")\n+  end\n+\n+  index = sortperm(real(evals[1][:]))\n+  evals_sorted = [real(evals[i][index]) for i=1:length(Ops)]\n+  evals_sorted, v[:, index]\n+end\n+\n+simdiag{T <: SparseOperator}(Ops::Vector{T}; kwargs...) = simdiag([full(A) for A=Ops]; kwargs...)","path":"src/spectralanalysis.jl","position":61,"original_position":61,"commit_id":"d7a5f3c1d1ae72b03566c3b6bee074fc584f2b6c","original_commit_id":"d7a5f3c1d1ae72b03566c3b6bee074fc584f2b6c","user":{"login":"bastikr","id":102507,"avatar_url":"https://avatars.githubusercontent.com/u/102507?v=3","gravatar_id":"","url":"https://api.github.com/users/bastikr","html_url":"https://github.com/bastikr","followers_url":"https://api.github.com/users/bastikr/followers","following_url":"https://api.github.com/users/bastikr/following{/other_user}","gists_url":"https://api.github.com/users/bastikr/gists{/gist_id}","starred_url":"https://api.github.com/users/bastikr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bastikr/subscriptions","organizations_url":"https://api.github.com/users/bastikr/orgs","repos_url":"https://api.github.com/users/bastikr/repos","events_url":"https://api.github.com/users/bastikr/events{/privacy}","received_events_url":"https://api.github.com/users/bastikr/received_events","type":"User","site_admin":false},"body":"Don't do automatic conversions from a sparse to a full operator. Might use too much memory. Throw an error instead with a message that only dense operators can be diagonalized.","created_at":"2017-02-20T12:21:40Z","updated_at":"2017-02-20T12:35:45Z","html_url":"https://github.com/bastikr/QuantumOptics.jl/pull/37#discussion_r102005770","pull_request_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/pulls/37","_links":{"self":{"href":"https://api.github.com/repos/bastikr/QuantumOptics.jl/pulls/comments/102005770"},"html":{"href":"https://github.com/bastikr/QuantumOptics.jl/pull/37#discussion_r102005770"},"pull_request":{"href":"https://api.github.com/repos/bastikr/QuantumOptics.jl/pulls/37"}}},"pull_request":{"url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/pulls/37","id":106978258,"html_url":"https://github.com/bastikr/QuantumOptics.jl/pull/37","diff_url":"https://github.com/bastikr/QuantumOptics.jl/pull/37.diff","patch_url":"https://github.com/bastikr/QuantumOptics.jl/pull/37.patch","issue_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/issues/37","number":37,"state":"open","locked":false,"title":"Simultaneous diagonalization","user":{"login":"david-pl","id":18166442,"avatar_url":"https://avatars.githubusercontent.com/u/18166442?v=3","gravatar_id":"","url":"https://api.github.com/users/david-pl","html_url":"https://github.com/david-pl","followers_url":"https://api.github.com/users/david-pl/followers","following_url":"https://api.github.com/users/david-pl/following{/other_user}","gists_url":"https://api.github.com/users/david-pl/gists{/gist_id}","starred_url":"https://api.github.com/users/david-pl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-pl/subscriptions","organizations_url":"https://api.github.com/users/david-pl/orgs","repos_url":"https://api.github.com/users/david-pl/repos","events_url":"https://api.github.com/users/david-pl/events{/privacy}","received_events_url":"https://api.github.com/users/david-pl/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-02-20T10:33:50Z","updated_at":"2017-02-20T12:35:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"85a460906fbf6b008f6412aa406d36b99d363c04","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/pulls/37/commits","review_comments_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/pulls/37/comments","review_comment_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/issues/37/comments","statuses_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/statuses/d7a5f3c1d1ae72b03566c3b6bee074fc584f2b6c","head":{"label":"david-pl:simdiag","ref":"simdiag","sha":"d7a5f3c1d1ae72b03566c3b6bee074fc584f2b6c","user":{"login":"david-pl","id":18166442,"avatar_url":"https://avatars.githubusercontent.com/u/18166442?v=3","gravatar_id":"","url":"https://api.github.com/users/david-pl","html_url":"https://github.com/david-pl","followers_url":"https://api.github.com/users/david-pl/followers","following_url":"https://api.github.com/users/david-pl/following{/other_user}","gists_url":"https://api.github.com/users/david-pl/gists{/gist_id}","starred_url":"https://api.github.com/users/david-pl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-pl/subscriptions","organizations_url":"https://api.github.com/users/david-pl/orgs","repos_url":"https://api.github.com/users/david-pl/repos","events_url":"https://api.github.com/users/david-pl/events{/privacy}","received_events_url":"https://api.github.com/users/david-pl/received_events","type":"User","site_admin":false},"repo":{"id":75192410,"name":"QuantumOptics.jl","full_name":"david-pl/QuantumOptics.jl","owner":{"login":"david-pl","id":18166442,"avatar_url":"https://avatars.githubusercontent.com/u/18166442?v=3","gravatar_id":"","url":"https://api.github.com/users/david-pl","html_url":"https://github.com/david-pl","followers_url":"https://api.github.com/users/david-pl/followers","following_url":"https://api.github.com/users/david-pl/following{/other_user}","gists_url":"https://api.github.com/users/david-pl/gists{/gist_id}","starred_url":"https://api.github.com/users/david-pl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/david-pl/subscriptions","organizations_url":"https://api.github.com/users/david-pl/orgs","repos_url":"https://api.github.com/users/david-pl/repos","events_url":"https://api.github.com/users/david-pl/events{/privacy}","received_events_url":"https://api.github.com/users/david-pl/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/david-pl/QuantumOptics.jl","description":"Quantum optics toolbox for Julia","fork":true,"url":"https://api.github.com/repos/david-pl/QuantumOptics.jl","forks_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/forks","keys_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/teams","hooks_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/hooks","issue_events_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/issues/events{/number}","events_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/events","assignees_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/assignees{/user}","branches_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/branches{/branch}","tags_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/tags","blobs_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/languages","stargazers_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/stargazers","contributors_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/contributors","subscribers_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/subscribers","subscription_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/subscription","commits_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/contents/{+path}","compare_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/merges","archive_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/downloads","issues_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/issues{/number}","pulls_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/labels{/name}","releases_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/releases{/id}","deployments_url":"https://api.github.com/repos/david-pl/QuantumOptics.jl/deployments","created_at":"2016-11-30T14:03:04Z","updated_at":"2016-11-30T14:03:06Z","pushed_at":"2017-02-20T10:32:25Z","git_url":"git://github.com/david-pl/QuantumOptics.jl.git","ssh_url":"git@github.com:david-pl/QuantumOptics.jl.git","clone_url":"https://github.com/david-pl/QuantumOptics.jl.git","svn_url":"https://github.com/david-pl/QuantumOptics.jl","homepage":null,"size":2238,"stargazers_count":0,"watchers_count":0,"language":"Julia","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bastikr:master","ref":"master","sha":"61d02c2f2cc374d3c52da93fd8302dd892b5b8bc","user":{"login":"bastikr","id":102507,"avatar_url":"https://avatars.githubusercontent.com/u/102507?v=3","gravatar_id":"","url":"https://api.github.com/users/bastikr","html_url":"https://github.com/bastikr","followers_url":"https://api.github.com/users/bastikr/followers","following_url":"https://api.github.com/users/bastikr/following{/other_user}","gists_url":"https://api.github.com/users/bastikr/gists{/gist_id}","starred_url":"https://api.github.com/users/bastikr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bastikr/subscriptions","organizations_url":"https://api.github.com/users/bastikr/orgs","repos_url":"https://api.github.com/users/bastikr/repos","events_url":"https://api.github.com/users/bastikr/events{/privacy}","received_events_url":"https://api.github.com/users/bastikr/received_events","type":"User","site_admin":false},"repo":{"id":54069751,"name":"QuantumOptics.jl","full_name":"bastikr/QuantumOptics.jl","owner":{"login":"bastikr","id":102507,"avatar_url":"https://avatars.githubusercontent.com/u/102507?v=3","gravatar_id":"","url":"https://api.github.com/users/bastikr","html_url":"https://github.com/bastikr","followers_url":"https://api.github.com/users/bastikr/followers","following_url":"https://api.github.com/users/bastikr/following{/other_user}","gists_url":"https://api.github.com/users/bastikr/gists{/gist_id}","starred_url":"https://api.github.com/users/bastikr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bastikr/subscriptions","organizations_url":"https://api.github.com/users/bastikr/orgs","repos_url":"https://api.github.com/users/bastikr/repos","events_url":"https://api.github.com/users/bastikr/events{/privacy}","received_events_url":"https://api.github.com/users/bastikr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bastikr/QuantumOptics.jl","description":"Quantum optics toolbox for Julia","fork":false,"url":"https://api.github.com/repos/bastikr/QuantumOptics.jl","forks_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/forks","keys_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/teams","hooks_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/hooks","issue_events_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/issues/events{/number}","events_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/events","assignees_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/assignees{/user}","branches_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/branches{/branch}","tags_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/tags","blobs_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/languages","stargazers_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/stargazers","contributors_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/contributors","subscribers_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/subscribers","subscription_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/subscription","commits_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/contents/{+path}","compare_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/merges","archive_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/downloads","issues_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/issues{/number}","pulls_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/labels{/name}","releases_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/releases{/id}","deployments_url":"https://api.github.com/repos/bastikr/QuantumOptics.jl/deployments","created_at":"2016-03-16T22:05:35Z","updated_at":"2017-01-22T07:29:57Z","pushed_at":"2017-02-20T12:08:36Z","git_url":"git://github.com/bastikr/QuantumOptics.jl.git","ssh_url":"git@github.com:bastikr/QuantumOptics.jl.git","clone_url":"https://github.com/bastikr/QuantumOptics.jl.git","svn_url":"https://github.com/bastikr/QuantumOptics.jl","homepage":null,"size":2178,"stargazers_count":9,"watchers_count":9,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":6,"mirror_url":null,"open_issues_count":3,"forks":6,"open_issues":3,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bastikr/QuantumOptics.jl/pulls/37"},"html":{"href":"https://github.com/bastikr/QuantumOptics.jl/pull/37"},"issue":{"href":"https://api.github.com/repos/bastikr/QuantumOptics.jl/issues/37"},"comments":{"href":"https://api.github.com/repos/bastikr/QuantumOptics.jl/issues/37/comments"},"review_comments":{"href":"https://api.github.com/repos/bastikr/QuantumOptics.jl/pulls/37/comments"},"review_comment":{"href":"https://api.github.com/repos/bastikr/QuantumOptics.jl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bastikr/QuantumOptics.jl/pulls/37/commits"},"statuses":{"href":"https://api.github.com/repos/bastikr/QuantumOptics.jl/statuses/d7a5f3c1d1ae72b03566c3b6bee074fc584f2b6c"}}}}
{"actor":{"display_login":"bastikr"}}