#8986: Add support for convex rational polyhedral cones
----------------------------------+-----------------------------------------
   Reporter:  novoselt            |       Owner:  mhampton    
       Type:  enhancement         |      Status:  needs_review
   Priority:  major               |   Milestone:  sage-4.4.4  
  Component:  geometry            |    Keywords:              
     Author:  Andrey Novoseltsev  |    Upstream:  N/A         
   Reviewer:  Volker Braun        |      Merged:              
Work_issues:                      |  
----------------------------------+-----------------------------------------
Changes (by novoselt):

  * status:  needs_work => needs_review


Comment:

 OK, I think I have addressed all the points in the original review except
 2) which is pretty much impossible to realize completely (originally I was
 thinking of (1,1,1) as vectors, but they are just tuples, see the above
 comment for vector behaviour in this situation). I have added a general
 warning about tuples in the main `ToricLattice` documentation.

 I added `__contains__` to `ToricLattice`, since I discovered that the
 inherited implementation is not suitable.

 I added `__contains__`, `_contains`, and `contains` to cones. The real job
 is done in `_contains`, two others call it. The reason for the third
 function is an attempt to make warnings show where the actual potential
 mistake was, which requires the same calling depth. Unfortunately, in my
 tests it worked as I wanted only if it was triggered by some library code,
 in the notebook for created functions and attached files it just shows
 `main`. But that may change and maybe the terminal behaves differently.
 Now `cone.contains(stuff)` will try its best to return `True` by
 interpreting `stuff` as a point in the ambient space of `cone`, i.e. in
 `cone.lattice().base_extend(RR)`. However, it will catch points from
 foreign lattices first and return `False` with a warning, visible the
 first time for each location.

 That's how reviewer's code works with the new version of the patch:
 {{{
 sage: octant = Cone([(1,0,0), (0,1,0), (0,0,1)])
 sage: N = octant.lattice()
 sage: n = N(1,1,1)
 sage: n.set_immutable()
 sage: n in octant # True was desired
 True
 sage: (1,0,0) in octant # True was desired
 True
 sage: N(1,0,0) in octant.rays()  # was and should be True
 True
 sage: n = N(1,0,0)
 sage: n.set_immutable()
 sage: n in octant.ray_set()  # was and should be True
 True
 sage: M = N.dual()
 sage: M(1,0,0) == N(1,0,0)   # Error was desired
 False
 sage: (1,0,0) == N(1,0,0)    # True was desired, but difficult to get
 False
 sage: M(1,0,0) == (1,0,0)    # True was desired, but difficult to get
 False
 sage: (1,0,0) == (1,0,0)     # works as expected
 True
 sage: (1,0,0) in octant.rays()  # True was desired, but difficult to get
 False
 sage: M(1,0,0) in octant.rays()  # Error was desired
 False
 sage: cone = Cone([[1,0],[0,1]])
 sage: (1,1) in cone # Was False
 True
 sage: M = cone.lattice().dual()
 sage: M(1,1) in cone # Now gives warning on the first attempt
 __main__:1: UserWarning: you have checked if a cone contains a point from
 another lattice, this is always False!
 False
 }}}
 I suppose two lines marked "Error was desired" can also give a warning the
 first time they are invoked, if we implement a custom `__eq__` in addition
 to `__cmp__` for `ToricLatticeElement`. Should this be done?

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/8986#comment:14>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to