-
-
Notifications
You must be signed in to change notification settings - Fork 553
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 the classical construction of the 120-cell #28429
Comments
Branch: u/jipilab/classic120 |
Last 10 new commits:
|
Commit: |
Dependencies: #27760 |
comment:3
I merged the missing commit from #27760 to get a clean bot test. |
comment:4
I think this can be simplified: -list(set([tuple(p) for p in flatten([Permutations(list(c)).list() for c in cp])]))
+list(set([tuple(p) for c in cp for p in Permutations(list(c))])) so there are less transient (large) lists. Also, you should be able to do verts += itertools.chain.from_iterable([p(tuple(c)) for p in even_perm] for c in cp) since |
comment:5
Hi Travis, Thanks for the feedback, I'll do the changes. The new implementation with normaliz takes less than 1 sec. Before, it was taking much longer that's why it was tagged not tested. Now, for the default |
comment:6
A few comments:
- sage: polytopes.one_hundred_twenty_cell(backend='normaliz',construction='as_permutahedron') # not tested - long time
+ sage: polytopes.one_hundred_twenty_cell(backend='normaliz', construction='as_permutahedron') # not tested - long time
I count 24.
sage: %time polytopes.one_hundred_twenty_cell(backend='normaliz')
|
comment:7
Replying to @kliem:
I should have read the code better... Still one could do all the signs with one line instead of doing it over and over again. Something like: - # The 64 permutations of [±2,±2,0,0] (the ± are independant)
- verts = Permutations([0,0,2,2]).list() + Permutations([0,0,-2,-2]).list() + Permutations([0,0,2,-2]).list()
-
- # The 64 permutations of the following vectors:
- # [±1,±1,±1,±sqrt(5)]
- # [±1/phi^2,±phi,±phi,±phi]
- # [±1/phi,±1/phi,±1/phi,±phi^2]
- from sage.categories.cartesian_product import cartesian_product
- from sage.misc.flatten import flatten
- full_perm_vectors = [[[1,-1],[1,-1],[1,-1],[-sqrt5,sqrt5]],
- [[phi_inv**2,-phi_inv**2],[phi,-phi],[phi,-phi],[-phi,phi]],
- [[phi_inv,-phi_inv],[phi_inv,-phi_inv],[phi_inv,-phi_inv],[-(phi**2),phi**2]]]
- for vect in full_perm_vectors:
- cp = cartesian_product(vect)
- # The cartesian product creates duplicates, so we reduce it:
- verts += list(set([tuple(p) for p in flatten([Permutations(list(c)).list() for c in cp])]))
-
- # The 96 even permutations of [0,±1/phi^2,±1,±phi^2]
- # The 96 even permutations of [0,±1/phi,±phi,±sqrt(5)]
- # The 192 even permutations of [±1/phi,±1,±phi,±2]
- import itertools
- even_perm_vectors = [[[0],[phi_inv**2,-phi_inv**2],[1,-1],[-(phi**2),phi**2]],
- [[0],[phi_inv,-phi_inv],[phi,-phi],[-sqrt5,sqrt5]],
- [[phi_inv,-phi_inv],[1,-1],[phi,-phi],[-2,2]]]
- even_perm = AlternatingGroup(4)
- for vect in even_perm_vectors:
- cp = cartesian_product(vect)
- # The cartesian product creates duplicates, so we reduce it:
- verts += list(itertools.chain.from_iterable([[p(tuple(c)) for p in even_perm] for c in cp]))
+ # The permutations of:
+ # [2,2,0,0]
+ # [1,1,1,sqrt(5)]
+ # [1/phi^2,phi,phi,phi]
+ # [1/phi,1/phi,1/phi,phi^2]
+ vectors = [[2,2,0,0], [1,1,1,sqrt5], [1/phi**2,phi,phi,phi], [1/phi, 1/phi, 1/phi, phi**2]]
+ verts_no_sign = list(x for vec in vectors for x in Permutations(vec).list())
+
+ # The even permutations of [0,1/phi^2,1,phi^2]
+ # The even permutations of [0,1/phi,phi,sqrt(5)]
+ # The even permutations of [1/phi,1,phi,2]
+ import itertools
+ vectors = [[0,1/phi**2,1,phi**2], [0,1/phi,phi,sqrt5], [1/phi,1,phi,2]]
+ even_perm = AlternatingGroup(4)
+ verts_no_sign += list(itertools.chain.from_iterable([[p(tuple(vec)) for p in even_perm] for vec in vectors]))
+
+ # Adding for each vertex copies in all orthants:
+ # [1,1,1,sqrt(5)] -> [±1,±1,±1,±sqrt(5)]
+ from itertools import product
+ verts = [[sign[i]*perm[i] for i in range(4)] for sign in product(*[[1,-1]]*4) for perm in verts_no_sign] But I guess it's up to taste, what one prefers. |
comment:10
I did the changes. I decided to keep the construction as is. I added a raise ValueError if one tries to construct it with |
comment:11
Some minor things:
also I still count 24 permutations as I already mentioned.
|
comment:13
Replying to @kliem:
Typo. Fixed.
Well, this does what I want, what else can I say? It is very annoying to write something that creates them without duplicates, and we are dealing with a negligible amount of vertices, so I see now reason to make a fuss about inefficiency here.
Done.
That's a wonderful rhetorical question. My rhetorical answer: to make you ask rhetorical questions. ;-) New commits:
|
Changed branch from u/jipilab/classic120 to u/jipilab/classic120bis |
comment:15
Replying to @jplab:
Well, as every entry is unique, the cartesian product creates no duplicates. Hence, you don't have to remove them. This is why I find this comment very confusing. You comment that you will remove duplicates, but neither are there duplicate nor do you do any instructions that would remove duplicates, if they where there. Also you have a typo in your chain import, so this doesn't build. |
comment:17
Oops, yes, I changed the Perhaps my comment is not clear enough, it is not the cartesian product but the action of the even permutations: + import itertools import chain
+ even_perm_vectors = [[[0],[phi_inv**2,-phi_inv**2],[1,-1],[-(phi**2),phi**2]],
+ [[0],[phi_inv,-phi_inv],[phi,-phi],[-sqrt5,sqrt5]],
+ [[phi_inv,-phi_inv],[1,-1],[phi,-phi],[-2,2]]]
+ even_perm = AlternatingGroup(4)
+ for vect in even_perm_vectors:
+ cp = cartesian_product(vect)
+ # The cartesian product creates duplicates, so we reduce it:
+ verts += chain.from_iterable([p(tuple(c)) for p in even_perm] for c in cp)
^-------p acts here and creates duplicates |
Branch pushed to git repo; I updated commit sha1. New commits:
|
Branch pushed to git repo; I updated commit sha1. New commits:
|
comment:20
Should be good to go now. |
Reviewer: Jonathan Kliem |
comment:21
LGTM |
Changed branch from u/jipilab/classic120bis to |
Ticket #27760 introduced the 120-cell in the library, but it does not give the classical construction of Coxeter form 1969 available on Wikipedia:
https://en.wikipedia.org/wiki/120-cell
This ticket provides this classical construction which is much faster since it uses only a degree 2 extension of the rationals.
Depends on #27760
CC: @w-bruns @jplab @mkoeppe @videlec
Component: geometry
Keywords: polytopes, non-rational, normaliz
Author: Jean-Philippe Labbé
Branch/Commit:
9464179
Reviewer: Jonathan Kliem
Issue created by migration from https://trac.sagemath.org/ticket/28429
The text was updated successfully, but these errors were encountered: