Opened 6 years ago

Closed 6 years ago

# Implements is_zero and is_commutative for infinity ring

Reported by: Owned by: virmaux major sage-6.7 calculus InfinityRing, matrix, days64 jipilab, rws Aladin Virmaux Jean-Philippe Labbé N/A 76307b8 76307b8af01f0af127a7a2abb2cd79851f59028e

Infinity ring is commutative and non-zero.

Because there is no `is_zero` and `is_commutative` method for `InfinityRing`, numerous methods fails for matrices with infinity elements. This problem came up in relation with the ticket #17798.

```sage: m = Matrix([Infinity])
sage: m.nrows()
1
sage: m.rows()
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

[...]
AttributeError: 'InfinityRing_class' object has no attribute 'is_zero'
```

### comment:1 Changed 6 years ago by virmaux

• Branch set to u/virmaux/matrix_with_infinity

### comment:2 Changed 6 years ago by virmaux

• Commit set to 270acabc1c9ab7ac116a188643fcc90a01c5043d
• Status changed from new to needs_review

New commits:

 ​270acab `17990: add is_zero and is_commutative methods for InfinityRing`

### comment:3 Changed 6 years ago by kcrisman

Do other systems (such as in the mission statement) even have matrices with infinity? I guess the infinity ring is commutative...?

### comment:4 Changed 6 years ago by virmaux

Hello! I am not sure to understand your question. Are you looking for actual examples in sage of code using matrix for infinity elements ?

The depth of the problem of the mission statement is that the base ring of `InfinityRing` is itself. The methods rows is looking if self has the attribute is_commutative, and if not suppose that self.base_ring has it.

### comment:5 Changed 6 years ago by kcrisman

Sorry, what I meant was do other math software systems such as Maple, Mathematica, Magma, ... have matrices with infinity in them? Does anyone ever use such things? Or should we instead disallow them? (I'm not speaking of arrays with `NaN` values, but of matrices specifically and infinity specifically.)

### comment:6 follow-up: ↓ 7 Changed 6 years ago by jipilab

• Description modified (diff)

Coxeter matrices is an example of matrix where infinity is a possible value. See #17798.

### comment:7 in reply to: ↑ 6 Changed 6 years ago by mmezzarobba

Coxeter matrices is an example of matrix where infinity is a possible value. See #17798.

But matrices over the infinity ring will not allow you to mix infinite entries with integers or whatever else. While

```sage: Matrix([[SR(Infinity), 1],[2,3]])
[+Infinity         1]
[        2         3]
```

works fine.

### comment:8 Changed 6 years ago by vdelecroix

Hello,

```We check that #17990 is fixed::
```

should be

```We check that :trac:`17990` is fixed::
```

On the other hand, a better solution would be to use the new category framework for that and get rid of `ParentWithGens`.

Vincent

### comment:9 follow-up: ↓ 10 Changed 6 years ago by tscrim

This ticket deals exclusively with `MatrixSpace` over `InfinityRing`, and in this case, it is `InfinityRing` that needs to become a new-style `Parent` class to fix this ticket and perhaps is the better fix IMO for `is_zero` (along with the implementation of `is_commutative`).

In parallel to this, `MatrixSpace` should become a `Parent`, and since it walks like one, it shouldn't be too hard to convert it over.

For matrices with infinities, we want to construct a Coxeter matrix without the current hack of representing `oo` with `-1` (in `CoxeterMatrixGroup`), nor do we want to use the `SymbolicRing` as we feel it is way too heavy-handed of a solution. I guess fundamentally we want a 2D array since we don't need the ground set to be a ring (it'd be `NN[oo]`), but the matrix class(es) in Sage have nice displays...

### comment:10 in reply to: ↑ 9 ; follow-up: ↓ 11 Changed 6 years ago by mmezzarobba

For matrices with infinities, we want to construct a Coxeter matrix without the current hack of representing `oo` with `-1` (in `CoxeterMatrixGroup`), nor do we want to use the `SymbolicRing` as we feel it is way too heavy-handed of a solution.

So then I guess you need something like an "Alexandroff extension functor" that you could apply to a Parent to adjoin it an element at infinity, don't you?

### comment:11 in reply to: ↑ 10 ; follow-up: ↓ 15 Changed 6 years ago by tscrim

For matrices with infinities, we want to construct a Coxeter matrix without the current hack of representing `oo` with `-1` (in `CoxeterMatrixGroup`), nor do we want to use the `SymbolicRing` as we feel it is way too heavy-handed of a solution.

So then I guess you need something like an "Alexandroff extension functor" that you could apply to a Parent to adjoin it an element at infinity, don't you?

If that means given an ordered set `S`, we can add an element `oo` such that `x < oo` for all in `S`, then yes.

### comment:12 Changed 6 years ago by chapoton

• Status changed from needs_review to needs_work

Please use the trac role `:trac:`17990`` instead of just `#17990` in the doc.

### comment:13 Changed 6 years ago by git

• Commit changed from 270acabc1c9ab7ac116a188643fcc90a01c5043d to 36263134d2c65c97ef3e57e8f0efa2e8ba0b52b9

Branch pushed to git repo; I updated commit sha1. New commits:

 ​f8a9536 `Merge branch 'develop' into t/17990/matrix_with_infinity` ​3626313 `17790: correct use of trac role`

### comment:14 Changed 6 years ago by virmaux

• Status changed from needs_work to needs_review

I just merged develop and corrected the wrong reference to trac into `:trac:`17990``.

### comment:15 in reply to: ↑ 11 Changed 6 years ago by mmezzarobba

So then I guess you need something like an "Alexandroff extension functor" that you could apply to a Parent to adjoin it an element at infinity, don't you?

If that means given an ordered set `S`, we can add an element `oo` such that `x < oo` for all in `S`, then yes.

Well, the reference to Alexandroff extensions is not appropriate then, but the idea would be the same.

In any case, let me ask again: is the following really what you want?

```sage: matrix([[Infinity], [1]])
[               +Infinity]
[A positive finite number]
```

### comment:16 Changed 6 years ago by jipilab

I believe not. What we wish to have is something like this:

```sage: Matrix([[oo, 3],[2,3]])
[+Infinity         1]
[        2         3]
sage: M.parent()
Full MatrixSpace of 2 by 2 dense matrices over (NN\cup \{oo\}) <--------------
```

... but this is not related to the ticket description. If the ticket is fixed, it will be enough for now.

### comment:17 Changed 6 years ago by chapoton

• Milestone changed from sage-6.6 to sage-6.7

### comment:18 Changed 6 years ago by jipilab

Coming back to the description of the ticket, does it make sense for Infinityring to have the two methods

is_zero() and is_commutative()?

IMHO, the answer is yes and the patch fixes this. This is the problem raised in the ticket. Otherwise, the description should be changed to be more precise.

### comment:19 Changed 6 years ago by jipilab

• Description modified (diff)
• Reviewers set to Jean-Philippe Labbé
• Status changed from needs_review to needs_work

Could you please do the following

-add your full name as an Author, -make the title of the ticket reflect the addition of the two methods.

This ticket is not about matrix with Infinity, but rather about the fact that we need two methods on the infinity ring.

### comment:20 Changed 6 years ago by virmaux

• Authors set to Aladin Virmaux
• Description modified (diff)
• Summary changed from Matrix with Infinity to Implements is_zero and is_commutative for infinity ring

Hey, sorry for the delay but I have been really busy these last days. I have also merged develop and corrected a few PEP8.

Last edited 6 years ago by virmaux (previous) (diff)

### comment:21 Changed 6 years ago by git

• Commit changed from 36263134d2c65c97ef3e57e8f0efa2e8ba0b52b9 to 76307b8af01f0af127a7a2abb2cd79851f59028e

Branch pushed to git repo; I updated commit sha1. New commits:

 ​610c335 `Merge branch 'develop' into t/17990/matrix_with_infinity` ​76307b8 `PEP 8`

### comment:22 Changed 6 years ago by jipilab

• Status changed from needs_work to positive_review

This looks good to me.

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

• Branch changed from u/virmaux/matrix_with_infinity to 76307b8af01f0af127a7a2abb2cd79851f59028e
• Resolution set to fixed
• Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.