08.02.2015 Views

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

Sage Reference Manual: Matrices and Spaces of Matrices - Mirrors

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Sage</strong> <strong>Reference</strong> <strong>Manual</strong>: <strong>Matrices</strong> <strong>and</strong> <strong>Spaces</strong> <strong>of</strong> <strong>Matrices</strong>, Release 6.1.1<br />

Over number fields, PARI is used by default, but general-purpose code can be requested. Same vector<br />

space, same bases, different code.:<br />

sage: Q = QuadraticField(-7)<br />

sage: a = Q.gen(0)<br />

sage: A = matrix(Q, [[ 2, 5-a, 15-a, 16+4*a],<br />

... [2+a, a, -7 + 5*a, -3+3*a]])<br />

sage: K = A.right_kernel(algorithm=’default’); K<br />

Vector space <strong>of</strong> degree 4 <strong>and</strong> dimension 2 over Number Field in a with defining polynomial x^2<br />

Basis matrix:<br />

[ 1 0 7/88*a + 3/88 -3/176*a - 39/176]<br />

[ 0 1 -1/88*a - 13/88 13/176*a - 7/176]<br />

sage: A*K.basis_matrix().transpose() == zero_matrix(Q, 2, 2)<br />

True<br />

sage: B = copy(A)<br />

sage: G = A.right_kernel(algorithm=’generic’); G<br />

Vector space <strong>of</strong> degree 4 <strong>and</strong> dimension 2 over Number Field in a with defining polynomial x^2<br />

Basis matrix:<br />

[ 1 0 7/88*a + 3/88 -3/176*a - 39/176]<br />

[ 0 1 -1/88*a - 13/88 13/176*a - 7/176]<br />

sage: B*G.basis_matrix().transpose() == zero_matrix(Q, 2, 2)<br />

True<br />

sage: K == G<br />

True<br />

For matrices over the integers, several options are possible. The basis can be an LLL-reduced basis or an<br />

echelon basis. The pivot basis isnot available. A heuristic will decide whether to use a p-adic algorithm<br />

from the IML library or an algorithm from the PARI library. Note how specifying the algorithm can mildly<br />

influence the LLL basis.<br />

sage: A = matrix(ZZ, [[0, -1, -1, 2, 9, 4, -4],<br />

... [-1, 1, 0, -2, -7, -1, 6],<br />

... [2, 0, 1, 0, 1, -5, -2],<br />

... [-1, -1, -1, 3, 10, 10, -9],<br />

... [-1, 2, 0, -3, -7, 1, 6]])<br />

sage: A.right_kernel(basis=’echelon’)<br />

Free module <strong>of</strong> degree 7 <strong>and</strong> rank 2 over Integer Ring<br />

Echelon basis matrix:<br />

[ 1 5 -8 3 -1 -1 -1]<br />

[ 0 11 -19 5 -2 -3 -3]<br />

sage: B = copy(A)<br />

sage: B.right_kernel(basis=’LLL’)<br />

Free module <strong>of</strong> degree 7 <strong>and</strong> rank 2 over Integer Ring<br />

User basis matrix:<br />

[ 2 -1 3 1 0 1 1]<br />

[-5 -3 2 -5 1 -1 -1]<br />

sage: C = copy(A)<br />

sage: C.right_kernel(basis=’pivot’)<br />

Traceback (most recent call last):<br />

...<br />

ValueError: pivot basis only available over a field, not over Integer Ring<br />

sage: D = copy(A)<br />

sage: D.right_kernel(algorithm=’pari’)<br />

Free module <strong>of</strong> degree 7 <strong>and</strong> rank 2 over Integer Ring<br />

Echelon basis matrix:<br />

[ 1 5 -8 3 -1 -1 -1]<br />

[ 0 11 -19 5 -2 -3 -3]<br />

sage: E = copy(A)<br />

sage: E.right_kernel(algorithm=’padic’, basis=’LLL’)<br />

238 Chapter 7. Base class for matrices, part 2

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!