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

Add product of spaces #859

Closed
adler-j opened this issue Jan 24, 2017 · 5 comments
Closed

Add product of spaces #859

adler-j opened this issue Jan 24, 2017 · 5 comments

Comments

@adler-j
Copy link
Member

adler-j commented Jan 24, 2017

A rather obvious syntax that we have not started using is the product of spaces, i.e. one could easily envision

>>> r2 = odl.rn(2)
>>> r3 = odl.rn(3)
>>> r2 * r3
ProductSpace(rn(2), r3)
>>> r2 ** 4
ProductSpace(rn(2), 4)

sub-classes could then overload this syntax to provide more advanced storage and functionality, i.e. in #857.

>>> space = odl.uniform_discr(0, 1, 100)
>>> space ** 3
uniform_discr(0, 1, 100, shape=3)  # or w/e syntax we pick
@kohr-h
Copy link
Member

kohr-h commented Jan 24, 2017

How about

>>> space = odl.uniform_discr(0, 1, 100)
>>> space ** 3
uniform_discr([0.0, 0.0, 0.0], [1.0, 1.0, 1.0], (100, 100, 100))

?
There could be an internal (or public) property like pspace_shape, which gives the shape that is not part of the base space but added to the "left".

@adler-j
Copy link
Member Author

adler-j commented Jan 24, 2017

Well your suggestion is strictly different from mine and frankly doesn't really make sense in how you usually write notation. You are taking the power as a power of a domain, while I take it as a power of the range. Your suggestion is hence not compatible with this suggestion, since it has no obvious equivalent in the case of non-uniform_discr spaces.

Example, my proposal:

>>> space = odl.uniform_discr(0, 1, 100)
>>> (space ** 3)[0]
uniform_discr(0, 1, 100)

your proposal would, if it is to be consistent with slicing, give

>>> space = odl.uniform_discr(0, 1, 100)
>>> (space ** 3)[0]
uniform_discr([0, 0], [1, 1], [100, 100])

Mathematically it doesn't make much sense either. If I write F({1, 2, 3}, R) to mean the set of functions from {1, 2, 3} to R, then F({1, 2, 3}, R)^2 should be the set of ordered 2-tuples of such functions. I.e.

F({1, 2, 3}, R)^2 = (F({1, 2, 3}, R), F({1, 2, 3}, R))

this can be identified with

F({1, 2, 3}, R)^2 = F({1, 2, 3}, R^2)

but doesn't have an isomorphism to what you propose, i.e.

F({1, 2, 3}, R)^2 != F({1, 2, 3}^2, R)

@kohr-h
Copy link
Member

kohr-h commented Jan 24, 2017

Oh never mind, what I wrote was obviously BS. That kind of stuff would only work for tensor spaces, where you would add a 3 to the shape on the left, obviously not adding 2 axes as I wrote above.

@adler-j
Copy link
Member Author

adler-j commented Jan 24, 2017

Well what you wrote could be given the syntax

>>> space = odl.uniform_discr(0, 1, 100)
>>> 3 ** space
uniform_discr([0.0, 0.0, 0.0], [1.0, 1.0, 1.0], (100, 100, 100))

which I think would make sense?

@kohr-h
Copy link
Member

kohr-h commented Jan 24, 2017

Haha, not quite sure about that.. I just know 2^X as the power set of X, which has 2^n elements if X has n. That analogy doesn't really hold here, does it?
Perhaps space * 3 instead? No, seriously, I think it's okay to type that one out.

adler-j added a commit to adler-j/odl that referenced this issue Feb 6, 2017
adler-j added a commit to adler-j/odl that referenced this issue Feb 6, 2017
adler-j added a commit to adler-j/odl that referenced this issue Feb 6, 2017
adler-j added a commit to adler-j/odl that referenced this issue Feb 6, 2017
adler-j added a commit to adler-j/odl that referenced this issue Feb 6, 2017
@adler-j adler-j closed this as completed in e2ed423 Feb 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants