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: a = matrix({(1,1):10, (2,1):-3, (2,2):4/3}); a<br />

[ 0 0 0]<br />

[ 0 10 0]<br />

[ 0 -3 4/3]<br />

sage: a.trace()<br />

34/3<br />

trace_<strong>of</strong>_product(other)<br />

Returns the trace <strong>of</strong> self * other without computing the entire product.<br />

EXAMPLES:<br />

sage: M = r<strong>and</strong>om_matrix(ZZ, 10, 20)<br />

sage: N = r<strong>and</strong>om_matrix(ZZ, 20, 10)<br />

sage: M.trace_<strong>of</strong>_product(N)<br />

-1629<br />

sage: (M*N).trace()<br />

-1629<br />

visualize_structure(filename=None, maxsize=512)<br />

Write a PNG image to ‘filename’ which visualizes self by putting black pixels in those positions which<br />

have nonzero entries.<br />

White pixels are put at positions with zero entries. If ‘maxsize’ is given, then the maximal dimension in<br />

either x or y direction is set to ‘maxsize’ depending on which is bigger. If the image is scaled, the darkness<br />

<strong>of</strong> the pixel reflects how many <strong>of</strong> the represented entries are nonzero. So if e.g. one image pixel actually<br />

represents a 2x2 submatrix, the dot is darker the more <strong>of</strong> the four values are nonzero.<br />

INPUT:<br />

•filename - either a path or None in which case a filename in the current directory is chosen automatically<br />

(default:None)<br />

maxsize - maximal dimension in either x or y direction <strong>of</strong> the resulting image. If None or a maxsize<br />

larger than max(self.nrows(),self.ncols()) is given the image will have the same pixelsize as the matrix<br />

dimensions (default: 512)<br />

EXAMPLE:<br />

sage: M = r<strong>and</strong>om_matrix(CC, 4)<br />

sage: M.visualize_structure(os.path.join(SAGE_TMP, "matrix.png"))<br />

weak_popov_form(ascend=True)<br />

This function computes a weak Popov form <strong>of</strong> a matrix over a rational function field k(x), for k a field.<br />

INPUT:<br />

•ascend - if True, rows <strong>of</strong> output matrix W are sorted so degree (= the maximum <strong>of</strong> the degrees <strong>of</strong> the<br />

elements in the row) increases monotonically, <strong>and</strong> otherwise degrees decrease.<br />

OUTPUT:<br />

A 3-tuple (W, N, d) consisting <strong>of</strong>:<br />

1.W - a matrix over k(x) giving a weak the Popov form <strong>of</strong> self<br />

2.N - a matrix over k[x] representing row operations used to transform self to W<br />

3.d - degree <strong>of</strong> respective columns <strong>of</strong> W; the degree <strong>of</strong> a column is the maximum <strong>of</strong> the degree <strong>of</strong> its<br />

elements<br />

N is invertible over k(x). These matrices satisfy the relation N ∗ self = W .<br />

EXAMPLES:<br />

262 Chapter 7. Base class for matrices, part 2

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

Saved successfully!

Ooh no, something went wrong!