STXXL
1.4-dev
|
This section introduces into the STXXL matrix container (to learn more about the structure of stxxl::matrix, see section Matrix).
Before using a STXXL matrix, we initially have to define and then to instantiate a matrix object. Two template parameters are required to define a stxxl::matrix container. ValueType defines the type of the contained objects (must be a POD with no references to internal memory) and BlockSizeLength specifies the side length of the square submatrices (blocks). BlockSizeLength is given in bits and must be a multiple of k assuming a valueType of k bits. The block schedular is used for swapping of blocks and provide blocks for temporary storage and expects the type of swappable_blocks to manage as a parameter. Can be some specialized subclass. We used matrix_swappable_block as a subclass which holds the same template parameters as the aforementioned stxxl::matrix container.
Instanciate three new height x width (3 x 3 in this example) matrices A, B and C using a block schedular.
Note that all values are initially set to zero.
To insert and access elements, the STXXL matrix container intends different iterators. Iterate for example row-by-row beginning with the top row can be done with the row_major_iterator. The operator * accesses a single element the iterator points to just now.
To detect the height and width of a given matrix C, we can call:
The STXXL Matrix container provides the following arithmetic operations:
(See examples/containers/matrix1.cpp for the sourcecode of the following example).