Ask Your Question

retrieve field of a Matrix

asked 2016-11-24 13:42:28 +0200

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 14:05:09 +0200

slelievre gravatar image

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 17:52:41 +0200 )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 13:42:28 +0200

Seen: 187 times

Last updated: Nov 24 '16