35#ifndef _BLAZE_MATH_EXPRESSIONS_DMATGENEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DMATGENEXPR_H_
89 :
public MatGenExpr< DenseMatrix< DMatGenExpr<MT,OP,SO>, SO > >
105 using ReturnType =
decltype( std::declval<OP>()( std::declval<size_t>(), std::declval<size_t>() ) );
145 ,
op_( std::move(op) )
414 ,
op_( std::move( op ) )
478 inline size_t rows() const noexcept {
509 template<
typename T >
510 inline bool canAlias(
const T* alias )
const noexcept {
522 template<
typename T >
523 inline bool isAliased(
const T* alias )
const noexcept {
619inline decltype(
auto)
generate(
size_t m,
size_t n, OP op )
628 using ReturnType =
const DMatGenExpr< MT, OP, StorageOrder_v<MT> >;
629 return ReturnType( m, n, std::move( op ) );
675inline decltype(
auto)
generate(
size_t m,
size_t n, OP op )
717inline decltype(
auto)
submatrix(
const DMatGenExpr<MT,OP,SO>& expr, RSAs... args )
726 if( ( I + M > expr.rows() ) || ( J + N > expr.columns() ) ) {
735 return generate( M, N, [op=expr.operation()](
size_t i,
size_t j ) {
736 return op( i+I, j+J );
775 if( (
row + m > expr.rows() ) || (
column + n > expr.columns() ) ) {
785 return op( i+row, j+column );
826 if( expr.rows() <= I ) {
869 if( expr.rows() <= index ) {
878 return op( index, i );
921 static constexpr size_t indices[] = { I, Is... };
922 for(
size_t i=0UL; i<
sizeof...(Is)+1UL; ++i ) {
923 if( expr.rows() <= indices[i] ) {
929 return generate(
sizeof...(Is)+1UL, expr.columns(), [op=expr.operation()](
size_t i,
size_t j ) {
930 static constexpr size_t indices[] = { I, Is... };
931 return op( indices[i], j );
958inline decltype(
auto)
rows(
const DMatGenExpr<MT,OP,SO> expr, T* indices,
size_t n, RRAs... args )
964 constexpr bool isChecked( !Contains_v< TypeList<RRAs...>, Unchecked > );
967 for(
size_t i=0UL; i<n; ++i ) {
968 if( expr.rows() <=
size_t( indices[i] ) ) {
974 SmallArray<size_t,128UL> newIndices( indices, indices+n );
976 return generate( n, expr.columns(), [op=expr.operation(),newIndices](
size_t i,
size_t j ){
977 return op( newIndices[i], j );
1003 ,
typename... RRAs >
1004inline decltype(
auto)
rows(
const DMatGenExpr<MT,OP,SO>& expr, P p,
size_t n, RRAs... args )
1010 constexpr bool isChecked( !Contains_v< TypeList<RRAs...>, Unchecked > );
1013 for(
size_t i=0UL; i<n; ++i ) {
1014 if( expr.rows() <=
size_t( p(i) ) ) {
1020 return generate( n, expr.columns(), [op=expr.operation(),p](
size_t i,
size_t j ){
1021 return op( p(i), j );
1052 ,
typename... CRAs >
1053inline decltype(
auto)
column(
const DMatGenExpr<MT,OP,SO>& expr, CRAs... args )
1059 constexpr bool isChecked( !Contains_v< TypeList<CRAs...>, Unchecked > );
1062 if( expr.columns() <= I ) {
1070 return generate<columnVector>( expr.rows(), [op=expr.operation()](
size_t i ){
1092template<
typename MT
1095 ,
typename... CRAs >
1096inline decltype(
auto)
column(
const DMatGenExpr<MT,OP,SO>& expr,
size_t index, CRAs... args )
1102 constexpr bool isChecked( !Contains_v< TypeList<CRAs...>, Unchecked > );
1105 if( expr.columns() <= index ) {
1113 return generate<columnVector>( expr.rows(), [op=expr.operation(),index](
size_t i ){
1114 return op( i, index );
1147 ,
typename... RCAs >
1148inline decltype(
auto)
columns(
const DMatGenExpr<MT,OP,SO>& expr, RCAs... args )
1154 constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
1157 static constexpr size_t indices[] = { I, Is... };
1158 for(
size_t i=0UL; i<
sizeof...(Is)+1UL; ++i ) {
1159 if( expr.columns() <= indices[i] ) {
1165 return generate( expr.rows(),
sizeof...(Is)+1UL, [op=expr.operation()](
size_t i,
size_t j ) {
1166 static constexpr size_t indices[] = { I, Is... };
1167 return op( i, indices[j] );
1189template<
typename MT
1193 ,
typename... RCAs >
1194inline decltype(
auto)
columns(
const DMatGenExpr<MT,OP,SO> expr, T* indices,
size_t n, RCAs... args )
1200 constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
1203 for(
size_t i=0UL; i<n; ++i ) {
1204 if( expr.columns() <=
size_t( indices[i] ) ) {
1210 SmallArray<size_t,128UL> newIndices( indices, indices+n );
1212 return generate( expr.rows(), n, [op=expr.operation(),newIndices](
size_t i,
size_t j ){
1213 return op( i, newIndices[j] );
1235template<
typename MT
1239 ,
typename... RCAs >
1240inline decltype(
auto)
columns(
const DMatGenExpr<MT,OP,SO>& expr, P p,
size_t n, RCAs... args )
1246 constexpr bool isChecked( !Contains_v< TypeList<RCAs...>, Unchecked > );
1249 for(
size_t i=0UL; i<n; ++i ) {
1250 if( expr.columns() <=
size_t( p(i) ) ) {
1256 return generate( expr.rows(), n, [op=expr.operation(),p](
size_t i,
size_t j ){
1257 return op( i, p(j) );
1288 ,
typename... RBAs >
1289inline decltype(
auto)
band(
const DMatGenExpr<MT,OP,SO>& expr, RBAs... args )
1293 const BandData<CBAs...> bd( args... );
1295 const size_t row ( bd.band() >= 0L ? 0UL : -bd.band() );
1296 const size_t column( bd.band() >= 0L ? bd.band() : 0UL );
1297 const size_t size (
min( expr.rows() - row, expr.columns() - column ) );
1299 const bool isChecked( !Contains_v< TypeList<RBAs...>, Unchecked > );
1302 if( ( bd.band() > 0L && column >= expr.columns() ) ||
1303 ( bd.band() < 0L && row >= expr.rows() ) ) {
1308 BLAZE_USER_ASSERT( bd.band() <= 0L || column < expr.columns(),
"Invalid band access index" );
1309 BLAZE_USER_ASSERT( bd.band() >= 0L || row < expr.rows(),
"Invalid band access index" );
1312 return generate( size, [op=expr.operation(),row,column](
size_t i ){
1313 return op( i+row, i+column );
Header file for auxiliary alias declarations.
typename T::TransposeType TransposeType_t
Alias declaration for nested TransposeType type definitions.
Definition Aliases.h:550
typename T::ElementType ElementType_t
Alias declaration for nested ElementType type definitions.
Definition Aliases.h:190
Header file for run time assertion macros.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the function trace functionality.
Macro for CUDA compatibility.
Header file for the MAYBE_UNUSED function template.
Header file for the RemoveCVRef type trait.
Header file for the SmallArray implementation.
Header file for the type list functionality.
Iterator over the elements of the dense matrix generator expression.
Definition DMatGenExpr.h:118
size_t n_
Column index of the current matrix element.
Definition DMatGenExpr.h:389
BLAZE_DEVICE_CALLABLE ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition DMatGenExpr.h:155
ElementType ValueType
Type of the underlying elements.
Definition DMatGenExpr.h:122
BLAZE_DEVICE_CALLABLE bool operator<=(const ConstIterator &rhs) const noexcept
Less-than comparison between two ConstIterator objects.
Definition DMatGenExpr.h:305
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition DMatGenExpr.h:348
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition DMatGenExpr.h:121
OP op_
The custom binary operation.
Definition DMatGenExpr.h:390
BLAZE_DEVICE_CALLABLE bool operator>=(const ConstIterator &rhs) const noexcept
Greater-than comparison between two ConstIterator objects.
Definition DMatGenExpr.h:319
size_t m_
Row index of the current matrix element.
Definition DMatGenExpr.h:388
PointerType pointer
Pointer return type.
Definition DMatGenExpr.h:130
BLAZE_DEVICE_CALLABLE ConstIterator & operator--()
Pre-decrement operator.
Definition DMatGenExpr.h:211
BLAZE_DEVICE_CALLABLE bool operator==(const ConstIterator &rhs) const noexcept
Equality comparison between two ConstIterator objects.
Definition DMatGenExpr.h:249
BLAZE_DEVICE_CALLABLE bool operator<(const ConstIterator &rhs) const noexcept
Less-than comparison between two ConstIterator objects.
Definition DMatGenExpr.h:277
BLAZE_DEVICE_CALLABLE DifferenceType operator-(const ConstIterator &rhs) const noexcept
Calculating the number of elements between two iterators.
Definition DMatGenExpr.h:333
BLAZE_DEVICE_CALLABLE ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition DMatGenExpr.h:238
BLAZE_DEVICE_CALLABLE bool operator>(const ConstIterator &rhs) const noexcept
Greater-than comparison between two ConstIterator objects.
Definition DMatGenExpr.h:291
DifferenceType difference_type
Difference between two iterators.
Definition DMatGenExpr.h:132
BLAZE_DEVICE_CALLABLE ConstIterator & operator++()
Pre-increment operator.
Definition DMatGenExpr.h:184
ptrdiff_t DifferenceType
Difference between two iterators.
Definition DMatGenExpr.h:125
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition DMatGenExpr.h:363
BLAZE_DEVICE_CALLABLE const ConstIterator operator++(int)
Post-increment operator.
Definition DMatGenExpr.h:198
ValueType value_type
Type of the underlying elements.
Definition DMatGenExpr.h:129
IteratorCategory iterator_category
The iterator category.
Definition DMatGenExpr.h:128
BLAZE_DEVICE_CALLABLE ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition DMatGenExpr.h:170
ElementType * PointerType
Pointer return type.
Definition DMatGenExpr.h:123
BLAZE_DEVICE_CALLABLE bool operator!=(const ConstIterator &rhs) const noexcept
Inequality comparison between two ConstIterator objects.
Definition DMatGenExpr.h:263
ElementType & ReferenceType
Reference return type.
Definition DMatGenExpr.h:124
BLAZE_DEVICE_CALLABLE ConstIterator(size_t m, size_t n, OP op)
Constructor for the ConstIterator class.
Definition DMatGenExpr.h:142
BLAZE_DEVICE_CALLABLE const ConstIterator operator--(int)
Post-decrement operator.
Definition DMatGenExpr.h:225
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition DMatGenExpr.h:378
ReferenceType reference
Reference return type.
Definition DMatGenExpr.h:131
Expression object for the dense matrix generate() function.
Definition DMatGenExpr.h:91
OP Operation
Data type of the custom binary operation.
Definition DMatGenExpr.h:111
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition DMatGenExpr.h:401
decltype(std::declval< OP >()(std::declval< size_t >(), std::declval< size_t >())) ReturnType
Return type for expression template evaluations.
Definition DMatGenExpr.h:105
MatGenExpr< DenseMatrix< This, SO > > BaseType
Base type of this DMatGenExpr instance.
Definition DMatGenExpr.h:98
TransposeType_t< MT > TransposeType
Transpose type for expression template evaluations.
Definition DMatGenExpr.h:101
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition DMatGenExpr.h:523
const DMatGenExpr & CompositeType
Data type for composite expression templates.
Definition DMatGenExpr.h:108
Operation op_
The custom binary operation.
Definition DMatGenExpr.h:553
size_t rows() const noexcept
Returns the current number of rows of the matrix.
Definition DMatGenExpr.h:478
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition DMatGenExpr.h:544
ElementType_t< MT > ElementType
Resulting element type.
Definition DMatGenExpr.h:102
DMatGenExpr(size_t m, size_t n, OP &&op) noexcept
Constructor for the DMatGenExpr class.
Definition DMatGenExpr.h:411
DMatGenExpr< MT, OP, SO > This
Type of this DMatGenExpr instance.
Definition DMatGenExpr.h:95
Operation operation() const
Returns a copy of the custom binary operation.
Definition DMatGenExpr.h:498
ConstIterator end(size_t i) const
Returns an iterator just past the last non-zero element of row/column i.
Definition DMatGenExpr.h:468
ConstIterator begin(size_t i) const
Returns an iterator to the first non-zero element of row/column i.
Definition DMatGenExpr.h:457
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition DMatGenExpr.h:510
size_t n_
The number of columns of the dense matrix generator.
Definition DMatGenExpr.h:552
size_t columns() const noexcept
Returns the current number of columns of the matrix.
Definition DMatGenExpr.h:488
RemoveCVRef_t< MT > ResultType
Result type for expression template evaluations.
Definition DMatGenExpr.h:100
ReturnType operator()(size_t i, size_t j) const noexcept
2D-access to the matrix elements.
Definition DMatGenExpr.h:425
size_t m_
The number of rows of the dense matrix generator.
Definition DMatGenExpr.h:551
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition DMatGenExpr.h:534
ReturnType at(size_t i, size_t j) const
Checked access to the matrix elements.
Definition DMatGenExpr.h:440
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition DMatGenExpr.h:398
Efficient implementation of a dynamic matrix.
Definition DynamicMatrix.h:242
Pointer difference type of the Blaze library.
Constraint on the data type.
Constraint on the data type.
Header file for the Computation base class.
Header file for the DenseMatrix base class.
Header file for the MatGenExpr base class.
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition Band.h:140
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition Column.h:137
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition DMatDMatMapExpr.h:1339
decltype(auto) generate(size_t m, size_t n, OP op)
Generates a new dense matrix filled via the given custom binary operation.
Definition DMatGenExpr.h:675
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.
Definition Expression.h:81
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.
Definition StorageOrder.h:63
constexpr ptrdiff_t Size_v
Auxiliary variable template for the Size type trait.
Definition Size.h:176
constexpr ptrdiff_t DefaultSize_v
Default size of the Size type trait.
Definition Size.h:72
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.
Definition AlignmentFlag.h:63
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition Matrix.h:644
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition Matrix.h:660
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition Matrix.h:676
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition Row.h:137
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition Assert.h:101
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition Assert.h:117
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition Submatrix.h:181
#define BLAZE_DEVICE_CALLABLE
Conditional macro that sets host and device attributes when compiled with CUDA.
Definition HostDevice.h:94
constexpr bool defaultStorageOrder
The default storage order for all matrices of the Blaze library.
Definition StorageOrder.h:75
typename RemoveCVRef< T >::Type RemoveCVRef_t
Auxiliary alias declaration for the RemoveCVRef type trait.
Definition RemoveCVRef.h:99
constexpr bool Contains_v
Auxiliary variable template for the Contains type trait.
Definition Contains.h:138
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition MaybeUnused.h:81
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition Exception.h:235
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition FunctionTrace.h:94
constexpr bool isChecked(const Ts &... args)
Extracting blaze::Check arguments from a given list of arguments.
Definition Check.h:225
Check< false > Unchecked
Type of the blaze::unchecked instance.
Definition Check.h:104
Header file for the exception macros of the math module.
Constraints on the storage order of matrix types.
Header file for all forward declarations for dense vectors and matrices.
Header file for all forward declarations for expression class templates.
Header file for the Size type trait.
Header file for the StorageOrder type trait.
Base class for all compute expression templates.
Definition Computation.h:68
Base class for all matrix generator expression templates.
Definition MatGenExpr.h:68
Implementation of a type list.
Definition TypeList.h:120
Header file for the default storage order for all vectors of the Blaze library.
Header file for basic type definitions.