Opened 7 years ago

Closed 7 years ago

#19364 closed enhancement (fixed)

Add edges() and endpoints() method to intervals

Reported by: jdemeyer Owned by:
Priority: major Milestone: sage-6.10
Component: basic arithmetic Keywords:
Cc: Merged in:
Authors: Jeroen Demeyer Reviewers: Vincent Delecroix
Report Upstream: N/A Work issues:
Branch: 388d495 (Commits, GitHub, GitLab) Commit: 388d495a093e551084e137f947e51ad74f6e0100
Dependencies: Stopgaps:

Status badges

Description (last modified by jdemeyer)

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.

Change History (14)

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:3 Changed 7 years ago by jdemeyer

  • Branch set to u/jdemeyer/add_edges___method_to_rif_and_cif_elements

comment:4 Changed 7 years ago by jdemeyer

  • Commit set to 388d495a093e551084e137f947e51ad74f6e0100
  • Milestone changed from sage-6.9 to sage-6.10
  • Status changed from new to needs_review

New commits:

388d495Add 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: 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

Replying to chapoton:

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: 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: Changed 7 years ago by vdelecroix

Replying to jdemeyer:

"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: Changed 7 years ago by jdemeyer

Replying to vdelecroix:

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

Replying to jdemeyer:

Replying to vdelecroix:

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.

comment:14 Changed 7 years ago by vbraun

  • Branch changed from u/jdemeyer/add_edges___method_to_rif_and_cif_elements to 388d495a093e551084e137f947e51ad74f6e0100
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.