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.2Warning: An upper bound on the absolute value <strong>of</strong> the entries may be set when the algorithmis echelonizable or unimodular. In these cases it is possible for this constructor to fail with aValueError. If you must have this routine return successfully, do not set upper_bound. This behaviorcan be partially controlled by a max_tries keyword.Note: When constructing matrices with r<strong>and</strong>om entries <strong>and</strong> no additional properties (i.e. whenalgorithm=’r<strong>and</strong>omize’), most <strong>of</strong> the r<strong>and</strong>omness is controlled by the r<strong>and</strong>om_element method forelements <strong>of</strong> the base ring <strong>of</strong> the matrix, so the documentation <strong>of</strong> that method may be relevant or useful. Also,the default is to not create zero entries, unless the density keyword is set to something strictly less than one.EXAMPLES:R<strong>and</strong>om integer matrices. With no arguments, the majority <strong>of</strong> the entries are -1 <strong>and</strong> 1, never zero, <strong>and</strong> rarely“large.”sage: r<strong>and</strong>om_matrix(ZZ, 5, 5)[ -8 2 0 0 1][ -1 2 1 -95 -1][ -2 -12 0 0 1][ -1 1 -1 -2 -1][ 4 -4 -6 5 0]The distribution keyword set to uniform will limit values between -2 <strong>and</strong> 2, <strong>and</strong> never zero.sage: r<strong>and</strong>om_matrix(ZZ, 5, 5, distribution=’uniform’)[ 1 0 -2 1 1][ 1 0 0 0 2][-1 -2 0 2 -2][-1 -1 1 1 2][ 0 -2 -1 0 0]The x <strong>and</strong> y keywords can be used to distribute entries uniformly. When both are used x is the minimum <strong>and</strong> yis one greater than the the maximum. But still entries are never zero, even if the range contains zero.sage: r<strong>and</strong>om_matrix(ZZ, 4, 8, x=70, y=100)[81 82 70 81 78 71 79 94][80 98 89 87 91 94 94 77][86 89 85 92 95 94 72 89][78 80 89 82 94 72 90 92]sage: r<strong>and</strong>om_matrix(ZZ, 3, 7, x=-5, y=5)[-3 3 1 -5 3 1 2][ 3 3 0 3 -5 -2 1][ 0 -2 -2 2 -3 -4 -2]If only x is given, then it is used as the upper bound <strong>of</strong> a range starting at 0.sage: r<strong>and</strong>om_matrix(ZZ, 5, 5, x=25)[20 16 8 3 8][ 8 2 2 14 5][18 18 10 20 11][19 16 17 15 7][ 0 24 3 17 24]To allow, <strong>and</strong> control, zero entries use the density keyword at a value strictly below the default <strong>of</strong> 1.0, even ifdistributing entries across an interval that does not contain zero already. Note that for a square matrix it is onlynecessary to set a single dimension.47

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

Saved successfully!

Ooh no, something went wrong!