-
Notifications
You must be signed in to change notification settings - Fork 6
Behavior of accessor functions on ladderops #21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We didn't have these functions exported yet, which is why you couldn't call it (if you input Also on a side note - from what you posted, it looks like you're using a post-v0.3 release of Julia. We're targeting the v0.3 release for now, since it's the current stable version. Functionality might be broken if you use a newer build than that...though keeping track of issues on the latest build now will help when we update to v0.4 in the future :) EDIT: Ah early morning tiredness got me, I see where calling |
Are you sure you didn't have a Either way, try pulling the latest version and see if it takes care of the problems you were having. EDIT: I bet you ran the test suite before your second example! We had |
@jrevels thanks for input on this. However I had pulled the latest master and then did this |
The ambiguity warnings are definitely due to being on v0.4, as Like I said, v0.4 compatibility isn't one of our goals for now, but I'm curious - what's the output when you call |
Also, you shouldn't need to call |
I end up with these when I run methods(coeffs) and methods(rawcoeffs) julia> methods(coeffs)
# 2 methods for generic function "coeffs":
coeffs(qarr::QuArray{B<:QuBase.AbstractBasis{S<:QuBase.AbstractStructure},T,N,A}) at /home/amit/Downloads/SemVII/QuBase.jl/src/arrays/quarray.jl:34
coeffs(ct::CTranspose{B,T,N,A}) at /home/amit/Downloads/SemVII/QuBase.jl/src/arrays/quarray.jl:78
julia> methods(rawcoeffs)
# 2 methods for generic function "rawcoeffs":
rawcoeffs(qarr::QuArray{B<:QuBase.AbstractBasis{S<:QuBase.AbstractStructure},T,N,A}) at /home/amit/Downloads/SemVII/QuBase.jl/src/arrays/quarray.jl:33
rawcoeffs(ct::CTranspose{B,T,N,A}) at /home/amit/Downloads/SemVII/QuBase.jl/src/arrays/quarray.jl:77 As per my understanding these are as expected. And yeah coming to require statement, I did not pull in the latest commit which had exported so I had to do it. Though I did pull in the master before that. So what do you suggest for this case, I was trying to implement the position and momentum related operators by using lowerop and raiseop (by initially defining +,- for QuArray). Should I move to a lower version and build julia and then carry out the operations or is there any other work around ?? |
That output you just posted looks okay...it's possible the behavior you were having trouble with before might be coming from a bug in Julia master, though I'm not running v0.4 so I wouldn't know. Either way, it seems like it's just an incompatibility issue. I'm going to tag it as such and close this up, but feel free to update this thread if anything related pops up, it could be useful later when we do eventually move to the v0.4 :)
Yes, specifically you should be building off of the latest stable release (the "release-0.3" branch of the Julia language repo) for all development/testing/usage of QuBase. There was a mention of having an experimental 0.4 branch but it's not a priority for us right now. |
@jrevels I have reverted back to the stable version. Here are a few related doubts :
function +{B<:OrthonormalBasis}(qm1::QuMatrix{B}, qm2::QuMatrix{B})
return QuArray(rawcoeffs(qm1)+rawcoeffs(qm2), bases(qm1,1), bases(qm1,1))
end Then when I do this using QuBase
require("/home/amit/Downloads/SemVII/QuBase.jl/src/arrays/quarray.jl")
require("/home/amit/Downloads/SemVII/QuBase.jl/src/arrays/arraymath.jl")
m = [1.0+1im 2+2im 3+3im;
4+4im 5+5im 6+6im;
7+7im 8+8im 9+9im]
qm = QuArray(m)
println(qm)
qm1 = 1/2*qm
println(qm1)
a = raiseop(3)
println(a)
b = lowerop(3)
println(b)
println(a*b)
println(qm+qm1)
println(a+b) I get the consistent results until the last one, the last one fails. Here is the output 3x3 QuMatrix in FiniteBasis{Orthonormal,1}:
...coefficients: Array{Complex{Float64},2}
Complex{Float64}[1.0 + 1.0im 2.0 + 2.0im 3.0 + 3.0im
4.0 + 4.0im 5.0 + 5.0im 6.0 + 6.0im
7.0 + 7.0im 8.0 + 8.0im 9.0 + 9.0im]
3x3 QuMatrix in FiniteBasis{Orthonormal,1}:
...coefficients: Array{Complex{Float64},2}
Complex{Float64}[0.5 + 0.5im 1.0 + 1.0im 1.5 + 1.5im
2.0 + 2.0im 2.5 + 2.5im 3.0 + 3.0im
3.5 + 3.5im 4.0 + 4.0im 4.5 + 4.5im]
3x3 QuMatrix in FiniteBasis{Orthonormal,1}:
...coefficients: SparseMatrixCSC{Float64,Int64}
[2, 1] = 1.0
[3, 2] = 1.41421
3x3 QuMatrix in FiniteBasis{Orthonormal,1}:
...coefficients: SparseMatrixCSC{Float64,Int64}
[1, 2] = 1.0
[2, 3] = 1.41421
3x3 QuMatrix in FiniteBasis{Orthonormal,1}:
...coefficients: SparseMatrixCSC{Float64,Int64}
[2, 2] = 1.0
[3, 3] = 2.0
3x3 QuMatrix in FiniteBasis{Orthonormal,1}:
...coefficients: Array{Complex{Float64},2}
Complex{Float64}[1.5 + 1.5im 3.0 + 3.0im 4.5 + 4.5im
6.0 + 6.0im 7.5 + 7.5im 9.0 + 9.0im
10.5 + 10.5im 12.0 + 12.0im 13.5 + 13.5im]
ERROR: `+` has no method matching +(::QuArray{FiniteBasis{Orthonormal,1},Float64,2,SparseMatrixCSC{Float64,Int64}}, ::QuArray{FiniteBasis{Orthonormal,1},Float64,2,SparseMatrixCSC{Float64,Int64}})
|
You don't need the
(Maybe we should have some kind of assert macro which checks that the bases are actually equal?) if you get this to work, try to generalize this function to arbitrary In general we have to pass the bases around, since they contain additional information. For example, they could result from a tensor product of states. In your last example, [1] If you have two versions of QuBase, say one installed via
|
@acroy Ah seems like include statement gives the result. Thanks for this :). I will try sending in a pull with the additions. |
The following error occurs when accessor functions are called on ladderops.
Similarly with respect to other functions. I have tried playing around but I have not found any solution for this. It would be great to hear something on this. Thanks.
The text was updated successfully, but these errors were encountered: