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 />

TESTS:<br />

Bogus values <strong>of</strong> the eps keyword will be caught.<br />

sage: A.singular_values(eps=’junk’)<br />

Traceback (most recent call last):<br />

...<br />

ValueError: could not convert string to float: junk<br />

REFERENCES:<br />

AUTHOR:<br />

•Rob Beezer - (2011-02-18)<br />

solve_left(b)<br />

Solve the vector equation x*A = b for a nonsingular A.<br />

INPUT:<br />

•self - a square matrix that is nonsigular (<strong>of</strong> full rank).<br />

•b - a vector <strong>of</strong> the correct size. Elements <strong>of</strong> the vector must coerce into the base ring <strong>of</strong> the coefficient<br />

matrix. In particular, if b has entries from CDF then self must have CDF as its base ring.<br />

OUTPUT:<br />

The unique solution x to the matrix equation x*A = b, as a vector over the same base ring as self.<br />

ALGORITHM:<br />

Uses the solve() routine from the SciPy scipy.linalg module, after taking the tranpose <strong>of</strong> the<br />

coefficient matrix.<br />

EXAMPLES:<br />

Over the reals.<br />

sage: A = matrix(RDF, 3,3, [1,2,5,7.6,2.3,1,1,2,-1]); A<br />

[ 1.0 2.0 5.0]<br />

[ 7.6 2.3 1.0]<br />

[ 1.0 2.0 -1.0]<br />

sage: b = vector(RDF,[1,2,3])<br />

sage: x = A.solve_left(b); x.zero_at(1e-18) # fix noisy zeroes<br />

(0.666666666..., 0.0, 0.333333333...)<br />

sage: x.parent()<br />

Vector space <strong>of</strong> dimension 3 over Real Double Field<br />

sage: x*A<br />

(1.0, 2.0, 3.0)<br />

Over the complex numbers.<br />

(-1.55765124... - 0.644483985...*I, 0.183274021... + 0.286476868...*I, 0.270818505... + 0.24<br />

sage: A = matrix(CDF, [[ 0, -1 + 2*I, 1 - 3*I, I],<br />

... [2 + 4*I, -2 + 3*I, -1 + 2*I, -1 - I],<br />

... [ 2 + I, 1 - I, -1, 5],<br />

... [ 3*I, -1 - I, -1 + I, -3 + I]])<br />

sage: b = vector(CDF, [2 -3*I, 3, -2 + 3*I, 8])<br />

sage: x = A.solve_left(b); x<br />

sage: x.parent()<br />

Vector space <strong>of</strong> dimension 4 over Complex Double Field<br />

sage: abs(x*A - b) < 1e-14<br />

True<br />

389

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

Saved successfully!

Ooh no, something went wrong!