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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<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 />

True<br />

sage: C == -P<br />

True<br />

sage: E = A.right_kernel_matrix(algorithm=’default’, basis=’echelon’); E<br />

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

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

sage: A*E.transpose() == zero_matrix(QQ, 4, 2)<br />

True<br />

Since the rationals are a field, we can call the general code available for any field by using the ‘generic’<br />

keyword.<br />

sage: A = matrix(QQ, [[1, 0, 1, -3, 1],<br />

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

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

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

sage: G = A.right_kernel_matrix(algorithm=’generic’, basis=’echelon’); G<br />

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

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

sage: A*G.transpose() == zero_matrix(QQ, 4, 2)<br />

True<br />

We verify that the rational matrix code is called for both dense <strong>and</strong> sparse rational matrices, with equal<br />

result.<br />

sage: A = matrix(QQ, [[1, 0, 1, -3, 1],<br />

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

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

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

... sparse=False)<br />

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

sage: set_verbose(1)<br />

sage: D = A.right_kernel(); D<br />

verbose ...<br />

verbose 1 () computing right kernel matrix over the rationals for 4x5 matrix<br />

...<br />

verbose 1 () done computing right kernel matrix over the rationals for 4x5 matrix<br />

...<br />

Vector space <strong>of</strong> degree 5 <strong>and</strong> dimension 2 over Rational Field<br />

Basis matrix:<br />

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

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

sage: S = B.right_kernel(); S<br />

verbose ...<br />

verbose 1 () computing right kernel matrix over the rationals for 4x5 matrix<br />

...<br />

verbose 1 () done computing right kernel matrix over the rationals for 4x5 matrix<br />

...<br />

Vector space <strong>of</strong> degree 5 <strong>and</strong> dimension 2 over Rational Field<br />

Basis matrix:<br />

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

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

sage: set_verbose(0)<br />

sage: D == S<br />

True<br />

Over Number Fields:<br />

Kernels are by default computed by PARI, (except for exceptions like the rationals themselves). The raw<br />

results from PARI are a pivot basis, so the basis keywords ‘computed’ <strong>and</strong> ‘pivot’ will return the same<br />

242 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!