tri_solve [MTL Home] Programmers Guide
  Contents | Index |  Search 


Category:algorithms Component type:function
Prototype
template <class MatT, class MatB, class Side>
void tri_solve(const MatT& T, MatB& B, Side s) ;
Description
This solves the equation T*X = B or X*T = B where T is an upper or lower triangular matrix, and B is a general matrix. The resulting matrix X is written onto matrix B. The first equation is solved if left_side is specified. The second equation is solved if right_side is specified. Currently only works with dense storage format.
Definition
mtl.h
Requirements on types
  • MatT::value_type and MatB::value_type must be the same type
  • the multiplication operator must be defined for MatT::value_type
  • the division operator must be defined for MatT::value_type
  • the addition operator must be defined for MatT::value_type
Preconditions
Complexity
O(n^3)
Example
In matmat_trisolve.cc:
  // Example use of tri_solve with upper and lower triangles

  typedef matrix< double,
                  rectangle<>, 
                  dense<>, 
                  row_major >::type Matrix;
  Matrix B(M,N);
  Matrix X(M,N);
  triangle_view<Matrix, upper>::type U(M,M);
  Matrix R(M,N);
  // fill the matrices ...

  tri_solve(U, X, left_side());

  triangle<Matrix, lower>::type L(M,M);
  tri_solve(L, X, left_side());

Notes
See also

[MTL Home] Copyright © 1998,1999 University of Notre Dame. All Rights Reserved.