Opened 7 years ago

Closed 7 years ago

# Add edges() and endpoints() method to intervals

Reported by: Owned by: jdemeyer major sage-6.10 basic arithmetic Jeroen Demeyer Vincent Delecroix N/A 388d495 388d495a093e551084e137f947e51ad74f6e0100

Add an edges() method to intervals (elements of RIF and CIF).

1. For complex intervals, return the 4 edges of the rectangular interval as intervals.
2. For real intervals, return the endpoints as single-point intervals.

For CIF, we also add an endpoints() method returning the 4 corners of the interval.

In other words, if the given interval lives in some N-dimensional space, then:

1. edges() returns the (N-1)-dimensional faces as intervals.
2. endpoints() returns the 0-dimensional faces as points.

### comment:1 Changed 7 years ago by jdemeyer

• Description modified (diff)
• Summary changed from Add edges() method to RIF and CIF elements to Add edges() and endpoints() method to RIF and CIF elements

### comment:2 Changed 7 years ago by jdemeyer

• Summary changed from Add edges() and endpoints() method to RIF and CIF elements to Add edges() and endpoints() method to intervals

### comment:4 Changed 7 years ago by jdemeyer

• Milestone changed from sage-6.9 to sage-6.10
• Status changed from new to needs_review

New commits:

 ​388d495 Add edges() and endpoints() methods to intervals

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

• Description modified (diff)

### comment:6 Changed 7 years ago by jdemeyer

• Description modified (diff)

### comment:7 follow-up: ↓ 8 Changed 7 years ago by chapoton

Strange order:

(lower left, upper right, upper left, lower right)

what is the reason of this choice ?

### comment:8 in reply to: ↑ 7 Changed 7 years ago by jdemeyer

Strange order:

(lower left, upper right, upper left, lower right)

what is the reason of this choice ?

The rationale is the following: suppose you need 2 endpoints defining the interval (i.e. such that the union is the whole interval). In that case, those endpoints are interval.endpoints()[:2] both in the real and complex case.

For the edges() method, I put pairs of opposing edges next to each other, because an application might want to process such pairs of opposing edges. The fact that the endpoints() method also returns pairs of opposing endpoints is consistent with that.

### comment:9 Changed 7 years ago by vdelecroix

• Status changed from needs_review to needs_info

Are both methods really needed? endpoints already contains all the information. The only advantage of edges I see is that the output belongs to the same field.

### comment:10 follow-up: ↓ 11 Changed 7 years ago by jdemeyer

• Status changed from needs_info to needs_review

"needed" is always very subjective. I mean, is Sage (the program as a whole) "needed"?

The main motivation is to allow more easily code which can run unchanged for both RIF and CIF. Depending on the application, that would be either edges() or endpoints() which happen to coincide for RIF but not for CIF.

### comment:11 in reply to: ↑ 10 ; follow-up: ↓ 12 Changed 7 years ago by vdelecroix

"needed" is always very subjective. I mean, is Sage (the program as a whole) "needed"?

The main motivation is to allow more easily code which can run unchanged for both RIF and CIF. Depending on the application, that would be either edges() or endpoints() which happen to coincide for RIF but not for CIF.

I understand that you need an implementation in both RIF and CIF. I do not understand why you need two methods. My comment concerned the fact that edges can easily be deduced from endpoints.

### comment:12 in reply to: ↑ 11 ; follow-up: ↓ 13 Changed 7 years ago by jdemeyer

My comment concerned the fact that edges can easily be deduced from endpoints.

It's not really obvious to me how can one easily construct edges given endpoints.

But even then, there is very little harm in having redundant methods. For CIF, I think that both endpoints and edges are useful. Since I want something consistent for RIF and CIF, I also added edges to RIF.

### comment:13 in reply to: ↑ 12 Changed 7 years ago by vdelecroix

• Reviewers set to Vincent Delecroix
• Status changed from needs_review to positive_review

My comment concerned the fact that edges can easily be deduced from endpoints.

It's not really obvious to me how can one easily construct edges given endpoints.

But even then, there is very little harm in having redundant methods. For CIF, I think that both endpoints and edges are useful. Since I want something consistent for RIF and CIF, I also added edges to RIF.

All right. Let it go.