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

•Jason Grout (2008-03): almost a complete rewrite, with bits <strong>and</strong> pieces from the original implementation<br />

sage.matrix.constructor.block_diagonal_matrix(*sub_matrices, **kwds)<br />

This function is available as block_diagonal_matrix(...) <strong>and</strong> matrix.block_diagonal(...).<br />

Create a block matrix whose diagonal block entries are given by sub_matrices, with zero elsewhere.<br />

See also block_matrix().<br />

EXAMPLES:<br />

sage: A = matrix(ZZ, 2, [1,2,3,4])<br />

sage: block_diagonal_matrix(A, A)<br />

[1 2|0 0]<br />

[3 4|0 0]<br />

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

[0 0|1 2]<br />

[0 0|3 4]<br />

The sub-matrices need not be square:<br />

sage: B = matrix(QQ, 2, 3, range(6))<br />

sage: block_diagonal_matrix(~A, B)<br />

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

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

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

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

[ 0 0| 3 4 5]<br />

sage.matrix.constructor.block_matrix(*args, **kwds)<br />

This function is available as block_matrix(...) <strong>and</strong> matrix.block(...).<br />

Returns a larger matrix made by concatenating submatrices (rows first, then columns). For example, the matrix<br />

[ A B ]<br />

[ C D ]<br />

is made up <strong>of</strong> submatrices A, B, C, <strong>and</strong> D.<br />

INPUT:<br />

The block_matrix comm<strong>and</strong> takes a list <strong>of</strong> submatrices to add as blocks, optionally preceded by a ring <strong>and</strong> the<br />

number <strong>of</strong> block rows <strong>and</strong> block columns, <strong>and</strong> returns a matrix.<br />

The submatrices can be specified as a list <strong>of</strong> matrices (using nrows <strong>and</strong> ncols to determine their layout), or a<br />

list <strong>of</strong> lists <strong>of</strong> matrices, where each list forms a row.<br />

•ring - the base ring<br />

•nrows - the number <strong>of</strong> block rows<br />

•ncols - the number <strong>of</strong> block cols<br />

•sub_matrices - matrices (see below for syntax)<br />

•subdivide - boolean, whether or not to add subdivision information to the matrix<br />

•sparse - boolean, whether to make the resulting matrix sparse<br />

EXAMPLES:<br />

sage: A = matrix(QQ, 2, 2, [3,9,6,10])<br />

sage: block_matrix([ [A, -A], [~A, 100*A] ])<br />

[ 3 9| -3 -9]<br />

[ 6 10| -6 -10]<br />

22 Chapter 2. Matrix Constructor

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

Saved successfully!

Ooh no, something went wrong!