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

otherwise they are discarded. When subdivide is False there is no subdivision information in the<br />

result.<br />

Warning: If subdivide is True then unequal row subdivisions will be discarded, since it would<br />

be ambiguous how to interpret them. If the subdivision behavior is not what you need, you can manage<br />

subdivisions yourself with methods like get_subdivisions() <strong>and</strong> subdivide(). You<br />

might also find block_matrix() or block_diagonal_matrix() useful <strong>and</strong> simpler in some<br />

instances.<br />

EXAMPLES:<br />

Augmenting with a matrix.<br />

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

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

sage: A.augment(B)<br />

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

[ 4 5 6 7 3 4 5]<br />

[ 8 9 10 11 6 7 8]<br />

Augmenting with a vector.<br />

sage: A = matrix(QQ, 2, [0, 2, 4, 6, 8, 10])<br />

sage: v = vector(QQ, 2, [100, 200])<br />

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

[ 0 2 4 100]<br />

[ 6 8 10 200]<br />

Errors are raised if the sizes are incompatible.<br />

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

sage: B = matrix(RR, [[10, 20], [30, 40], [50, 60]])<br />

sage: A.augment(B)<br />

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

...<br />

TypeError: number <strong>of</strong> rows must be the same, 2 != 3<br />

sage: v = vector(RR, [100, 200, 300])<br />

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

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

...<br />

TypeError: number <strong>of</strong> rows must be the same, 2 != 3<br />

Setting subdivide to True will, in its simplest form, add a subdivision between self <strong>and</strong> right.<br />

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

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

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

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

[ 4 5 6 7| 5 6 7 8 9]<br />

[ 8 9 10 11|10 11 12 13 14]<br />

Column subdivisions are preserved by augmentation, <strong>and</strong> enriched, if subdivisions are requested. (So<br />

multiple augmentations can be recorded.)<br />

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

sage: A.subdivide(None, [1])<br />

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

sage: B.subdivide(None, [2])<br />

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

98 Chapter 6. Base class for matrices, part 1

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

Saved successfully!

Ooh no, something went wrong!