Ask Your Question
1

Converting kernel to matrix

asked 2011-01-09 00:15:35 -0600

Mustafa gravatar image

I construct a matrix A and compute its kernel by

A = matrix(GF(2),vectors)
B = A.kernel()

Now I want to convert B to a matrix, such that I can use .nrows() and other matrix-methods, how to do that?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2011-01-09 01:50:18 -0600

DSM gravatar image

(Showing my work).

The first thing I tried was the obvious:

sage: vectors = [[1,0,1],[1,0,1],[1,1,0]]
sage: A = matrix(GF(2),vectors)
sage: B = A.kernel()
sage: matrix(B)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
[...]
ValueError: Invalid matrix constructor.  Type matrix? for help

which didn't work. So looked at B:

sage: B
Vector space of degree 3 and dimension 1 over Finite Field of size 2
Basis matrix:
[1 1 0]

and saw that it clearly knows about the matrix I think you're looking for. In Sage, functionality often lives inside objects, so if you type help(B) or or type "B." and then tab, you can see the list of internal functions, and I found both .matrix and .basis_matrix. I think either should work here, so:

sage: M = B.basis_matrix()
sage: M
[1 1 0]
sage: type(M)
<type 'sage.matrix.matrix_mod2_dense.Matrix_mod2_dense'>
sage: M.nrows()
1

Is that what you were after?

edit flag offensive delete link more

Comments

That is it! Thank you.

Mustafa gravatar imageMustafa ( 2011-01-09 09:06:01 -0600 )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

Stats

Asked: 2011-01-09 00:15:35 -0600

Seen: 253 times

Last updated: Jan 09 '11