Skip to content
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

Complex coeffs support. #38

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

amitjamadagni
Copy link
Contributor

Currently we get an error doing this :

julia> statevec(1, FiniteBasis(2))
2-element QuVector in FiniteBasis{Orthonormal}:
...coefficients: Array{Float64,1}
[1.0,0.0]

julia> complex(statevec(1, FiniteBasis(2)))
ERROR: `complex` has no method matching complex(::QuArray{FiniteBasis{Orthonormal},Float64,1,Array{Float64,1}})

This further gives an error when we do something like this :

julia> using QuDynamics

julia> qode45 = QuPropagator(sigmax, statevec(1, FiniteBasis(2)), 0.:0.1:2*pi, QuODE45())
QuPropagator{QuODE45,QuArray{FiniteBasis{Orthonormal},Float64,1,Array{Float64,1}},QuSchrodingerEq{H<:AbstractQuArray{B<:AbstractBasis{S<:AbstractStructure},T,2}}}(QuSchrodingerEq{QuArray{FiniteBasis{Orthonormal},Float64,2,Array{Float64,2}}}(2x2 QuMatrix in FiniteBasis{Orthonormal}:
...coefficients: Array{Float64,2}
[0.0 1.0
 1.0 0.0]),2-element QuVector in FiniteBasis{Orthonormal}:
...coefficients: Array{Float64,1}
[1.0,0.0],0.0:0.1:6.2,QuODE45(Dict{Symbol,Any}()))

julia> next_qode45 = next(qode45, start(qode45))
ERROR: InexactError()
 in setindex! at array.jl:307
 in copy! at abstractarray.jl:149
 in setindex! at array.jl:307
 in oderk_adapt at .julia/v0.3/ODE/src/runge_kutta.jl:279
 in ode45_dp at .julia/v0.3/ODE/src/runge_kutta.jl:212
 in propagate at .julia/v0.3/QuDynamics/src/propodesolvers.jl:28
 in next at .julia/v0.3/QuDynamics/src/propmachinery.jl:47

This PR aims to fix this.

@acroy
Copy link
Contributor

acroy commented Jul 13, 2015

Definitely required. There are, however, more functions like complex. So the question is if/how we can support all of them in an elegant way?

@amitjamadagni
Copy link
Contributor Author

@acroy could we have an issue for all the functions or we could just list them out here, there was a use case so I thought of this but if we could list all at one place we would get a more neater picture.

@acroy
Copy link
Contributor

acroy commented Jul 16, 2015

The "easy" way would be to use code generation to provide functions for float, float16, float32, etc. But I have the feeling that this is not the best (and future proof) way to do that. Maybe we just need a bunch of converts. Anyways I think it would be good to look at other Array-like types and figure out how this is handled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants