Views

Table of Contents

General Concepts


Views represents parts of a vector or matrix, such as a subvector, a submatrix, or a specific row or column of a matrix. As such, views act as a reference to a specific part of a vector or matrix. This reference is valid and can be used in every way as any other vector or matrix can be used as long as the referenced vector or matrix is not resized or entirely destroyed. Views also act as alias to the elements of the vector or matrix: Changes made to the elements (e.g. modifying values, inserting or erasing elements) via the view are immediately visible in the vector or matrix and changes made via the vector or matrix are immediately visible in the view.

The Blaze library provides the following views on vectors and matrices:

Vector views:

Matrix views:


Examples

// Setup of the 3x5 row-major matrix
//
// ( 1 0 -2 3 0 )
// ( 0 2 5 -1 -1 )
// ( 1 0 0 2 1 )
//
DynamicMatrix<int> A( 3UL, 5UL );
A(0,0) = 1; A(0,1) = 0; A(0,2) = -2; A(0,3) = 3; A(0,4) = 0;
A(1,0) = 0; A(1,1) = 2; A(1,2) = 5; A(1,3) = -1; A(1,4) = -1;
A(2,0) = 1; A(2,1) = 0; A(2,2) = 0; A(2,3) = 2; A(2,4) = 1;
// Setup of the 2-dimensional row vector
//
// ( 18 19 )
//
StaticVector<int,rowVector> vec( 18, 19 );
// Assigning to the elements (1,2) and (1,3) via a subvector of a row
//
// ( 1 0 -2 3 0 )
// ( 0 2 18 19 -1 )
// ( 1 0 0 2 1 )
//
subvector( row( A, 1UL ), 2UL, 2UL ) = vec;


Previous: Triangular Matrices     Next: Subvectors