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

productmeasure(::Vector{<:Dirac}) #80

Open
cscherrer opened this issue Aug 11, 2022 · 1 comment
Open

productmeasure(::Vector{<:Dirac}) #80

cscherrer opened this issue Aug 11, 2022 · 1 comment

Comments

@cscherrer
Copy link
Collaborator

Currently, a product of Diracs works like this:

julia> productmeasure(Dirac.([1,2,3]))
ProductMeasure([Dirac(1), Dirac(2), Dirac(3)])

In some cases, we might prefer to write this as

Dirac([1, 2, 3])

This is much simpler, at the cost of an allocation.

For cases where we end up building an array of Diracs only to later take a product, we should look for ways to think ahead, so we can jump straight to this second representation. In this case we can often avoid the allocation.

I don't think there's a need to have a single canonical form for this. We can instead add some methods to deal with ProductMeasure{<:AbstractArray{<:Dirac}} and take advantage of this structure.

@oschulz
Copy link
Collaborator

oschulz commented Aug 12, 2022

I guess it makes sense to do such "contractions" where possible.

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

2 participants