12.07.2015 Views

Sage Reference Manual: Matrices and Spaces of Matrices

Sage Reference Manual: Matrices and Spaces of Matrices

Sage Reference Manual: Matrices and Spaces of Matrices

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.2A negative size sometimes causes the error that there are too many elements.sage: diagonal_matrix(-2, [2])Traceback (most recent call last):...ValueError: number <strong>of</strong> diagonal matrix entries (1) exceeds the requested matrix size (-2)Types for the entries are limited, even though they may have a length.sage: diagonal_matrix(x^2)Traceback (most recent call last):...TypeError: diagonal matrix entries are not a supported type (list, tuple, vector, or NumPy arrayAUTHOR:•Rob Beezer (2011-01-11): total rewritesage.matrix.constructor.elementary_matrix(arg0, arg1=None, **kwds)This function is available as elementary_matrix(...) <strong>and</strong> matrix.elementary(...).Creates a square matrix that corresponds to a row operation or a column operation.FORMATS:In each case, R is the base ring, <strong>and</strong> is optional. n is the size <strong>of</strong> the square matrix created. Any call mayinclude the sparse keyword to determine the representation used. The default is False which leads to adense representation. We describe the matrices by their associated row operation, see the output description formore.•elementary_matrix(R, n, row1=i, row2=j)The matrix which swaps rows i <strong>and</strong> j.•elementary_matrix(R, n, row1=i, scale=s)The matrix which multiplies row i by s.•elementary_matrix(R, n, row1=i, row2=j, scale=s)The matrix which multiplies row j by s <strong>and</strong> adds it to row i.Elementary matrices representing column operations are created in an entirely analogous way, replacing row1by col1 <strong>and</strong> replacing row2 by col2.Specifying the ring for entries <strong>of</strong> the matrix is optional. If it is not given, <strong>and</strong> a scale parameter is provided, thena ring containing the value <strong>of</strong> scale will be used. Otherwise, the ring defaults to the integers.OUTPUT:An elementary matrix is a square matrix that is very close to being an identity matrix. If E is an elementarymatrix <strong>and</strong> A is any matrix with the same number <strong>of</strong> rows, then E*A is the result <strong>of</strong> applying a row operationto A. This is how the three types created by this function are described. Similarly, an elementary matrix canbe associated with a column operation, so if E has the same number <strong>of</strong> columns as A then A*E is the result <strong>of</strong>performing a column operation on A.An elementary matrix representing a row operation is created if row1 is specified, while an elementary matrixrepresenting a column operation is created if col1 is specified.EXAMPLES:Over the integers, creating row operations. Recall that row <strong>and</strong> column numbering begins at zero.31

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

Saved successfully!

Ooh no, something went wrong!