block2D<Block, OffsetGen> [MTL Home] Programmers Guide
  Contents | Index |  Search 


Category:containers,adaptors Component type:type
Description
For use in blocked algorithms with rectangle dense matrices. The blocks all have the same size (vs. variable sizes as in a partitioned matrix). The matrix objects for each block are not stored, they are generated on the fly as they are requested, and they are lightweight object on the stack so no overhead is incurred.

The blocking size must divide evenly into the original matrix size. One good way to ensure this is to partition the original matrix into a main region that divides evenly and into the blocks, and 3 others edge regions that do not get blocked.

Use the block_view type constructor and the blocked function to create matrices of this type.

Example
In blocked_matrix.cc:
  const int M = 4;
  const int N = 4;
  typedef matrix<double,
                 rectangle<>, 
                 dense<>, 
                 column_major >::type Matrix;
  Matrix A(M,N);

  for (int i = 0; i < M; ++i)
    for (int j = 0; j < N; ++j)
      A(i, j) = i * N + j;
  print_all_matrix(A);

  block_view<Matrix,2,2>::type
                     bA = blocked(A, blk<2,2>());
  print_partitioned_matrix(bA);

  block_view<Matrix>::type cA = blocked(A, 2, 2);
  print_partitioned_by_column(cA);

Definition
block2D.h
Template Parameters

ParameterDescriptionDefault
BlockThe submatrix block, a dense external matrix. 
OffsetGenThe Offset generator. 
Model of
Members
Member Where defined Description
self    
T    
enum { M = 0, N = 0, BM = Block::M, BN = Block::N }    
size_type   The 1D container type
difference_type   The type for differences between iterators
block_dim_type    
Offset    
dim_type    
sparsity   This is a dense 2D container
storage_loc   This has external storage
strideability   This is strideable
value_type   The 1D container type
reference   A reference to the value type
pointer   The type for pointers to the value type
template <int isConst>
class __iterator
  The iterator type
iterator    
const_iterator    
dyn_dim    
bdt    
template <class TwoD>
block2D (TwoD& x, dyn_dim b)
  Constructor from underlying 2D container
block2D (const block2D& x)   Copy Constructor
const block2D& operator= (const block2D& x)    
block2D ()   Default Constructor
~block2D ()   Destructor
iterator begin ()   Return an iterator pointing to the first 1D container
iterator end ()   Return an iterator pointing past the end of the 2D container
const_iterator begin () const   Return a const iterator pointing to the first 1D container
const_iterator end () const   Return a const iterator pointing past the end of the 2D container
block_vector operator[] (size_type i)   Return a reference to the ith 1D container
Block operator() (size_type i, size_type j)   Return a reference to the (i,j) element, where (i,j) is in the 2D coordinate system
const Block operator() (size_type i, size_type j) const   Return a const reference to the (i,j) element, where (i,j) is in the 2D coordinate system
size_type ld () const   The leading dimension
New members
Notes
See also

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