35 #ifndef _BLAZE_MATH_SPARSE_ZEROVECTOR_H_ 36 #define _BLAZE_MATH_SPARSE_ZEROVECTOR_H_ 166 template<
typename Type
167 ,
bool TF = defaultTransposeFlag >
169 :
public SparseVector< ZeroVector<Type,TF>, TF >
194 template<
typename NewType >
203 template<
size_t NewN >
220 explicit inline constexpr
ZeroVector() noexcept;
240 inline constexpr
ConstReference operator[](
size_t index ) const noexcept;
252 template< typename VT >
263 inline constexpr
size_t size() const noexcept;
264 inline constexpr
size_t capacity() const noexcept;
265 inline constexpr
size_t nonZeros() const noexcept;
266 inline constexpr
void clear() noexcept;
267 inline constexpr
void resize(
size_t n ) noexcept;
284 template< typename Other > inline
bool canAlias ( const Other* alias ) const noexcept;
285 template< typename Other > inline
bool isAliased( const Other* alias ) const noexcept;
321 template< typename Type,
bool TF >
336 template<
typename Type
349 template<
typename Type
366 template<
typename Type
368 template<
typename VT >
372 if( !IsZero_v<VT> && !
isZero( ~v ) ) {
393 template<
typename Type
417 template<
typename Type
422 if( index >= size_ ) {
436 template<
typename Type
451 template<
typename Type
466 template<
typename Type
481 template<
typename Type
509 template<
typename Type
511 template<
typename VT >
515 if( !IsZero_v<VT> && !
isZero( ~rhs ) ) {
519 size_ = (~rhs).
size();
539 template<
typename Type
553 template<
typename Type
570 template<
typename Type
586 template<
typename Type
605 template<
typename Type
620 template<
typename Type
624 const size_t tmp( size_ );
650 template<
typename Type
674 template<
typename Type
698 template<
typename Type
730 template<
typename Type
732 template<
typename Other >
752 template<
typename Type
754 template<
typename Other >
774 template<
typename Type
798 template<
typename Type,
bool TF >
801 template<
typename Type,
bool TF >
804 template<
bool RF,
typename Type,
bool TF >
807 template<
typename Type,
bool TF >
810 template<
typename Type,
bool TF >
823 template<
typename Type
839 template<
typename Type
877 return ( v.size() == 0UL );
899 template<
typename Type
918 template<
typename Type
936 template<
typename Type
938 inline void erase( ZeroVector<Type,TF>& v,
size_t index )
957 template<
typename Type
982 template<
typename Type
1019 template<
typename Type
1022 inline void erase( ZeroVector<Type,TF>& v, Pred predicate )
1056 template<
typename Type
1060 inline void erase( ZeroVector<Type,TF>& m,
Iterator first,
Iterator last, Pred predicate )
1092 template<
typename VT
1094 inline ZeroVector<ElementType_t<VT>,TF>
1114 template<
typename Type,
bool TF >
1115 struct IsUniform< ZeroVector<Type,TF> >
1132 template<
typename Type,
bool TF >
1133 struct IsZero< ZeroVector<Type,TF> >
1150 template<
typename Type,
bool TF >
1151 struct IsResizable< ZeroVector<Type,TF> >
1168 template<
typename T1,
typename T2 >
1169 struct AddTraitEval1< T1, T2
1172 !IsZero_v<T1> && IsZero_v<T2> > >
1174 using Type = Rebind_t< ResultType_t<T1>, AddTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1177 template<
typename T1,
typename T2 >
1178 struct AddTraitEval1< T1, T2
1181 IsZero_v<T1> && !IsZero_v<T2> > >
1183 using Type = Rebind_t< ResultType_t<T2>, AddTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1186 template<
typename T1,
typename T2 >
1187 struct AddTraitEval1< T1, T2
1190 IsZero_v<T1> && IsZero_v<T2> > >
1192 using ET1 = ElementType_t<T1>;
1193 using ET2 = ElementType_t<T2>;
1195 using Type = ZeroVector< AddTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1211 template<
typename T1,
typename T2 >
1212 struct SubTraitEval1< T1, T2
1215 !IsZero_v<T1> && IsZero_v<T2> > >
1217 using Type = Rebind_t< ResultType_t<T1>, SubTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1220 template<
typename T1,
typename T2 >
1221 struct SubTraitEval1< T1, T2
1224 IsZero_v<T1> && !IsZero_v<T2> > >
1226 using Type = Rebind_t< ResultType_t<T2>, SubTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1229 template<
typename T1,
typename T2 >
1230 struct SubTraitEval1< T1, T2
1233 IsZero_v<T1> && IsZero_v<T2> > >
1235 using ET1 = ElementType_t<T1>;
1236 using ET2 = ElementType_t<T2>;
1238 using Type = ZeroVector< SubTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1254 template<
typename T1,
typename T2 >
1255 struct MultTraitEval1< T1, T2
1260 using ET1 = ElementType_t<T1>;
1262 using Type = ZeroVector< MultTrait_t<ET1,T2>, TransposeFlag_v<T1> >;
1265 template<
typename T1,
typename T2 >
1266 struct MultTraitEval1< T1, T2
1271 using ET2 = ElementType_t<T2>;
1273 using Type = ZeroVector< MultTrait_t<T1,ET2>, TransposeFlag_v<T2> >;
1276 template<
typename T1,
typename T2 >
1277 struct MultTraitEval1< T1, T2
1279 ( IsColumnVector_v<T1> && IsColumnVector_v<T2> ) ) &&
1280 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1282 using ET1 = ElementType_t<T1>;
1283 using ET2 = ElementType_t<T2>;
1285 using Type = ZeroVector< MultTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1288 template<
typename T1,
typename T2 >
1289 struct MultTraitEval1< T1, T2
1291 IsColumnVector_v<T2> &&
1292 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1294 using ET1 = ElementType_t<T1>;
1295 using ET2 = ElementType_t<T2>;
1297 using Type = ZeroVector< MultTrait_t<ET1,ET2>,
false >;
1300 template<
typename T1,
typename T2 >
1301 struct MultTraitEval1< T1, T2
1304 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1306 using ET1 = ElementType_t<T1>;
1307 using ET2 = ElementType_t<T2>;
1309 using Type = ZeroVector< MultTrait_t<ET1,ET2>,
true >;
1325 template<
typename T1,
typename T2 >
1326 struct DivTraitEval1< T1, T2
1331 using ET1 = ElementType_t<T1>;
1333 using Type = ZeroVector< DivTrait_t<ET1,T2>, TransposeFlag_v<T1> >;
1336 template<
typename T1,
typename T2 >
1337 struct DivTraitEval1< T1, T2
1339 ( IsColumnVector_v<T1> && IsColumnVector_v<T2> ) ) &&
1340 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1342 using ET1 = ElementType_t<T1>;
1343 using ET2 = ElementType_t<T2>;
1345 using Type = ZeroVector< DivTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1361 template<
typename T1,
typename T2 >
1362 struct CrossTraitEval1< T1, T2
1365 ( IsZero_v<T1> || IsZero_v<T2> ) > >
1367 using Tmp = MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >;
1369 using Type = ZeroVector< SubTrait_t<Tmp,Tmp>, TransposeFlag_v<T1> >;
1385 template<
typename T,
typename OP >
1386 struct UnaryMapTraitEval1< T, OP
1388 YieldsZero_v<OP,T> > >
1390 using ET = ElementType_t<T>;
1392 using Type = ZeroVector< MapTrait_t<ET,OP>, TransposeFlag_v<T> >;
1400 template<
typename T1,
typename T2,
typename OP >
1401 struct BinaryMapTraitEval1< T1, T2, OP
1404 YieldsZero_v<OP,T1,T2> > >
1406 using ET1 = ElementType_t<T1>;
1407 using ET2 = ElementType_t<T2>;
1409 using Type = ZeroVector< MapTrait_t<ET1,ET2,OP>, TransposeFlag_v<T1> >;
1425 template<
typename T1,
bool TF,
typename T2 >
1426 struct HighType< ZeroVector<T1,TF>, ZeroVector<T2,TF> >
1428 using Type = ZeroVector< typename HighType<T1,T2>::Type, TF >;
1444 template<
typename T1,
bool TF,
typename T2 >
1445 struct LowType< ZeroVector<T1,TF>, ZeroVector<T2,TF> >
1447 using Type = ZeroVector< typename LowType<T1,T2>::Type, TF >;
1463 template<
typename VT,
size_t I,
size_t N >
1464 struct SubvectorTraitEval1< VT, I, N
1467 using Type = ZeroVector< RemoveConst_t< ElementType_t<VT> >, TransposeFlag_v<VT> >;
1483 template<
typename VT,
size_t N >
1484 struct ElementsTraitEval1< VT, N
1487 using Type = ZeroVector< RemoveConst_t< ElementType_t<VT> >, TransposeFlag_v<VT> >;
1503 template<
typename MT,
size_t I >
1504 struct RowTraitEval1< MT, I
1507 using Type = ZeroVector< RemoveConst_t< ElementType_t<MT> >,
true >;
1523 template<
typename MT,
size_t I >
1524 struct ColumnTraitEval1< MT, I
1527 using Type = ZeroVector< RemoveConst_t< ElementType_t<MT> >,
false >;
1543 template<
typename MT, ptrdiff_t I >
1544 struct BandTraitEval1< MT, I
1547 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, a compilation error is created.
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.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
Header file for basic type definitions.
constexpr ZeroVector() noexcept
The default constructor for ZeroVector.
Definition: ZeroVector.h:338
Header file for the SparseVector base class.
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.The IsMatrix_v variable template provides a c...
Definition: IsMatrix.h:139
Header file for the row trait.
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:178
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
const Type & Reference
Reference to a zero vector element.
Definition: ZeroVector.h:185
Header file for the IsRowVector type trait.
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: ZeroVector.h:776
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: ZeroVector.h:214
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
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: TrueType.h:61
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
size_t size_
The current size/dimension of the zero vector.
Definition: ZeroVector.h:295
constexpr void resize(size_t n) noexcept
Changing the size of the zero vector.
Definition: ZeroVector.h:607
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the elements trait.
Header file for the band trait.
Constraint on the data type.
Header file for the IsMatrix type trait.
constexpr ConstIterator cbegin() const noexcept
Returns an iterator to the first non-zero element of the zero vector.
Definition: ZeroVector.h:454
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:673
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:588
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:182
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for all forward declarations of the math module.
#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:733
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: ZeroVector.h:755
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:1335
const Type & ConstReference
Reference to a constant zero vector element.
Definition: ZeroVector.h:186
Resize mechanism to obtain a ZeroVector with a different fixed number of elements.
Definition: ZeroVector.h:204
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.The IsVector_v variable template provides a c...
Definition: IsVector.h:140
constexpr ConstIterator begin() const noexcept
Returns an iterator to the first non-zero element of the zero vector.
Definition: ZeroVector.h:439
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:396
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:572
Header file for the IsVector type trait.
static const Type zero_
The zero element.
Definition: ZeroVector.h:297
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
constexpr bool IsZero_v
Auxiliary variable template for the IsZero type trait.The IsZero_v variable template provides a conve...
Definition: IsZero.h:165
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:701
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:653
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:555
Header file for the IsZero type trait.
#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, a compilation error is created.
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:281
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:484
Rebind mechanism to obtain a ZeroVector with different data/element type.
Definition: ZeroVector.h:195
ConstIterator lowerBound(size_t index) const
Returns an iterator to the first index not less then the given index.
Definition: ZeroVector.h:677
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:73
constexpr bool IsRowVector_v
Auxiliary variable template for the IsRowVector type trait.The IsRowVector_v variable template provid...
Definition: IsRowVector.h:143
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:186
Header file for the default transpose flag for all vectors of the Blaze library.
static const Type zero_
Neutral element for accesses to zero elements.
Definition: CompressedMatrix.h:3295
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:138
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:263
ConstReference at(size_t index) const
Checked access to the zero vector elements.
Definition: ZeroVector.h:420
const Type & ReturnType
Return type for expression template evaluations.
Definition: ZeroVector.h:183
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
constexpr size_t size() const noexcept
Returns the current size/dimension of the zero vector.
Definition: ZeroVector.h:541
constexpr void swap(ZeroVector &v) noexcept
Swapping the contents of two zero vectors.
Definition: ZeroVector.h:622
constexpr ConstIterator end() const noexcept
Returns an iterator just past the last non-zero element of the zero vector.
Definition: ZeroVector.h:469
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 HighType type trait.
Header file for the TrueType type/value trait base class.
Header file for the function trace functionality.