35 #ifndef _BLAZE_MATH_SPARSE_ZEROVECTOR_H_ 36 #define _BLAZE_MATH_SPARSE_ZEROVECTOR_H_ 168 template<
typename Type
169 ,
bool TF = defaultTransposeFlag >
171 :
public Expression< SparseVector< ZeroVector<Type,TF>, TF > >
196 template<
typename NewType >
205 template<
size_t NewN >
222 explicit inline constexpr
ZeroVector() noexcept;
242 inline constexpr
ConstReference operator[](
size_t index ) const noexcept;
254 template< typename VT >
265 inline constexpr
size_t size() const noexcept;
266 inline constexpr
size_t capacity() const noexcept;
267 inline constexpr
size_t nonZeros() const noexcept;
268 inline constexpr
void clear() noexcept;
269 inline constexpr
void resize(
size_t n ) noexcept;
286 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
287 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
323 template< typename Type,
bool TF >
338 template<
typename Type
351 template<
typename Type
368 template<
typename Type
370 template<
typename VT >
374 if( !IsZero_v<VT> && !
isZero( ~v ) ) {
395 template<
typename Type
419 template<
typename Type
424 if( index >= size_ ) {
438 template<
typename Type
453 template<
typename Type
468 template<
typename Type
483 template<
typename Type
511 template<
typename Type
513 template<
typename VT >
517 if( !IsZero_v<VT> && !
isZero( ~rhs ) ) {
521 size_ = (~rhs).
size();
541 template<
typename Type
555 template<
typename Type
572 template<
typename Type
588 template<
typename Type
607 template<
typename Type
622 template<
typename Type
626 const size_t tmp( size_ );
652 template<
typename Type
676 template<
typename Type
700 template<
typename Type
732 template<
typename Type
734 template<
typename Other >
754 template<
typename Type
756 template<
typename Other >
776 template<
typename Type
800 template<
typename Type,
bool TF >
803 template<
typename Type,
bool TF >
806 template<
bool RF,
typename Type,
bool TF >
809 template<
typename Type,
bool TF >
812 template<
typename Type,
bool TF >
825 template<
typename Type
841 template<
typename Type
879 return ( v.size() == 0UL );
901 template<
typename Type
920 template<
typename Type
938 template<
typename Type
940 inline void erase( ZeroVector<Type,TF>& v,
size_t index )
959 template<
typename Type
961 ,
typename Iterator >
962 inline Iterator erase( ZeroVector<Type,TF>& v, Iterator pos )
984 template<
typename Type
986 ,
typename Iterator >
987 inline Iterator erase( ZeroVector<Type,TF>& m, Iterator first, Iterator last )
1021 template<
typename Type
1024 inline void erase( ZeroVector<Type,TF>& v, Pred predicate )
1058 template<
typename Type
1062 inline void erase( ZeroVector<Type,TF>& m, Iterator first, Iterator last, Pred predicate )
1104 template<
typename T,
bool TF = defaultTransposeFlag >
1105 inline constexpr decltype(
auto)
zero(
size_t n ) noexcept
1128 template<
typename VT
1130 inline ZeroVector<ElementType_t<VT>,TF>
1150 template<
typename Type,
bool TF >
1151 struct IsUniform< ZeroVector<Type,TF> >
1168 template<
typename Type,
bool TF >
1169 struct IsZero< ZeroVector<Type,TF> >
1186 template<
typename Type,
bool TF >
1187 struct IsResizable< ZeroVector<Type,TF> >
1204 template<
typename T1,
typename T2 >
1205 struct AddTraitEval1< T1, T2
1208 !IsZero_v<T1> && IsZero_v<T2> > >
1210 using Type = Rebind_t< ResultType_t<T1>, AddTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1213 template<
typename T1,
typename T2 >
1214 struct AddTraitEval1< T1, T2
1217 IsZero_v<T1> && !IsZero_v<T2> > >
1219 using Type = Rebind_t< ResultType_t<T2>, AddTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1222 template<
typename T1,
typename T2 >
1223 struct AddTraitEval1< T1, T2
1226 IsZero_v<T1> && IsZero_v<T2> > >
1228 using ET1 = ElementType_t<T1>;
1229 using ET2 = ElementType_t<T2>;
1231 using Type = ZeroVector< AddTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1247 template<
typename T1,
typename T2 >
1248 struct SubTraitEval1< T1, T2
1251 !IsZero_v<T1> && IsZero_v<T2> > >
1253 using Type = Rebind_t< ResultType_t<T1>, SubTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1256 template<
typename T1,
typename T2 >
1257 struct SubTraitEval1< T1, T2
1260 IsZero_v<T1> && !IsZero_v<T2> > >
1262 using Type = Rebind_t< ResultType_t<T2>, SubTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1265 template<
typename T1,
typename T2 >
1266 struct SubTraitEval1< T1, T2
1269 IsZero_v<T1> && IsZero_v<T2> > >
1271 using ET1 = ElementType_t<T1>;
1272 using ET2 = ElementType_t<T2>;
1274 using Type = ZeroVector< SubTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1290 template<
typename T1,
typename T2 >
1291 struct MultTraitEval1< T1, T2
1296 using ET1 = ElementType_t<T1>;
1298 using Type = ZeroVector< MultTrait_t<ET1,T2>, TransposeFlag_v<T1> >;
1301 template<
typename T1,
typename T2 >
1302 struct MultTraitEval1< T1, T2
1307 using ET2 = ElementType_t<T2>;
1309 using Type = ZeroVector< MultTrait_t<T1,ET2>, TransposeFlag_v<T2> >;
1312 template<
typename T1,
typename T2 >
1313 struct MultTraitEval1< T1, T2
1315 ( IsColumnVector_v<T1> && IsColumnVector_v<T2> ) ) &&
1316 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1318 using ET1 = ElementType_t<T1>;
1319 using ET2 = ElementType_t<T2>;
1321 using Type = ZeroVector< MultTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1324 template<
typename T1,
typename T2 >
1325 struct MultTraitEval1< T1, T2
1327 IsColumnVector_v<T2> &&
1328 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1330 using ET1 = ElementType_t<T1>;
1331 using ET2 = ElementType_t<T2>;
1333 using Type = ZeroVector< MultTrait_t<ET1,ET2>,
false >;
1336 template<
typename T1,
typename T2 >
1337 struct MultTraitEval1< T1, T2
1340 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1342 using ET1 = ElementType_t<T1>;
1343 using ET2 = ElementType_t<T2>;
1345 using Type = ZeroVector< MultTrait_t<ET1,ET2>,
true >;
1361 template<
typename T1,
typename T2 >
1362 struct KronTraitEval1< T1, T2
1368 using ET1 = ElementType_t<T1>;
1369 using ET2 = ElementType_t<T2>;
1371 static constexpr
bool TF = ( IsZero_v<T2> ? TransposeFlag_v<T2> : TransposeFlag_v<T1> );
1373 using Type = ZeroVector< MultTrait_t<ET1,ET2>, TF >;
1389 template<
typename T1,
typename T2 >
1390 struct DivTraitEval1< T1, T2
1395 using ET1 = ElementType_t<T1>;
1397 using Type = ZeroVector< DivTrait_t<ET1,T2>, TransposeFlag_v<T1> >;
1400 template<
typename T1,
typename T2 >
1401 struct DivTraitEval1< T1, T2
1403 ( IsColumnVector_v<T1> && IsColumnVector_v<T2> ) ) &&
1404 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1406 using ET1 = ElementType_t<T1>;
1407 using ET2 = ElementType_t<T2>;
1409 using Type = ZeroVector< DivTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1425 template<
typename T1,
typename T2 >
1426 struct CrossTraitEval1< T1, T2
1429 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1431 using Tmp = MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >;
1433 using Type = ZeroVector< SubTrait_t<Tmp,Tmp>, TransposeFlag_v<T1> >;
1449 template<
typename T,
typename OP >
1450 struct UnaryMapTraitEval1< T, OP
1452 YieldsZero_v<OP,T> > >
1454 using ET = ElementType_t<T>;
1456 using Type = ZeroVector< MapTrait_t<ET,OP>, TransposeFlag_v<T> >;
1464 template<
typename T1,
typename T2,
typename OP >
1465 struct BinaryMapTraitEval1< T1, T2, OP
1468 YieldsZero_v<OP,T1,T2> > >
1470 using ET1 = ElementType_t<T1>;
1471 using ET2 = ElementType_t<T2>;
1473 using Type = ZeroVector< MapTrait_t<ET1,ET2,OP>, TransposeFlag_v<T1> >;
1489 template<
typename T1,
bool TF,
typename T2 >
1490 struct HighType< ZeroVector<T1,TF>, ZeroVector<T2,TF> >
1492 using Type = ZeroVector< typename HighType<T1,T2>::Type, TF >;
1508 template<
typename T1,
bool TF,
typename T2 >
1509 struct LowType< ZeroVector<T1,TF>, ZeroVector<T2,TF> >
1511 using Type = ZeroVector< typename LowType<T1,T2>::Type, TF >;
1527 template<
typename VT,
size_t I,
size_t N >
1528 struct SubvectorTraitEval1< VT, I, N
1531 using Type = ZeroVector< RemoveConst_t< ElementType_t<VT> >, TransposeFlag_v<VT> >;
1547 template<
typename VT,
size_t N >
1548 struct ElementsTraitEval1< VT, N
1551 using Type = ZeroVector< RemoveConst_t< ElementType_t<VT> >, TransposeFlag_v<VT> >;
1567 template<
typename MT,
size_t I >
1568 struct RowTraitEval1< MT, I
1571 using Type = ZeroVector< RemoveConst_t< ElementType_t<MT> >,
true >;
1587 template<
typename MT,
size_t I >
1588 struct ColumnTraitEval1< MT, I
1591 using Type = ZeroVector< RemoveConst_t< ElementType_t<MT> >,
false >;
1607 template<
typename MT, ptrdiff_t I >
1608 struct BandTraitEval1< MT, I
1611 using Type = ZeroVector< RemoveConst_t< ElementType_t<MT> >, defaultTransposeFlag >;
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type,...
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.The IsMatrix_v variable template provides a c...
Definition: IsMatrix.h:138
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
Header file for the subtraction trait.
Header file for basic type definitions.
constexpr ZeroVector() noexcept
The default constructor for ZeroVector.
Definition: ZeroVector.h:340
Header file for the SparseVector base class.
Header file for the row trait.
constexpr bool IsRowVector_v
Auxiliary variable template for the IsRowVector type trait.The IsRowVector_v variable template provid...
Definition: IsRowVector.h:142
Header file for the isZero shim.
Header file for the YieldsZero type trait.
ZeroVector< Type, TF > This
Type of this ZeroVector instance.
Definition: ZeroVector.h:180
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
const Type & Reference
Reference to a zero vector element.
Definition: ZeroVector.h:187
Header file for the IsRowVector type trait.
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: ZeroVector.h:778
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: ZeroVector.h:216
Header file for the MAYBE_UNUSED function template.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type,...
Definition: Volatile.h:79
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: IntegralConstant.h:132
Header file for all forward declarations of the math module.
size_t size_
The current size/dimension of the zero vector.
Definition: ZeroVector.h:297
constexpr void resize(size_t n) noexcept
Changing the size of the zero vector.
Definition: ZeroVector.h:609
Header file for the elements trait.
Header file for the band trait.
Constraint on the data type.
Header file for the IsMatrix type trait.
decltype(auto) constexpr zero(size_t m, size_t n) noexcept
Creating a zero matrix.
Definition: ZeroMatrix.h:1353
constexpr ConstIterator cbegin() const noexcept
Returns an iterator to the first non-zero element of the zero vector.
Definition: ZeroVector.h:456
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:677
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
constexpr void clear() noexcept
Clearing the zero vector.
Definition: ZeroVector.h:590
Header file for the ValueIndexPair class.
Header file for the LowType type trait.
Header file for the multiplication trait.
Type ElementType
Type of the zero vector elements.
Definition: ZeroVector.h:184
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Header file for the IsSMPAssignable type trait.
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: ZeroVector.h:735
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: ZeroVector.h:757
Header file for the subvector trait.
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
Constraint on the data type.
ZeroMatrix< ElementType_t< MT >, SO > declzero(const Matrix< MT, SO > &m)
Declares the given matrix expression m as zero matrix.
Definition: ZeroMatrix.h:1379
const Type & ConstReference
Reference to a constant zero vector element.
Definition: ZeroVector.h:188
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
Resize mechanism to obtain a ZeroVector with a different fixed number of elements.
Definition: ZeroVector.h:206
constexpr ConstIterator begin() const noexcept
Returns an iterator to the first non-zero element of the zero vector.
Definition: ZeroVector.h:441
Header file for the Kron product trait.
Header file for the TransposeFlag type trait.
constexpr ConstReference operator[](size_t index) const noexcept
Subscript operator for the direct access to the zero vector elements.
Definition: ZeroVector.h:398
Header file for the exception macros of the math module.
constexpr size_t nonZeros() const noexcept
Returns the number of non-zero elements in the zero vector.
Definition: ZeroVector.h:574
Header file for the IsVector type trait.
static const Type zero_
The zero element.
Definition: ZeroVector.h:299
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:615
constexpr bool IsZero_v
Auxiliary variable template for the IsZero type trait.The IsZero_v variable template provides a conve...
Definition: IsZero.h:166
Header file for the IsNumeric type trait.
ConstIterator upperBound(size_t index) const
Returns an iterator to the first index greater then the given index.
Definition: ZeroVector.h:703
Header file for the RemoveConst type trait.
Header file for run time assertion macros.
ConstIterator find(size_t index) const
Searches for a specific vector element.
Definition: ZeroVector.h:655
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
Constraint on the data type.
constexpr size_t capacity() const noexcept
Returns the maximum capacity of the zero vector.
Definition: ZeroVector.h:557
Header file for the IsZero type trait.
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.The IsVector_v variable template provides a c...
Definition: IsVector.h:139
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type,...
Definition: Reference.h:79
Header file for the column trait.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:282
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Constraint on the data type.
constexpr ConstIterator cend() const noexcept
Returns an iterator just past the last non-zero element of the zero vector.
Definition: ZeroVector.h:486
Rebind mechanism to obtain a ZeroVector with different data/element type.
Definition: ZeroVector.h:197
ConstIterator lowerBound(size_t index) const
Returns an iterator to the first index not less then the given index.
Definition: ZeroVector.h:679
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:73
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:198
Header file for the default transpose flag for all vectors of the Blaze library.
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:146
Header file for the IntegralConstant class template.
Header file for the map trait.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
ConstReference at(size_t index) const
Checked access to the zero vector elements.
Definition: ZeroVector.h:422
const Type & ReturnType
Return type for expression template evaluations.
Definition: ZeroVector.h:185
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
constexpr size_t size() const noexcept
Returns the current size/dimension of the zero vector.
Definition: ZeroVector.h:543
constexpr void swap(ZeroVector &v) noexcept
Swapping the contents of two zero vectors.
Definition: ZeroVector.h:624
constexpr ConstIterator end() const noexcept
Returns an iterator just past the last non-zero element of the zero vector.
Definition: ZeroVector.h:471
Efficient implementation of an arbitrary sized zero vector.The ZeroVector class template is the repre...
Definition: Forward.h:51
Header file for the IsColumnVector type trait.
Header file for the IsResizable type trait.
Header file for the Expression base class.
Header file for the HighType type trait.
Header file for the function trace functionality.