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

[3/2 200 5/2]<br />

[ 3 7/2 4]<br />

We test that an exception is raised when the block is out <strong>of</strong> bounds:<br />

sage: matrix([1]).set_block(0,1,matrix([1]))<br />

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

...<br />

IndexError: matrix window index out <strong>of</strong> range<br />

smith_form()<br />

If self is a matrix over a principal ideal domain R, return matrices D, U, V over R such that D = U * self *<br />

V, U <strong>and</strong> V have unit determinant, <strong>and</strong> D is diagonal with diagonal entries the ordered elementary divisors<br />

<strong>of</strong> self, ordered so that D i | D i+1 . Note that U <strong>and</strong> V are not uniquely defined in general, <strong>and</strong> D is defined<br />

only up to units.<br />

INPUT:<br />

•self - a matrix over an integral domain. If the base ring is not a PID, the routine might work, or else<br />

it will fail having found an example <strong>of</strong> a non-principal ideal. Note that we do not call any methods<br />

to check whether or not the base ring is a PID, since this might be quite expensive (e.g. for rings <strong>of</strong><br />

integers <strong>of</strong> number fields <strong>of</strong> large degree).<br />

ALGORITHM: Lifted wholesale from http://en.wikipedia.org/wiki/Smith_normal_form<br />

See Also:<br />

elementary_divisors()<br />

AUTHORS:<br />

•David Loeffler (2008-12-05)<br />

EXAMPLES:<br />

An example over the ring <strong>of</strong> integers <strong>of</strong> a number field (<strong>of</strong> class number 1):<br />

sage: OE = NumberField(x^2 - x + 2,’w’).ring_<strong>of</strong>_integers()<br />

sage: w = OE.ring_generators()[0]<br />

sage: m = Matrix([ [1, w],[w,7]])<br />

sage: d, u, v = m.smith_form()<br />

sage: (d, u, v)<br />

(<br />

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

[ 0 -w + 9], [-w 1], [ 0 1]<br />

)<br />

sage: u * m * v == d<br />

True<br />

sage: u.base_ring() == v.base_ring() == d.base_ring() == OE<br />

True<br />

sage: u.det().is_unit() <strong>and</strong> v.det().is_unit()<br />

True<br />

An example over the polynomial ring QQ[x]:<br />

sage: R. = QQ[]; m=x*matrix(R,2,2,1) - matrix(R, 2,2,[3,-4,1,-1]); m.smith_form()<br />

(<br />

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

[ 0 x^2 - 2*x + 1], [ 1 x - 3], [ 0 1]<br />

)<br />

An example over a field:<br />

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