31.01.2014 Views

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

Version 5.0 The LEDA User Manual

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.

5.16 Real-Valued Matrices ( real matrix )<br />

1. Definition<br />

An instance of the data type real matrix is a matrix of variables of type real.<br />

#include < <strong>LEDA</strong>/numbers/real matrix.h ><br />

2. Creation<br />

real matrix M(int n = 0, int m = 0);<br />

creates an instance M of type real matrix, M is initialized to the<br />

n × m - zero matrix.<br />

real matrix<br />

M(int n, int m, real ∗ D);<br />

creates the n × m matrix M with M(i, j) = D[i ∗ m + j] for 0 ≤<br />

i ≤ n − 1 and 0 ≤ j ≤ m − 1. Precondition: D points to an array<br />

of at least n ∗ m numbers of type real.<br />

3. Operations<br />

int M.dim1( ) returns n, the number of rows of M.<br />

int M.dim2( ) returns m, the number of columns of M.<br />

real vector& M.row(int i)<br />

real vector M.col(int i)<br />

real matrix M.trans( )<br />

returns the i-th row of M (an m-vector).<br />

Precondition: 0 ≤ i ≤ n − 1.<br />

returns the i-th column of M (an n-vector).<br />

Precondition: 0 ≤ i ≤ m − 1.<br />

returns M T (m × n - matrix).<br />

real matrix M.inv( ) returns the inverse matrix of M.<br />

Precondition: M is quadratic and M.det() ≠ 0.<br />

real M.det( ) returns the determinant of M.<br />

Precondition: M is quadratic.<br />

real vector M.solve(const real vector& b)<br />

returns vector x with M · x = b.<br />

Precondition: M.dim1() == M.dim2() = =b.dim() and<br />

M.det() ≠ 0.<br />

real& M(int i, int j) returns M i,j .<br />

Precondition: 0 ≤ i ≤ n − 1 and 0 ≤ j ≤ m − 1.

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

Saved successfully!

Ooh no, something went wrong!