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

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.2TESTS:sage: MS1.one()[1,2] = 3Traceback (most recent call last):...ValueError: matrix is immutable; please change a copy instead (i.e., use copy(M) to change ar<strong>and</strong>om_element(density=None, *args, **kwds)Returns a r<strong>and</strong>om element from this matrix space.INPUT:•density - float or None (default: None); rough measure <strong>of</strong> the proportion <strong>of</strong> nonzero entries inthe r<strong>and</strong>om matrix; if set to None, all entries <strong>of</strong> the matrix are r<strong>and</strong>omized, allowing for any element<strong>of</strong> the underlying ring, but if set to a float, a proportion <strong>of</strong> entries is selected <strong>and</strong> r<strong>and</strong>omized tonon-zero elements <strong>of</strong> the ring•*args, **kwds - remaining parameters, which may be passed to the r<strong>and</strong>om_element function <strong>of</strong>the base ring. (“may be”, since this function calls the r<strong>and</strong>omize function on the zero matrix, whichneed not call the r<strong>and</strong>om_element function <strong>of</strong> the base ring at all in general.)OUTPUT:•MatrixNote: This method will r<strong>and</strong>omize a proportion <strong>of</strong> roughly density entries in a newly allocated zeromatrix.By default, if the user sets the value <strong>of</strong> density explicitly, this method will enforce that these entries areset to non-zero values. However, if the test for equality with zero in the base ring is too expensive, the usercan override this behaviour by passing the argument nonzero=False to this method.Otherwise, if the user does not set the value <strong>of</strong> density, the default value is taken to be 1, <strong>and</strong> the optionnonzero=False is passed to the r<strong>and</strong>omize method.EXAMPLES:sage: Mat(ZZ,2,5).r<strong>and</strong>om_element()[ -8 2 0 0 1][ -1 2 1 -95 -1]sage: Mat(QQ,2,5).r<strong>and</strong>om_element(density=0.5)[ 2 0 0 0 1][ 0 0 0 -1 0]sage: Mat(QQ,3,sparse=True).r<strong>and</strong>om_element()[ -1 -1 -1][ -3 -1/3 -1][ 0 -1 1]sage: Mat(GF(9,’a’),3,sparse=True).r<strong>and</strong>om_element()[ a 2*a 1][ 2 1 a + 2][ 2*a 2 2]row_space()Return the module spanned by all rows <strong>of</strong> matrices in this matrix space. This is a free module <strong>of</strong> rank thenumber <strong>of</strong> rows. It will be sparse or dense as this matrix space is sparse or dense.EXAMPLES:sage: M = Mat(ZZ,20,5,sparse=False); M.row_space()Ambient free module <strong>of</strong> rank 5 over the principal ideal domain Integer Ring11

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

Saved successfully!

Ooh no, something went wrong!