Blaze 3.9
Sparse.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_VIEWS_SUBVECTOR_SPARSE_H_
36#define _BLAZE_MATH_VIEWS_SUBVECTOR_SPARSE_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <iterator>
44#include <blaze/math/Aliases.h>
73#include <blaze/util/Assert.h>
74#include <blaze/util/EnableIf.h>
75#include <blaze/util/mpl/If.h>
76#include <blaze/util/Types.h>
80
81
82namespace blaze {
83
84//=================================================================================================
85//
86// CLASS TEMPLATE SPECIALIZATION FOR SPARSE SUBVECTORS
87//
88//=================================================================================================
89
90//*************************************************************************************************
98template< typename VT // Type of the sparse vector
99 , AlignmentFlag AF // Alignment flag
100 , bool TF // Transpose flag
101 , size_t... CSAs > // Compile time subvector arguments
102class Subvector<VT,AF,TF,false,CSAs...>
103 : public View< SparseVector< Subvector<VT,AF,TF,false,CSAs...>, TF > >
104 , private SubvectorData<CSAs...>
105{
106 private:
107 //**Type definitions****************************************************************************
108 using DataType = SubvectorData<CSAs...>;
109 using Operand = If_t< IsExpression_v<VT>, VT, VT& >;
110 //**********************************************************************************************
111
112 public:
113 //**Type definitions****************************************************************************
115 using This = Subvector<VT,AF,TF,false,CSAs...>;
116
117 using BaseType = View< SparseVector<This,TF> >;
118 using ViewedType = VT;
119 using ResultType = SubvectorTrait_t<VT,CSAs...>;
120 using TransposeType = TransposeType_t<ResultType>;
121 using ElementType = ElementType_t<VT>;
122 using ReturnType = ReturnType_t<VT>;
123 using CompositeType = const Subvector&;
124
126 using ConstReference = ConstReference_t<VT>;
127
129 using Reference = If_t< IsConst_v<VT>, ConstReference, Reference_t<VT> >;
130 //**********************************************************************************************
131
132 //**SubvectorElement class definition***********************************************************
135 template< typename VectorType // Type of the sparse vector
136 , typename IteratorType > // Type of the sparse vector iterator
137 class SubvectorElement
138 : private SparseElement
139 {
140 public:
141 //**Constructor******************************************************************************
147 inline SubvectorElement( IteratorType pos, size_t offset )
148 : pos_ ( pos ) // Iterator to the current position within the sparse subvector
149 , offset_( offset ) // Offset within the according sparse vector
150 {}
151 //*******************************************************************************************
152
153 //**Assignment operator**********************************************************************
159 template< typename T > inline SubvectorElement& operator=( const T& v ) {
160 *pos_ = v;
161 return *this;
162 }
163 //*******************************************************************************************
164
165 //**Addition assignment operator*************************************************************
171 template< typename T > inline SubvectorElement& operator+=( const T& v ) {
172 *pos_ += v;
173 return *this;
174 }
175 //*******************************************************************************************
176
177 //**Subtraction assignment operator**********************************************************
183 template< typename T > inline SubvectorElement& operator-=( const T& v ) {
184 *pos_ -= v;
185 return *this;
186 }
187 //*******************************************************************************************
188
189 //**Multiplication assignment operator*******************************************************
195 template< typename T > inline SubvectorElement& operator*=( const T& v ) {
196 *pos_ *= v;
197 return *this;
198 }
199 //*******************************************************************************************
200
201 //**Division assignment operator*************************************************************
207 template< typename T > inline SubvectorElement& operator/=( const T& v ) {
208 *pos_ /= v;
209 return *this;
210 }
211 //*******************************************************************************************
212
213 //**Element access operator******************************************************************
218 inline const SubvectorElement* operator->() const {
219 return this;
220 }
221 //*******************************************************************************************
222
223 //**Value function***************************************************************************
228 inline decltype(auto) value() const {
229 return pos_->value();
230 }
231 //*******************************************************************************************
232
233 //**Index function***************************************************************************
238 inline size_t index() const {
239 return pos_->index() - offset_;
240 }
241 //*******************************************************************************************
242
243 private:
244 //**Member variables*************************************************************************
245 IteratorType pos_;
246 size_t offset_;
247 //*******************************************************************************************
248 };
249 //**********************************************************************************************
250
251 //**SubvectorIterator class definition**********************************************************
254 template< typename VectorType // Type of the sparse vector
255 , typename IteratorType > // Type of the sparse vector iterator
256 class SubvectorIterator
257 {
258 public:
259 //**Type definitions*************************************************************************
260 using IteratorCategory = std::forward_iterator_tag;
261 using ValueType = SubvectorElement<VectorType,IteratorType>;
262 using PointerType = ValueType;
263 using ReferenceType = ValueType;
264 using DifferenceType = ptrdiff_t;
265
266 // STL iterator requirements
267 using iterator_category = IteratorCategory;
268 using value_type = ValueType;
269 using pointer = PointerType;
270 using reference = ReferenceType;
271 using difference_type = DifferenceType;
272 //*******************************************************************************************
273
274 //**Default constructor**********************************************************************
277 inline SubvectorIterator()
278 : pos_ () // Iterator to the current sparse element
279 , offset_() // The offset of the subvector within the sparse vector
280 {}
281 //*******************************************************************************************
282
283 //**Constructor******************************************************************************
289 inline SubvectorIterator( IteratorType iterator, size_t index )
290 : pos_ ( iterator ) // Iterator to the current sparse element
291 , offset_( index ) // The offset of the subvector within the sparse vector
292 {}
293 //*******************************************************************************************
294
295 //**Constructor******************************************************************************
300 template< typename VectorType2, typename IteratorType2 >
301 inline SubvectorIterator( const SubvectorIterator<VectorType2,IteratorType2>& it )
302 : pos_ ( it.base() ) // Iterator to the current sparse element.
303 , offset_( it.offset() ) // The offset of the subvector within the sparse vector
304 {}
305 //*******************************************************************************************
306
307 //**Prefix increment operator****************************************************************
312 inline SubvectorIterator& operator++() {
313 ++pos_;
314 return *this;
315 }
316 //*******************************************************************************************
317
318 //**Postfix increment operator***************************************************************
323 inline const SubvectorIterator operator++( int ) {
324 const SubvectorIterator tmp( *this );
325 ++(*this);
326 return tmp;
327 }
328 //*******************************************************************************************
329
330 //**Element access operator******************************************************************
335 inline ReferenceType operator*() const {
336 return ReferenceType( pos_, offset_ );
337 }
338 //*******************************************************************************************
339
340 //**Element access operator******************************************************************
345 inline PointerType operator->() const {
346 return PointerType( pos_, offset_ );
347 }
348 //*******************************************************************************************
349
350 //**Equality operator************************************************************************
356 template< typename VectorType2, typename IteratorType2 >
357 inline bool operator==( const SubvectorIterator<VectorType2,IteratorType2>& rhs ) const {
358 return base() == rhs.base();
359 }
360 //*******************************************************************************************
361
362 //**Inequality operator**********************************************************************
368 template< typename VectorType2, typename IteratorType2 >
369 inline bool operator!=( const SubvectorIterator<VectorType2,IteratorType2>& rhs ) const {
370 return !( *this == rhs );
371 }
372 //*******************************************************************************************
373
374 //**Subtraction operator*********************************************************************
380 inline DifferenceType operator-( const SubvectorIterator& rhs ) const {
381 return pos_ - rhs.pos_;
382 }
383 //*******************************************************************************************
384
385 //**Base function****************************************************************************
390 inline IteratorType base() const {
391 return pos_;
392 }
393 //*******************************************************************************************
394
395 //**Offset function**************************************************************************
400 inline size_t offset() const noexcept {
401 return offset_;
402 }
403 //*******************************************************************************************
404
405 private:
406 //**Member variables*************************************************************************
407 IteratorType pos_;
408 size_t offset_;
409 //*******************************************************************************************
410 };
411 //**********************************************************************************************
412
413 //**Type definitions****************************************************************************
415 using ConstIterator = SubvectorIterator< const VT, ConstIterator_t<VT> >;
416
418 using Iterator = If_t< IsConst_v<VT>, ConstIterator, SubvectorIterator< VT, Iterator_t<VT> > >;
419 //**********************************************************************************************
420
421 //**Compilation flags***************************************************************************
423 static constexpr bool smpAssignable = VT::smpAssignable;
424
426 static constexpr bool compileTimeArgs = DataType::compileTimeArgs;
427 //**********************************************************************************************
428
429 //**Constructors********************************************************************************
432 template< typename... RSAs >
433 explicit inline Subvector( VT& vector, RSAs... args );
434
435 Subvector( const Subvector& ) = default;
437 //**********************************************************************************************
438
439 //**Destructor**********************************************************************************
442 ~Subvector() = default;
444 //**********************************************************************************************
445
446 //**Data access functions***********************************************************************
449 inline Reference operator[]( size_t index );
450 inline ConstReference operator[]( size_t index ) const;
451 inline Reference at( size_t index );
452 inline ConstReference at( size_t index ) const;
453 inline Iterator begin ();
454 inline ConstIterator begin () const;
455 inline ConstIterator cbegin() const;
456 inline Iterator end ();
457 inline ConstIterator end () const;
458 inline ConstIterator cend () const;
460 //**********************************************************************************************
461
462 //**Assignment operators************************************************************************
465 inline Subvector& operator= ( initializer_list<ElementType> list );
466 inline Subvector& operator= ( const Subvector& rhs );
467 template< typename VT2 > inline Subvector& operator= ( const Vector<VT2,TF>& rhs );
468 template< typename VT2 > inline Subvector& operator+=( const Vector<VT2,TF>& rhs );
469 template< typename VT2 > inline Subvector& operator-=( const Vector<VT2,TF>& rhs );
470 template< typename VT2 > inline Subvector& operator*=( const Vector<VT2,TF>& rhs );
471 template< typename VT2 > inline Subvector& operator/=( const DenseVector<VT2,TF>& rhs );
472 template< typename VT2 > inline Subvector& operator%=( const Vector<VT2,TF>& rhs );
474 //**********************************************************************************************
475
476 //**Utility functions***************************************************************************
479 using DataType::offset;
480 using DataType::size;
481
482 inline VT& operand() noexcept;
483 inline const VT& operand() const noexcept;
484
485 inline size_t capacity() const noexcept;
486 inline size_t nonZeros() const;
487 inline void reset();
488 inline void reserve( size_t n );
490 //**********************************************************************************************
491
492 //**Insertion functions*************************************************************************
495 inline Iterator set ( size_t index, const ElementType& value );
496 inline Iterator insert( size_t index, const ElementType& value );
497 inline void append( size_t index, const ElementType& value, bool check=false );
499 //**********************************************************************************************
500
501 //**Erase functions*****************************************************************************
504 inline void erase( size_t index );
505 inline Iterator erase( Iterator pos );
506 inline Iterator erase( Iterator first, Iterator last );
507
508 template< typename Pred, typename = DisableIf_t< IsIntegral_v<Pred> > >
509 inline void erase( Pred predicate );
510
511 template< typename Pred >
512 inline void erase( Iterator first, Iterator last, Pred predicate );
514 //**********************************************************************************************
515
516 //**Lookup functions****************************************************************************
519 inline Iterator find ( size_t index );
520 inline ConstIterator find ( size_t index ) const;
521 inline Iterator lowerBound( size_t index );
522 inline ConstIterator lowerBound( size_t index ) const;
523 inline Iterator upperBound( size_t index );
524 inline ConstIterator upperBound( size_t index ) const;
526 //**********************************************************************************************
527
528 //**Numeric functions***************************************************************************
531 template< typename Other > inline Subvector& scale( const Other& scalar );
533 //**********************************************************************************************
534
535 //**Expression template evaluation functions****************************************************
538 template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
539 template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
540
541 inline bool canSMPAssign() const noexcept;
542
543 template< typename VT2 > inline void assign ( const DenseVector <VT2,TF>& rhs );
544 template< typename VT2 > inline void assign ( const SparseVector<VT2,TF>& rhs );
545 template< typename VT2 > inline void addAssign( const DenseVector <VT2,TF>& rhs );
546 template< typename VT2 > inline void addAssign( const SparseVector<VT2,TF>& rhs );
547 template< typename VT2 > inline void subAssign( const DenseVector <VT2,TF>& rhs );
548 template< typename VT2 > inline void subAssign( const SparseVector<VT2,TF>& rhs );
550 //**********************************************************************************************
551
552 private:
553 //**Member variables****************************************************************************
556 Operand vector_;
558 //**********************************************************************************************
559
560 //**Compile time checks*************************************************************************
566 //**********************************************************************************************
567};
569//*************************************************************************************************
570
571
572
573
574//=================================================================================================
575//
576// CONSTRUCTORS
577//
578//=================================================================================================
579
580//*************************************************************************************************
594template< typename VT // Type of the sparse vector
595 , AlignmentFlag AF // Alignment flag
596 , bool TF // Transpose flag
597 , size_t... CSAs > // Compile time subvector arguments
598template< typename... RSAs > // Runtime subvector arguments
599inline Subvector<VT,AF,TF,false,CSAs...>::Subvector( VT& vector, RSAs... args )
600 : DataType( args... ) // Base class initialization
601 , vector_ ( vector ) // The vector containing the subvector
602{
603 if( isChecked( args... ) ) {
604 if( offset() + size() > vector.size() ) {
605 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
606 }
607 }
608 else {
609 BLAZE_USER_ASSERT( offset() + size() <= vector.size(), "Invalid subvector specification" );
610 }
611}
613//*************************************************************************************************
614
615
616
617
618//=================================================================================================
619//
620// DATA ACCESS FUNCTIONS
621//
622//=================================================================================================
623
624//*************************************************************************************************
634template< typename VT // Type of the sparse vector
635 , AlignmentFlag AF // Alignment flag
636 , bool TF // Transpose flag
637 , size_t... CSAs > // Compile time subvector arguments
638inline typename Subvector<VT,AF,TF,false,CSAs...>::Reference
639 Subvector<VT,AF,TF,false,CSAs...>::operator[]( size_t index )
640{
641 BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
642 return vector_[offset()+index];
643}
645//*************************************************************************************************
646
647
648//*************************************************************************************************
658template< typename VT // Type of the sparse vector
659 , AlignmentFlag AF // Alignment flag
660 , bool TF // Transpose flag
661 , size_t... CSAs > // Compile time subvector arguments
662inline typename Subvector<VT,AF,TF,false,CSAs...>::ConstReference
663 Subvector<VT,AF,TF,false,CSAs...>::operator[]( size_t index ) const
664{
665 BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
666 return const_cast<const VT&>( vector_ )[offset()+index];
667}
669//*************************************************************************************************
670
671
672//*************************************************************************************************
683template< typename VT // Type of the sparse vector
684 , AlignmentFlag AF // Alignment flag
685 , bool TF // Transpose flag
686 , size_t... CSAs > // Compile time subvector arguments
687inline typename Subvector<VT,AF,TF,false,CSAs...>::Reference
688 Subvector<VT,AF,TF,false,CSAs...>::at( size_t index )
689{
690 if( index >= size() ) {
691 BLAZE_THROW_OUT_OF_RANGE( "Invalid subvector access index" );
692 }
693 return (*this)[index];
694}
696//*************************************************************************************************
697
698
699//*************************************************************************************************
710template< typename VT // Type of the sparse vector
711 , AlignmentFlag AF // Alignment flag
712 , bool TF // Transpose flag
713 , size_t... CSAs > // Compile time subvector arguments
714inline typename Subvector<VT,AF,TF,false,CSAs...>::ConstReference
715 Subvector<VT,AF,TF,false,CSAs...>::at( size_t index ) const
716{
717 if( index >= size() ) {
718 BLAZE_THROW_OUT_OF_RANGE( "Invalid subvector access index" );
719 }
720 return (*this)[index];
721}
723//*************************************************************************************************
724
725
726//*************************************************************************************************
734template< typename VT // Type of the sparse vector
735 , AlignmentFlag AF // Alignment flag
736 , bool TF // Transpose flag
737 , size_t... CSAs > // Compile time subvector arguments
738inline typename Subvector<VT,AF,TF,false,CSAs...>::Iterator
740{
741 if( offset() == 0UL )
742 return Iterator( vector_.begin(), offset() );
743 else
744 return Iterator( vector_.lowerBound( offset() ), offset() );
745}
747//*************************************************************************************************
748
749
750//*************************************************************************************************
758template< typename VT // Type of the sparse vector
759 , AlignmentFlag AF // Alignment flag
760 , bool TF // Transpose flag
761 , size_t... CSAs > // Compile time subvector arguments
762inline typename Subvector<VT,AF,TF,false,CSAs...>::ConstIterator
764{
765 if( offset() == 0UL )
766 return ConstIterator( vector_.cbegin(), offset() );
767 else
768 return ConstIterator( vector_.lowerBound( offset() ), offset() );
769}
771//*************************************************************************************************
772
773
774//*************************************************************************************************
782template< typename VT // Type of the sparse vector
783 , AlignmentFlag AF // Alignment flag
784 , bool TF // Transpose flag
785 , size_t... CSAs > // Compile time subvector arguments
786inline typename Subvector<VT,AF,TF,false,CSAs...>::ConstIterator
788{
789 if( offset() == 0UL )
790 return ConstIterator( vector_.cbegin(), offset() );
791 else
792 return ConstIterator( vector_.lowerBound( offset() ), offset() );
793}
795//*************************************************************************************************
796
797
798//*************************************************************************************************
806template< typename VT // Type of the sparse vector
807 , AlignmentFlag AF // Alignment flag
808 , bool TF // Transpose flag
809 , size_t... CSAs > // Compile time subvector arguments
810inline typename Subvector<VT,AF,TF,false,CSAs...>::Iterator
812{
813 if( offset() + size() == vector_.size() )
814 return Iterator( vector_.end(), offset() );
815 else
816 return Iterator( vector_.lowerBound( offset() + size() ), offset() );
817}
819//*************************************************************************************************
820
821
822//*************************************************************************************************
830template< typename VT // Type of the sparse vector
831 , AlignmentFlag AF // Alignment flag
832 , bool TF // Transpose flag
833 , size_t... CSAs > // Compile time subvector arguments
834inline typename Subvector<VT,AF,TF,false,CSAs...>::ConstIterator
836{
837 if( offset() + size() == vector_.size() )
838 return ConstIterator( vector_.cend(), offset() );
839 else
840 return ConstIterator( vector_.lowerBound( offset() + size() ), offset() );
841}
843//*************************************************************************************************
844
845
846//*************************************************************************************************
854template< typename VT // Type of the sparse vector
855 , AlignmentFlag AF // Alignment flag
856 , bool TF // Transpose flag
857 , size_t... CSAs > // Compile time subvector arguments
858inline typename Subvector<VT,AF,TF,false,CSAs...>::ConstIterator
860{
861 if( offset() + size() == vector_.size() )
862 return ConstIterator( vector_.cend(), offset() );
863 else
864 return ConstIterator( vector_.lowerBound( offset() + size() ), offset() );
865}
867//*************************************************************************************************
868
869
870
871
872//=================================================================================================
873//
874// ASSIGNMENT OPERATORS
875//
876//=================================================================================================
877
878//*************************************************************************************************
893template< typename VT // Type of the sparse vector
894 , AlignmentFlag AF // Alignment flag
895 , bool TF // Transpose flag
896 , size_t... CSAs > // Compile time subvector arguments
897inline Subvector<VT,AF,TF,false,CSAs...>&
898 Subvector<VT,AF,TF,false,CSAs...>::operator=( initializer_list<ElementType> list )
899{
900 using blaze::assign;
901
902 if( list.size() > size() ) {
903 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to subvector" );
904 }
905
906 const InitializerVector<ElementType,TF> tmp( list, size() );
907
908 if( !tryAssign( vector_, tmp, offset() ) ) {
909 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
910 }
911
912 decltype(auto) left( derestrict( *this ) );
913
914 reset();
915 assign( left, tmp );
916
917 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
918
919 return *this;
920}
922//*************************************************************************************************
923
924
925//*************************************************************************************************
937template< typename VT // Type of the sparse vector
938 , AlignmentFlag AF // Alignment flag
939 , bool TF // Transpose flag
940 , size_t... CSAs > // Compile time subvector arguments
941inline Subvector<VT,AF,TF,false,CSAs...>&
942 Subvector<VT,AF,TF,false,CSAs...>::operator=( const Subvector& rhs )
943{
944 using blaze::assign;
945
948
949 if( this == &rhs || ( &vector_ == &rhs.vector_ && offset() == rhs.offset() ) )
950 return *this;
951
952 if( size() != rhs.size() ) {
953 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
954 }
955
956 if( !tryAssign( vector_, rhs, offset() ) ) {
957 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
958 }
959
960 decltype(auto) left( derestrict( *this ) );
961
962 if( rhs.canAlias( this ) ) {
963 const ResultType tmp( rhs );
964 reset();
965 assign( left, tmp );
966 }
967 else {
968 reset();
969 assign( left, rhs );
970 }
971
972 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
973
974 return *this;
975}
977//*************************************************************************************************
978
979
980//*************************************************************************************************
992template< typename VT // Type of the sparse vector
993 , AlignmentFlag AF // Alignment flag
994 , bool TF // Transpose flag
995 , size_t... CSAs > // Compile time subvector arguments
996template< typename VT2 > // Type of the right-hand side vector
997inline Subvector<VT,AF,TF,false,CSAs...>&
998 Subvector<VT,AF,TF,false,CSAs...>::operator=( const Vector<VT2,TF>& rhs )
999{
1000 using blaze::assign;
1001
1004
1005 if( size() != (*rhs).size() ) {
1006 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1007 }
1008
1009 using Right = If_t< IsRestricted_v<VT>, CompositeType_t<VT2>, const VT2& >;
1010 Right right( *rhs );
1011
1012 if( !tryAssign( vector_, right, offset() ) ) {
1013 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1014 }
1015
1016 decltype(auto) left( derestrict( *this ) );
1017
1018 if( IsReference_v<Right> || right.canAlias( this ) ) {
1019 const ResultType_t<VT2> tmp( right );
1020 reset();
1021 assign( left, tmp );
1022 }
1023 else {
1024 reset();
1025 assign( left, right );
1026 }
1027
1028 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1029
1030 return *this;
1031}
1033//*************************************************************************************************
1034
1035
1036//*************************************************************************************************
1048template< typename VT // Type of the sparse vector
1049 , AlignmentFlag AF // Alignment flag
1050 , bool TF // Transpose flag
1051 , size_t... CSAs > // Compile time subvector arguments
1052template< typename VT2 > // Type of the right-hand side vector
1053inline Subvector<VT,AF,TF,false,CSAs...>&
1054 Subvector<VT,AF,TF,false,CSAs...>::operator+=( const Vector<VT2,TF>& rhs )
1055{
1056 using blaze::assign;
1057
1061
1062 using AddType = AddTrait_t< ResultType, ResultType_t<VT2> >;
1063
1066
1067 if( size() != (*rhs).size() ) {
1068 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1069 }
1070
1071 const AddType tmp( *this + (*rhs) );
1072
1073 if( !tryAssign( vector_, tmp, offset() ) ) {
1074 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1075 }
1076
1077 decltype(auto) left( derestrict( *this ) );
1078
1079 left.reset();
1080 assign( left, tmp );
1081
1082 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1083
1084 return *this;
1085}
1087//*************************************************************************************************
1088
1089
1090//*************************************************************************************************
1102template< typename VT // Type of the sparse vector
1103 , AlignmentFlag AF // Alignment flag
1104 , bool TF // Transpose flag
1105 , size_t... CSAs > // Compile time subvector arguments
1106template< typename VT2 > // Type of the right-hand side vector
1107inline Subvector<VT,AF,TF,false,CSAs...>&
1108 Subvector<VT,AF,TF,false,CSAs...>::operator-=( const Vector<VT2,TF>& rhs )
1109{
1110 using blaze::assign;
1111
1115
1116 using SubType = SubTrait_t< ResultType, ResultType_t<VT2> >;
1117
1120
1121 if( size() != (*rhs).size() ) {
1122 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1123 }
1124
1125 const SubType tmp( *this - (*rhs) );
1126
1127 if( !tryAssign( vector_, tmp, offset() ) ) {
1128 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1129 }
1130
1131 decltype(auto) left( derestrict( *this ) );
1132
1133 left.reset();
1134 assign( left, tmp );
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 , AlignmentFlag AF // Alignment flag
1159 , bool TF // Transpose flag
1160 , size_t... CSAs > // Compile time subvector arguments
1161template< typename VT2 > // Type of the right-hand side vector
1162inline Subvector<VT,AF,TF,false,CSAs...>&
1163 Subvector<VT,AF,TF,false,CSAs...>::operator*=( const Vector<VT2,TF>& rhs )
1164{
1165 using blaze::assign;
1166
1170
1171 using MultType = MultTrait_t< ResultType, ResultType_t<VT2> >;
1172
1175
1176 if( size() != (*rhs).size() ) {
1177 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1178 }
1179
1180 const MultType tmp( *this * (*rhs) );
1181
1182 if( !tryAssign( vector_, tmp, offset() ) ) {
1183 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1184 }
1185
1186 decltype(auto) left( derestrict( *this ) );
1187
1188 left.reset();
1189 assign( left, tmp );
1190
1191 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1192
1193 return *this;
1194}
1196//*************************************************************************************************
1197
1198
1199//*************************************************************************************************
1211template< typename VT // Type of the sparse vector
1212 , AlignmentFlag AF // Alignment flag
1213 , bool TF // Transpose flag
1214 , size_t... CSAs > // Compile time subvector arguments
1215template< typename VT2 > // Type of the right-hand side dense vector
1216inline Subvector<VT,AF,TF,false,CSAs...>&
1217 Subvector<VT,AF,TF,false,CSAs...>::operator/=( const DenseVector<VT2,TF>& rhs )
1218{
1219 using blaze::assign;
1220
1223 BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_t<VT2> );
1225
1226 using DivType = DivTrait_t< ResultType, ResultType_t<VT2> >;
1227
1231
1232 if( size() != (*rhs).size() ) {
1233 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1234 }
1235
1236 const DivType tmp( *this / (*rhs) );
1237
1238 if( !tryAssign( vector_, tmp, offset() ) ) {
1239 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1240 }
1241
1242 decltype(auto) left( derestrict( *this ) );
1243
1244 left.reset();
1245 assign( left, tmp );
1246
1247 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1248
1249 return *this;
1250}
1252//*************************************************************************************************
1253
1254
1255//*************************************************************************************************
1268template< typename VT // Type of the sparse vector
1269 , AlignmentFlag AF // Alignment flag
1270 , bool TF // Transpose flag
1271 , size_t... CSAs > // Compile time subvector arguments
1272template< typename VT2 > // Type of the right-hand side vector
1273inline Subvector<VT,AF,TF,false,CSAs...>&
1274 Subvector<VT,AF,TF,false,CSAs...>::operator%=( const Vector<VT2,TF>& rhs )
1275{
1276 using blaze::assign;
1277
1280
1281 using CrossType = CrossTrait_t< ResultType, ResultType_t<VT2> >;
1282
1286
1287 if( size() != 3UL || (*rhs).size() != 3UL ) {
1288 BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
1289 }
1290
1291 const CrossType tmp( *this % (*rhs) );
1292
1293 if( !tryAssign( vector_, tmp, offset() ) ) {
1294 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1295 }
1296
1297 decltype(auto) left( derestrict( *this ) );
1298
1299 left.reset();
1300 assign( left, tmp );
1301
1302 BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1303
1304 return *this;
1305}
1307//*************************************************************************************************
1308
1309
1310
1311
1312//=================================================================================================
1313//
1314// UTILITY FUNCTIONS
1315//
1316//=================================================================================================
1317
1318//*************************************************************************************************
1324template< typename VT // Type of the sparse vector
1325 , AlignmentFlag AF // Alignment flag
1326 , bool TF // Transpose flag
1327 , size_t... CSAs > // Compile time subvector arguments
1328inline VT& Subvector<VT,AF,TF,false,CSAs...>::operand() noexcept
1329{
1330 return vector_;
1331}
1333//*************************************************************************************************
1334
1335
1336//*************************************************************************************************
1342template< typename VT // Type of the sparse vector
1343 , AlignmentFlag AF // Alignment flag
1344 , bool TF // Transpose flag
1345 , size_t... CSAs > // Compile time subvector arguments
1346inline const VT& Subvector<VT,AF,TF,false,CSAs...>::operand() const noexcept
1347{
1348 return vector_;
1349}
1351//*************************************************************************************************
1352
1353
1354//*************************************************************************************************
1360template< typename VT // Type of the sparse vector
1361 , AlignmentFlag AF // Alignment flag
1362 , bool TF // Transpose flag
1363 , size_t... CSAs > // Compile time subvector arguments
1364inline size_t Subvector<VT,AF,TF,false,CSAs...>::capacity() const noexcept
1365{
1366 return nonZeros() + vector_.capacity() - vector_.nonZeros();
1367}
1369//*************************************************************************************************
1370
1371
1372//*************************************************************************************************
1380template< typename VT // Type of the sparse vector
1381 , AlignmentFlag AF // Alignment flag
1382 , bool TF // Transpose flag
1383 , size_t... CSAs > // Compile time subvector arguments
1385{
1386 return end() - begin();
1387}
1389//*************************************************************************************************
1390
1391
1392//*************************************************************************************************
1398template< typename VT // Type of the sparse vector
1399 , AlignmentFlag AF // Alignment flag
1400 , bool TF // Transpose flag
1401 , size_t... CSAs > // Compile time subvector arguments
1403{
1404 vector_.erase( vector_.lowerBound( offset() ), vector_.lowerBound( offset() + size() ) );
1405}
1407//*************************************************************************************************
1408
1409
1410//*************************************************************************************************
1420template< typename VT // Type of the sparse vector
1421 , AlignmentFlag AF // Alignment flag
1422 , bool TF // Transpose flag
1423 , size_t... CSAs > // Compile time subvector arguments
1424void Subvector<VT,AF,TF,false,CSAs...>::reserve( size_t n )
1425{
1426 const size_t current( capacity() );
1427
1428 if( n > current ) {
1429 vector_.reserve( vector_.capacity() + n - current );
1430 }
1431}
1433//*************************************************************************************************
1434
1435
1436
1437
1438//=================================================================================================
1439//
1440// INSERTION FUNCTIONS
1441//
1442//=================================================================================================
1443
1444//*************************************************************************************************
1456template< typename VT // Type of the sparse vector
1457 , AlignmentFlag AF // Alignment flag
1458 , bool TF // Transpose flag
1459 , size_t... CSAs > // Compile time subvector arguments
1460inline typename Subvector<VT,AF,TF,false,CSAs...>::Iterator
1461 Subvector<VT,AF,TF,false,CSAs...>::set( size_t index, const ElementType& value )
1462{
1463 return Iterator( vector_.set( offset() + index, value ), offset() );
1464}
1466//*************************************************************************************************
1467
1468
1469//*************************************************************************************************
1482template< typename VT // Type of the sparse vector
1483 , AlignmentFlag AF // Alignment flag
1484 , bool TF // Transpose flag
1485 , size_t... CSAs > // Compile time subvector arguments
1486inline typename Subvector<VT,AF,TF,false,CSAs...>::Iterator
1487 Subvector<VT,AF,TF,false,CSAs...>::insert( size_t index, const ElementType& value )
1488{
1489 return Iterator( vector_.insert( offset() + index, value ), offset() );
1490}
1492//*************************************************************************************************
1493
1494
1495//*************************************************************************************************
1520template< typename VT // Type of the sparse vector
1521 , AlignmentFlag AF // Alignment flag
1522 , bool TF // Transpose flag
1523 , size_t... CSAs > // Compile time subvector arguments
1524inline void Subvector<VT,AF,TF,false,CSAs...>::append( size_t index, const ElementType& value, bool check )
1525{
1526 if( offset() + size() == vector_.size() )
1527 vector_.append( offset() + index, value, check );
1528 else if( !check || !isDefault<strict>( value ) )
1529 vector_.insert( offset() + index, value );
1530}
1532//*************************************************************************************************
1533
1534
1535
1536
1537//=================================================================================================
1538//
1539// ERASE FUNCTIONS
1540//
1541//=================================================================================================
1542
1543//*************************************************************************************************
1552template< typename VT // Type of the sparse vector
1553 , AlignmentFlag AF // Alignment flag
1554 , bool TF // Transpose flag
1555 , size_t... CSAs > // Compile time subvector arguments
1556inline void Subvector<VT,AF,TF,false,CSAs...>::erase( size_t index )
1557{
1558 vector_.erase( offset() + index );
1559}
1561//*************************************************************************************************
1562
1563
1564//*************************************************************************************************
1573template< typename VT // Type of the sparse vector
1574 , AlignmentFlag AF // Alignment flag
1575 , bool TF // Transpose flag
1576 , size_t... CSAs > // Compile time subvector arguments
1577inline typename Subvector<VT,AF,TF,false,CSAs...>::Iterator
1578 Subvector<VT,AF,TF,false,CSAs...>::erase( Iterator pos )
1579{
1580 return Iterator( vector_.erase( pos.base() ), offset() );
1581}
1583//*************************************************************************************************
1584
1585
1586//*************************************************************************************************
1596template< typename VT // Type of the sparse vector
1597 , AlignmentFlag AF // Alignment flag
1598 , bool TF // Transpose flag
1599 , size_t... CSAs > // Compile time subvector arguments
1600inline typename Subvector<VT,AF,TF,false,CSAs...>::Iterator
1601 Subvector<VT,AF,TF,false,CSAs...>::erase( Iterator first, Iterator last )
1602{
1603 return Iterator( vector_.erase( first.base(), last.base() ), offset() );
1604}
1606//*************************************************************************************************
1607
1608
1609//*************************************************************************************************
1632template< typename VT // Type of the sparse vector
1633 , AlignmentFlag AF // Alignment flag
1634 , bool TF // Transpose flag
1635 , size_t... CSAs > // Compile time subvector arguments
1636template< typename Pred // Type of the unary predicate
1637 , typename > // Type restriction on the unary predicate
1638inline void Subvector<VT,AF,TF,false,CSAs...>::erase( Pred predicate )
1639{
1640 vector_.erase( begin().base(), end().base(), predicate );
1641}
1643//*************************************************************************************************
1644
1645
1646//*************************************************************************************************
1672template< typename VT // Type of the sparse vector
1673 , AlignmentFlag AF // Alignment flag
1674 , bool TF // Transpose flag
1675 , size_t... CSAs > // Compile time subvector arguments
1676template< typename Pred > // Type of the unary predicate
1677inline void Subvector<VT,AF,TF,false,CSAs...>::erase( Iterator first, Iterator last, Pred predicate )
1678{
1679 vector_.erase( first.base(), last.base(), predicate );
1680}
1682//*************************************************************************************************
1683
1684
1685
1686
1687//=================================================================================================
1688//
1689// LOOKUP FUNCTIONS
1690//
1691//=================================================================================================
1692
1693//*************************************************************************************************
1707template< typename VT // Type of the sparse vector
1708 , AlignmentFlag AF // Alignment flag
1709 , bool TF // Transpose flag
1710 , size_t... CSAs > // Compile time subvector arguments
1711inline typename Subvector<VT,AF,TF,false,CSAs...>::Iterator
1713{
1714 const Iterator_t<VT> pos( vector_.find( offset() + index ) );
1715
1716 if( pos != vector_.end() )
1717 return Iterator( pos, offset() );
1718 else
1719 return end();
1720}
1722//*************************************************************************************************
1723
1724
1725//*************************************************************************************************
1739template< typename VT // Type of the sparse vector
1740 , AlignmentFlag AF // Alignment flag
1741 , bool TF // Transpose flag
1742 , size_t... CSAs > // Compile time subvector arguments
1743inline typename Subvector<VT,AF,TF,false,CSAs...>::ConstIterator
1744 Subvector<VT,AF,TF,false,CSAs...>::find( size_t index ) const
1745{
1746 const ConstIterator_t<VT> pos( vector_.find( offset() + index ) );
1747
1748 if( pos != vector_.end() )
1749 return Iterator( pos, offset() );
1750 else
1751 return end();
1752}
1754//*************************************************************************************************
1755
1756
1757//*************************************************************************************************
1770template< typename VT // Type of the sparse vector
1771 , AlignmentFlag AF // Alignment flag
1772 , bool TF // Transpose flag
1773 , size_t... CSAs > // Compile time subvector arguments
1774inline typename Subvector<VT,AF,TF,false,CSAs...>::Iterator
1776{
1777 return Iterator( vector_.lowerBound( offset() + index ), offset() );
1778}
1780//*************************************************************************************************
1781
1782
1783//*************************************************************************************************
1796template< typename VT // Type of the sparse vector
1797 , AlignmentFlag AF // Alignment flag
1798 , bool TF // Transpose flag
1799 , size_t... CSAs > // Compile time subvector arguments
1800inline typename Subvector<VT,AF,TF,false,CSAs...>::ConstIterator
1802{
1803 return ConstIterator( vector_.lowerBound( offset() + index ), offset() );
1804}
1806//*************************************************************************************************
1807
1808
1809//*************************************************************************************************
1822template< typename VT // Type of the sparse vector
1823 , AlignmentFlag AF // Alignment flag
1824 , bool TF // Transpose flag
1825 , size_t... CSAs > // Compile time subvector arguments
1826inline typename Subvector<VT,AF,TF,false,CSAs...>::Iterator
1828{
1829 return Iterator( vector_.upperBound( offset() + index ), offset() );
1830}
1832//*************************************************************************************************
1833
1834
1835//*************************************************************************************************
1848template< typename VT // Type of the sparse vector
1849 , AlignmentFlag AF // Alignment flag
1850 , bool TF // Transpose flag
1851 , size_t... CSAs > // Compile time subvector arguments
1852inline typename Subvector<VT,AF,TF,false,CSAs...>::ConstIterator
1854{
1855 return ConstIterator( vector_.upperBound( offset() + index ), offset() );
1856}
1858//*************************************************************************************************
1859
1860
1861
1862
1863//=================================================================================================
1864//
1865// NUMERIC FUNCTIONS
1866//
1867//=================================================================================================
1868
1869//*************************************************************************************************
1880template< typename VT // Type of the sparse vector
1881 , AlignmentFlag AF // Alignment flag
1882 , bool TF // Transpose flag
1883 , size_t... CSAs > // Compile time subvector arguments
1884template< typename Other > // Data type of the scalar value
1885inline Subvector<VT,AF,TF,false,CSAs...>&
1886 Subvector<VT,AF,TF,false,CSAs...>::scale( const Other& scalar )
1887{
1888 for( Iterator element=begin(); element!=end(); ++element )
1889 element->value() *= scalar;
1890 return *this;
1891}
1893//*************************************************************************************************
1894
1895
1896
1897
1898//=================================================================================================
1899//
1900// EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1901//
1902//=================================================================================================
1903
1904//*************************************************************************************************
1915template< typename VT // Type of the sparse vector
1916 , AlignmentFlag AF // Alignment flag
1917 , bool TF // Transpose flag
1918 , size_t... CSAs > // Compile time subvector arguments
1919template< typename Other > // Data type of the foreign expression
1920inline bool Subvector<VT,AF,TF,false,CSAs...>::canAlias( const Other* alias ) const noexcept
1921{
1922 return vector_.isAliased( &unview( *alias ) );
1923}
1925//*************************************************************************************************
1926
1927
1928//*************************************************************************************************
1939template< typename VT // Type of the sparse vector
1940 , AlignmentFlag AF // Alignment flag
1941 , bool TF // Transpose flag
1942 , size_t... CSAs > // Compile time subvector arguments
1943template< typename Other > // Data type of the foreign expression
1944inline bool Subvector<VT,AF,TF,false,CSAs...>::isAliased( const Other* alias ) const noexcept
1945{
1946 return vector_.isAliased( &unview( *alias ) );
1947}
1949//*************************************************************************************************
1950
1951
1952//*************************************************************************************************
1963template< typename VT // Type of the sparse vector
1964 , AlignmentFlag AF // Alignment flag
1965 , bool TF // Transpose flag
1966 , size_t... CSAs > // Compile time subvector arguments
1967inline bool Subvector<VT,AF,TF,false,CSAs...>::canSMPAssign() const noexcept
1968{
1969 return false;
1970}
1972//*************************************************************************************************
1973
1974
1975//*************************************************************************************************
1987template< typename VT // Type of the sparse vector
1988 , AlignmentFlag AF // Alignment flag
1989 , bool TF // Transpose flag
1990 , size_t... CSAs > // Compile time subvector arguments
1991template< typename VT2 > // Type of the right-hand side dense vector
1992inline void Subvector<VT,AF,TF,false,CSAs...>::assign( const DenseVector<VT2,TF>& rhs )
1993{
1994 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
1995 BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1996
1997 reserve( (*rhs).size() );
1998
1999 for( size_t i=0UL; i<size(); ++i ) {
2000 append( i, (*rhs)[i], true );
2001 }
2002}
2004//*************************************************************************************************
2005
2006
2007//*************************************************************************************************
2019template< typename VT // Type of the sparse vector
2020 , AlignmentFlag AF // Alignment flag
2021 , bool TF // Transpose flag
2022 , size_t... CSAs > // Compile time subvector arguments
2023template< typename VT2 > // Type of the right-hand side sparse vector
2024inline void Subvector<VT,AF,TF,false,CSAs...>::assign( const SparseVector<VT2,TF>& rhs )
2025{
2026 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
2027 BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
2028
2029 reserve( (*rhs).nonZeros() );
2030
2031 for( ConstIterator_t<VT2> element=(*rhs).begin(); element!=(*rhs).end(); ++element ) {
2032 append( element->index(), element->value(), true );
2033 }
2034}
2036//*************************************************************************************************
2037
2038
2039//*************************************************************************************************
2051template< typename VT // Type of the sparse vector
2052 , AlignmentFlag AF // Alignment flag
2053 , bool TF // Transpose flag
2054 , size_t... CSAs > // Compile time subvector arguments
2055template< typename VT2 > // Type of the right-hand side dense vector
2056inline void Subvector<VT,AF,TF,false,CSAs...>::addAssign( const DenseVector<VT2,TF>& rhs )
2057{
2058 using AddType = AddTrait_t< ResultType, ResultType_t<VT2> >;
2059
2063
2064 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
2065
2066 const AddType tmp( serial( *this + (*rhs) ) );
2067 reset();
2068 assign( tmp );
2069}
2071//*************************************************************************************************
2072
2073
2074//*************************************************************************************************
2086template< typename VT // Type of the sparse vector
2087 , AlignmentFlag AF // Alignment flag
2088 , bool TF // Transpose flag
2089 , size_t... CSAs > // Compile time subvector arguments
2090template< typename VT2 > // Type of the right-hand side sparse vector
2091inline void Subvector<VT,AF,TF,false,CSAs...>::addAssign( const SparseVector<VT2,TF>& rhs )
2092{
2093 using AddType = AddTrait_t< ResultType, ResultType_t<VT2> >;
2094
2098
2099 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
2100
2101 const AddType tmp( serial( *this + (*rhs) ) );
2102 reset();
2103 assign( tmp );
2104}
2106//*************************************************************************************************
2107
2108
2109//*************************************************************************************************
2121template< typename VT // Type of the sparse vector
2122 , AlignmentFlag AF // Alignment flag
2123 , bool TF // Transpose flag
2124 , size_t... CSAs > // Compile time subvector arguments
2125template< typename VT2 > // Type of the right-hand side dense vector
2126inline void Subvector<VT,AF,TF,false,CSAs...>::subAssign( const DenseVector<VT2,TF>& rhs )
2127{
2128 using SubType = SubTrait_t< ResultType, ResultType_t<VT2> >;
2129
2133
2134 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
2135
2136 const SubType tmp( serial( *this - (*rhs) ) );
2137 reset();
2138 assign( tmp );
2139}
2141//*************************************************************************************************
2142
2143
2144//*************************************************************************************************
2156template< typename VT // Type of the sparse vector
2157 , AlignmentFlag AF // Alignment flag
2158 , bool TF // Transpose flag
2159 , size_t... CSAs > // Compile time subvector arguments
2160template< typename VT2 > // Type of the right-hand side sparse vector
2161inline void Subvector<VT,AF,TF,false,CSAs...>::subAssign( const SparseVector<VT2,TF>& rhs )
2162{
2163 using SubType = SubTrait_t< ResultType, ResultType_t<VT2> >;
2164
2168
2169 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
2170
2171 const SubType tmp( serial( *this - (*rhs) ) );
2172 reset();
2173 assign( tmp );
2174}
2176//*************************************************************************************************
2177
2178} // namespace blaze
2179
2180#endif
Header file for the addition trait.
Header file for auxiliary alias declarations.
Header file for the alignment flag enumeration.
Header file for run time assertion macros.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the 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 EnableIf class template.
Header file for the If class template.
Header file for the IsConst type trait.
Header file for the isDefault shim.
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.
Header file for the implementation of the SubvectorData class template.
Header file for the subvector 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.
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
#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_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
typename SubvectorTrait< VT, CSAs... >::Type SubvectorTrait_t
Auxiliary alias declaration for the SubvectorTrait type trait.
Definition: SubvectorTrait.h:145
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
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.
Definition: AlignmentFlag.h:63
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 the serial shim.
Header file for the SparseElement base class.
Header file for basic type definitions.
Header file for the implementation of the Subvector base template.