{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/comments/28657113","id":28657113,"diff_hunk":"@@ -16,4 +16,16 @@\n     one_at_ind!(arr, i) = setindex!(arr, one(eltype(arr)), i)\n     single_coeff(i, lens...) = one_at_ind!(zeros(lens), i)\n \n-export statevec\n\\ No newline at end of file\n+function coherentstatevec(n::Int,alpha::Number;method=\"direct\")\n+    s = rand(n)\n+    z = zeros(QuArray(s))\n+    for i in [1:n]\n+        z = z + ((alpha^(i-1))/sqrt(factorial(i)))*statevec(i, FiniteBasis(n))","path":"src/arrays/constructors.jl","position":10,"original_position":10,"commit_id":"3586dc1fc6e55496dac189b409ac22efa9f18c42","original_commit_id":"3586dc1fc6e55496dac189b409ac22efa9f18c42","user":{"login":"acroy","id":6170781,"avatar_url":"https://avatars.githubusercontent.com/u/6170781?v=3","gravatar_id":"","url":"https://api.github.com/users/acroy","html_url":"https://github.com/acroy","followers_url":"https://api.github.com/users/acroy/followers","following_url":"https://api.github.com/users/acroy/following{/other_user}","gists_url":"https://api.github.com/users/acroy/gists{/gist_id}","starred_url":"https://api.github.com/users/acroy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/acroy/subscriptions","organizations_url":"https://api.github.com/users/acroy/orgs","repos_url":"https://api.github.com/users/acroy/repos","events_url":"https://api.github.com/users/acroy/events{/privacy}","received_events_url":"https://api.github.com/users/acroy/received_events","type":"User","site_admin":false},"body":"... And it should be `factorial(i-1)`. Note that creating the coefficients like that is probably not a good idea if n is large. If one would do this it might be better (I.e. More efficient) to use a recursive prescription. Something like (untestet!)\r\n```\r\ncs = zeros(n)\r\ncs[1]=one(alpha)\r\nFor i in 2:n\r\n   cs[i] = alpha/sqrt(i-1)*cs[i-1]\r\nend\r\nQuArray(cs)\r\n```\r\nAlso note that the resulting state is not normalized (only approximately), because the formula for the elements in Fock space assumes infinite n. But I would anyways go with the other definition below and only use the formula in the test.\r\n","created_at":"2015-04-19T21:27:13Z","updated_at":"2015-04-19T21:27:13Z","html_url":"https://github.com/JuliaQuantum/QuBase.jl/pull/25#discussion_r28657113","pull_request_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/comments/28657113"},"html":{"href":"https://github.com/JuliaQuantum/QuBase.jl/pull/25#discussion_r28657113"},"pull_request":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/25","id":33560853,"html_url":"https://github.com/JuliaQuantum/QuBase.jl/pull/25","diff_url":"https://github.com/JuliaQuantum/QuBase.jl/pull/25.diff","patch_url":"https://github.com/JuliaQuantum/QuBase.jl/pull/25.patch","issue_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/issues/25","number":25,"state":"open","locked":false,"title":"Operators : Squeeze, displaceop. Addition : expm, full","user":{"login":"amitjamadagni","id":1212282,"avatar_url":"https://avatars.githubusercontent.com/u/1212282?v=3","gravatar_id":"","url":"https://api.github.com/users/amitjamadagni","html_url":"https://github.com/amitjamadagni","followers_url":"https://api.github.com/users/amitjamadagni/followers","following_url":"https://api.github.com/users/amitjamadagni/following{/other_user}","gists_url":"https://api.github.com/users/amitjamadagni/gists{/gist_id}","starred_url":"https://api.github.com/users/amitjamadagni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitjamadagni/subscriptions","organizations_url":"https://api.github.com/users/amitjamadagni/orgs","repos_url":"https://api.github.com/users/amitjamadagni/repos","events_url":"https://api.github.com/users/amitjamadagni/events{/privacy}","received_events_url":"https://api.github.com/users/amitjamadagni/received_events","type":"User","site_admin":false},"body":"An attempt at implementing expm, full (sparse to dense) as expm is not implemented for sparse matrix. With respect to the implementation of expm with respect to sparse matrix, I have been referring to the https://github.com/JuliaLang/julia/issues/10035 which had hints at scipy implementation. The scipy implementation is based on the following algorithm (http://core.ac.uk/download/pdf/17664.pdf) as cited in the documentation. I will try a hand at implementing this if already not implemented, but that said as exponentiation is only available for dense matrix, I have implemented full function and added the expm on the top of that.  \r\nAlso the `*` method using DualMatrix was giving some inconsistent results, an attempt has been made to get it work.  \r\nAny comments would be helpful. Thanks ","created_at":"2015-04-17T16:35:27Z","updated_at":"2015-04-19T21:27:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"56f79b7d16e009714ee2b82fc4b36a2efa5a3baf","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/25/commits","review_comments_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/25/comments","review_comment_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/issues/25/comments","statuses_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/statuses/3586dc1fc6e55496dac189b409ac22efa9f18c42","head":{"label":"amitjamadagni:ops","ref":"ops","sha":"3586dc1fc6e55496dac189b409ac22efa9f18c42","user":{"login":"amitjamadagni","id":1212282,"avatar_url":"https://avatars.githubusercontent.com/u/1212282?v=3","gravatar_id":"","url":"https://api.github.com/users/amitjamadagni","html_url":"https://github.com/amitjamadagni","followers_url":"https://api.github.com/users/amitjamadagni/followers","following_url":"https://api.github.com/users/amitjamadagni/following{/other_user}","gists_url":"https://api.github.com/users/amitjamadagni/gists{/gist_id}","starred_url":"https://api.github.com/users/amitjamadagni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitjamadagni/subscriptions","organizations_url":"https://api.github.com/users/amitjamadagni/orgs","repos_url":"https://api.github.com/users/amitjamadagni/repos","events_url":"https://api.github.com/users/amitjamadagni/events{/privacy}","received_events_url":"https://api.github.com/users/amitjamadagni/received_events","type":"User","site_admin":false},"repo":{"id":30266049,"name":"QuBase.jl","full_name":"amitjamadagni/QuBase.jl","owner":{"login":"amitjamadagni","id":1212282,"avatar_url":"https://avatars.githubusercontent.com/u/1212282?v=3","gravatar_id":"","url":"https://api.github.com/users/amitjamadagni","html_url":"https://github.com/amitjamadagni","followers_url":"https://api.github.com/users/amitjamadagni/followers","following_url":"https://api.github.com/users/amitjamadagni/following{/other_user}","gists_url":"https://api.github.com/users/amitjamadagni/gists{/gist_id}","starred_url":"https://api.github.com/users/amitjamadagni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitjamadagni/subscriptions","organizations_url":"https://api.github.com/users/amitjamadagni/orgs","repos_url":"https://api.github.com/users/amitjamadagni/repos","events_url":"https://api.github.com/users/amitjamadagni/events{/privacy}","received_events_url":"https://api.github.com/users/amitjamadagni/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/amitjamadagni/QuBase.jl","description":"A foundational library for quantum mechanics in Julia","fork":true,"url":"https://api.github.com/repos/amitjamadagni/QuBase.jl","forks_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/forks","keys_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/teams","hooks_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/hooks","issue_events_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/issues/events{/number}","events_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/events","assignees_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/assignees{/user}","branches_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/branches{/branch}","tags_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/tags","blobs_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/languages","stargazers_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/stargazers","contributors_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/contributors","subscribers_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/subscribers","subscription_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/subscription","commits_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/contents/{+path}","compare_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/merges","archive_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/downloads","issues_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/issues{/number}","pulls_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/labels{/name}","releases_url":"https://api.github.com/repos/amitjamadagni/QuBase.jl/releases{/id}","created_at":"2015-02-03T21:41:39Z","updated_at":"2015-04-13T19:54:45Z","pushed_at":"2015-04-19T20:24:04Z","git_url":"git://github.com/amitjamadagni/QuBase.jl.git","ssh_url":"git@github.com:amitjamadagni/QuBase.jl.git","clone_url":"https://github.com/amitjamadagni/QuBase.jl.git","svn_url":"https://github.com/amitjamadagni/QuBase.jl","homepage":null,"size":517,"stargazers_count":0,"watchers_count":0,"language":"Julia","has_issues":false,"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":"JuliaQuantum:master","ref":"master","sha":"60fa292d1f738f96b254702a55af08c5740bfbb1","user":{"login":"JuliaQuantum","id":8118127,"avatar_url":"https://avatars.githubusercontent.com/u/8118127?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaQuantum","html_url":"https://github.com/JuliaQuantum","followers_url":"https://api.github.com/users/JuliaQuantum/followers","following_url":"https://api.github.com/users/JuliaQuantum/following{/other_user}","gists_url":"https://api.github.com/users/JuliaQuantum/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaQuantum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaQuantum/subscriptions","organizations_url":"https://api.github.com/users/JuliaQuantum/orgs","repos_url":"https://api.github.com/users/JuliaQuantum/repos","events_url":"https://api.github.com/users/JuliaQuantum/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaQuantum/received_events","type":"Organization","site_admin":false},"repo":{"id":28000700,"name":"QuBase.jl","full_name":"JuliaQuantum/QuBase.jl","owner":{"login":"JuliaQuantum","id":8118127,"avatar_url":"https://avatars.githubusercontent.com/u/8118127?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaQuantum","html_url":"https://github.com/JuliaQuantum","followers_url":"https://api.github.com/users/JuliaQuantum/followers","following_url":"https://api.github.com/users/JuliaQuantum/following{/other_user}","gists_url":"https://api.github.com/users/JuliaQuantum/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaQuantum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaQuantum/subscriptions","organizations_url":"https://api.github.com/users/JuliaQuantum/orgs","repos_url":"https://api.github.com/users/JuliaQuantum/repos","events_url":"https://api.github.com/users/JuliaQuantum/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaQuantum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JuliaQuantum/QuBase.jl","description":"A foundational library for quantum mechanics in Julia","fork":false,"url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl","forks_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/forks","keys_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/teams","hooks_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/hooks","issue_events_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/issues/events{/number}","events_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/events","assignees_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/assignees{/user}","branches_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/branches{/branch}","tags_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/tags","blobs_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/git/refs{/sha}","trees_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/statuses/{sha}","languages_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/languages","stargazers_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/stargazers","contributors_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/contributors","subscribers_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/subscribers","subscription_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/subscription","commits_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/commits{/sha}","git_commits_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/git/commits{/sha}","comments_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/comments{/number}","issue_comment_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/issues/comments{/number}","contents_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/contents/{+path}","compare_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/merges","archive_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/downloads","issues_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/issues{/number}","pulls_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls{/number}","milestones_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/milestones{/number}","notifications_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/labels{/name}","releases_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/releases{/id}","created_at":"2014-12-14T16:45:57Z","updated_at":"2015-04-13T19:22:13Z","pushed_at":"2015-04-19T20:24:05Z","git_url":"git://github.com/JuliaQuantum/QuBase.jl.git","ssh_url":"git@github.com:JuliaQuantum/QuBase.jl.git","clone_url":"https://github.com/JuliaQuantum/QuBase.jl.git","svn_url":"https://github.com/JuliaQuantum/QuBase.jl","homepage":null,"size":1192,"stargazers_count":14,"watchers_count":14,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":6,"forks":2,"open_issues":6,"watchers":14,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/25"},"html":{"href":"https://github.com/JuliaQuantum/QuBase.jl/pull/25"},"issue":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/issues/25"},"comments":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/statuses/3586dc1fc6e55496dac189b409ac22efa9f18c42"}}}}