| ||||||
| ||||||
| Prototype | ||||||
|
template <class TriMatrix, class VecX> void tri_solve(const TriMatrix& T, MTL_OUT(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 | ||||||
| Preconditions | ||||||
|
| ||||||
| Complexity | ||||||
| Example | ||||||
In tri_solve.cc:
// Select a lower triangular matrix with packed storage typedef matrix< double, triangle<lower>, packed<>, row_major >::type Matrix; // The external vector uses memory from an "outside" source, // in this case vector b below will use memory from array db typedef external_vec<double> Vector; const int N = 3; Matrix A(N); set_diagonal(A, 1); //Fill the matrix... A(0,0) = 1; A(1,0) = 2; A(1,1) = 4; A(2,0) = 3; A(2,1) = 5; A(2,2) = 7; double db[] = { 7, 46, 124}; Vector b(db, N); cout << "A in packed form" << endl; print_row(A);// print the matrix in row-wise fashion cout << "b:" << endl; print_vector(b); // This is also known as backward or forward substitution // In this case, since A is a lower triangular matrix // so this call performs a forward substitution // computes: A^-1 * b -> b tri_solve(A, b); cout << "A^-1 * b:" << endl; print_vector(b); | ||||||
| Notes | ||||||
| See also | ||||||

Copyright ©
1998,1999 University of Notre Dame. All Rights Reserved.