Ask Your Question

retrieve field of a Matrix

asked 2016-11-24 06:42:28 -0500

fagui gravatar image

it may sound a stupid question,

but I'd like to know how to retrieve in a variable the field overwhich a Matrix is defined

for example, if


Is there a function where i can define for example K'= M.field() [and K' would be equal to K]


M.parent() provides some information of course, but we cannot use it directly

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2016-11-24 07:05:09 -0500

Use the base_ring method.

Here is an example.

Define a field.

sage: K = GF(7)
sage: K
Finite Field of size 7

A matrix over this field.

sage: M = random_matrix(K, 2, 2)

The matrix's base ring:

sage: KK = M.base_ring()
sage: KK
Finite Field of size 7

Check that it is the same as your original field.

sage: K is KK
edit flag offensive delete link more


thank you !

fagui gravatar imagefagui ( 2016-11-24 10:52:41 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-11-24 06:42:28 -0500

Seen: 19 times

Last updated: Nov 24 '16