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 0 0 0 0 1], False)<br />

]<br />

TESTS:<br />

sage: t = matrix(QQ, 3, [3, 0, -2, 0, -2, 0, 0, 0, 0]);<br />

sage: t.decomposition_<strong>of</strong>_subspace(v, check_restrict = False) == t.decomposition_<strong>of</strong>_subspace(<br />

True<br />

denominator()<br />

Return the least common multiple <strong>of</strong> the denominators <strong>of</strong> the elements <strong>of</strong> self.<br />

If there is no denominator function for the base field, or no LCM function for the denominators, raise a<br />

TypeError.<br />

EXAMPLES:<br />

sage: A = MatrixSpace(QQ,2)([’1/2’, ’1/3’, ’1/5’, ’1/7’])<br />

sage: A.denominator()<br />

210<br />

A trivial example:<br />

sage: A = matrix(QQ, 0,2)<br />

sage: A.denominator()<br />

1<br />

Denominators are not defined for real numbers:<br />

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

sage: A.denominator()<br />

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

...<br />

TypeError: denominator not defined for elements <strong>of</strong> the base ring<br />

We can even compute the denominator <strong>of</strong> matrix over the fraction field <strong>of</strong> Z[x].<br />

sage: K. = Frac(ZZ[’x’])<br />

sage: A = MatrixSpace(K,2)([1/x, 2/(x+1), 1, 5/(x^3)])<br />

sage: A.denominator()<br />

x^4 + x^3<br />

Here’s an example involving a cyclotomic field:<br />

sage: K. = CyclotomicField(3)<br />

sage: M = MatrixSpace(K,3,sparse=True)<br />

sage: A = M([(1+z)/3,(2+z)/3,z/3,1,1+z,-2,1,5,-1+z])<br />

sage: print A<br />

[1/3*z + 1/3 1/3*z + 2/3 1/3*z]<br />

[ 1 z + 1 -2]<br />

[ 1 5 z - 1]<br />

sage: print A.denominator()<br />

3<br />

density()<br />

Return the density <strong>of</strong> the matrix.<br />

By density we underst<strong>and</strong> the ratio <strong>of</strong> the number <strong>of</strong> nonzero positions <strong>and</strong> the self.nrows() * self.ncols(),<br />

i.e. the number <strong>of</strong> possible nonzero positions.<br />

EXAMPLE:<br />

149

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

Saved successfully!

Ooh no, something went wrong!