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 = MatrixSpace(ZZ, 2,0)(0); d,u,v = m.smith_form(); u*m*v == d<br />

True<br />

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

True<br />

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

True<br />

See Also:<br />

elementary_divisors()<br />

stack(bottom, subdivide=False)<br />

Return the matrix self on top <strong>of</strong> bottom: [ self ] [ bottom ]<br />

EXAMPLES:<br />

sage: M = Matrix(ZZ, 2, 3, range(6))<br />

sage: N = Matrix(ZZ, 1, 3, [10,11,12])<br />

sage: M.stack(N)<br />

[ 0 1 2]<br />

[ 3 4 5]<br />

[10 11 12]<br />

A vector may be stacked below a matrix.<br />

sage: A = matrix(ZZ, 2, 4, range(8))<br />

sage: v = vector(ZZ, 4, range(4))<br />

sage: A.stack(v)<br />

[0 1 2 3]<br />

[4 5 6 7]<br />

[0 1 2 3]<br />

The subdivide option will add a natural subdivision between self <strong>and</strong><br />

bottom. For more details about how subdivisions are managed when stacking, see<br />

sage.matrix.matrix1.Matrix.stack().<br />

sage: A = matrix(ZZ, 3, 4, range(12))<br />

sage: B = matrix(ZZ, 2, 4, range(8))<br />

sage: A.stack(B, subdivide=True)<br />

[ 0 1 2 3]<br />

[ 4 5 6 7]<br />

[ 8 9 10 11]<br />

[-----------]<br />

[ 0 1 2 3]<br />

[ 4 5 6 7]<br />

TESTS:<br />

Stacking a dense matrix atop a sparse one should work:<br />

sage: M = Matrix(ZZ, 2, 3, range(6))<br />

sage: M.is_sparse()<br />

False<br />

sage: N = diagonal_matrix([10,11,12], sparse=True)<br />

sage: N.is_sparse()<br />

True<br />

sage: P = M.stack(N); P<br />

[ 0 1 2]<br />

[ 3 4 5]<br />

[10 0 0]<br />

[ 0 11 0]<br />

335

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

Saved successfully!

Ooh no, something went wrong!