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

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

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

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

Row subdivisions can be preserved, but only if they are identical. Otherwise, this information is discarded<br />

<strong>and</strong> must be managed separately.<br />

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

The result retains the base ring <strong>of</strong> self by coercing the elements <strong>of</strong> right into the base ring <strong>of</strong> self.<br />

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

sage: B = matrix(RR, 2, [sin(1.1), sin(2.2)])<br />

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

[ 1 183017397/205358938]<br />

[ 2 106580492/131825561]<br />

sage: C.parent()<br />

Full MatrixSpace <strong>of</strong> 2 by 2 dense matrices over Rational Field<br />

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

[0.89120736006... 1.00000000000000]<br />

[0.80849640381... 2.00000000000000]<br />

sage: D.parent()<br />

Full MatrixSpace <strong>of</strong> 2 by 2 dense matrices over Real Field with 53 bits <strong>of</strong> precision<br />

Sometimes it is not possible to coerce into the base ring <strong>of</strong> self. A solution is to change the base ring<br />

<strong>of</strong> self to a more expansive ring. Here we mix the rationals with a ring <strong>of</strong> polynomials with rational<br />

coefficients.<br />

sage: R = PolynomialRing(QQ, ’y’)<br />

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

sage: B = matrix(R, 1, [’y’, ’y^2’])<br />

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

[ y y^2 1 2]<br />

sage: C.parent()<br />

Full MatrixSpace <strong>of</strong> 1 by 4 dense matrices over Univariate Polynomial Ring in y over Rational<br />

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

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

...<br />

TypeError: not a constant polynomial<br />

sage: E = A.change_ring(R)<br />

99

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

Saved successfully!

Ooh no, something went wrong!