{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/comments/22402742","id":22402742,"diff_hunk":"@@ -0,0 +1,146 @@\n+import Base: size,\n+    length,\n+    getindex,\n+    similar,\n+    in,\n+    ctranspose,\n+    transpose,\n+    summary,\n+    zeros,\n+    #TODO: Implement the below operations\n+    *,.*,\n+    /,./,\n+    +,.+,\n+    -,.-,\n+    kron\n+\n+abstract AbstractQuArray{B<:(AbstractBasis...), T, N} <: AbstractArray{T,N}\n+\n+###########\n+# QuArray #                 \n+###########\n+    # B<:(AbstractBasis...) allows us to have a basis for each dimension, \n+    # and gives us a less ambiguous way to determine if a QuArray will act\n+    # like a vector, matrix, or tensor compared to just looking at the \n+    # dimension parameter N. \n+    type QuArray{B<:(AbstractBasis...), T, N, A} <: AbstractQuArray{B, T, N}\n+        coeffs::A\n+        bases::B\n+        function QuArray(coeffs::AbstractArray{T, N}, bases::B) \n+            if checkbases(coeffs, bases) \n+                new(coeffs, bases)\n+            else \n+                error(\"Coefficient array does not conform to input bases\")\n+            end\n+        end\n+    end\n+\n+    # We can't use N to tell whether something is really a vector\n+    # since row vectors are N=2 (quite unfortunate). We can, however,\n+    # infer the behavior from the number of bases...\n+    typealias QuVector{B<:AbstractBasis,T,N,A} QuArray{(B,),T,N,A}\n+    typealias QuMatrix{R<:AbstractBasis,C<:AbstractBasis,T,N,A} QuArray{(R,C),T,N,A}\n+\n+    QuArray{T,N}(coeffs::AbstractArray{T, N}, bases::(AbstractBasis...)) = QuArray{typeof(bases), T, N, typeof(coeffs)}(coeffs, bases)\n+    QuArray(coeffs, bases::AbstractBasis...) = QuArray(coeffs, bases)\n+    QuArray(coeffs) = QuArray(coeffs, basesfordims(size(coeffs)))\n+    \n+    ############################\n+    # Convenience Constructors #\n+    ############################\n+    statevec(i::Int, fb::FiniteBasis) = QuArray(single_coeff(i, length(fb)), fb)\n+    statevec(i::Int, lens::Int...=i) = statevec(i, FiniteBasis(lens))\n+\n+    ######################\n+    # Property Functions #\n+    ######################\n+    bases(qa::QuArray) = qa.bases\n+    coeffs(qa::QuArray) = qa.coeffs\n+\n+    size(qa::QuArray, i...) = size(qa.coeffs, i...)\n+\n+    ########################\n+    # Array-like functions #\n+    ########################\n+    similar{B,T}(qa::QuArray{B,T}, element_type=T) = QuArray(similar(qa.coeffs, T), qa.bases)\n+    # is there a way to properly define the below for\n+    # any arbitrary basis? Obviously doesn't make sense\n+    # for B<:AbstractInfiniteBasis, and I'm reluctant to\n+    # enforce that every B<:AbstractFiniteBasis will have a \n+    # constructor B(::Int), which is the below is doing with\n+    # FiniteBasis.\n+    function similar{B<:(FiniteBasis...),T}(qa::QuArray{B,T}, element_type, dims)\n+        return QuArray(similar(qa.coeffs, T, dims), basesfordims(dims, B))\n+    end \n+    getindex(qa::QuArray, i::AbstractArray) = getindex(qa.coeffs, i)\n+    getindex(qa::QuArray, i::Real) = getindex(qa.coeffs, i)\n+    getindex(qa::QuArray, i) = getindex(qa.coeffs, i)\n+    getindex(qa::QuArray, i...) = getindex(qa.coeffs, i...)\n+\n+    in(c, qa::QuArray) = in(c, qa.coeffs)\n+\n+    ctranspose(qa::QuVector) = QuArray(ctranspose(qa.coeffs), qa.bases)\n+    ctranspose(qa::QuMatrix) = QuArray(ctranspose(qa.coeffs), reverse(qa.bases))\n+    transpose(qa::QuVector) = QuArray(transpose(qa.coeffs), qa.bases)\n+    transpose(qa::QuMatrix) = QuArray(transpose(qa.coeffs), reverse(qa.bases))\n+\n+    zeros(qa::QuArray) = QuArray(zeros(qa.coeffs), qa.bases)","path":"src/arrays/quarray.jl","position":87,"original_position":87,"commit_id":"544458eac2a7dd73f20595f32e2ec003bf5cd643","original_commit_id":"544458eac2a7dd73f20595f32e2ec003bf5cd643","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":"Could you add `eye(qa::QuArray)` as well?","created_at":"2015-01-01T22:31:41Z","updated_at":"2015-01-01T22:31:41Z","html_url":"https://github.com/JuliaQuantum/QuBase.jl/pull/5#discussion_r22402742","pull_request_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/5","_links":{"self":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/comments/22402742"},"html":{"href":"https://github.com/JuliaQuantum/QuBase.jl/pull/5#discussion_r22402742"},"pull_request":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/5"}}},"pull_request":{"url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/5","id":26670498,"html_url":"https://github.com/JuliaQuantum/QuBase.jl/pull/5","diff_url":"https://github.com/JuliaQuantum/QuBase.jl/pull/5.diff","patch_url":"https://github.com/JuliaQuantum/QuBase.jl/pull/5.patch","issue_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/issues/5","number":5,"state":"open","locked":false,"title":"Basic framework for QuArrays and basis types","user":{"login":"jrevels","id":3277443,"avatar_url":"https://avatars.githubusercontent.com/u/3277443?v=3","gravatar_id":"","url":"https://api.github.com/users/jrevels","html_url":"https://github.com/jrevels","followers_url":"https://api.github.com/users/jrevels/followers","following_url":"https://api.github.com/users/jrevels/following{/other_user}","gists_url":"https://api.github.com/users/jrevels/gists{/gist_id}","starred_url":"https://api.github.com/users/jrevels/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jrevels/subscriptions","organizations_url":"https://api.github.com/users/jrevels/orgs","repos_url":"https://api.github.com/users/jrevels/repos","events_url":"https://api.github.com/users/jrevels/events{/privacy}","received_events_url":"https://api.github.com/users/jrevels/received_events","type":"User","site_admin":false},"body":"This PR splits off the non-QuDirac work from #4. To copy the summary from there, here's what this PR does:\r\n\r\n1. Provides a cleaner directory structure and a more comprehensive type hierarchy.\r\n2. Organizes/cleans up existing code, as well as splits off QuDirac-related work into the [QuDirac repo, which got moved under the JuliaQuantum organization.](https://github.com/JuliaQuantum/QuDirac.jl) That repo is where abstract Dirac-notated states and operator functionality will live for the time being, whereas QuBase will be focused on: \r\n    - solvers/modeling capability for coefficient arrays\r\n    - a foundational type system\r\n    - a solid, general implementation for `QuArray`s and fundamental basis types\r\n3. Updates the `creationop` method provided by @acroy to work with arbitrary number of particles (you can pick which particle the operator should act on). I renamed it to `raiseop` for brevity's sake and implemented `lowerop` as well. These methods aren't optimized in the slightest (likely a tad slower than @acroy's original implementation), but provide a good starting point for ladder operations in multi-particle systems.\r\n4. Gives a single type implementation of `FiniteBasis` that supports a tensor product structure\r\n5. Implements a couple of functions for `QuArray`/`FiniteBasis`, including pretty-printing for `QuArray`s (let me know what you think, it's hard to compactly convey all that info).\r\n \r\nSorry for the previous commit; I had to go back and fix the tabs-to-spaces thing again for some reason.  ","created_at":"2014-12-30T01:40:12Z","updated_at":"2015-01-01T22:31:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d0bc89569d1be6b08982439f8391ea4e59a709c5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/5/commits","review_comments_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/5/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/5/comments","statuses_url":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/statuses/544458eac2a7dd73f20595f32e2ec003bf5cd643","head":{"label":"JuliaQuantum:basic-func","ref":"basic-func","sha":"544458eac2a7dd73f20595f32e2ec003bf5cd643","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":"2014-12-25T16:11:35Z","pushed_at":"2014-12-31T03:43:43Z","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":334,"stargazers_count":3,"watchers_count":3,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":3,"default_branch":"master"}},"base":{"label":"JuliaQuantum:master","ref":"master","sha":"81f3ddb1caecae15cecb9d4f6244eb1df8f4fed1","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":"2014-12-25T16:11:35Z","pushed_at":"2014-12-31T03:43:43Z","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":334,"stargazers_count":3,"watchers_count":3,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":2,"forks":1,"open_issues":2,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/5"},"html":{"href":"https://github.com/JuliaQuantum/QuBase.jl/pull/5"},"issue":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/issues/5"},"comments":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/issues/5/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/pulls/5/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/5/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaQuantum/QuBase.jl/statuses/544458eac2a7dd73f20595f32e2ec003bf5cd643"}}}}