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


Category:containers,selectors Component type:type
Description
This storage type gives an "array of pointers" style implementation of a matrix. Each row or column of the matrix is allocated separately. The type of vector used for the rows or columns is very flexible, and one can choose from any of the OneD storage types, which include dense, compressed, sparse_pair, tree, and linked_list.
 matrix < double,
          rectangle<>,
          array< dense<> >,
          row_major >::type
 [ ] -> [  1  0  0  4  0 ]
 [ ] -> [  0  7  8  0  0 ]
 [ ] -> [ 11  0 13 14  0 ]
 [ ] -> [ 16  0 18  0 20 ]
 [ ] -> [  0 22  0 24  0 ]

 matrix < double, 
          rectangle<>,
          array< sparse_pair<> >,
          row_major >::type
 [ ] -> [ (1,0) (4,3) ]
 [ ] -> [ (7,1) (8,2) ]
 [ ] -> [ (11,0) (13,2) (14,3) ]
 [ ] -> [ (16,0) (18,2) (20,4) ]
 [ ] -> [ (22,1) (24,3) ]
 

One advantage of this type of storage is that rows can be swapped in constant time. For instance, one could swap the row 3 and 4 of a matrix in the following way.

 Matrix::OneD tmp = A[3];
 A[3] = A[4];
 A[4] = tmp;
 
The rows are individually reference counted so that the user does not have to worry about deallocating the rows.
Example
Definition
matrix.h
Template Parameters

ParameterDescriptionDefault
OneDThe storage type used for each row/column of the matrix dense
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
TwoDStorage
Members
Member Where defined Description
size_type    
enum { id=ARRAY, oned_id=OneD::id, ext=MemLoc, issparse = OneD::issparse, index=index_from_zero }    
New members
Notes
See also

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