Blaze 3.9
Sparse.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_VIEWS_ELEMENTS_SPARSE_H_
36#define _BLAZE_MATH_VIEWS_ELEMENTS_SPARSE_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <iterator>
44#include <blaze/math/Aliases.h>
74#include <blaze/util/Assert.h>
75#include <blaze/util/EnableIf.h>
76#include <blaze/util/mpl/If.h>
77#include <blaze/util/Types.h>
81
82
83namespace blaze {
84
85//=================================================================================================
86//
87// CLASS TEMPLATE SPECIALIZATION FOR SPARSE VECTORS
88//
89//=================================================================================================
90
91//*************************************************************************************************
98template< typename VT // Type of the sparse vector
99 , bool TF // Transpose flag
100 , typename... CEAs > // Compile time element arguments
101class Elements<VT,TF,false,CEAs...>
102 : public View< SparseVector< Elements<VT,TF,false,CEAs...>, TF > >
103 , private ElementsData<CEAs...>
104{
105 private:
106 //**Type definitions****************************************************************************
107 using DataType = ElementsData<CEAs...>;
108 using Operand = If_t< IsExpression_v<VT>, VT, VT& >;
109 //**********************************************************************************************
110
111 //**Compile time flags**************************************************************************
112 using DataType::N;
113 //**********************************************************************************************
114
115 public:
116 //**Type definitions****************************************************************************
118 using This = Elements<VT,TF,false,CEAs...>;
119
121 using BaseType = View< SparseVector<This,TF> >;
122
123 using ViewedType = VT;
124 using ResultType = ElementsTrait_t<VT,N>;
125 using TransposeType = TransposeType_t<ResultType>;
126 using ElementType = ElementType_t<VT>;
127 using ReturnType = ReturnType_t<VT>;
128 using CompositeType = const Elements&;
129
131 using ConstReference = ConstReference_t<VT>;
132
134 using Reference = If_t< IsConst_v<VT>, ConstReference, Reference_t<VT> >;
135 //**********************************************************************************************
136
137 //**ElementsElement class definition************************************************************
140 template< typename IteratorType > // Type of the sparse vector iterator
141 class ElementsElement
142 : private SparseElement
143 {
144 public:
145 //**Constructor******************************************************************************
151 inline ElementsElement( IteratorType pos, size_t index )
152 : pos_ ( pos ) // Iterator to the current position within the element selection
153 , index_( index ) // Index within the according element selection
154 {}
155 //*******************************************************************************************
156
157 //**Assignment operator**********************************************************************
163 template< typename T > inline ElementsElement& operator=( const T& v ) {
164 *pos_ = v;
165 return *this;
166 }
167 //*******************************************************************************************
168
169 //**Addition assignment operator*************************************************************
175 template< typename T > inline ElementsElement& operator+=( const T& v ) {
176 *pos_ += v;
177 return *this;
178 }
179 //*******************************************************************************************
180
181 //**Subtraction assignment operator**********************************************************
187 template< typename T > inline ElementsElement& operator-=( const T& v ) {
188 *pos_ -= v;
189 return *this;
190 }
191 //*******************************************************************************************
192
193 //**Multiplication assignment operator*******************************************************
199 template< typename T > inline ElementsElement& operator*=( const T& v ) {
200 *pos_ *= v;
201 return *this;
202 }
203 //*******************************************************************************************
204
205 //**Division assignment operator*************************************************************
211 template< typename T > inline ElementsElement& operator/=( const T& v ) {
212 *pos_ /= v;
213 return *this;
214 }
215 //*******************************************************************************************
216
217 //**Element access operator******************************************************************
222 inline const ElementsElement* operator->() const {
223 return this;
224 }
225 //*******************************************************************************************
226
227 //**Value function***************************************************************************
232 inline decltype(auto) value() const {
233 return pos_->value();
234 }
235 //*******************************************************************************************
236
237 //**Index function***************************************************************************
242 inline size_t index() const {
243 return index_;
244 }
245 //*******************************************************************************************
246
247 private:
248 //**Member variables*************************************************************************
249 IteratorType pos_;
250 size_t index_;
251 //*******************************************************************************************
252 };
253 //**********************************************************************************************
254
255 //**ElementsIterator class definition***********************************************************
258 template< typename ET // Type of the element selection
259 , typename IteratorType > // Type of the sparse vector iterator
260 class ElementsIterator
261 {
262 public:
263 //**Type definitions*************************************************************************
264 using IteratorCategory = std::forward_iterator_tag;
265 using ValueType = ElementsElement<IteratorType>;
266 using PointerType = ValueType;
267 using ReferenceType = ValueType;
268 using DifferenceType = ptrdiff_t;
269
270 // STL iterator requirements
271 using iterator_category = IteratorCategory;
272 using value_type = ValueType;
273 using pointer = PointerType;
274 using reference = ReferenceType;
275 using difference_type = DifferenceType;
276 //*******************************************************************************************
277
278 //**Constructor******************************************************************************
281 inline ElementsIterator()
282 : elements_( nullptr ) // Pointer to the element selection
283 , index_ ( 0UL) // Index within the according element selection
284 , pos_ () // Iterator to the current position within the element selection
285 {}
286 //*******************************************************************************************
287
288 //**Constructor******************************************************************************
294 inline ElementsIterator( ET* elements, size_t index )
295 : elements_( elements ) // Pointer to the element selection
296 , index_ ( index ) // Index within the according element selection
297 , pos_ () // Iterator to the current position within the element selection
298 {
299 for( ; index_<elements_->size(); ++index_ ) {
300 pos_ = elements_->operand().find( elements_->idx(index_) );
301 if( pos_ != elements_->operand().end() ) break;
302 }
303 }
304 //*******************************************************************************************
305
306 //**Constructor******************************************************************************
313 inline ElementsIterator( ET* elements, size_t index, IteratorType pos )
314 : elements_( elements ) // Pointer to the element selection
315 , index_ ( index ) // Index within the according element selection
316 , pos_ ( pos ) // Iterator to the current position within the element selection
317 {}
318 //*******************************************************************************************
319
320 //**Constructor******************************************************************************
325 template< typename ET2, typename IteratorType2 >
326 inline ElementsIterator( const ElementsIterator<ET2,IteratorType2>& it )
327 : elements_( it.elements_ ) // Pointer to the element selection
328 , index_ ( it.index_ ) // Index within the according element selection
329 , pos_ ( it.pos_ ) // Iterator to the current position within the element selection
330 {}
331 //*******************************************************************************************
332
333 //**Prefix increment operator****************************************************************
338 inline ElementsIterator& operator++() {
339 ++index_;
340 for( ; index_<elements_->size(); ++index_ ) {
341 pos_ = elements_->operand().find( elements_->idx(index_) );
342 if( pos_ != elements_->operand().end() ) break;
343 }
344 return *this;
345 }
346 //*******************************************************************************************
347
348 //**Postfix increment operator***************************************************************
353 inline const ElementsIterator operator++( int ) {
354 const ElementsIterator tmp( *this );
355 ++(*this);
356 return tmp;
357 }
358 //*******************************************************************************************
359
360 //**Element access operator******************************************************************
365 inline ReferenceType operator*() const {
366 return ReferenceType( pos_, index_ );
367 }
368 //*******************************************************************************************
369
370 //**Element access operator******************************************************************
375 inline PointerType operator->() const {
376 return PointerType( pos_, index_ );
377 }
378 //*******************************************************************************************
379
380 //**Equality operator************************************************************************
386 inline bool operator==( const ElementsIterator& rhs ) const {
387 return index_ == rhs.index_;
388 }
389 //*******************************************************************************************
390
391 //**Inequality operator**********************************************************************
397 inline bool operator!=( const ElementsIterator& rhs ) const {
398 return index_ != rhs.index_;
399 }
400 //*******************************************************************************************
401
402 //**Subtraction operator*********************************************************************
408 inline DifferenceType operator-( const ElementsIterator& rhs ) const {
409 size_t counter( 0UL );
410 for( size_t j=rhs.index_; j<index_; ++j ) {
411 if( elements_->find( j ) != elements_->end() )
412 ++counter;
413 }
414 return counter;
415 }
416 //*******************************************************************************************
417
418 private:
419 //**Member variables*************************************************************************
420 ET* elements_;
421 size_t index_;
422 IteratorType pos_;
423 //*******************************************************************************************
424
425 //**Friend declarations**********************************************************************
426 template< typename VT2, bool TF2, bool DF2, typename... CEAs2 > friend class Elements;
427 template< typename ET2, typename IteratorType2 > friend class ElementsIterator;
428 //*******************************************************************************************
429 };
430 //**********************************************************************************************
431
432 //**Type definitions****************************************************************************
434 using ConstIterator = ElementsIterator< const This, ConstIterator_t<VT> >;
435
437 using Iterator = If_t< IsConst_v<VT>, ConstIterator, ElementsIterator< This, Iterator_t<VT> > >;
438 //**********************************************************************************************
439
440 //**Compilation flags***************************************************************************
442 static constexpr bool smpAssignable = false;
443
445 static constexpr bool compileTimeArgs = DataType::compileTimeArgs;
446 //**********************************************************************************************
447
448 //**Constructors********************************************************************************
451 template< typename... REAs >
452 explicit inline Elements( VT& vector, REAs... args );
453
454 Elements( const Elements& ) = default;
455 Elements( Elements&& ) = default;
457 //**********************************************************************************************
458
459 //**Destructor**********************************************************************************
462 ~Elements() = default;
464 //**********************************************************************************************
465
466 //**Data access functions***********************************************************************
469 inline Reference operator[]( size_t index );
470 inline ConstReference operator[]( size_t index ) const;
471 inline Reference at( size_t index );
472 inline ConstReference at( size_t index ) const;
473 inline Iterator begin ();
474 inline ConstIterator begin () const;
475 inline ConstIterator cbegin() const;
476 inline Iterator end ();
477 inline ConstIterator end () const;
478 inline ConstIterator cend () const;
480 //**********************************************************************************************
481
482 //**Assignment operators************************************************************************
485 inline Elements& operator= ( initializer_list<ElementType> list );
486 inline Elements& operator= ( const Elements& rhs );
487 template< typename VT2 > inline Elements& operator= ( const Vector<VT2,TF>& rhs );
488 template< typename VT2 > inline Elements& operator+=( const Vector<VT2,TF>& rhs );
489 template< typename VT2 > inline Elements& operator-=( const Vector<VT2,TF>& rhs );
490 template< typename VT2 > inline Elements& operator*=( const Vector<VT2,TF>& rhs );
491 template< typename VT2 > inline Elements& operator/=( const DenseVector<VT2,TF>& rhs );
492 template< typename VT2 > inline Elements& operator%=( const Vector<VT2,TF>& rhs );
494 //**********************************************************************************************
495
496 //**Utility functions***************************************************************************
499 using DataType::idces;
500 using DataType::idx;
501 using DataType::size;
502
503 inline VT& operand() noexcept;
504 inline const VT& operand() const noexcept;
505
506 inline size_t capacity() const noexcept;
507 inline size_t nonZeros() const;
508 inline void reset();
509 inline void reserve( size_t n );
511 //**********************************************************************************************
512
513 //**Insertion functions*************************************************************************
516 inline Iterator set ( size_t index, const ElementType& value );
517 inline Iterator insert( size_t index, const ElementType& value );
518 inline void append( size_t index, const ElementType& value, bool check=false );
520 //**********************************************************************************************
521
522 //**Erase functions*****************************************************************************
525 inline void erase( size_t index );
526 inline Iterator erase( Iterator pos );
527 inline Iterator erase( Iterator first, Iterator last );
528
529 template< typename Pred, typename = DisableIf_t< IsIntegral_v<Pred> > >
530 inline void erase( Pred predicate );
531
532 template< typename Pred >
533 inline void erase( Iterator first, Iterator last, Pred predicate );
535 //**********************************************************************************************
536
537 //**Lookup functions****************************************************************************
540 inline Iterator find ( size_t index );
541 inline ConstIterator find ( size_t index ) const;
542 inline Iterator lowerBound( size_t index );
543 inline ConstIterator lowerBound( size_t index ) const;
544 inline Iterator upperBound( size_t index );
545 inline ConstIterator upperBound( size_t index ) const;
547 //**********************************************************************************************
548
549 //**Numeric functions***************************************************************************
552 template< typename Other > inline Elements& scale( const Other& scalar );
554 //**********************************************************************************************
555
556 //**Expression template evaluation functions****************************************************
559 template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
560 template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
561
562 inline bool canSMPAssign() const noexcept;
563
564 template< typename VT2 > inline void assign ( const DenseVector <VT2,TF>& rhs );
565 template< typename VT2 > inline void assign ( const SparseVector<VT2,TF>& rhs );
566 template< typename VT2 > inline void addAssign( const Vector<VT2,TF>& rhs );
567 template< typename VT2 > inline void subAssign( const Vector<VT2,TF>& rhs );
569 //**********************************************************************************************
570
571 private:
572 //**Member variables****************************************************************************
575 Operand vector_;
577 //**********************************************************************************************
578
579 //**Compile time checks*************************************************************************
586 //**********************************************************************************************
587};
589//*************************************************************************************************
590
591
592
593
594//=================================================================================================
595//
596// CONSTRUCTORS
597//
598//=================================================================================================
599
600//*************************************************************************************************
613template< typename VT // Type of the sparse vector
614 , bool TF // Transpose flag
615 , typename... CEAs > // Compile time element arguments
616template< typename... REAs > // Optional arguments
617inline Elements<VT,TF,false,CEAs...>::Elements( VT& vector, REAs... args )
618 : DataType( args... ) // Base class initialization
619 , vector_ ( vector ) // The vector containing the elements
620{
621 if( isChecked( args... ) ) {
622 for( size_t i=0UL; i<size(); ++i ) {
623 if( vector_.size() <= idx(i) ) {
624 BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
625 }
626 }
627 }
628}
630//*************************************************************************************************
631
632
633
634
635//=================================================================================================
636//
637// DATA ACCESS FUNCTIONS
638//
639//=================================================================================================
640
641//*************************************************************************************************
651template< typename VT // Type of the sparse vector
652 , bool TF // Transpose flag
653 , typename... CEAs > // Compile time element arguments
654inline typename Elements<VT,TF,false,CEAs...>::Reference
655 Elements<VT,TF,false,CEAs...>::operator[]( size_t index )
656{
657 BLAZE_USER_ASSERT( index < size(), "Invalid element access index" );
658 return vector_[idx(index)];
659}
661//*************************************************************************************************
662
663
664//*************************************************************************************************
674template< typename VT // Type of the sparse vector
675 , bool TF // Transpose flag
676 , typename... CEAs > // Compile time element arguments
677inline typename Elements<VT,TF,false,CEAs...>::ConstReference
678 Elements<VT,TF,false,CEAs...>::operator[]( size_t index ) const
679{
680 BLAZE_USER_ASSERT( index < size(), "Invalid element access index" );
681 return const_cast<const VT&>( vector_ )[idx(index)];
682}
684//*************************************************************************************************
685
686
687//*************************************************************************************************
698template< typename VT // Type of the sparse vector
699 , bool TF // Transpose flag
700 , typename... CEAs > // Compile time element arguments
701inline typename Elements<VT,TF,false,CEAs...>::Reference
702 Elements<VT,TF,false,CEAs...>::at( size_t index )
703{
704 if( index >= size() ) {
705 BLAZE_THROW_OUT_OF_RANGE( "Invalid element access index" );
706 }
707 return (*this)[index];
708}
710//*************************************************************************************************
711
712
713//*************************************************************************************************
724template< typename VT // Type of the sparse vector
725 , bool TF // Transpose flag
726 , typename... CEAs > // Compile time element arguments
727inline typename Elements<VT,TF,false,CEAs...>::ConstReference
728 Elements<VT,TF,false,CEAs...>::at( size_t index ) const
729{
730 if( index >= size() ) {
731 BLAZE_THROW_OUT_OF_RANGE( "Invalid element access index" );
732 }
733 return (*this)[index];
734}
736//*************************************************************************************************
737
738
739//*************************************************************************************************
747template< typename VT // Type of the sparse vector
748 , bool TF // Transpose flag
749 , typename... CEAs > // Compile time element arguments
750inline typename Elements<VT,TF,false,CEAs...>::Iterator
752{
753 return Iterator( this, 0UL );
754}
756//*************************************************************************************************
757
758
759//*************************************************************************************************
767template< typename VT // Type of the sparse vector
768 , bool TF // Transpose flag
769 , typename... CEAs > // Compile time element arguments
770inline typename Elements<VT,TF,false,CEAs...>::ConstIterator
772{
773 return ConstIterator( this, 0UL );
774}
776//*************************************************************************************************
777
778
779//*************************************************************************************************
787template< typename VT // Type of the sparse vector
788 , bool TF // Transpose flag
789 , typename... CEAs > // Compile time element arguments
790inline typename Elements<VT,TF,false,CEAs...>::ConstIterator
792{
793 return ConstIterator( this, 0UL );
794}
796//*************************************************************************************************
797
798
799//*************************************************************************************************
807template< typename VT // Type of the sparse vector
808 , bool TF // Transpose flag
809 , typename... CEAs > // Compile time element arguments
810inline typename Elements<VT,TF,false,CEAs...>::Iterator
812{
813 return Iterator( this, size() );
814}
816//*************************************************************************************************
817
818
819//*************************************************************************************************
827template< typename VT // Type of the sparse vector
828 , bool TF // Transpose flag
829 , typename... CEAs > // Compile time element arguments
830inline typename Elements<VT,TF,false,CEAs...>::ConstIterator
832{
833 return ConstIterator( this, size() );
834}
836//*************************************************************************************************
837
838
839//*************************************************************************************************
847template< typename VT // Type of the sparse vector
848 , bool TF // Transpose flag
849 , typename... CEAs > // Compile time element arguments
850inline typename Elements<VT,TF,false,CEAs...>::ConstIterator
852{
853 return ConstIterator( this, size() );
854}
856//*************************************************************************************************
857
858
859
860
861//=================================================================================================
862//
863// ASSIGNMENT OPERATORS
864//
865//=================================================================================================
866
867//*************************************************************************************************
883template< typename VT // Type of the sparse vector
884 , bool TF // Transpose flag
885 , typename... CEAs > // Compile time element arguments
886inline Elements<VT,TF,false,CEAs...>&
887 Elements<VT,TF,false,CEAs...>::operator=( initializer_list<ElementType> list )
888{
889 using blaze::assign;
890
891 if( list.size() > size() ) {
892 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to elements" );
893 }
894
895 const InitializerVector<ElementType,TF> tmp( list, size() );
896
897 if( IsRestricted_v<VT> ) {
898 for( size_t i=0UL; i<size(); ++i ) {
899 if( !trySet( vector_, idx(i), tmp[i] ) ) {
900 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
901 }
902 }
903 }
904
905 decltype(auto) left( derestrict( *this ) );
906
907 assign( left, tmp );
908
909 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
910
911 return *this;
912}
914//*************************************************************************************************
915
916
917//*************************************************************************************************
929template< typename VT // Type of the sparse vector
930 , bool TF // Transpose flag
931 , typename... CEAs > // Compile time element arguments
932inline Elements<VT,TF,false,CEAs...>&
933 Elements<VT,TF,false,CEAs...>::operator=( const Elements& rhs )
934{
935 using blaze::assign;
936
939
940 if( &rhs == this || ( &vector_ == &rhs.vector_ && compareIndices( *this, rhs ) ) )
941 return *this;
942
943 if( size() != rhs.size() ) {
944 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
945 }
946
947 if( IsRestricted_v<VT> ) {
948 for( size_t i=0UL; i<size(); ++i ) {
949 if( !trySet( vector_, idx(i), rhs[i] ) ) {
950 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
951 }
952 }
953 }
954
955 decltype(auto) left( derestrict( *this ) );
956
957 if( rhs.canAlias( this ) ) {
958 const ResultType tmp( rhs );
959 assign( left, tmp );
960 }
961 else {
962 assign( left, rhs );
963 }
964
965 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
966
967 return *this;
968}
970//*************************************************************************************************
971
972
973//*************************************************************************************************
985template< typename VT // Type of the sparse vector
986 , bool TF // Transpose flag
987 , typename... CEAs > // Compile time element arguments
988template< typename VT2 > // Type of the right-hand side vector
989inline Elements<VT,TF,false,CEAs...>&
990 Elements<VT,TF,false,CEAs...>::operator=( const Vector<VT2,TF>& rhs )
991{
992 using blaze::assign;
993
996
997 if( size() != (*rhs).size() ) {
998 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
999 }
1000
1001 using Right = If_t< IsRestricted_v<VT>, CompositeType_t<VT2>, const VT2& >;
1002 Right right( *rhs );
1003
1004 if( IsRestricted_v<VT> ) {
1005 for( size_t i=0UL; i<size(); ++i ) {
1006 if( !trySet( vector_, idx(i), right[i] ) ) {
1007 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1008 }
1009 }
1010 }
1011
1012 decltype(auto) left( derestrict( *this ) );
1013
1014 if( IsReference_v<Right> || right.canAlias( this ) ) {
1015 const ResultType_t<VT2> tmp( right );
1016 assign( left, tmp );
1017 }
1018 else {
1019 assign( left, right );
1020 }
1021
1022 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1023
1024 return *this;
1025}
1027//*************************************************************************************************
1028
1029
1030//*************************************************************************************************
1042template< typename VT // Type of the sparse vector
1043 , bool TF // Transpose flag
1044 , typename... CEAs > // Compile time element arguments
1045template< typename VT2 > // Type of the right-hand side vector
1046inline Elements<VT,TF,false,CEAs...>&
1047 Elements<VT,TF,false,CEAs...>::operator+=( const Vector<VT2,TF>& rhs )
1048{
1049 using blaze::addAssign;
1050
1053
1054 if( size() != (*rhs).size() ) {
1055 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1056 }
1057
1058 using Right = If_t< IsRestricted_v<VT>, CompositeType_t<VT2>, const VT2& >;
1059 Right right( *rhs );
1060
1061 if( IsRestricted_v<VT> ) {
1062 for( size_t i=0UL; i<size(); ++i ) {
1063 if( !tryAdd( vector_, idx(i), right[i] ) ) {
1064 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1065 }
1066 }
1067 }
1068
1069 decltype(auto) left( derestrict( *this ) );
1070
1071 if( IsReference_v<Right> && right.canAlias( this ) ) {
1072 const ResultType_t<VT2> tmp( right );
1073 addAssign( left, tmp );
1074 }
1075 else {
1076 addAssign( left, right );
1077 }
1078
1079 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1080
1081 return *this;
1082}
1084//*************************************************************************************************
1085
1086
1087//*************************************************************************************************
1099template< typename VT // Type of the sparse vector
1100 , bool TF // Transpose flag
1101 , typename... CEAs > // Compile time element arguments
1102template< typename VT2 > // Type of the right-hand side vector
1103inline Elements<VT,TF,false,CEAs...>&
1104 Elements<VT,TF,false,CEAs...>::operator-=( const Vector<VT2,TF>& rhs )
1105{
1106 using blaze::subAssign;
1107
1110
1111 if( size() != (*rhs).size() ) {
1112 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1113 }
1114
1115 using Right = If_t< IsRestricted_v<VT>, CompositeType_t<VT2>, const VT2& >;
1116 Right right( *rhs );
1117
1118 if( IsRestricted_v<VT> ) {
1119 for( size_t i=0UL; i<size(); ++i ) {
1120 if( !trySub( vector_, idx(i), right[i] ) ) {
1121 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1122 }
1123 }
1124 }
1125
1126 decltype(auto) left( derestrict( *this ) );
1127
1128 if( IsReference_v<Right> && right.canAlias( this ) ) {
1129 const ResultType_t<VT2> tmp( right );
1130 subAssign( left, tmp );
1131 }
1132 else {
1133 subAssign( left, right );
1134 }
1135
1136 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1137
1138 return *this;
1139}
1141//*************************************************************************************************
1142
1143
1144//*************************************************************************************************
1157template< typename VT // Type of the sparse vector
1158 , bool TF // Transpose flag
1159 , typename... CEAs > // Compile time element arguments
1160template< typename VT2 > // Type of the right-hand side vector
1161inline Elements<VT,TF,false,CEAs...>&
1162 Elements<VT,TF,false,CEAs...>::operator*=( const Vector<VT2,TF>& rhs )
1163{
1164 using blaze::assign;
1165
1169
1170 using MultType = MultTrait_t< ResultType, ResultType_t<VT2> >;
1171
1174
1175 if( size() != (*rhs).size() ) {
1176 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1177 }
1178
1179 const MultType tmp( *this * (*rhs) );
1180
1181 if( IsRestricted_v<VT> ) {
1182 for( size_t i=0UL; i<size(); ++i ) {
1183 if( !trySet( vector_, idx(i), tmp[i] ) ) {
1184 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1185 }
1186 }
1187 }
1188
1189 decltype(auto) left( derestrict( *this ) );
1190
1191 assign( left, tmp );
1192
1193 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1194
1195 return *this;
1196}
1198//*************************************************************************************************
1199
1200
1201//*************************************************************************************************
1213template< typename VT // Type of the sparse vector
1214 , bool TF // Transpose flag
1215 , typename... CEAs > // Compile time element arguments
1216template< typename VT2 > // Type of the right-hand side dense vector
1217inline Elements<VT,TF,false,CEAs...>&
1218 Elements<VT,TF,false,CEAs...>::operator/=( const DenseVector<VT2,TF>& rhs )
1219{
1220 using blaze::assign;
1221
1224 BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_t<VT2> );
1226
1227 using DivType = DivTrait_t< ResultType, ResultType_t<VT2> >;
1228
1232
1233 if( size() != (*rhs).size() ) {
1234 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1235 }
1236
1237 const DivType tmp( *this / (*rhs) );
1238
1239 if( IsRestricted_v<VT> ) {
1240 for( size_t i=0UL; i<size(); ++i ) {
1241 if( !trySet( vector_, idx(i), tmp[i] ) ) {
1242 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1243 }
1244 }
1245 }
1246
1247 decltype(auto) left( derestrict( *this ) );
1248
1249 assign( left, tmp );
1250
1251 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1252
1253 return *this;
1254}
1256//*************************************************************************************************
1257
1258
1259//*************************************************************************************************
1272template< typename VT // Type of the sparse vector
1273 , bool TF // Transpose flag
1274 , typename... CEAs > // Compile time element arguments
1275template< typename VT2 > // Type of the right-hand side vector
1276inline Elements<VT,TF,false,CEAs...>&
1277 Elements<VT,TF,false,CEAs...>::operator%=( const Vector<VT2,TF>& rhs )
1278{
1279 using blaze::assign;
1280
1283
1284 using CrossType = CrossTrait_t< ResultType, ResultType_t<VT2> >;
1285
1289
1290 if( size() != 3UL || (*rhs).size() != 3UL ) {
1291 BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
1292 }
1293
1294 const CrossType tmp( *this % (*rhs) );
1295
1296 if( IsRestricted_v<VT> ) {
1297 for( size_t i=0UL; i<size(); ++i ) {
1298 if( !trySet( vector_, idx(i), tmp[i] ) ) {
1299 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1300 }
1301 }
1302 }
1303
1304 decltype(auto) left( derestrict( *this ) );
1305
1306 assign( left, tmp );
1307
1308 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1309
1310 return *this;
1311}
1313//*************************************************************************************************
1314
1315
1316
1317
1318//=================================================================================================
1319//
1320// UTILITY FUNCTIONS
1321//
1322//=================================================================================================
1323
1324//*************************************************************************************************
1330template< typename VT // Type of the sparse vector
1331 , bool TF // Transpose flag
1332 , typename... CEAs > // Compile time element arguments
1333inline VT& Elements<VT,TF,false,CEAs...>::operand() noexcept
1334{
1335 return vector_;
1336}
1338//*************************************************************************************************
1339
1340
1341//*************************************************************************************************
1347template< typename VT // Type of the sparse vector
1348 , bool TF // Transpose flag
1349 , typename... CEAs > // Compile time element arguments
1350inline const VT& Elements<VT,TF,false,CEAs...>::operand() const noexcept
1351{
1352 return vector_;
1353}
1355//*************************************************************************************************
1356
1357
1358//*************************************************************************************************
1364template< typename VT // Type of the sparse vector
1365 , bool TF // Transpose flag
1366 , typename... CEAs > // Compile time element arguments
1367inline size_t Elements<VT,TF,false,CEAs...>::capacity() const noexcept
1368{
1369 return nonZeros() + vector_.capacity() - vector_.nonZeros();
1370}
1372//*************************************************************************************************
1373
1374
1375//*************************************************************************************************
1384template< typename VT // Type of the sparse vector
1385 , bool TF // Transpose flag
1386 , typename... CEAs > // Compile time element arguments
1387inline size_t Elements<VT,TF,false,CEAs...>::nonZeros() const
1388{
1389 size_t counter( 0UL );
1390 for( ConstIterator element=begin(); element!=end(); ++element ) {
1391 ++counter;
1392 }
1393 return counter;
1394}
1396//*************************************************************************************************
1397
1398
1399//*************************************************************************************************
1405template< typename VT // Type of the sparse vector
1406 , bool TF // Transpose flag
1407 , typename... CEAs > // Compile time element arguments
1409{
1410 for( size_t i=0UL; i<size(); ++i )
1411 vector_.erase( idx(i) );
1412}
1414//*************************************************************************************************
1415
1416
1417//*************************************************************************************************
1427template< typename VT // Type of the sparse vector
1428 , bool TF // Transpose flag
1429 , typename... CEAs > // Compile time element arguments
1430void Elements<VT,TF,false,CEAs...>::reserve( size_t n )
1431{
1432 const size_t current( capacity() );
1433
1434 if( n > current ) {
1435 vector_.reserve( vector_.capacity() + n - current );
1436 }
1437}
1439//*************************************************************************************************
1440
1441
1442
1443
1444//=================================================================================================
1445//
1446// INSERTION FUNCTIONS
1447//
1448//=================================================================================================
1449
1450//*************************************************************************************************
1462template< typename VT // Type of the sparse vector
1463 , bool TF // Transpose flag
1464 , typename... CEAs > // Compile time element arguments
1465inline typename Elements<VT,TF,false,CEAs...>::Iterator
1466 Elements<VT,TF,false,CEAs...>::set( size_t index, const ElementType& value )
1467{
1468 return Iterator( this, index, vector_.set( idx(index), value ) );
1469}
1471//*************************************************************************************************
1472
1473
1474//*************************************************************************************************
1487template< typename VT // Type of the sparse vector
1488 , bool TF // Transpose flag
1489 , typename... CEAs > // Compile time element arguments
1490inline typename Elements<VT,TF,false,CEAs...>::Iterator
1491 Elements<VT,TF,false,CEAs...>::insert( size_t index, const ElementType& value )
1492{
1493 return Iterator( this, index, vector_.insert( idx(index), value ) );
1494}
1496//*************************************************************************************************
1497
1498
1499//*************************************************************************************************
1524template< typename VT // Type of the sparse vector
1525 , bool TF // Transpose flag
1526 , typename... CEAs > // Compile time element arguments
1527inline void Elements<VT,TF,false,CEAs...>::append( size_t index, const ElementType& value, bool check )
1528{
1529 if( !check || !isDefault<strict>( value ) )
1530 vector_.insert( idx(index), value );
1531}
1533//*************************************************************************************************
1534
1535
1536
1537
1538//=================================================================================================
1539//
1540// ERASE FUNCTIONS
1541//
1542//=================================================================================================
1543
1544//*************************************************************************************************
1553template< typename VT // Type of the sparse vector
1554 , bool TF // Transpose flag
1555 , typename... CEAs > // Compile time element arguments
1556inline void Elements<VT,TF,false,CEAs...>::erase( size_t index )
1557{
1558 vector_.erase( idx(index) );
1559}
1561//*************************************************************************************************
1562
1563
1564//*************************************************************************************************
1573template< typename VT // Type of the sparse vector
1574 , bool TF // Transpose flag
1575 , typename... CEAs > // Compile time element arguments
1576inline typename Elements<VT,TF,false,CEAs...>::Iterator
1577 Elements<VT,TF,false,CEAs...>::erase( Iterator pos )
1578{
1579 const size_t index( pos.index_ );
1580
1581 if( index == size() )
1582 return pos;
1583
1584 vector_.erase( pos.pos_ );
1585 return Iterator( this, index+1UL );
1586}
1588//*************************************************************************************************
1589
1590
1591//*************************************************************************************************
1601template< typename VT // Type of the sparse vector
1602 , bool TF // Transpose flag
1603 , typename... CEAs > // Compile time element arguments
1604inline typename Elements<VT,TF,false,CEAs...>::Iterator
1605 Elements<VT,TF,false,CEAs...>::erase( Iterator first, Iterator last )
1606{
1607 for( ; first!=last; ++first ) {
1608 vector_.erase( first.pos_ );
1609 }
1610
1611 return Iterator( this, last.index_ );
1612}
1614//*************************************************************************************************
1615
1616
1617//*************************************************************************************************
1640template< typename VT // Type of the sparse vector
1641 , bool TF // Transpose flag
1642 , typename... CEAs > // Compile time element arguments
1643template< typename Pred // Type of the unary predicate
1644 , typename > // Type restriction on the unary predicate
1645inline void Elements<VT,TF,false,CEAs...>::erase( Pred predicate )
1646{
1647 erase( begin(), end(), predicate );
1648}
1650//*************************************************************************************************
1651
1652
1653//*************************************************************************************************
1679template< typename VT // Type of the sparse vector
1680 , bool TF // Transpose flag
1681 , typename... CEAs > // Compile time element arguments
1682template< typename Pred > // Type of the unary predicate
1683inline void Elements<VT,TF,false,CEAs...>::erase( Iterator first, Iterator last, Pred predicate )
1684{
1685 for( ; first!=last; ++first ) {
1686 if( predicate( first->value() ) )
1687 vector_.erase( first.pos_ );
1688 }
1689}
1691//*************************************************************************************************
1692
1693
1694
1695
1696//=================================================================================================
1697//
1698// LOOKUP FUNCTIONS
1699//
1700//=================================================================================================
1701
1702//*************************************************************************************************
1716template< typename VT // Type of the sparse vector
1717 , bool TF // Transpose flag
1718 , typename... CEAs > // Compile time element arguments
1719inline typename Elements<VT,TF,false,CEAs...>::Iterator
1721{
1722 const Iterator_t<VT> pos( vector_.find( idx(index) ) );
1723
1724 if( pos != vector_.end() )
1725 return Iterator( this, index, pos );
1726 else
1727 return end();
1728}
1730//*************************************************************************************************
1731
1732
1733//*************************************************************************************************
1747template< typename VT // Type of the sparse vector
1748 , bool TF // Transpose flag
1749 , typename... CEAs > // Compile time element arguments
1750inline typename Elements<VT,TF,false,CEAs...>::ConstIterator
1751 Elements<VT,TF,false,CEAs...>::find( size_t index ) const
1752{
1753 const ConstIterator_t<VT> pos( vector_.find( idx(index) ) );
1754
1755 if( pos != vector_.end() )
1756 return ConstIterator( this, index, pos );
1757 else
1758 return end();
1759}
1761//*************************************************************************************************
1762
1763
1764//*************************************************************************************************
1777template< typename VT // Type of the sparse vector
1778 , bool TF // Transpose flag
1779 , typename... CEAs > // Compile time element arguments
1780inline typename Elements<VT,TF,false,CEAs...>::Iterator
1782{
1783 for( ; index<size(); ++index ) {
1784 const Iterator_t<VT> pos( vector_.find( idx(index) ) );
1785 if( pos != vector_.end() )
1786 return Iterator( this, index, pos );
1787 }
1788 return end();
1789}
1791//*************************************************************************************************
1792
1793
1794//*************************************************************************************************
1807template< typename VT // Type of the sparse vector
1808 , bool TF // Transpose flag
1809 , typename... CEAs > // Compile time element arguments
1810inline typename Elements<VT,TF,false,CEAs...>::ConstIterator
1811 Elements<VT,TF,false,CEAs...>::lowerBound( size_t index ) const
1812{
1813 for( ; index<size(); ++index ) {
1814 const ConstIterator_t<VT> pos( vector_.find( idx(index) ) );
1815 if( pos != vector_.end() )
1816 return ConstIterator( this, index, pos );
1817 }
1818 return end();
1819}
1821//*************************************************************************************************
1822
1823
1824//*************************************************************************************************
1837template< typename VT // Type of the sparse vector
1838 , bool TF // Transpose flag
1839 , typename... CEAs > // Compile time element arguments
1840inline typename Elements<VT,TF,false,CEAs...>::Iterator
1842{
1843 while( (++index) < size() ) {
1844 const Iterator_t<VT> pos( vector_.find( idx(index) ) );
1845 if( pos != vector_.end() )
1846 return Iterator( this, index, pos );
1847 }
1848 return end();
1849}
1851//*************************************************************************************************
1852
1853
1854//*************************************************************************************************
1867template< typename VT // Type of the sparse vector
1868 , bool TF // Transpose flag
1869 , typename... CEAs > // Compile time element arguments
1870inline typename Elements<VT,TF,false,CEAs...>::ConstIterator
1871 Elements<VT,TF,false,CEAs...>::upperBound( size_t index ) const
1872{
1873 while( (++index) < size() ) {
1874 const ConstIterator_t<VT> pos( vector_.find( idx(index) ) );
1875 if( pos != vector_.end() )
1876 return ConstIterator( this, index, pos );
1877 }
1878 return end();
1879}
1881//*************************************************************************************************
1882
1883
1884
1885
1886//=================================================================================================
1887//
1888// NUMERIC FUNCTIONS
1889//
1890//=================================================================================================
1891
1892//*************************************************************************************************
1903template< typename VT // Type of the sparse vector
1904 , bool TF // Transpose flag
1905 , typename... CEAs > // Compile time element arguments
1906template< typename Other > // Data type of the scalar value
1907inline Elements<VT,TF,false,CEAs...>&
1908 Elements<VT,TF,false,CEAs...>::scale( const Other& scalar )
1909{
1910 for( Iterator element=begin(); element!=end(); ++element )
1911 element->value() *= scalar;
1912 return *this;
1913}
1915//*************************************************************************************************
1916
1917
1918
1919
1920//=================================================================================================
1921//
1922// EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1923//
1924//=================================================================================================
1925
1926//*************************************************************************************************
1937template< typename VT // Type of the sparse vector
1938 , bool TF // Transpose flag
1939 , typename... CEAs > // Compile time element arguments
1940template< typename Other > // Data type of the foreign expression
1941inline bool Elements<VT,TF,false,CEAs...>::canAlias( const Other* alias ) const noexcept
1942{
1943 return vector_.isAliased( &unview( *alias ) );
1944}
1946//*************************************************************************************************
1947
1948
1949//*************************************************************************************************
1960template< typename VT // Type of the sparse vector
1961 , bool TF // Transpose flag
1962 , typename... CEAs > // Compile time element arguments
1963template< typename Other > // Data type of the foreign expression
1964inline bool Elements<VT,TF,false,CEAs...>::isAliased( const Other* alias ) const noexcept
1965{
1966 return vector_.isAliased( &unview( *alias ) );
1967}
1969//*************************************************************************************************
1970
1971
1972//*************************************************************************************************
1984template< typename VT // Type of the sparse vector
1985 , bool TF // Transpose flag
1986 , typename... CEAs > // Compile time element arguments
1987template< typename VT2 > // Type of the right-hand side dense vector
1988inline void Elements<VT,TF,false,CEAs...>::assign( const DenseVector<VT2,TF>& rhs )
1989{
1990 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
1991
1992 using RT = If_t< IsComputation_v<VT2>, ElementType_t<VT>, const ElementType_t<VT2>& >;
1993
1994 reserve( (*rhs).size() );
1995
1996 for( size_t i=0UL; i<size(); ++i ) {
1997 RT value( (*rhs)[i] );
1998 if( !isDefault<strict>( value ) )
1999 vector_.set( idx(i), std::move( value ) );
2000 else vector_.erase( idx(i) );
2001 }
2002}
2004//*************************************************************************************************
2005
2006
2007//*************************************************************************************************
2019template< typename VT // Type of the sparse vector
2020 , bool TF // Transpose flag
2021 , typename... CEAs > // Compile time element arguments
2022template< typename VT2 > // Type of the right-hand side sparse vector
2023inline void Elements<VT,TF,false,CEAs...>::assign( const SparseVector<VT2,TF>& rhs )
2024{
2025 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
2026
2027 using RT = If_t< IsComputation_v<VT2>, ElementType_t<VT>, const ElementType_t<VT2>& >;
2028
2029 size_t i( 0UL );
2030
2031 for( ConstIterator_t<VT2> element=(*rhs).begin(); element!=(*rhs).end(); ++element ) {
2032 for( ; i<element->index(); ++i )
2033 vector_.erase( idx(i) );
2034 RT value( element->value() );
2035 if( !isDefault<strict>( value ) )
2036 vector_.set( idx(i), std::move( value ) );
2037 else vector_.erase( idx(i) );
2038 ++i;
2039 }
2040 for( ; i<size(); ++i ) {
2041 vector_.erase( idx(i) );
2042 }
2043}
2045//*************************************************************************************************
2046
2047
2048//*************************************************************************************************
2060template< typename VT // Type of the sparse vector
2061 , bool TF // Transpose flag
2062 , typename... CEAs > // Compile time element arguments
2063template< typename VT2 > // Type of the right-hand side vector
2064inline void Elements<VT,TF,false,CEAs...>::addAssign( const Vector<VT2,TF>& rhs )
2065{
2066 using AddType = AddTrait_t< ResultType, ResultType_t<VT2> >;
2067
2070
2071 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
2072
2073 const AddType tmp( serial( *this + (*rhs) ) );
2074 assign( tmp );
2075}
2077//*************************************************************************************************
2078
2079
2080//*************************************************************************************************
2092template< typename VT // Type of the sparse vector
2093 , bool TF // Transpose flag
2094 , typename... CEAs > // Compile time element arguments
2095template< typename VT2 > // Type of the right-hand side vector
2096inline void Elements<VT,TF,false,CEAs...>::subAssign( const Vector<VT2,TF>& rhs )
2097{
2098 using SubType = SubTrait_t< ResultType, ResultType_t<VT2> >;
2099
2102
2103 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
2104
2105 const SubType tmp( serial( *this - (*rhs) ) );
2106 assign( tmp );
2107}
2109//*************************************************************************************************
2110
2111} // namespace blaze
2112
2113#endif
Header file for the addition trait.
Header file for auxiliary alias declarations.
Header file for run time assertion macros.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the cross product trait.
constexpr const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:751
Header file for the division trait.
Header file for the implementation of the ElementsData class template.
Header file for the elements trait.
Header file for the EnableIf class template.
Header file for the If class template.
Header file for the IsComputation type trait class.
Header file for the IsConst type trait.
Header file for the IsExpression type trait class.
Header file for the IsIntegral type trait.
Header file for the IsReference type trait.
Header file for the IsRestricted type trait.
Deactivation of problematic macros.
Header file for the multiplication trait.
Header file for the subtraction trait.
Initializer list type of the Blaze library.
Pointer difference type of the Blaze library.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the implementation of a vector representation of an initializer list.
Header file for the SparseVector base class.
Header file for the View base class.
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( ).
Definition: DenseMatrix.h:574
auto operator+=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Addition assignment operator for the addition of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:386
auto operator*=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:510
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:9640
auto operator-=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Subtraction assignment operator for the subtraction of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:448
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:207
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_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition: RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.
Definition: TransExpr.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_NOT_BE_ELEMENTS_TYPE(T)
Constraint on the data type.
Definition: Elements.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: SparseVector.h:61
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: DenseVector.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SUBVECTOR_TYPE(T)
Constraint on the data type.
Definition: Subvector.h:81
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:253
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:628
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:730
MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:562
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:692
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
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
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:518
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
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
MT::Iterator upperBound(SparseMatrix< MT, SO > &sm, size_t i, size_t j)
Returns an iterator to the first index greater than the given index.
Definition: SparseMatrix.h:244
MT::Iterator lowerBound(SparseMatrix< MT, SO > &sm, size_t i, size_t j)
Returns an iterator to the first index not less than the given index.
Definition: SparseMatrix.h:194
MT::Iterator find(SparseMatrix< MT, SO > &sm, size_t i, size_t j)
Searches for a specific matrix element.
Definition: SparseMatrix.h:144
constexpr bool IsIntegral_v
Auxiliary variable template for the IsIntegral type trait.
Definition: IsIntegral.h:95
#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
typename EnableIf<!Condition, T >::Type DisableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:175
constexpr bool isChecked(const Ts &... args)
Extracting blaze::Check arguments from a given list of arguments.
Definition: Check.h:225
Header file for the exception macros of the math module.
Header file for the extended initializer_list functionality.
Constraint on the data type.
Header file for all forward declarations for expression class templates.
Header file for the serial shim.
Header file for the SparseElement base class.
Header file for basic type definitions.
Header file for the implementation of the Elements base template.