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

ParticuleBasis #339

Open
ghost opened this issue Aug 19, 2022 · 2 comments
Open

ParticuleBasis #339

ghost opened this issue Aug 19, 2022 · 2 comments

Comments

@ghost
Copy link

ghost commented Aug 19, 2022

Hello, I was wondering if you could add a ParticuleBasis abstract type such that

PositionBasis <: ParticuleBasis
MomentumBasis <: ParticuleBasis
@david-pl
Copy link
Member

We could, but I don't really see a use for it. If you just want to dispatch on this in a script, you can also do something like

const ParticleBasis = Union{<:MomentumBasis,<:PositionBasis}

function f(b::ParticleBasis)
# do stuff
end

What do you want to achieve here?

@ghost
Copy link
Author

ghost commented Aug 22, 2022

I want to define many functions that work the same for both momentum and position basis. Stuff like

create(b::ParticuleBasis) = (position(b) + im * momentum(b)) / sqrt(2)
destroy(...) = ...
displace(...) = ...
squeeze(...) = ...
...

I also want to define some operators on a composite particule and spin basis.

I know the difference in runtime between the union and abstract type version is marginal, but I find the abstract type version cleaner.

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

No branches or pull requests

1 participant