Ask Your Question
1

retrieve field of a Matrix

asked 8 years ago

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

K=GF(7)
M=random_matrix(K,2,2)

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

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 8 years ago

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
True
Preview: (hide)
link

Comments

thank you !

fagui gravatar imagefagui ( 8 years ago )

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

Stats

Asked: 8 years ago

Seen: 287 times

Last updated: Nov 24 '16