tri_solve Programmers Guide Contents | Index |  Search

Category:algorithms Component type:function
Prototype
template <class TriMatrix, class VecX>
void tri_solve(const TriMatrix& T, VecX x) ;
Description
Use with trianguler matrixes only ie. use the triangle adaptor class. To use with a sparse matrix, the sparse matrix must be wrapped with a triangle adaptor. You must specify "packed" in the triangle adaptor. The sparse matrix must only have elements in the correct side.
Definition
mtl.h
Requirements on types
• Matrix::value_type and VecX::value_type must be the same type
• the multiplication operator must be defined for Matrix::value_type
• the division operator must be defined for Matrix::value_type
• the addition operator must be defined for Matrix::value_type
Preconditions
Complexity
Example
In tri_solve.cc:

typedef matrix< double,
triangle<lower>,
packed<>,
row_major >::type Matrix;
typedef external_vec<double> Vector;
const int N = 3;

Matrix A(N, N);

set_diagonal(A, 1);

//Fill the matrix...

A(1,0) = 2;  A(1,1) = 4;
A(2,0) = 3;  A(2,1) = 5; A(2,2) = 6;

double db[] = { 7, 46, 115};
Vector b(db, N);

cout << "A in packed form" << endl;
print_row(A);

cout << "b:" << endl;
print_vector(b);

tri_solve(A, b);

cout << "A^-1 * b:" << endl;

print_vector(b);

Notes
See also