Modules | Functions

Modules

 DenseColumn
 
 DenseRow
 
 Dense Submatrix
 
 Dense Subvector
 
 SparseColumn
 
 SparseRow
 
 Sparse Submatrix
 
 Sparse Subvector
 

Functions

template<typename MT , bool SO>
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type blaze::column (Matrix< MT, SO > &matrix, size_t index)
 Creating a view on a specific column of the given matrix. More...
 
template<typename MT , bool SO>
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< const MT >::Type >::Type blaze::column (const Matrix< MT, SO > &matrix, size_t index)
 Creating a view on a specific column of the given constant matrix. More...
 
template<typename MT , bool SO>
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type blaze::row (Matrix< MT, SO > &matrix, size_t index)
 Creating a view on a specific row of the given matrix. More...
 
template<typename MT , bool SO>
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< const MT >::Type >::Type blaze::row (const Matrix< MT, SO > &matrix, size_t index)
 Creating a view on a specific row of the given constant matrix. More...
 
template<typename MT , bool SO>
SubmatrixExprTrait< MT, unaligned >::Type blaze::submatrix (Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
 Creating a view on a specific submatrix of the given matrix. More...
 
template<typename MT , bool SO>
SubmatrixExprTrait< const MT, unaligned >::Type blaze::submatrix (const Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
 Creating a view on a specific submatrix of the given matrix. More...
 
template<bool AF, typename MT , bool SO>
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename SubmatrixExprTrait< MT, AF >::Type >::Type blaze::submatrix (Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
 Creating a view on a specific submatrix of the given matrix. More...
 
template<bool AF, typename MT , bool SO>
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename SubmatrixExprTrait< const MT, AF >::Type >::Type blaze::submatrix (const Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
 Creating a view on a specific submatrix of the given matrix. More...
 
template<typename VT , bool TF>
SubvectorExprTrait< VT, unaligned >::Type blaze::subvector (Vector< VT, TF > &vector, size_t index, size_t size)
 Creating a view on a specific subvector of the given vector. More...
 
template<typename VT , bool TF>
SubvectorExprTrait< const VT, unaligned >::Type blaze::subvector (const Vector< VT, TF > &vector, size_t index, size_t size)
 Creating a view on a specific subvector of the given vector. More...
 
template<bool AF, typename VT , bool TF>
DisableIf< Or< IsComputation< VT >, IsTransExpr< VT > >, typename SubvectorExprTrait< VT, AF >::Type >::Type blaze::subvector (Vector< VT, TF > &vector, size_t index, size_t size)
 Creating a view on a specific subvector of the given vector. More...
 
template<bool AF, typename VT , bool TF>
DisableIf< Or< IsComputation< VT >, IsTransExpr< VT > >, typename SubvectorExprTrait< const VT, AF >::Type >::Type blaze::subvector (const Vector< VT, TF > &vector, size_t index, size_t size)
 Creating a view on a specific subvector of the given vector. More...
 

Detailed Description

Function Documentation

template<typename MT , bool SO>
DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> > , typename ColumnExprTrait<MT>::Type >::Type blaze::column ( Matrix< MT, SO > &  matrix,
size_t  index 
)
inline

Creating a view on a specific column of the given matrix.

Parameters
matrixThe matrix containing the column.
indexThe index of the column.
Returns
View on the specified column of the matrix.
Exceptions
std::invalid_argumentInvalid column access index.

This function returns an expression representing the specified column of the given matrix.

DenseMatrix D;
SparseMatrix S;
// ... Resizing and initialization
// Creating a view on the 3rd column of the dense matrix D
// Creating a view on the 4th column of the sparse matrix S
template<typename MT , bool SO>
DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> > , typename ColumnExprTrait<const MT>::Type >::Type blaze::column ( const Matrix< MT, SO > &  matrix,
size_t  index 
)
inline

Creating a view on a specific column of the given constant matrix.

Parameters
matrixThe constant matrix containing the column.
indexThe index of the column.
Returns
View on the specified column of the matrix.
Exceptions
std::invalid_argumentInvalid column access index.

This function returns an expression representing the specified column of the given matrix.

DenseMatrix D;
SparseMatrix S;
// ... Resizing and initialization
// Creating a view on the 3rd column of the dense matrix D
// Creating a view on the 4th column of the sparse matrix S
template<typename MT , bool SO>
DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> > , typename RowExprTrait<MT>::Type >::Type blaze::row ( Matrix< MT, SO > &  matrix,
size_t  index 
)
inline

Creating a view on a specific row of the given matrix.

Parameters
matrixThe matrix containing the row.
indexThe index of the row.
Returns
View on the specified row of the matrix.
Exceptions
std::invalid_argumentInvalid row access index.

This function returns an expression representing the specified row of the given matrix.

DenseMatrix D;
SparseMatrix S;
// ... Resizing and initialization
// Creating a view on the 3rd row of the dense matrix D
// Creating a view on the 4th row of the sparse matrix S
template<typename MT , bool SO>
DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> > , typename RowExprTrait<const MT>::Type >::Type blaze::row ( const Matrix< MT, SO > &  matrix,
size_t  index 
)
inline

Creating a view on a specific row of the given constant matrix.

Parameters
matrixThe constant matrix containing the row.
indexThe index of the row.
Returns
View on the specified row of the matrix.
Exceptions
std::invalid_argumentInvalid row access index.

This function returns an expression representing the specified row of the given matrix.

DenseMatrix D;
SparseMatrix S;
// ... Resizing and initialization
// Creating a view on the 3rd row of the dense matrix D
// Creating a view on the 4th row of the sparse matrix S
template<typename MT , bool SO>
SubmatrixExprTrait<MT,unaligned>::Type blaze::submatrix ( Matrix< MT, SO > &  matrix,
size_t  row,
size_t  column,
size_t  m,
size_t  n 
)
inline

Creating a view on a specific submatrix of the given matrix.

Parameters
matrixThe matrix containing the submatrix.
rowThe index of the first row of the submatrix.
columnThe index of the first column of the submatrix.
mThe number of rows of the submatrix.
nThe number of columns of the submatrix.
Returns
View on the specific submatrix of the matrix.
Exceptions
std::invalid_argumentInvalid submatrix specification.

This function returns an expression representing the specified submatrix of the given matrix. The following example demonstrates the creation of a dense and sparse submatrix:

DenseMatrix D;
SparseMatrix S;
// ... Resizing and initialization
// Creating a dense submatrix of size 8x4, starting in row 0 and column 16
blaze::DenseSubmatrix<DenseMatrix> dsm = submatrix( D, 0UL, 16UL, 8UL, 4UL );
// Creating a sparse submatrix of size 7x3, starting in row 2 and column 4
blaze::SparseSubmatrix<SparseMatrix> ssm = submatrix( S, 2UL, 4UL, 7UL, 3UL );

In case the submatrix is not properly specified (i.e. if the specified row or column is larger than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) a std::invalid_argument exception is thrown.

Please note that this function creates an unaligned dense or sparse submatrix. For instance, the creation of the dense submatrix is equivalent to the following three function calls:

blaze::DenseSubmatrix<DenseMatrix> dsm = submatrix<unaligned>( D, 0UL, 16UL, 8UL, 4UL );
blaze::DenseSubmatrix<DenseMatrix,unaligned> dsm = submatrix<unaligned>( D, 0UL, 16UL, 8UL, 4UL );

In contrast to unaligned submatrices, which provide full flexibility, aligned submatrices pose additional alignment restrictions. However, especially in case of dense submatrices this may result in considerable performance improvements. In order to create an aligned submatrix the following function call has to be used:

blaze::DenseSubmatrix<DenseMatrix,aligned> dsm = submatrix<aligned>( D, 0UL, 16UL, 8UL, 4UL );

Note however that in this case the given arguments row, columns, m, and n are subject to additional checks to guarantee proper alignment.

template<typename MT , bool SO>
SubmatrixExprTrait<const MT,unaligned>::Type blaze::submatrix ( const Matrix< MT, SO > &  matrix,
size_t  row,
size_t  column,
size_t  m,
size_t  n 
)
inline

Creating a view on a specific submatrix of the given matrix.

Parameters
matrixThe matrix containing the submatrix.
rowThe index of the first row of the submatrix.
columnThe index of the first column of the submatrix.
mThe number of rows of the submatrix.
nThe number of columns of the submatrix.
Returns
View on the specific submatrix of the matrix.
Exceptions
std::invalid_argumentInvalid submatrix specification.

This function returns an expression representing the specified submatrix of the given matrix. The following example demonstrates the creation of a dense and sparse submatrix:

DenseMatrix D;
SparseMatrix S;
// ... Resizing and initialization
// Creating a dense submatrix of size 8x4, starting in row 0 and column 16
blaze::DenseSubmatrix<DenseMatrix> dsm = submatrix( D, 0UL, 16UL, 8UL, 4UL );
// Creating a sparse submatrix of size 7x3, starting in row 2 and column 4
blaze::SparseSubmatrix<SparseMatrix> ssm = submatrix( S, 2UL, 4UL, 7UL, 3UL );

In case the submatrix is not properly specified (i.e. if the specified row or column is larger than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) a std::invalid_argument exception is thrown.

Please note that this function creates an unaligned dense or sparse submatrix. For instance, the creation of the dense submatrix is equivalent to the following three function calls:

blaze::DenseSubmatrix<DenseMatrix> dsm = submatrix<unaligned>( D, 0UL, 16UL, 8UL, 4UL );
blaze::DenseSubmatrix<DenseMatrix,unaligned> dsm = submatrix<unaligned>( D, 0UL, 16UL, 8UL, 4UL );

In contrast to unaligned submatrices, which provide full flexibility, aligned submatrices pose additional alignment restrictions. However, especially in case of dense submatrices this may result in considerable performance improvements. In order to create an aligned submatrix the following function call has to be used:

blaze::DenseSubmatrix<DenseMatrix,aligned> dsm = submatrix<aligned>( D, 0UL, 16UL, 8UL, 4UL );

Note however that in this case the given arguments row, columns, m, and n are subject to additional checks to guarantee proper alignment.

template<bool AF, typename MT , bool SO>
DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> > , typename SubmatrixExprTrait<MT,AF>::Type >::Type blaze::submatrix ( Matrix< MT, SO > &  matrix,
size_t  row,
size_t  column,
size_t  m,
size_t  n 
)
inline

Creating a view on a specific submatrix of the given matrix.

Parameters
matrixThe matrix containing the submatrix.
rowThe index of the first row of the submatrix.
columnThe index of the first column of the submatrix.
mThe number of rows of the submatrix.
nThe number of columns of the submatrix.
Returns
View on the specific submatrix of the matrix.
Exceptions
std::invalid_argumentInvalid submatrix specification.

This function returns an expression representing an aligned or unaligned submatrix of the given dense or sparse matrix, based on the specified alignment flag AF. The following example demonstrates the creation of both an aligned and unaligned submatrix:

DenseMatrix D;
SparseMatrix S;
// ... Resizing and initialization
// Creating an aligned dense submatrix of size 8x4, starting in row 0 and column 16
blaze::DenseSubmatrix<DenseMatrix,aligned> dsm = submatrix<aligned>( D, 0UL, 16UL, 8UL, 4UL );
// Creating an unaligned sparse submatrix of size 7x3, starting in row 2 and column 4
blaze::SparseSubmatrix<SparseMatrix,unaligned> ssm = submatrix<unaligned>( S, 2UL, 4UL, 7UL, 3UL );

In case the submatrix is not properly specified (i.e. if the specified row or column is larger than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) a std::invalid_argument exception is thrown.

In contrast to unaligned submatrices, which provide full flexibility, aligned submatrices pose additional alignment restrictions and the given row, column, m, and n arguments are subject to additional checks to guarantee proper alignment. However, especially in case of dense submatrices this may result in considerable performance improvements.

The alignment restrictions refer to system dependent address restrictions for the used element type and the available vectorization mode (SSE, AVX, ...). The following source code gives some examples for a double precision dense matrix, assuming that AVX is available, which packs 4 double values into an intrinsic vector:

MatrixType D( 13UL, 17UL );
// ... Resizing and initialization
// OK: Starts at position (0,0) and the number of rows and columns are a multiple of 4
SubmatrixType dsm1 = submatrix<aligned>( D, 0UL, 0UL, 8UL, 12UL );
// OK: First row and column and the number of rows and columns are all a multiple of 4
SubmatrixType dsm2 = submatrix<aligned>( D, 4UL, 12UL, 8UL, 16UL );
// OK: First row and column are a multiple of 4 and the submatrix includes the last row and column
SubmatrixType dsm3 = submatrix<aligned>( D, 4UL, 0UL, 9UL, 17UL );
// Error: First row is not a multiple of 4
SubmatrixType dsm4 = submatrix<aligned>( D, 2UL, 4UL, 12UL, 12UL );
// Error: First column is not a multiple of 4
SubmatrixType dsm5 = submatrix<aligned>( D, 0UL, 2UL, 8UL, 8UL );
// Error: The number of rows is not a multiple of 4 and the submatrix does not include the last row
SubmatrixType dsm6 = submatrix<aligned>( D, 0UL, 0UL, 7UL, 8UL );
// Error: The number of columns is not a multiple of 4 and the submatrix does not include the last column
SubmatrixType dsm6 = submatrix<aligned>( D, 0UL, 0UL, 8UL, 11UL );

In case any alignment restrictions are violated, a std::invalid_argument exception is thrown.

template<bool AF, typename MT , bool SO>
DisableIf< Or< IsComputation<MT>, IsTransExpr<MT> > , typename SubmatrixExprTrait<const MT,AF>::Type >::Type blaze::submatrix ( const Matrix< MT, SO > &  matrix,
size_t  row,
size_t  column,
size_t  m,
size_t  n 
)
inline

Creating a view on a specific submatrix of the given matrix.

Parameters
matrixThe matrix containing the submatrix.
rowThe index of the first row of the submatrix.
columnThe index of the first column of the submatrix.
mThe number of rows of the submatrix.
nThe number of columns of the submatrix.
Returns
View on the specific submatrix of the matrix.
Exceptions
std::invalid_argumentInvalid submatrix specification.

This function returns an expression representing an aligned or unaligned submatrix of the given dense or sparse matrix, based on the specified alignment flag AF. The following example demonstrates the creation of both an aligned and unaligned submatrix:

DenseMatrix D;
SparseMatrix S;
// ... Resizing and initialization
// Creating an aligned dense submatrix of size 8x4, starting in row 0 and column 16
blaze::DenseSubmatrix<DenseMatrix,aligned> dsm = submatrix<aligned>( D, 0UL, 16UL, 8UL, 4UL );
// Creating an unaligned sparse submatrix of size 7x3, starting in row 2 and column 4
blaze::SparseSubmatrix<SparseMatrix,unaligned> ssm = submatrix<unaligned>( S, 2UL, 4UL, 7UL, 3UL );

In case the submatrix is not properly specified (i.e. if the specified row or column is larger than the total number of rows or columns of the given matrix or the submatrix is specified beyond the number of rows or columns of the matrix) a std::invalid_argument exception is thrown.

In contrast to unaligned submatrices, which provide full flexibility, aligned submatrices pose additional alignment restrictions and the given row, column, m, and n arguments are subject to additional checks to guarantee proper alignment. However, especially in case of dense submatrices this may result in considerable performance improvements.

The alignment restrictions refer to system dependent address restrictions for the used element type and the available vectorization mode (SSE, AVX, ...). The following source code gives some examples for a double precision dense matrix, assuming that AVX is available, which packs 4 double values into an intrinsic vector:

MatrixType D( 13UL, 17UL );
// ... Resizing and initialization
// OK: Starts at position (0,0) and the number of rows and columns are a multiple of 4
SubmatrixType dsm1 = submatrix<aligned>( D, 0UL, 0UL, 8UL, 12UL );
// OK: First row and column and the number of rows and columns are all a multiple of 4
SubmatrixType dsm2 = submatrix<aligned>( D, 4UL, 12UL, 8UL, 16UL );
// OK: First row and column are a multiple of 4 and the submatrix includes the last row and column
SubmatrixType dsm3 = submatrix<aligned>( D, 4UL, 0UL, 9UL, 17UL );
// Error: First row is not a multiple of 4
SubmatrixType dsm4 = submatrix<aligned>( D, 2UL, 4UL, 12UL, 12UL );
// Error: First column is not a multiple of 4
SubmatrixType dsm5 = submatrix<aligned>( D, 0UL, 2UL, 8UL, 8UL );
// Error: The number of rows is not a multiple of 4 and the submatrix does not include the last row
SubmatrixType dsm6 = submatrix<aligned>( D, 0UL, 0UL, 7UL, 8UL );
// Error: The number of columns is not a multiple of 4 and the submatrix does not include the last column
SubmatrixType dsm6 = submatrix<aligned>( D, 0UL, 0UL, 8UL, 11UL );

In case any alignment restrictions are violated, a std::invalid_argument exception is thrown.

template<typename VT , bool TF>
SubvectorExprTrait<VT,unaligned>::Type blaze::subvector ( Vector< VT, TF > &  vector,
size_t  index,
size_t  size 
)
inline

Creating a view on a specific subvector of the given vector.

Parameters
vectorThe vector containing the subvector.
indexThe index of the first element of the subvector.
sizeThe size of the subvector.
Returns
View on the specific subvector of the vector.
Exceptions
std::invalid_argumentInvalid subvector specification.

This function returns an expression representing the specified subvector of the given vector. The following example demonstrates the creation of a dense and sparse subvector:

DenseVector d;
SparseVector s;
// ... Resizing and initialization
// Creating a dense subvector of size 8, starting from index 4
// Creating a sparse subvector of size 7, starting from index 5

In case the subvector is not properly specified (i.e. if the specified first index is larger than the total size of the given vector or the subvector is specified beyond the size of the vector) a std::invalid_argument exception is thrown.

Please note that this function creates an unaligned dense or sparse subvector. For instance, the creation of the dense subvector is equivalent to the following three function calls:

blaze::DenseSubvector<DenseVector> dsv = subvector<unaligned>( v, 4UL, 8UL );
blaze::DenseSubvector<DenseVector,unaligned> dsv = subvector<unaligned>( v, 4UL, 8UL );

In contrast to unaligned subvectors, which provide full flexibility, aligned subvectors pose additional alignment restrictions. However, especially in case of dense subvectors this may result in considerable performance improvements. In order to create an aligned subvector the following function call has to be used:

blaze::DenseSubvector<DenseVector,aligned> = subvector<aligned>( v, 4UL, 8UL );

Note however that in this case the given index and size are subject to additional checks to guarantee proper alignment.

template<typename VT , bool TF>
SubvectorExprTrait<const VT,unaligned>::Type blaze::subvector ( const Vector< VT, TF > &  vector,
size_t  index,
size_t  size 
)
inline

Creating a view on a specific subvector of the given vector.

Parameters
vectorThe vector containing the subvector.
indexThe index of the first element of the subvector.
sizeThe size of the subvector.
Returns
View on the specific subvector of the vector.
Exceptions
std::invalid_argumentInvalid subvector specification.

This function returns an expression representing the specified subvector of the given vector. The following example demonstrates the creation of a dense and sparse subvector:

DenseVector d;
SparseVector s;
// ... Resizing and initialization
// Creating a dense subvector of size 8, starting from index 4
// Creating a sparse subvector of size 7, starting from index 5

In case the subvector is not properly specified (i.e. if the specified first index is larger than the total size of the given vector or the subvector is specified beyond the size of the vector) a std::invalid_argument exception is thrown.

Please note that this function creates an unaligned dense or sparse subvector. For instance, the creation of the dense subvector is equivalent to the following three function calls:

blaze::DenseSubvector<DenseVector> dsv = subvector<unaligned>( v, 4UL, 8UL );
blaze::DenseSubvector<DenseVector,unaligned> dsv = subvector<unaligned>( v, 4UL, 8UL );

In contrast to unaligned subvectors, which provide full flexibility, aligned subvectors pose additional alignment restrictions. However, especially in case of dense subvectors this may result in considerable performance improvements. In order to create an aligned subvector the following function call has to be used:

blaze::DenseSubvector<DenseVector,aligned> = subvector<aligned>( v, 4UL, 8UL );

Note however that in this case the given index and size are subject to additional checks to guarantee proper alignment.

template<bool AF, typename VT , bool TF>
DisableIf< Or< IsComputation<VT>, IsTransExpr<VT> > , typename SubvectorExprTrait<VT,AF>::Type >::Type blaze::subvector ( Vector< VT, TF > &  vector,
size_t  index,
size_t  size 
)
inline

Creating a view on a specific subvector of the given vector.

Parameters
vectorThe vector containing the subvector.
indexThe index of the first element of the subvector.
sizeThe size of the subvector.
Returns
View on the specific subvector of the vector.
Exceptions
std::invalid_argumentInvalid subvector specification.

This function returns an expression representing an aligned or unaligned subvector of the given dense or sparse vector, based on the specified alignment flag AF. The following example demonstrates the creation of both an aligned and unaligned subvector:

DenseVector d;
SparseVector s;
// ... Resizing and initialization
// Creating an aligned dense subvector of size 8 starting from index 4
blaze::DenseSubvector<DenseVector,aligned> dsv = subvector<aligned>( d, 4UL, 8UL );
// Creating an unaligned subvector of size 7 starting from index 3
blaze::SparseSubvector<SparseVector,unaligned> ssv = subvector<unaligned>( s, 3UL, 7UL );

In case the subvector is not properly specified (i.e. if the specified first index is larger than the total size of the given vector or the subvector is specified beyond the size of the vector) a std::invalid_argument exception is thrown.

In contrast to unaligned subvectors, which provide full flexibility, aligned subvectors pose additional alignment restrictions and the given index and size are subject to additional checks to guarantee proper alignment. However, especially in case of dense subvectors this may result in considerable performance improvements.

The alignment restrictions refer to system dependent address restrictions for the used element type and the available vectorization mode (SSE, AVX, ...). The following source code gives some examples for a double precision dense vector, assuming that AVX is available, which packs 4 double values into an intrinsic vector:

VectorType d( 17UL );
// ... Resizing and initialization
// OK: Starts at the beginning and the size is a multiple of 4
SubvectorType dsv1 = subvector<aligned>( d, 0UL, 12UL );
// OK: Start index and the size are both a multiple of 4
SubvectorType dsv2 = subvector<aligned>( d, 4UL, 8UL );
// OK: The start index is a multiple of 4 and the subvector includes the last element
SubvectorType dsv3 = subvector<aligned>( d, 8UL, 9UL );
// Error: Start index is not a multiple of 4
SubvectorType dsv4 = subvector<aligned>( d, 5UL, 8UL );
// Error: Size is not a multiple of 4 and the subvector does not include the last element
SubvectorType dsv5 = subvector<aligned>( d, 8UL, 5UL );

In case any alignment restrictions are violated, a std::invalid_argument exception is thrown.

template<bool AF, typename VT , bool TF>
DisableIf< Or< IsComputation<VT>, IsTransExpr<VT> > , typename SubvectorExprTrait<const VT,AF>::Type >::Type blaze::subvector ( const Vector< VT, TF > &  vector,
size_t  index,
size_t  size 
)
inline

Creating a view on a specific subvector of the given vector.

Parameters
vectorThe vector containing the subvector.
indexThe index of the first element of the subvector.
sizeThe size of the subvector.
Returns
View on the specific subvector of the vector.
Exceptions
std::invalid_argumentInvalid subvector specification.

This function returns an expression representing an aligned or unaligned subvector of the given dense or sparse vector, based on the specified alignment flag AF. The following example demonstrates the creation of both an aligned and unaligned subvector:

DenseVector d;
SparseVector s;
// ... Resizing and initialization
// Creating an aligned dense subvector of size 8 starting from index 4
blaze::DenseSubvector<DenseVector,aligned> dsv = subvector<aligned>( d, 4UL, 8UL );
// Creating an unaligned subvector of size 7 starting from index 3
blaze::SparseSubvector<SparseVector,unaligned> ssv = subvector<unaligned>( s, 3UL, 7UL );

In case the subvector is not properly specified (i.e. if the specified first index is larger than the total size of the given vector or the subvector is specified beyond the size of the vector) a std::invalid_argument exception is thrown.

In contrast to unaligned subvectors, which provide full flexibility, aligned subvectors pose additional alignment restrictions and the given index and size are subject to additional checks to guarantee proper alignment. However, especially in case of dense subvectors this may result in considerable performance improvements.

The alignment restrictions refer to system dependent address restrictions for the used element type and the available vectorization mode (SSE, AVX, ...). The following source code gives some examples for a double precision dense vector, assuming that AVX is available, which packs 4 double values into an intrinsic vector:

VectorType d( 17UL );
// ... Resizing and initialization
// OK: Starts at the beginning and the size is a multiple of 4
SubvectorType dsv1 = subvector<aligned>( d, 0UL, 12UL );
// OK: Start index and the size are both a multiple of 4
SubvectorType dsv2 = subvector<aligned>( d, 4UL, 8UL );
// OK: The start index is a multiple of 4 and the subvector includes the last element
SubvectorType dsv3 = subvector<aligned>( d, 8UL, 9UL );
// Error: Start index is not a multiple of 4
SubvectorType dsv4 = subvector<aligned>( d, 5UL, 8UL );
// Error: Size is not a multiple of 4 and the subvector does not include the last element
SubvectorType dsv5 = subvector<aligned>( d, 8UL, 5UL );

In case any alignment restrictions are violated, a std::invalid_argument exception is thrown.