Dividing a matrix by integer one returns a matrix over rational field

24 views
Skip to first unread message

slabbe

unread,
Jun 24, 2016, 8:58:41 AM6/24/16
to sage-support
sage: m = identity_matrix(3)
sage: m.parent()
Full MatrixSpace of 3 by 3 dense matrices over Integer Ring
sage: (m/1).parent()
Full MatrixSpace of 3 by 3 dense matrices over Rational Field

I was expecting Integer Ring for the last result. Why not?

Sébastien

John Cremona

unread,
Jun 24, 2016, 9:06:22 AM6/24/16
to SAGE support
Presumably for the same reason as

sage: a=3
sage: a.parent()
Integer Ring
sage: (a/1).parent()
Rational Field

The type (and parent) of the result is the same whether or not the
division goes exactly.

John

>
> Sébastien
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support...@googlegroups.com.
> To post to this group, send email to sage-s...@googlegroups.com.
> Visit this group at https://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.

Jeroen Demeyer

unread,
Jun 24, 2016, 11:54:03 AM6/24/16
to sage-s...@googlegroups.com
There is a general philosophy in Sage that the *parent* of the output of
an operation should only depend on the *parent* of the inputs.

So, because 5/2 is a Rational, also 5/1 should be a Rational.
Reply all
Reply to author
Forward
0 new messages