triangle<int Uplo = dynamic_uplo> [MTL Home] Programmers Guide
  Contents | Index |  Search 


Category:containers,selectors Component type:type
Description
The triangular shape is a special case of the banded shape. There are four kinds of triangular matrices in MTL, based on the Uplo argument:
Uplo type Sub Super
upper 0 N - 1
unit_upper -1 N - 1
lower M - 1 0
unit_lower M - 1 -1
The following is an example of a triangle<upper> shaped matrix:
 [  1   2   3   4   5  ]
 [  0   6   7   8   9  ]
 [  0   0  10  11  12  ]
 [  0   0   0  13  14  ]
 [  0   0   0   0  15  ]
 
The next example is of a triangle<unit_lower> matrix. The main diagonal is not stored, since it consists of all ones. The MTL algorithms recognize when a matrix is ``unit'' and perform a slightly different operation to take this into account. The ones will not show up in an iteration of the matrix, and access to the A(i,i) element of a unit lower/upper matrix is an error.
 [  1   0   0   0   0  ]
 [  1   1   0   0   0  ]
 [  2   3   1   0   0  ]
 [  4   5   6   1   0  ]
 [  7   8   9  10   1  ]
 
Here are a couple examples of creating some triangular matrix types:
 typedef matrix < double,
                  triangle, 
                  banded<>,
                  column_major >::type UpperTriangle;

 typedef matrix < double,
                 triangle, 
                 packed<>,
                 row_major >::type UnitLowerTriangle;
 
Example
Definition
matrix.h
Template Parameters

ParameterDescriptionDefault
UploThe type of triangular matrix. Either upper, lower, unit_upper, or unit_lower. 
Model of
Members
Member Where defined Description
enum { id = TRI, uplo = Uplo, M=0, N=0 }    
New members
Notes
See also

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