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.11 Double-Valued Matrices ( matrix )<br />

1. Definition<br />

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

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

2. Creation<br />

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

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

- zero matrix.<br />

matrix<br />

M(int n, int m, double ∗ 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 double.<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 />

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

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

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

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

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

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

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

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

Precondition: M is quadratic.<br />

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

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

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

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

double& 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!