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

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.1.1<br />

First, note that the density parameter does not ensure the density <strong>of</strong> a matrix, it is only an upper bound.<br />

sage: A = r<strong>and</strong>om_matrix(GF(127),200,200,density=0.3)<br />

sage: A.density()<br />

5211/20000<br />

sage: A = matrix(QQ,3,3,[0,1,2,3,0,0,6,7,8])<br />

sage: A.density()<br />

2/3<br />

sage: a = matrix([[],[],[],[]])<br />

sage: a.density()<br />

0<br />

derivative(*args)<br />

Derivative with respect to variables supplied in args.<br />

Multiple variables <strong>and</strong> iteration counts may be supplied; see documentation for the global derivative()<br />

function for more details.<br />

EXAMPLES:<br />

sage: v = vector([1,x,x^2])<br />

sage: v.derivative(x)<br />

(0, 1, 2*x)<br />

sage: type(v.derivative(x)) == type(v)<br />

True<br />

sage: v = vector([1,x,x^2], sparse=True)<br />

sage: v.derivative(x)<br />

(0, 1, 2*x)<br />

sage: type(v.derivative(x)) == type(v)<br />

True<br />

sage: v.derivative(x,x)<br />

(0, 0, 2)<br />

det(*args, **kwds)<br />

Synonym for self.determinant(...).<br />

EXAMPLES:<br />

sage: A = MatrixSpace(Integers(8),3)([1,7,3, 1,1,1, 3,4,5])<br />

sage: A.det()<br />

6<br />

determinant(algorithm=None)<br />

Returns the determinant <strong>of</strong> self.<br />

ALGORITHM:<br />

For small matrices (n less than 4), this is computed using the naive formula. In the specific case <strong>of</strong> matrices<br />

over the integers modulo a non-prime, the determinant <strong>of</strong> a lift is computed over the integers. In general, the<br />

characteristic polynomial is computed either using the Hessenberg form (specified by "hessenberg")<br />

or the generic division-free algorithm (specified by "df"). When the base ring is an exact field, the<br />

default choice is "hessenberg", otherwise it is "df". Note that for matrices over most rings, more<br />

sophisticated algorithms can be used. (Type A.determinant to see what is done for a specific matrix<br />

A.)<br />

INPUT:<br />

•algorithm - string:<br />

– "df" - Generic O(n^4) division-free algorithm<br />

150 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!