First time here? Check out the FAQ!

Ask Your Question
1

Converting kernel to matrix

asked 14 years ago

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?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
3

answered 14 years ago

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?

Preview: (hide)
link

Comments

That is it! Thank you.

Mustafa gravatar imageMustafa ( 14 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

Stats

Asked: 14 years ago

Seen: 688 times

Last updated: Jan 09 '11