dense<int MemLoc=internal> [MTL Home] Programmers Guide
  Contents | Index |  Search 


Category:containers,selectors Component type:type
Description

TwoD Storage Type Selectors

This is the most common way of storing matrices, and consists of one contiguous piece of memory that is divided up into rows or columns of equal length. The following example shows how a matrix can be mapped to linear memory in either a row-major or column-major fashion.
 [ 1 2 3 ]
 [ 4 5 6 ]
 [ 7 8 9 ]
  
 row major:
 [ 1 2 3 4 5 6 7 8 9 ]
  
 column major:
 [ 1 4 7 2 5 8 3 6 9 ]
 

OneD Storage Type Selectors

This specifies a normal dense vector to be used as the OneD part of matrix with array storage.
Example
In swap_rows.cc:
  typedef matrix< double,
                  rectangle<>, 
                  dense<external>,
                  column_major>::type Matrix; 
  const Matrix::size_type N = 3;
  Matrix::size_type large;
  double dA[] = { 1, 3, 2, 1.5, 2.5, 3.5, 4.5, 9.5, 5.5 };
  Matrix A(dA, N, N);
  //  Find the largest element in column 1.
  large = max_index(A[0]);
  // Swap the first row with the row containing the largest
  // element in column 1.
  swap( rows(A)[0] , rows(A)[large]);

More examples can be found in general_matvec_mult.cc

Definition
matrix.h
Template Parameters

ParameterDescriptionDefault
MemLocSpecify whether the memory used is "owned" by the matrix or if it was provided to the matrix from some external source (with a pointer to some data) internal
Model of
Members
Member Where defined Description
size_type    
enum { id = DENSE, oned_id, ext=MemLoc, issparse=0, index }    
New members
Notes
See also

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