Opened 11 years ago

Closed 10 years ago

# Dimension of Polyhedron is not well defined

Reported by: Owned by: jipilab mhampton major sage-5.6 geometry dimension, polytope, polyhedron sage-5.6.beta3 Volker Braun David Loeffler N/A #11634, #13638, #11763

Given a vector space V and a polyhedron P, the dimension of P is the dimension of its affine hull, i.e. the smallest affine subspace of V in which P can live. (For a reference, see G.M. Ziegler's book "Lectures on Polytopes" p.5)

Right now, the dimension of a Polyhedron is defined as:

```    def dim(self):
"""
Return the dimension of the polyhedron.

EXAMPLES::

sage: simplex = Polyhedron(vertices = [[1,0,0,0],[0,0,0,1],[0,1,0,0],[0,0,1,0]])
sage: simplex.dim()
3
sage: simplex.ambient_dim()
4
"""
return self.ambient_dim() - self.n_equations()
```

But this is obviously not the truthful definition. With the way things are now, this leads to various problems such as:

```sage: P1=Polyhedron(vertices=[[1,0,0],[0,1,0],[0,0,1]])
sage: P2=Polyhedron(vertices=[[2,0,0],[0,2,0],[0,0,2]])
sage: Inter=P1.intersection(P2)
sage: Inter
The empty polyhedron in QQ^3.
sage: Inter.dim()
1
```

While the right answer should be -1.

One can produce many other examples...

Apply trac_12193_fix_dimension.patch

### comment:1 Changed 11 years ago by vbraun

Authors: → Volker Braun → #11763 modified (diff) new → needs_review

Fixed by attached patch.

### comment:2 Changed 11 years ago by davidloeffler

I've added a new patch which will stop the patchbot whining about trailing whitespace and commit messages.

Apply trac_12193_fix_dimension-v2.patch

### comment:3 Changed 11 years ago by vbraun

I'm fine with your changes :-)

### comment:4 Changed 11 years ago by davidloeffler

Status: needs_review → positive_review

### comment:5 Changed 11 years ago by jdemeyer

Dependencies: #11763 → #11634, #11763 sage-5.0 → sage-pending

### comment:6 Changed 11 years ago by vbraun

Rediffed for sage-5.0.beta11, nothing of interest changed.

### comment:8 Changed 10 years ago by vbraun

Rebased for #11763

### comment:9 Changed 10 years ago by vbraun

Milestone: sage-pending → sage-5.5

### comment:10 Changed 10 years ago by jdemeyer

Dependencies: #11634, #11763 → #11634, #13638, #11763 sage-5.5 → sage-pending

### comment:11 Changed 10 years ago by vbraun

Reviewers: → David Loeffler

### comment:12 Changed 10 years ago by vbraun

For the patchbot: apply trac_12193_fix_dimension.patch only

### comment:13 Changed 10 years ago by vbraun

The patchbot found a machine-dependent issue in a cmp() doctest, fixed now.

Updated patch

### comment:14 Changed 10 years ago by vbraun

Updated patch to push one patch hunk down to #11763.

### comment:15 Changed 10 years ago by jdemeyer

Milestone: sage-pending → sage-5.6

### comment:16 Changed 10 years ago by jdemeyer

Merged in: → sage-5.6.beta3 → fixed positive_review → closed
Note: See TracTickets for help on using tickets.