Modules | Functions

Modules

 Column
 
 Row
 
 Submatrix
 
 Subvector
 

Functions

template<typename MT , bool SO>
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, ColumnExprTrait_< MT > > 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>
const DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, ColumnExprTrait_< const MT > > 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 > >, ColumnExprTrait_< MT > > blaze::column (Matrix< MT, SO > &&matrix, size_t index)
 Creating a view on a specific column of the given temporary matrix. More...
 
template<typename MT , bool SO>
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, RowExprTrait_< MT > > 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>
const DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, RowExprTrait_< const MT > > 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>
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, RowExprTrait_< MT > > blaze::row (Matrix< MT, SO > &&matrix, size_t index)
 Creating a view on a specific row of the given temporary matrix. More...
 
template<typename MT , bool SO>
SubmatrixExprTrait_< MT, unaligned > 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>
const SubmatrixExprTrait_< const MT, unaligned > 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 constant matrix. More...
 
template<typename MT , bool SO>
SubmatrixExprTrait_< MT, unaligned > 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 temporary matrix. More...
 
template<bool AF, typename MT , bool SO>
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, SubmatrixExprTrait_< MT, AF > > 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>
const DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, SubmatrixExprTrait_< const MT, AF > > 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 constant matrix. More...
 
template<bool AF, typename MT , bool SO>
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, SubmatrixExprTrait_< MT, AF > > 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 temporary matrix. More...
 
template<typename VT , bool TF>
SubvectorExprTrait_< VT, unaligned > 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>
const SubvectorExprTrait_< const VT, unaligned > blaze::subvector (const Vector< VT, TF > &vector, size_t index, size_t size)
 Creating a view on a specific subvector of the given constant vector. More...
 
template<typename VT , bool TF>
SubvectorExprTrait_< VT, unaligned > blaze::subvector (Vector< VT, TF > &&vector, size_t index, size_t size)
 Creating a view on a specific subvector of the given temporary vector. More...
 
template<bool AF, typename VT , bool TF>
DisableIf_< Or< IsComputation< VT >, IsTransExpr< VT > >, SubvectorExprTrait_< VT, AF > > 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>
const DisableIf_< Or< IsComputation< VT >, IsTransExpr< VT > >, SubvectorExprTrait_< const VT, AF > > blaze::subvector (const Vector< VT, TF > &vector, size_t index, size_t size)
 Creating a view on a specific subvector of the given constant vector. More...
 
template<bool AF, typename VT , bool TF>
DisableIf_< Or< IsComputation< VT >, IsTransExpr< VT > >, SubvectorExprTrait_< VT, AF > > blaze::subvector (Vector< VT, TF > &&vector, size_t index, size_t size)
 Creating a view on a specific subvector of the given temporary vector. More...
 

Detailed Description

Function Documentation

template<typename MT , bool SO>
DisableIf_< Or< IsComputation<MT>, IsTransExpr<MT> >, ColumnExprTrait_<MT> > 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

In case the column is not properly specified (i.e. if the specified index is greater than or equal to the total number of the columns in the given matrix) a std::invalid_argument exception is thrown.

template<typename MT , bool SO>
const DisableIf_< Or< IsComputation<MT>, IsTransExpr<MT> >, ColumnExprTrait_<const MT> > 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 constant matrix.

const DenseMatrix D( ... );
const SparseMatrix S( ... );
// Creating a view on the 3rd column of the dense matrix D
// Creating a view on the 4th column of the sparse matrix S

In case the column is not properly specified (i.e. if the specified index is greater than or equal to the total number of the columns in the given matrix) a std::invalid_argument exception is thrown.

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

Creating a view on a specific column of the given temporary 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 temporary matrix. In case the column is not properly specified (i.e. if the specified index is greater than or equal to the total number of the columns in the given matrix) a std::invalid_argument exception is thrown.

template<typename MT , bool SO>
DisableIf_< Or< IsComputation<MT>, IsTransExpr<MT> >, RowExprTrait_<MT> > 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

In case the row is not properly specified (i.e. if the specified index is greater than or equal to the total number of the rows in the given matrix) a std::invalid_argument exception is thrown.

template<typename MT , bool SO>
const DisableIf_< Or< IsComputation<MT>, IsTransExpr<MT> >, RowExprTrait_<const MT> > 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 constant matrix.

const DenseMatrix D( ... );
const SparseMatrix S( ... );
// Creating a view on the 3rd row of the dense matrix D
// Creating a view on the 4th row of the sparse matrix S

In case the row is not properly specified (i.e. if the specified index is greater than or equal to the total number of the rows in the given matrix) a std::invalid_argument exception is thrown.

template<typename MT , bool SO>
DisableIf_< Or< IsComputation<MT>, IsTransExpr<MT> >, RowExprTrait_<MT> > blaze::row ( Matrix< MT, SO > &&  matrix,
size_t  index 
)
inline

Creating a view on a specific row of the given temporary 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 temporary matrix. In case the row is not properly specified (i.e. if the specified index is greater than or equal to the total number of the rows in the given matrix) a std::invalid_argument exception is thrown.

template<typename MT , bool SO>
SubmatrixExprTrait_<MT,unaligned> 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::Submatrix<DenseMatrix> dsm = submatrix( D, 0UL, 16UL, 8UL, 4UL );
// Creating a sparse submatrix of size 7x3, starting in row 2 and column 4
blaze::Submatrix<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::Submatrix<DenseMatrix> dsm = submatrix<unaligned>( D, 0UL, 16UL, 8UL, 4UL );
blaze::Submatrix<DenseMatrix,unaligned> dsm = submatrix ( D, 0UL, 16UL, 8UL, 4UL );
blaze::Submatrix<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::Submatrix<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>
const SubmatrixExprTrait_<const MT,unaligned> 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 constant matrix.

Parameters
matrixThe constant 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 constant matrix. The following example demonstrates the creation of a dense and sparse submatrix:

const DenseMatrix D( ... );
const SparseMatrix S( ... );
// Creating a dense submatrix of size 8x4, starting in row 0 and column 16
blaze::Submatrix<const DenseMatrix> dsm = submatrix( D, 0UL, 16UL, 8UL, 4UL );
// Creating a sparse submatrix of size 7x3, starting in row 2 and column 4
blaze::Submatrix<const 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::Submatrix<const DenseMatrix> dsm = submatrix<unaligned>( D, 0UL, 16UL, 8UL, 4UL );
blaze::Submatrix<const 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::Submatrix<const 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_<MT,unaligned> 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 temporary matrix.

Parameters
matrixThe temporary 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 temporary matrix. In case the submatrix is not properly specified (i.e. if the specified row or column is greater 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.

template<bool AF, typename MT , bool SO>
DisableIf_< Or< IsComputation<MT>, IsTransExpr<MT> >, SubmatrixExprTrait_<MT,AF> > 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::Submatrix<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::Submatrix<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, and column 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, ...). In order to be properly aligned the first element of each row/column of the submatrix must be aligned. The following source code gives some examples for a double precision row-major dynamic matrix, assuming that padding is enabled and that AVX is available, which packs 4 double values into a SIMD vector:

MatrixType D( 13UL, 17UL );
// ... Resizing and initialization
// OK: Starts at position (0,0), i.e. the first element of each row is aligned (due to padding)
SubmatrixType dsm1 = submatrix<aligned>( D, 0UL, 0UL, 7UL, 11UL );
// OK: First column is a multiple of 4, i.e. the first element of each row is aligned (due to padding)
SubmatrixType dsm2 = submatrix<aligned>( D, 3UL, 12UL, 8UL, 16UL );
// OK: First column is a multiple of 4 and the submatrix includes the last row and column
SubmatrixType dsm3 = submatrix<aligned>( D, 4UL, 0UL, 9UL, 17UL );
// Error: First column is not a multiple of 4, i.e. the first element is not aligned
SubmatrixType dsm4 = submatrix<aligned>( D, 2UL, 3UL, 12UL, 12UL );

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

template<bool AF, typename MT , bool SO>
const DisableIf_< Or< IsComputation<MT>, IsTransExpr<MT> >, SubmatrixExprTrait_<const MT,AF> > 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 constant matrix.

Parameters
matrixThe constant 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:

const DenseMatrix D( ... );
const SparseMatrix S( ... );
// Creating an aligned dense submatrix of size 8x4, starting in row 0 and column 16
blaze::Submatrix<const 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::Submatrix<const 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, and column 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, ...). In order to be properly aligned the first element of each row/column of the submatrix must be aligned. The following source code gives some examples for a double precision row-major dynamic matrix, assuming that padding is enabled and that AVX is available, which packs 4 double values into a SIMD vector:

const MatrixType D( ... );
// OK: Starts at position (0,0), i.e. the first element of each row is aligned (due to padding)
SubmatrixType dsm1 = submatrix<aligned>( D, 0UL, 0UL, 7UL, 11UL );
// OK: First column is a multiple of 4, i.e. the first element of each row is aligned (due to padding)
SubmatrixType dsm2 = submatrix<aligned>( D, 3UL, 12UL, 8UL, 16UL );
// OK: First column is a multiple of 4 and the submatrix includes the last row and column
SubmatrixType dsm3 = submatrix<aligned>( D, 4UL, 0UL, 9UL, 17UL );
// Error: First column is not a multiple of 4, i.e. the first element is not aligned
SubmatrixType dsm4 = submatrix<aligned>( D, 2UL, 3UL, 12UL, 12UL );

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> >, SubmatrixExprTrait_<MT,AF> > 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 temporary matrix.

Parameters
matrixThe temporary 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 temporary dense or sparse matrix, based on the specified alignment flag AF. 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) or any alignment restrictions are violated, a std::invalid_argument exception is thrown.

template<typename VT , bool TF>
SubvectorExprTrait_<VT,unaligned> 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 greater 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::Subvector<DenseVector> dsv = subvector<unaligned>( d, 4UL, 8UL );
blaze::Subvector<DenseVector,unaligned> dsv = subvector<unaligned>( d, 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::Subvector<DenseVector,aligned> = subvector<aligned>( d, 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>
const SubvectorExprTrait_<const VT,unaligned> blaze::subvector ( const Vector< VT, TF > &  vector,
size_t  index,
size_t  size 
)
inline

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

Parameters
vectorThe constant 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 constant vector. The following example demonstrates the creation of a dense and sparse subvector:

const DenseVector d( ... );
const 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 greater 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::Subvector<const DenseVector> dsv = subvector<unaligned>( d, 4UL, 8UL );
blaze::Subvector<const DenseVector,unaligned> dsv = subvector<unaligned>( d, 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::Subvector<const DenseVector,aligned> = subvector<aligned>( d, 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_<VT,unaligned> blaze::subvector ( Vector< VT, TF > &&  vector,
size_t  index,
size_t  size 
)
inline

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

Parameters
vectorThe temporary 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 temporary vector. In case the subvector is not properly specified (i.e. if the specified first index is greater 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.

template<bool AF, typename VT , bool TF>
DisableIf_< Or< IsComputation<VT>, IsTransExpr<VT> >, SubvectorExprTrait_<VT,AF> > 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::Subvector<DenseVector,aligned> dsv = subvector<aligned>( d, 4UL, 8UL );
// Creating an unaligned subvector of size 7 starting from index 3
blaze::Subvector<SparseVector,unaligned> ssv = subvector<unaligned>( s, 3UL, 7UL );

In case the subvector is not properly specified (i.e. if the specified first index is greater 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 is 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, ...). In order to be properly aligned the first element of the subvector must be aligned. The following source code gives some examples for a double precision dynamic vector, assuming that AVX is available, which packs 4 double values into a SIMD vector:

VectorType d( 17UL );
// ... Resizing and initialization
// OK: Starts at the beginning, i.e. the first element is aligned
SubvectorType dsv1 = subvector<aligned>( d, 0UL, 13UL );
// OK: Start index is a multiple of 4, i.e. the first element is aligned
SubvectorType dsv2 = subvector<aligned>( d, 4UL, 7UL );
// 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, i.e. the first element is not aligned
SubvectorType dsv4 = subvector<aligned>( d, 5UL, 8UL );

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

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

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

Parameters
vectorThe constant 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 constant dense or sparse vector, based on the specified alignment flag AF. The following example demonstrates the creation of both an aligned and unaligned subvector:

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

In case the subvector is not properly specified (i.e. if the specified first index is greater 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 is 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, ...). In order to be properly aligned the first element of the subvector must be aligned. The following source code gives some examples for a double precision dynamic vector, assuming that AVX is available, which packs 4 double values into a SIMD vector:

const VectorType d( ... );
// OK: Starts at the beginning, i.e. the first element is aligned
SubvectorType dsv1 = subvector<aligned>( d, 0UL, 13UL );
// OK: Start index is a multiple of 4, i.e. the first element is aligned
SubvectorType dsv2 = subvector<aligned>( d, 4UL, 7UL );
// 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, i.e. the first element is not aligned
SubvectorType dsv4 = subvector<aligned>( d, 5UL, 8UL );

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> >, SubvectorExprTrait_<VT,AF> > blaze::subvector ( Vector< VT, TF > &&  vector,
size_t  index,
size_t  size 
)
inline

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

Parameters
vectorThe temporary 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 temporary dense or sparse vector, based on the specified alignment flag AF. In case the subvector is not properly specified (i.e. if the specified first index is greater than the total size of the given vector or the subvector is specified beyond the size of the vector) or any alignment restrictions are violated, a std::invalid_argument exception is thrown.