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

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

Besides the integers, rings may be as general as principal ideal domains. Results are then free modules.<br />

sage: R. = QQ[]<br />

sage: A = matrix(R, [[ 1, y, 1+y^2],<br />

... [y^3, y^2, 2*y^3]])<br />

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

Free module <strong>of</strong> degree 3 <strong>and</strong> rank 1 over Univariate Polynomial Ring in y over Rational Field<br />

Echelon basis matrix:<br />

[-1 -y 1]<br />

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

True<br />

It is possible to compute a kernel for a matrix over an integral domain which is not a PID, but usually this<br />

will fail.<br />

sage: D. = ZZ[]<br />

sage: A = matrix(D, 2, 2, [[x^2 - x, -x + 5],<br />

... [x^2 - 8, -x + 2]])<br />

sage: A.right_kernel()<br />

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

...<br />

ArithmeticError: Ideal Ideal (x^2 - x, x^2 - 8) <strong>of</strong> Univariate Polynomial Ring in x over Inte<br />

<strong>Matrices</strong> over non-commutative rings are not a good idea either. These are the “usual” quaternions.<br />

sage: Q. = QuaternionAlgebra(-1,-1)<br />

sage: A = matrix(Q, 2, [i,j,-1,k])<br />

sage: A.right_kernel()<br />

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

...<br />

NotImplementedError: Cannot compute a matrix kernel over Quaternion Algebra (-1, -1) with ba<br />

Sparse matrices, over the rationals <strong>and</strong> the integers, use the same routines as the dense versions.<br />

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

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

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

... sparse=True)<br />

sage: A.right_kernel()<br />

Free module <strong>of</strong> degree 5 <strong>and</strong> rank 3 over Integer Ring<br />

Echelon basis matrix:<br />

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

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

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

sage: B = A.change_ring(QQ)<br />

sage: B.is_sparse()<br />

True<br />

sage: B.right_kernel()<br />

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

Basis matrix:<br />

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

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

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

With no columns, the kernel can only have dimension zero. With no rows, every possible vector is in the<br />

239

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

Saved successfully!

Ooh no, something went wrong!