35#ifndef _BLAZE_MATH_EXPRESSIONS_DVECGENEXPR_H_
36#define _BLAZE_MATH_EXPRESSIONS_DVECGENEXPR_H_
93 :
public VecGenExpr< DenseVector< DVecGenExpr<VT,OP,TF>, TF > >
109 using ReturnType =
decltype( std::declval<OP>()( std::declval<size_t>() ) );
147 ,
op_ ( std::move(op) )
234 return index_ == rhs.index_;
245 return index_ != rhs.index_;
256 return index_ < rhs.index_;
267 return index_ > rhs.index_;
278 return index_ <= rhs.index_;
289 return index_ >= rhs.index_;
300 return index_ - rhs.index_;
365 ,
op_ ( std::move( op ) )
388 if( index >=
size_ ) {
391 return (*
this)[index];
420 inline size_t size() const noexcept {
441 template<
typename T >
442 inline bool canAlias(
const T* alias )
const noexcept {
454 template<
typename T >
455 inline bool isAliased(
const T* alias )
const noexcept {
555 using ReturnType =
const DVecGenExpr< VT, OP, TransposeFlag_v<VT> >;
556 return ReturnType(
size, std::move( op ) );
658 divisor =
static_cast<ET
>(
size - 1UL );
664 auto delta(
evaluate( (
end - start ) / divisor ) );
666 return generate<TF>(
size, [ start=std::move(start), delta=std::move(delta) ](
size_t index ) {
667 return evaluate( start + index*delta );
714 divisor =
static_cast<ET
>(
size - 1UL );
720 auto delta(
evaluate( (
end - start ) / divisor ) );
722 return generate<TF>(
size, [ start=std::move(start), delta=std::move(delta) ](
size_t index ) {
757inline decltype(
auto)
subvector(
const DVecGenExpr<VT,OP,TF>& expr, RSAs... args )
766 if( I + N > expr.size() ) {
774 return generate( N, [op=expr.operation()](
size_t i ) {
811 if( index +
size > expr.size() ) {
819 return generate(
size, [op=expr.operation(),index](
size_t i ) {
820 return op( i+index );
863 static constexpr size_t indices[] = { I, Is... };
864 for(
size_t i=0UL; i<
sizeof...(Is)+1UL; ++i ) {
865 if( expr.size() <= indices[i] ) {
871 return generate(
sizeof...(Is)+1UL, [op=expr.operation()](
size_t i ) {
872 static constexpr size_t indices[] = { I, Is... };
873 return op( indices[i] );
900inline decltype(
auto)
elements(
const DVecGenExpr<VT,OP,TF>& expr, T* indices,
size_t n, REAs... args )
906 constexpr bool isChecked( !Contains_v< TypeList<REAs...>, Unchecked > );
909 for(
size_t i=0UL; i<n; ++i ) {
910 if( expr.size() <=
size_t( indices[i] ) ) {
916 SmallArray<size_t,128UL> newIndices( indices, indices+n );
918 return generate( n, [op=expr.operation(),newIndices](
size_t i ) {
919 return op( newIndices[i] );
946inline decltype(
auto)
elements(
const DVecGenExpr<VT,OP,TF>& expr, P p,
size_t n, REAs... args )
952 constexpr bool isChecked( !Contains_v< TypeList<REAs...>, Unchecked > );
955 for(
size_t i=0UL; i<n; ++i ) {
956 if( expr.size() <=
size_t( p(i) ) ) {
962 return generate( n, [op=expr.operation(),p](
size_t i ) {
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 evaluate shim.
Header file for the function trace functionality.
Macro for CUDA compatibility.
Header file for the IsFloatingPoint type trait.
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.
Header file for the UnderlyingBuiltin type trait.
Iterator over the elements of the dense vector generator expression.
Definition DVecGenExpr.h:122
BLAZE_DEVICE_CALLABLE bool operator==(const ConstIterator &rhs) const noexcept
Equality comparison between two ConstIterator objects.
Definition DVecGenExpr.h:233
BLAZE_DEVICE_CALLABLE ConstIterator & operator--()
Pre-decrement operator.
Definition DVecGenExpr.h:201
BLAZE_DEVICE_CALLABLE bool operator>=(const ConstIterator &rhs) const noexcept
Greater-than comparison between two ConstIterator objects.
Definition DVecGenExpr.h:288
size_t index_
Index of the current vector element.
Definition DVecGenExpr.h:342
BLAZE_DEVICE_CALLABLE const ConstIterator operator++(int)
Post-increment operator.
Definition DVecGenExpr.h:191
BLAZE_DEVICE_CALLABLE ReturnType operator*() const
Direct access to the element at the current iterator position.
Definition DVecGenExpr.h:222
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator+(const ConstIterator &it, size_t inc)
Addition between a ConstIterator and an integral value.
Definition DVecGenExpr.h:311
BLAZE_DEVICE_CALLABLE const ConstIterator operator--(int)
Post-decrement operator.
Definition DVecGenExpr.h:212
BLAZE_DEVICE_CALLABLE DifferenceType operator-(const ConstIterator &rhs) const noexcept
Calculating the number of elements between two iterators.
Definition DVecGenExpr.h:299
BLAZE_DEVICE_CALLABLE ConstIterator & operator-=(size_t dec)
Subtraction assignment operator.
Definition DVecGenExpr.h:169
ReferenceType reference
Reference return type.
Definition DVecGenExpr.h:135
BLAZE_DEVICE_CALLABLE bool operator!=(const ConstIterator &rhs) const noexcept
Inequality comparison between two ConstIterator objects.
Definition DVecGenExpr.h:244
ElementType & ReferenceType
Reference return type.
Definition DVecGenExpr.h:128
OP op_
The custom unary operation.
Definition DVecGenExpr.h:343
BLAZE_DEVICE_CALLABLE ConstIterator(size_t index, OP op)
Constructor for the ConstIterator class.
Definition DVecGenExpr.h:145
IteratorCategory iterator_category
The iterator category.
Definition DVecGenExpr.h:132
BLAZE_DEVICE_CALLABLE ConstIterator & operator++()
Pre-increment operator.
Definition DVecGenExpr.h:180
ptrdiff_t DifferenceType
Difference between two iterators.
Definition DVecGenExpr.h:129
ElementType * PointerType
Pointer return type.
Definition DVecGenExpr.h:127
DifferenceType difference_type
Difference between two iterators.
Definition DVecGenExpr.h:136
BLAZE_DEVICE_CALLABLE bool operator>(const ConstIterator &rhs) const noexcept
Greater-than comparison between two ConstIterator objects.
Definition DVecGenExpr.h:266
BLAZE_DEVICE_CALLABLE bool operator<=(const ConstIterator &rhs) const noexcept
Less-than comparison between two ConstIterator objects.
Definition DVecGenExpr.h:277
BLAZE_DEVICE_CALLABLE bool operator<(const ConstIterator &rhs) const noexcept
Less-than comparison between two ConstIterator objects.
Definition DVecGenExpr.h:255
ValueType value_type
Type of the underlying elements.
Definition DVecGenExpr.h:133
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator+(size_t inc, const ConstIterator &it)
Addition between an integral value and a ConstIterator.
Definition DVecGenExpr.h:323
ElementType ValueType
Type of the underlying elements.
Definition DVecGenExpr.h:126
BLAZE_DEVICE_CALLABLE ConstIterator & operator+=(size_t inc)
Addition assignment operator.
Definition DVecGenExpr.h:157
PointerType pointer
Pointer return type.
Definition DVecGenExpr.h:134
friend BLAZE_DEVICE_CALLABLE const ConstIterator operator-(const ConstIterator &it, size_t dec)
Subtraction between a ConstIterator and an integral value.
Definition DVecGenExpr.h:335
std::random_access_iterator_tag IteratorCategory
The iterator category.
Definition DVecGenExpr.h:125
Expression object for the dense vector generate() function.
Definition DVecGenExpr.h:95
TransposeType_t< VT > TransposeType
Transpose type for expression template evaluations.
Definition DVecGenExpr.h:105
const DVecGenExpr & CompositeType
Data type for composite expression templates.
Definition DVecGenExpr.h:112
ConstIterator end() const
Returns an iterator just past the last non-zero element of the dense vector.
Definition DVecGenExpr.h:410
bool canAlias(const T *alias) const noexcept
Returns whether the expression can alias with the given address alias.
Definition DVecGenExpr.h:442
ElementType_t< VT > ElementType
Resulting element type.
Definition DVecGenExpr.h:106
static constexpr bool smpAssignable
Compilation switch for the expression template assignment strategy.
Definition DVecGenExpr.h:354
size_t size_
The size/dimension of the dense vector generator.
Definition DVecGenExpr.h:483
OP Operation
Data type of the custom unary operation.
Definition DVecGenExpr.h:115
VecGenExpr< DenseVector< This, TF > > BaseType
Base type of this DVecGenExpr instance.
Definition DVecGenExpr.h:102
Operation operation() const
Returns a copy of the custom unary operation.
Definition DVecGenExpr.h:430
DVecGenExpr(size_t size, OP &&op) noexcept
Constructor for the DVecGenExpr class.
Definition DVecGenExpr.h:363
DVecGenExpr< VT, OP, TF > This
Type of this DVecGenExpr instance.
Definition DVecGenExpr.h:99
Operation op_
The custom unary operation.
Definition DVecGenExpr.h:484
RemoveCVRef_t< VT > ResultType
Result type for expression template evaluations.
Definition DVecGenExpr.h:104
ReturnType operator[](size_t index) const
Subscript operator for the direct access to the vector elements.
Definition DVecGenExpr.h:375
ReturnType at(size_t index) const
Checked access to the vector elements.
Definition DVecGenExpr.h:387
bool isAliased(const T *alias) const noexcept
Returns whether the expression is aliased with the given address alias.
Definition DVecGenExpr.h:455
static constexpr bool simdEnabled
Compilation switch for the expression template evaluation strategy.
Definition DVecGenExpr.h:351
decltype(std::declval< OP >()(std::declval< size_t >())) ReturnType
Return type for expression template evaluations.
Definition DVecGenExpr.h:109
size_t size() const noexcept
Returns the current size/dimension of the vector.
Definition DVecGenExpr.h:420
bool isAligned() const noexcept
Returns whether the operands of the expression are properly aligned in memory.
Definition DVecGenExpr.h:466
ConstIterator begin() const
Returns an iterator to the first non-zero element of the dense vector.
Definition DVecGenExpr.h:400
bool canSMPAssign() const noexcept
Returns whether the expression can be used in SMP assignments.
Definition DVecGenExpr.h:476
Efficient implementation of an arbitrary sized vector.
Definition DynamicVector.h:223
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 DenseVector base class.
Header file for the VecGenExpr base class.
decltype(auto) exp10(const DenseMatrix< MT, SO > &dm)
Computes for each single element of the dense matrix dm.
Definition DMatMapExpr.h:1857
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
decltype(auto) linspace(size_t size, T start, T end)
Generates a new dense vector filled with linearly spaced elements.
Definition DVecGenExpr.h:648
decltype(auto) logspace(size_t size, T start, T end)
Generates a new dense vector filled with logarithmically spaced elements.
Definition DVecGenExpr.h:704
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition Elements.h:143
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.
Definition Expression.h:81
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.
Definition TransposeFlag.h:63
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition DenseVector.h:61
typename UnderlyingBuiltin< T >::Type UnderlyingBuiltin_t
Auxiliary alias declaration for the UnderlyingBuiltin type trait.
Definition UnderlyingBuiltin.h:117
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
MT::ResultType evaluate(const Matrix< MT, SO > &matrix)
Evaluates the given matrix expression.
Definition Matrix.h:1282
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition Matrix.h:584
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition Matrix.h:676
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition Assert.h:117
decltype(auto) subvector(Vector< VT, TF > &, RSAs...)
Creating a view on a specific subvector of the given vector.
Definition Subvector.h:158
constexpr bool defaultTransposeFlag
The default transpose flag for all vectors of the Blaze library.
Definition TransposeFlag.h:75
#define BLAZE_DEVICE_CALLABLE
Conditional macro that sets host and device attributes when compiled with CUDA.
Definition HostDevice.h:94
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
typename If< Condition >::template Type< T1, T2 > If_t
Auxiliary alias template for the If class template.
Definition If.h:108
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.
Constraint on the data type.
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 TransposeFlag type trait.
Header file for the exp10 shim.
Base class for all compute expression templates.
Definition Computation.h:68
Implementation of a type list.
Definition TypeList.h:120
Base class for all vector generator expression templates.
Definition VecGenExpr.h:68
Header file for the default transpose flag for all vectors of the Blaze library.
Header file for basic type definitions.