If I act upon a polyhedron, the result is computed twice. Why does this 
happen, how can one avoid this?

Currently, in `Polyhedron_base` (the element class) the method 
`_acted_upon_` is defined, which is where the action is discovered.

In the following example, I try to act on a polyhedron with a matrix. If I 
first discover the action, I'm much faster than when I just plainly 
multiply.

The reason is that for discovering action manually, the method `an_element` 
of parent is used. Very smart, because this is an almost trivial element 
just to make things work.

However, if I just plainly multiply, it is not done this way. Instead it 
computes the result twice. Why?

Thank you,

Jonathan

sage: P = polytopes.permutahedron(6)
sage: M = matrix(P.base_ring(), P.dim(), P.ambient_dim(),
....:                         [v.vector() - P.an_affine_basis()[0].vector() 
for v in P.an_affine_basis()[1:]])
sage: %time coercion_model.analyse(M, P)
CPU times: user 18.5 ms, sys: 0 ns, total: 18.5 ms
Wall time: 17.5 ms
(['Action discovered.',
  Left action by Full MatrixSpace of 5 by 6 dense matrices over Integer Ring 
on Polyhedra in ZZ^6],
 Polyhedra in ZZ^5)
sage: %time M*P
CPU times: user 137 ms, sys: 3.39 ms, total: 141 ms
Wall time: 140 ms
A 5-dimensional polyhedron in ZZ^5 defined as the convex hull of 720 
vertices


sage: coercion_model.reset_cache()
sage: %time M*P
CPU times: user 256 ms, sys: 3.53 ms, total: 260 ms
Wall time: 259 ms
A 5-dimensional polyhedron in ZZ^5 defined as the convex hull of 720 
vertices

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/c6169b79-06e0-480d-89fc-80efa3ae1e90o%40googlegroups.com.

Reply via email to