35#ifndef _BLAZE_MATH_VIEWS_SUBVECTOR_H_
36#define _BLAZE_MATH_VIEWS_SUBVECTOR_H_
339 using ReturnType = Subvector_<VT,AF,I,N>;
340 return ReturnType( *vector, args... );
419 using ReturnType =
const Subvector_<const VT,AF,I,N>;
420 return ReturnType( *vector, args... );
451 using ReturnType = Subvector_<VT,AF,I,N>;
452 return ReturnType( *vector, args... );
697 using ReturnType = Subvector_<VT,AF>;
698 return ReturnType( *vector, index,
size, args... );
777 using ReturnType =
const Subvector_<const VT,AF>;
778 return ReturnType( *vector, index,
size, args... );
809 using ReturnType = Subvector_<VT,AF>;
810 return ReturnType( *vector, index,
size, args... );
840inline decltype(
auto)
subvector(
const VecVecAddExpr<VT>& vector, RSAs... args )
844 return subvector<AF,CSAs...>( (*vector).leftOperand(), args... ) +
845 subvector<AF,CSAs...>( (*vector).rightOperand(), args... );
872 return subvector<AF,CSAs...>( (*vector).leftOperand(), args... ) -
873 subvector<AF,CSAs...>( (*vector).rightOperand(), args... );
900 return subvector<AF,CSAs...>( (*vector).leftOperand(), args... ) *
901 subvector<AF,CSAs...>( (*vector).rightOperand(), args... );
963 return elements( *vector, [index](
size_t i ){
return i+index; },
size, args... );
994 return subvector<AF,CSAs...>( (*vector).leftOperand(), args... ) /
995 subvector<AF,CSAs...>( (*vector).rightOperand(), args... );
1017 ,
typename... RSAs >
1022 using ReturnType = Subvector_< VectorType_t<VT>,
unaligned, CSAs... >;
1023 return ReturnType( *vector, args... );
1045 ,
typename... RSAs >
1050 return subvector<AF,CSAs...>( (*vector).leftOperand(), args... ) * (*vector).rightOperand();
1072 ,
typename... RSAs >
1077 return subvector<AF,CSAs...>( (*vector).leftOperand(), args... ) / (*vector).rightOperand();
1099 ,
typename... RSAs >
1126 ,
typename... RSAs >
1133 (*vector).operation() );
1155 ,
typename... RSAs >
1182 ,
typename... RSAs >
1209 ,
typename... RSAs >
1236 ,
typename... RSAs >
1263 ,
typename... RSAs >
1292 ,
typename... RSAs >
1298 if( I + N > (*vector).size() ) {
1303 BLAZE_USER_ASSERT( I + N <= (*vector).size(),
"Invalid subvector specification" );
1306 const size_t n = (*vector).operand().size();
1308 return elements( (*vector).operand(), [n](
size_t i ) { return (i+I)%n; }, N,
unchecked );
1332 ,
typename... RSAs >
1333inline decltype(
auto)
1339 if( index +
size > (*vector).size() ) {
1347 const size_t n = (*vector).operand().size();
1349 return elements( (*vector).operand(), [index,n](
size_t i ) { return (i+index)%n; },
size,
unchecked );
1381inline decltype(
auto)
subvector( VT&& sv, RSAs... args )
1415inline decltype(
auto)
subvector( VT&& sv, RSAs... args )
1420 if( I + N > sv.size() ) {
1428 return subvector<AF>( sv.operand(), sv.offset() + I, N, args... );
1452inline decltype(
auto)
1453 subvector( VT&& sv,
size_t index,
size_t size, RSAs... args )
1458 if( index +
size > sv.size() ) {
1498inline decltype(
auto)
elements( VT&& sv, REAs... args )
1530inline decltype(
auto)
elements( VT&& sv, REAs... args )
1535 constexpr size_t indices[] = { I, Is... };
1536 for(
size_t i=0UL; i<
sizeof...(Is)+1UL; ++i ) {
1537 if( sv.size() <= indices[i] ) {
1543 return elements( sv.operand(), { I+sv.offset(), Is+sv.offset()... }, args... );
1564template<
typename VT
1568inline decltype(
auto)
elements( VT&& sv, T* indices,
size_t n, REAs... args )
1573 for(
size_t i=0UL; i<n; ++i ) {
1574 if( sv.size() <=
size_t( indices[i] ) ) {
1581 std::for_each( newIndices.begin(), newIndices.end(),
1582 [offset=sv.offset()](
size_t& index ){ index += offset; } );
1584 return elements( sv.operand(), newIndices.data(), n, args... );
1605template<
typename VT
1609inline decltype(
auto)
elements( VT&& sv, P p,
size_t n, REAs... args )
1614 for(
size_t i=0UL; i<n; ++i ) {
1615 if( sv.size() <=
size_t( p(i) ) ) {
1621 return elements( sv.operand(), [p,offset=sv.offset()](
size_t i ){ return p(i)+offset; }, n, args... );
1667inline bool isDefault(
const Subvector<VT,AF,TF,true,CSAs...>& sv )
1671 for(
size_t i=0UL; i<sv.size(); ++i )
1711inline bool isDefault(
const Subvector<VT,AF,TF,false,CSAs...>& sv )
1715 for(
const auto& element : *sv )
1741template<
typename VT
1746inline bool isIntact(
const Subvector<VT,AF,TF,DF,CSAs...>& sv )
noexcept
1748 return ( sv.offset() + sv.size() <= sv.operand().size() &&
1768template<
typename VT
1773inline bool isSame(
const Subvector<VT,AF,TF,DF,CSAs...>& a,
const Vector<VT,TF>& b )
noexcept
1775 return (
isSame( a.operand(), *b ) && ( a.size() == (*b).size() ) );
1794template<
typename VT
1799inline bool isSame(
const Vector<VT,TF>& a,
const Subvector<VT,AF,TF,DF,CSAs...>& b )
noexcept
1820template<
typename VT1
1830inline bool isSame(
const Subvector<VT1,AF1,TF1,DF1,CSAs1...>& a,
1831 const Subvector<VT2,AF2,TF2,DF2,CSAs2...>& b )
noexcept
1833 return (
isSame( a.operand(), b.operand() ) &&
1834 ( a.offset() == b.offset() ) &&
1835 ( a.size() == b.size() ) );
1856template<
typename VT
1862inline bool trySet(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
const ET& value )
1866 return trySet( sv.operand(), sv.offset()+index, value );
1888template<
typename VT
1895 trySet(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
size_t size,
const ET& value )
1900 return trySet( sv.operand(), sv.offset()+index,
size, value );
1921template<
typename VT
1927inline bool tryAdd(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
const ET& value )
1931 return tryAdd( sv.operand(), sv.offset()+index, value );
1953template<
typename VT
1960 tryAdd(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
size_t size,
const ET& value )
1965 return tryAdd( sv.operand(), sv.offset()+index,
size, value );
1986template<
typename VT
1992inline bool trySub(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
const ET& value )
1996 return trySub( sv.operand(), sv.offset()+index, value );
2018template<
typename VT
2025 trySub(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
size_t size,
const ET& value )
2030 return trySub( sv.operand(), sv.offset()+index,
size, value );
2051template<
typename VT
2057inline bool tryMult(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
const ET& value )
2061 return tryMult( sv.operand(), sv.offset()+index, value );
2083template<
typename VT
2090 tryMult(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
size_t size,
const ET& value )
2095 return tryMult( sv.operand(), sv.offset()+index,
size, value );
2116template<
typename VT
2122inline bool tryDiv(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
const ET& value )
2126 return tryDiv( sv.operand(), sv.offset()+index, value );
2148template<
typename VT
2155 tryDiv(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
size_t size,
const ET& value )
2160 return tryDiv( sv.operand(), sv.offset()+index,
size, value );
2181template<
typename VT
2186inline bool tryShift(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
int count )
2190 return tryShift( sv.operand(), sv.offset()+index, count );
2212template<
typename VT
2218 tryShift(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
size_t size,
int count )
2223 return tryShift( sv.operand(), sv.offset()+index,
size, count );
2244template<
typename VT
2250inline bool tryBitand(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
const ET& value )
2254 return tryBitand( sv.operand(), sv.offset()+index, value );
2276template<
typename VT
2283 tryBitand(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
size_t size,
const ET& value )
2288 return tryBitand( sv.operand(), sv.offset()+index,
size, value );
2309template<
typename VT
2315inline bool tryBitor(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
const ET& value )
2319 return tryBitor( sv.operand(), sv.offset()+index, value );
2341template<
typename VT
2348 tryBitor(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
size_t size,
const ET& value )
2353 return tryBitor( sv.operand(), sv.offset()+index,
size, value );
2374template<
typename VT
2380inline bool tryBitxor(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
const ET& value )
2384 return tryBitxor( sv.operand(), sv.offset()+index, value );
2406template<
typename VT
2413 tryBitxor(
const Subvector<VT,AF,TF,DF,CSAs...>& sv,
size_t index,
size_t size,
const ET& value )
2418 return tryBitxor( sv.operand(), sv.offset()+index,
size, value );
2439template<
typename VT1
2445inline bool tryAssign(
const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2451 return tryAssign( lhs.operand(), *rhs, lhs.offset() + index );
2472template<
typename VT1
2478inline bool tryAddAssign(
const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2484 return tryAddAssign( lhs.operand(), *rhs, lhs.offset() + index );
2505template<
typename VT1
2511inline bool trySubAssign(
const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2517 return trySubAssign( lhs.operand(), *rhs, lhs.offset() + index );
2538template<
typename VT1
2544inline bool tryMultAssign(
const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2550 return tryMultAssign( lhs.operand(), *rhs, lhs.offset() + index );
2571template<
typename VT1
2577inline bool tryDivAssign(
const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2583 return tryDivAssign( lhs.operand(), *rhs, lhs.offset() + index );
2604template<
typename VT1
2610inline bool tryShiftAssign(
const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2616 return tryShiftAssign( lhs.operand(), *rhs, lhs.offset() + index );
2637template<
typename VT1
2643inline bool tryBitandAssign(
const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2649 return tryBitandAssign( lhs.operand(), *rhs, lhs.offset() + index );
2670template<
typename VT1
2676inline bool tryBitorAssign(
const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2682 return tryBitorAssign( lhs.operand(), *rhs, lhs.offset() + index );
2703template<
typename VT1
2709inline bool tryBitxorAssign(
const Subvector<VT1,AF,TF,DF,CSAs...>& lhs,
2715 return tryBitxorAssign( lhs.operand(), *rhs, lhs.offset() + index );
2736template<
typename VT
2742inline decltype(
auto) derestrict( Subvector<VT,AF,TF,DF,I,N>& sv )
2765template<
typename VT
2771inline decltype(
auto) derestrict( Subvector<VT,AF,TF,DF,I,N>&& sv )
2794template<
typename VT
2798inline decltype(
auto) derestrict( Subvector<VT,AF,TF,DF>& sv )
2821template<
typename VT
2825inline decltype(
auto) derestrict( Subvector<VT,AF,TF,DF>&& sv )
2846template<
typename VT
2851inline decltype(
auto) unview( Subvector<VT,AF,TF,DF,CSAs...>& sv )
2853 return sv.operand();
2872template<
typename VT
2877inline decltype(
auto) unview(
const Subvector<VT,AF,TF,DF,CSAs...>& sv )
2879 return sv.operand();
2895template<
typename VT, AlignmentFlag AF,
bool TF,
bool DF,
size_t I,
size_t N >
2896struct Size< Subvector<VT,AF,TF,DF,I,N>, 0UL >
2897 :
public Ptrdiff_t< static_cast<ptrdiff_t>(N) >
2913template<
typename VT, AlignmentFlag AF,
bool TF,
bool DF,
size_t I,
size_t N >
2914struct MaxSize< Subvector<VT,AF,TF,DF,I,N>, 0UL >
2915 :
public Ptrdiff_t< static_cast<ptrdiff_t>(N) >
2931template<
typename VT,
AlignmentFlag AF,
bool TF,
bool DF,
size_t... CSAs >
2949template<
typename VT,
AlignmentFlag AF,
bool TF,
size_t... CSAs >
2967template<
typename VT,
AlignmentFlag AF,
bool TF,
size_t... CSAs >
2985template<
typename VT,
bool TF,
size_t... CSAs >
3003template<
typename VT,
AlignmentFlag AF,
bool TF,
size_t... CSAs >
Header file for auxiliary alias declarations.
Header file for the alignment flag enumeration.
Header file for run time assertion macros.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the HasConstDataAccess type trait.
Header file for the HasMutableDataAccess type trait.
Header file for the integer_sequence and index_sequence aliases.
Header file for the IntegralConstant class template.
Header file for the IsAligned type trait.
Header file for the IsContiguous type trait.
Header file for the isDefault shim.
Header file for the IsRestricted type trait.
Header file for the IsSubvector type trait.
Deactivation of problematic macros.
Header file for the MaxSize type trait.
Header file for the relaxation flag enumeration.
Header file for the RemoveReference type trait.
Header file for the SmallArray implementation.
Implementation of a dynamic array with small array optimization.
Definition SmallArray.h:84
Base class for N-dimensional vectors.
Definition Vector.h:82
Header file for the CrossExpr base class.
Header file for the VecEvalExpr base class.
Header file for the VecMapExpr base class.
Header file for the VecNoAliasExpr base class.
Header file for the VecNoSIMDExpr base class.
Header file for the VecRepeatExpr base class.
Header file for the VecScalarDivExpr base class.
Header file for the VecScalarMultExpr base class.
Header file for the VecSerialExpr base class.
Header file for the VecTransExpr base class.
Header file for the VecVecAddExpr base class.
Header file for the VecVecDivExpr base class.
Header file for the VecVecKronExpr base class.
Header file for the VecVecMapExpr base class.
Header file for the VecVecMultExpr base class.
Header file for the VecVecSubExpr base class.
Header file for the Vector CRTP base class.
decltype(auto) noalias(const DenseMatrix< MT, SO > &dm)
Forces the non-aliased evaluation of the given dense matrix expression dm.
Definition DMatNoAliasExpr.h:679
decltype(auto) eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition DMatEvalExpr.h:790
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition DMatTransExpr.h:766
decltype(auto) map(const DenseMatrix< MT1, SO > &lhs, const DenseMatrix< MT2, SO > &rhs, OP op)
Elementwise evaluation of the given binary operation on each single element of the dense matrices lhs...
Definition DMatDMatMapExpr.h:1144
decltype(auto) nosimd(const DenseMatrix< MT, SO > &dm)
Disables the SIMD evaluation of the given dense matrix expression dm.
Definition DMatNoSIMDExpr.h:717
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition DMatSerialExpr.h:812
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition DiagonalMatrix.h:207
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition DiagonalMatrix.h:169
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
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition RelaxationFlag.h:66
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.
Definition AlignmentFlag.h:63
@ unaligned
Flag for unaligned vectors and matrices.
Definition AlignmentFlag.h:64
@ aligned
Flag for aligned vectors and matrices.
Definition AlignmentFlag.h:65
bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition Matrix.h:1424
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_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
#define BLAZE_STATIC_ASSERT_MSG(expr, msg)
Compile time assertion macro.
Definition StaticAssert.h:123
decltype(auto) subvector(Vector< VT, TF > &, RSAs...)
Creating a view on a specific subvector of the given vector.
Definition Subvector.h:158
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition Inline.h:85
typename RemoveReference< T >::Type RemoveReference_t
Auxiliary alias declaration for the RemoveReference type trait.
Definition RemoveReference.h:95
IntegralConstant< ptrdiff_t, N > Ptrdiff_t
Compile time integral constant wrapper for ptrdiff_t.
Definition IntegralConstant.h:237
decltype(shift< Offset >(make_index_sequence< N >())) make_shifted_index_sequence
Auxiliary alias declaration for the setup of shifted index sequences.
Definition IntegerSequence.h:227
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition EnableIf.h:138
decltype(subsequence< Is... >(shift< Offset >(make_index_sequence< N >()))) make_shifted_index_subsequence
Auxiliary alias declaration for the setup of shifted index subsequences.
Definition IntegerSequence.h:247
BoolConstant< true > TrueType
Type traits base class.
Definition IntegralConstant.h:132
#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
constexpr Unchecked unchecked
Global Unchecked instance.
Definition Check.h:146
Header file for the exception macros of the math module.
Header file for the Size type trait.
Header file for the serial shim.
Base class for all cross product expression templates.
Definition CrossExpr.h:68
Compile time check for low-level access to constant data.
Definition HasConstDataAccess.h:76
Compile time check for low-level access to mutable data.
Definition HasMutableDataAccess.h:76
Compile time check for the alignment of data types.
Definition IsAligned.h:88
Compile time check for the memory layout of data types.
Definition IsContiguous.h:87
Compile time check for data types with restricted data access.
Definition IsRestricted.h:83
Compile time evaluation of the maximum size of vectors and matrices.
Definition MaxSize.h:118
Compile time evaluation of the size of vectors and matrices.
Definition Size.h:119
Base class for all vector evaluation expression templates.
Definition VecEvalExpr.h:69
Base class for all unary vector map expression templates.
Definition VecMapExpr.h:68
Base class for all vector no-alias expression templates.
Definition VecNoAliasExpr.h:68
Base class for all vector no-SIMD expression templates.
Definition VecNoSIMDExpr.h:88
Base class for all vector repeater expression templates.
Definition VecRepeatExpr.h:69
Base class for all vector/scalar division expression templates.
Definition VecScalarDivExpr.h:75
Base class for all vector/scalar multiplication expression templates.
Definition VecScalarMultExpr.h:76
Base class for all vector serial evaluation expression templates.
Definition VecSerialExpr.h:69
Base class for all vector transposition expression templates.
Definition VecTransExpr.h:69
Base class for all vector/vector division expression templates.
Definition VecVecDivExpr.h:68
Base class for all vector/vector Kronecker expression templates.
Definition VecVecKronExpr.h:69
Base class for all binary vector map expression templates.
Definition VecVecMapExpr.h:68
Base class for all vector/vector multiplication expression templates.
Definition VecVecMultExpr.h:68
Base class for all vector/vector subtraction expression templates.
Definition VecVecSubExpr.h:68
Header file for basic type definitions.
Header file for the implementation of the Subvector base template.
Subvector specialization for dense vectors.
Subvector specialization for sparse vectors.