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

sage: m = matrix( GF(17), 3, 3, [11,5,1,3,6,8,1,16,0]); d,u,v = m.smith_form()<br />

sage: d<br />

[1 0 0]<br />

[0 1 0]<br />

[0 0 0]<br />

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

True<br />

Some examples over non-PID’s work anyway:<br />

sage: R = EquationOrder(x^2 + 5, ’s’) # class number 2<br />

sage: s = R.ring_generators()[0]<br />

sage: A = matrix(R, 2, 2, [s-1,-s,-s,2*s+1])<br />

sage: D, U, V = A.smith_form()<br />

sage: D, U, V<br />

(<br />

[ 1 0] [ 4 s + 4] [ 1 -5*s + 6]<br />

[ 0 -s - 6], [ s s - 1], [ 0 1]<br />

)<br />

sage: D == U*A*V<br />

True<br />

Others don’t, but they fail quite constructively:<br />

sage: matrix(R,2,2,[s-1,-s-2,-2*s,-s-2]).smith_form()<br />

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

...<br />

ArithmeticError: Ideal Fractional ideal (2, s + 1) not principal<br />

Empty matrices are h<strong>and</strong>led safely:<br />

sage: m = MatrixSpace(OE, 2,0)(0); d,u,v=m.smith_form(); u*m*v == d<br />

True<br />

sage: m = MatrixSpace(OE, 0,2)(0); d,u,v=m.smith_form(); u*m*v == d<br />

True<br />

sage: m = MatrixSpace(OE, 0,0)(0); d,u,v=m.smith_form(); u*m*v == d<br />

True<br />

Some pathological cases that crashed earlier versions:<br />

sage: m = Matrix(OE, [[2*w,2*w-1,-w+1],[2*w+2,-2*w-1,w-1],[-2*w-1,-2*w-2,2*w-1]]); d, u, v =<br />

True<br />

sage: m = matrix(OE, 3, 3, [-5*w-1,-2*w-2,4*w-10,8*w,-w,w-1,-1,1,-8]); d,u,v = m.smith_form(<br />

True<br />

solve_left(B, check=True)<br />

If self is a matrix A, then this function returns a vector or matrix X such that XA = B. If B is a vector<br />

then X is a vector <strong>and</strong> if B is a matrix, then X is a matrix.<br />

INPUT:<br />

•B - a matrix<br />

•check - bool (default: True) - if False <strong>and</strong> self is nonsquare, may not raise an error message even if<br />

there is no solution. This is faster but more dangerous.<br />

EXAMPLES:<br />

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

sage: B = matrix(QQ,2,2, [1, 0, 1, -1])<br />

sage: X = A.solve_left(B)<br />

253

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

Saved successfully!

Ooh no, something went wrong!