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>
53 #include <blaze/math/Exception.h>
68 #include <blaze/util/Assert.h>
69 #include <blaze/util/DisableIf.h>
70 #include <blaze/util/EnableIf.h>
71 #include <blaze/util/mpl/If.h>
72 #include <blaze/util/Types.h>
79 
80 
81 namespace blaze {
82 
83 //=================================================================================================
84 //
85 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE SUBVECTORS
86 //
87 //=================================================================================================
88 
89 //*************************************************************************************************
97 template< typename VT // Type of the sparse vector
98  , bool AF // Alignment flag
99  , bool TF > // Transpose flag
100 class Subvector<VT,AF,TF,false>
101  : public View< SparseVector< Subvector<VT,AF,TF,false>, TF > >
102 {
103  private:
104  //**Type definitions****************************************************************************
106  using Operand = If_< IsExpression<VT>, VT, VT& >;
107  //**********************************************************************************************
108 
109  public:
110  //**Type definitions****************************************************************************
111  using This = Subvector<VT,AF,TF,false>;
112  using BaseType = SparseVector<This,TF>;
113  using ResultType = SubvectorTrait_<VT>;
114  using TransposeType = TransposeType_<ResultType>;
115  using ElementType = ElementType_<VT>;
116  using ReturnType = ReturnType_<VT>;
117  using CompositeType = const Subvector&;
118 
120  using ConstReference = ConstReference_<VT>;
121 
123  using Reference = If_< IsConst<VT>, ConstReference, Reference_<VT> >;
124  //**********************************************************************************************
125 
126  //**SubvectorElement class definition***********************************************************
129  template< typename VectorType // Type of the sparse vector
130  , typename IteratorType > // Type of the sparse vector iterator
131  class SubvectorElement
132  : private SparseElement
133  {
134  public:
135  //**Constructor******************************************************************************
141  inline SubvectorElement( IteratorType pos, size_t offset )
142  : pos_ ( pos ) // Iterator to the current position within the sparse subvector
143  , offset_( offset ) // Offset within the according sparse vector
144  {}
145  //*******************************************************************************************
146 
147  //**Assignment operator**********************************************************************
153  template< typename T > inline SubvectorElement& operator=( const T& v ) {
154  *pos_ = v;
155  return *this;
156  }
157  //*******************************************************************************************
158 
159  //**Addition assignment operator*************************************************************
165  template< typename T > inline SubvectorElement& operator+=( const T& v ) {
166  *pos_ += v;
167  return *this;
168  }
169  //*******************************************************************************************
170 
171  //**Subtraction assignment operator**********************************************************
177  template< typename T > inline SubvectorElement& operator-=( const T& v ) {
178  *pos_ -= v;
179  return *this;
180  }
181  //*******************************************************************************************
182 
183  //**Multiplication assignment operator*******************************************************
189  template< typename T > inline SubvectorElement& operator*=( const T& v ) {
190  *pos_ *= v;
191  return *this;
192  }
193  //*******************************************************************************************
194 
195  //**Division assignment operator*************************************************************
201  template< typename T > inline SubvectorElement& operator/=( const T& v ) {
202  *pos_ /= v;
203  return *this;
204  }
205  //*******************************************************************************************
206 
207  //**Element access operator******************************************************************
212  inline const SubvectorElement* operator->() const {
213  return this;
214  }
215  //*******************************************************************************************
216 
217  //**Value function***************************************************************************
222  inline decltype(auto) value() const {
223  return pos_->value();
224  }
225  //*******************************************************************************************
226 
227  //**Index function***************************************************************************
232  inline size_t index() const {
233  return pos_->index() - offset_;
234  }
235  //*******************************************************************************************
236 
237  private:
238  //**Member variables*************************************************************************
239  IteratorType pos_;
240  size_t offset_;
241  //*******************************************************************************************
242  };
243  //**********************************************************************************************
244 
245  //**SubvectorIterator class definition**********************************************************
248  template< typename VectorType // Type of the sparse vector
249  , typename IteratorType > // Type of the sparse vector iterator
250  class SubvectorIterator
251  {
252  public:
253  //**Type definitions*************************************************************************
254  using IteratorCategory = std::forward_iterator_tag;
255  using ValueType = SubvectorElement<VectorType,IteratorType>;
256  using PointerType = ValueType;
257  using ReferenceType = ValueType;
258  using DifferenceType = ptrdiff_t;
259 
260  // STL iterator requirements
261  using iterator_category = IteratorCategory;
262  using value_type = ValueType;
263  using pointer = PointerType;
264  using reference = ReferenceType;
265  using difference_type = DifferenceType;
266  //*******************************************************************************************
267 
268  //**Default constructor**********************************************************************
271  inline SubvectorIterator()
272  : pos_ () // Iterator to the current sparse element
273  , offset_() // The offset of the subvector within the sparse vector
274  {}
275  //*******************************************************************************************
276 
277  //**Constructor******************************************************************************
283  inline SubvectorIterator( IteratorType iterator, size_t index )
284  : pos_ ( iterator ) // Iterator to the current sparse element
285  , offset_( index ) // The offset of the subvector within the sparse vector
286  {}
287  //*******************************************************************************************
288 
289  //**Constructor******************************************************************************
294  template< typename VectorType2, typename IteratorType2 >
295  inline SubvectorIterator( const SubvectorIterator<VectorType2,IteratorType2>& it )
296  : pos_ ( it.base() ) // Iterator to the current sparse element.
297  , offset_( it.offset() ) // The offset of the subvector within the sparse vector
298  {}
299  //*******************************************************************************************
300 
301  //**Prefix increment operator****************************************************************
306  inline SubvectorIterator& operator++() {
307  ++pos_;
308  return *this;
309  }
310  //*******************************************************************************************
311 
312  //**Postfix increment operator***************************************************************
317  inline const SubvectorIterator operator++( int ) {
318  const SubvectorIterator tmp( *this );
319  ++(*this);
320  return tmp;
321  }
322  //*******************************************************************************************
323 
324  //**Element access operator******************************************************************
329  inline ReferenceType operator*() const {
330  return ReferenceType( pos_, offset_ );
331  }
332  //*******************************************************************************************
333 
334  //**Element access operator******************************************************************
339  inline PointerType operator->() const {
340  return PointerType( pos_, offset_ );
341  }
342  //*******************************************************************************************
343 
344  //**Equality operator************************************************************************
350  template< typename VectorType2, typename IteratorType2 >
351  inline bool operator==( const SubvectorIterator<VectorType2,IteratorType2>& rhs ) const {
352  return base() == rhs.base();
353  }
354  //*******************************************************************************************
355 
356  //**Inequality operator**********************************************************************
362  template< typename VectorType2, typename IteratorType2 >
363  inline bool operator!=( const SubvectorIterator<VectorType2,IteratorType2>& rhs ) const {
364  return !( *this == rhs );
365  }
366  //*******************************************************************************************
367 
368  //**Subtraction operator*********************************************************************
374  inline DifferenceType operator-( const SubvectorIterator& rhs ) const {
375  return pos_ - rhs.pos_;
376  }
377  //*******************************************************************************************
378 
379  //**Base function****************************************************************************
384  inline IteratorType base() const {
385  return pos_;
386  }
387  //*******************************************************************************************
388 
389  //**Offset function**************************************************************************
394  inline size_t offset() const noexcept {
395  return offset_;
396  }
397  //*******************************************************************************************
398 
399  private:
400  //**Member variables*************************************************************************
401  IteratorType pos_;
402  size_t offset_;
403  //*******************************************************************************************
404  };
405  //**********************************************************************************************
406 
407  //**Type definitions****************************************************************************
409  using ConstIterator = SubvectorIterator< const VT, ConstIterator_<VT> >;
410 
412  using Iterator = If_< IsConst<VT>, ConstIterator, SubvectorIterator< VT, Iterator_<VT> > >;
413  //**********************************************************************************************
414 
415  //**Compilation flags***************************************************************************
417  enum : bool { smpAssignable = VT::smpAssignable };
418  //**********************************************************************************************
419 
420  //**Constructors********************************************************************************
423  explicit inline Subvector( Operand vector, size_t index, size_t n );
424  // No explicitly declared copy constructor.
426  //**********************************************************************************************
427 
428  //**Destructor**********************************************************************************
429  // No explicitly declared destructor.
430  //**********************************************************************************************
431 
432  //**Data access functions***********************************************************************
435  inline Reference operator[]( size_t index );
436  inline ConstReference operator[]( size_t index ) const;
437  inline Reference at( size_t index );
438  inline ConstReference at( size_t index ) const;
439  inline Iterator begin ();
440  inline ConstIterator begin () const;
441  inline ConstIterator cbegin() const;
442  inline Iterator end ();
443  inline ConstIterator end () const;
444  inline ConstIterator cend () const;
446  //**********************************************************************************************
447 
448  //**Assignment operators************************************************************************
451  inline Subvector& operator= ( const Subvector& rhs );
452  template< typename VT2 > inline Subvector& operator= ( const Vector<VT2,TF>& rhs );
453  template< typename VT2 > inline Subvector& operator+=( const Vector<VT2,TF>& rhs );
454  template< typename VT2 > inline Subvector& operator-=( const Vector<VT2,TF>& rhs );
455  template< typename VT2 > inline Subvector& operator*=( const Vector<VT2,TF>& rhs );
456  template< typename VT2 > inline Subvector& operator/=( const DenseVector<VT2,TF>& rhs );
457  template< typename VT2 > inline Subvector& operator%=( const Vector<VT2,TF>& rhs );
458 
459  template< typename Other >
460  inline EnableIf_<IsNumeric<Other>, Subvector >& operator*=( Other rhs );
461 
462  template< typename Other >
463  inline EnableIf_<IsNumeric<Other>, Subvector >& operator/=( Other rhs );
465  //**********************************************************************************************
466 
467  //**Utility functions***************************************************************************
470  inline Operand operand() const noexcept;
471  inline size_t offset() const noexcept;
472  inline size_t size() const noexcept;
473  inline size_t capacity() const noexcept;
474  inline size_t nonZeros() const;
475  inline void reset();
476  inline void reserve( size_t n );
478  //**********************************************************************************************
479 
480  //**Insertion functions*************************************************************************
483  inline Iterator set ( size_t index, const ElementType& value );
484  inline Iterator insert( size_t index, const ElementType& value );
485  inline void append( size_t index, const ElementType& value, bool check=false );
487  //**********************************************************************************************
488 
489  //**Erase functions*****************************************************************************
492  inline void erase( size_t index );
493  inline Iterator erase( Iterator pos );
494  inline Iterator erase( Iterator first, Iterator last );
495 
496  template< typename Pred, typename = DisableIf_< IsIntegral<Pred> > >
497  inline void erase( Pred predicate );
498 
499  template< typename Pred >
500  inline void erase( Iterator first, Iterator last, Pred predicate );
502  //**********************************************************************************************
503 
504  //**Lookup functions****************************************************************************
507  inline Iterator find ( size_t index );
508  inline ConstIterator find ( size_t index ) const;
509  inline Iterator lowerBound( size_t index );
510  inline ConstIterator lowerBound( size_t index ) const;
511  inline Iterator upperBound( size_t index );
512  inline ConstIterator upperBound( size_t index ) const;
514  //**********************************************************************************************
515 
516  //**Numeric functions***************************************************************************
519  template< typename Other > inline Subvector& scale( const Other& scalar );
521  //**********************************************************************************************
522 
523  //**Expression template evaluation functions****************************************************
526  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
527  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
528 
529  inline bool canSMPAssign() const noexcept;
530 
531  template< typename VT2 > inline void assign ( const DenseVector <VT2,TF>& rhs );
532  template< typename VT2 > inline void assign ( const SparseVector<VT2,TF>& rhs );
533  template< typename VT2 > inline void addAssign( const DenseVector <VT2,TF>& rhs );
534  template< typename VT2 > inline void addAssign( const SparseVector<VT2,TF>& rhs );
535  template< typename VT2 > inline void subAssign( const DenseVector <VT2,TF>& rhs );
536  template< typename VT2 > inline void subAssign( const SparseVector<VT2,TF>& rhs );
538  //**********************************************************************************************
539 
540  private:
541  //**Member variables****************************************************************************
544  Operand vector_;
545  const size_t offset_;
546  const size_t size_;
547 
548  //**********************************************************************************************
549 
550  //**Compile time checks*************************************************************************
556  //**********************************************************************************************
557 };
559 //*************************************************************************************************
560 
561 
562 
563 
564 //=================================================================================================
565 //
566 // CONSTRUCTOR
567 //
568 //=================================================================================================
569 
570 //*************************************************************************************************
583 template< typename VT // Type of the sparse vector
584  , bool AF // Alignment flag
585  , bool TF > // Transpose flag
586 inline Subvector<VT,AF,TF,false>::Subvector( Operand vector, size_t index, size_t n )
587  : vector_( vector ) // The sparse vector containing the subvector
588  , offset_( index ) // The offset of the subvector within the sparse vector
589  , size_ ( n ) // The size of the subvector
590 {
591  if( index + n > vector.size() ) {
592  BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
593  }
594 }
596 //*************************************************************************************************
597 
598 
599 
600 
601 //=================================================================================================
602 //
603 // DATA ACCESS FUNCTIONS
604 //
605 //=================================================================================================
606 
607 //*************************************************************************************************
617 template< typename VT // Type of the sparse vector
618  , bool AF // Alignment flag
619  , bool TF > // Transpose flag
621  Subvector<VT,AF,TF,false>::operator[]( size_t index )
622 {
623  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
624  return vector_[offset_+index];
625 }
627 //*************************************************************************************************
628 
629 
630 //*************************************************************************************************
640 template< typename VT // Type of the sparse vector
641  , bool AF // Alignment flag
642  , bool TF > // Transpose flag
644  Subvector<VT,AF,TF,false>::operator[]( size_t index ) const
645 {
646  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
647  return const_cast<const VT&>( vector_ )[offset_+index];
648 }
650 //*************************************************************************************************
651 
652 
653 //*************************************************************************************************
664 template< typename VT // Type of the sparse vector
665  , bool AF // Alignment flag
666  , bool TF > // Transpose flag
668  Subvector<VT,AF,TF,false>::at( size_t index )
669 {
670  if( index >= size() ) {
671  BLAZE_THROW_OUT_OF_RANGE( "Invalid subvector access index" );
672  }
673  return (*this)[index];
674 }
676 //*************************************************************************************************
677 
678 
679 //*************************************************************************************************
690 template< typename VT // Type of the sparse vector
691  , bool AF // Alignment flag
692  , bool TF > // Transpose flag
694  Subvector<VT,AF,TF,false>::at( size_t index ) const
695 {
696  if( index >= size() ) {
697  BLAZE_THROW_OUT_OF_RANGE( "Invalid subvector access index" );
698  }
699  return (*this)[index];
700 }
702 //*************************************************************************************************
703 
704 
705 //*************************************************************************************************
713 template< typename VT // Type of the sparse vector
714  , bool AF // Alignment flag
715  , bool TF > // Transpose flag
717 {
718  if( offset_ == 0UL )
719  return Iterator( vector_.begin(), offset_ );
720  else
721  return Iterator( vector_.lowerBound( offset_ ), offset_ );
722 }
724 //*************************************************************************************************
725 
726 
727 //*************************************************************************************************
735 template< typename VT // Type of the sparse vector
736  , bool AF // Alignment flag
737  , bool TF > // Transpose flag
739 {
740  if( offset_ == 0UL )
741  return ConstIterator( vector_.cbegin(), offset_ );
742  else
743  return ConstIterator( vector_.lowerBound( offset_ ), offset_ );
744 }
746 //*************************************************************************************************
747 
748 
749 //*************************************************************************************************
757 template< typename VT // Type of the sparse vector
758  , bool AF // Alignment flag
759  , bool TF > // Transpose flag
761 {
762  if( offset_ == 0UL )
763  return ConstIterator( vector_.cbegin(), offset_ );
764  else
765  return ConstIterator( vector_.lowerBound( offset_ ), offset_ );
766 }
768 //*************************************************************************************************
769 
770 
771 //*************************************************************************************************
779 template< typename VT // Type of the sparse vector
780  , bool AF // Alignment flag
781  , bool TF > // Transpose flag
783 {
784  if( offset_ + size_ == vector_.size() )
785  return Iterator( vector_.end(), offset_ );
786  else
787  return Iterator( vector_.lowerBound( offset_ + size_ ), offset_ );
788 }
790 //*************************************************************************************************
791 
792 
793 //*************************************************************************************************
801 template< typename VT // Type of the sparse vector
802  , bool AF // Alignment flag
803  , bool TF > // Transpose flag
805 {
806  if( offset_ + size_ == vector_.size() )
807  return ConstIterator( vector_.cend(), offset_ );
808  else
809  return ConstIterator( vector_.lowerBound( offset_ + size_ ), offset_ );
810 }
812 //*************************************************************************************************
813 
814 
815 //*************************************************************************************************
823 template< typename VT // Type of the sparse vector
824  , bool AF // Alignment flag
825  , bool TF > // Transpose flag
827 {
828  if( offset_ + size_ == vector_.size() )
829  return ConstIterator( vector_.cend(), offset_ );
830  else
831  return ConstIterator( vector_.lowerBound( offset_ + size_ ), offset_ );
832 }
834 //*************************************************************************************************
835 
836 
837 
838 
839 //=================================================================================================
840 //
841 // ASSIGNMENT OPERATORS
842 //
843 //=================================================================================================
844 
845 //*************************************************************************************************
857 template< typename VT // Type of the sparse vector
858  , bool AF // Alignment flag
859  , bool TF > // Transpose flag
860 inline Subvector<VT,AF,TF,false>&
861  Subvector<VT,AF,TF,false>::operator=( const Subvector& rhs )
862 {
863  using blaze::assign;
864 
867 
868  if( this == &rhs || ( &vector_ == &rhs.vector_ && offset_ == rhs.offset_ ) )
869  return *this;
870 
871  if( size() != rhs.size() ) {
872  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
873  }
874 
875  if( !tryAssign( vector_, rhs, offset_ ) ) {
876  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
877  }
878 
879  decltype(auto) left( derestrict( *this ) );
880 
881  if( rhs.canAlias( &vector_ ) ) {
882  const ResultType tmp( rhs );
883  reset();
884  assign( left, tmp );
885  }
886  else {
887  reset();
888  assign( left, rhs );
889  }
890 
891  BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
892 
893  return *this;
894 }
896 //*************************************************************************************************
897 
898 
899 //*************************************************************************************************
911 template< typename VT // Type of the sparse vector
912  , bool AF // Alignment flag
913  , bool TF > // Transpose flag
914 template< typename VT2 > // Type of the right-hand side vector
915 inline Subvector<VT,AF,TF,false>&
916  Subvector<VT,AF,TF,false>::operator=( const Vector<VT2,TF>& rhs )
917 {
918  using blaze::assign;
919 
922 
923  if( size() != (~rhs).size() ) {
924  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
925  }
926 
927  using Right = If_< IsRestricted<VT>, CompositeType_<VT2>, const VT2& >;
928  Right right( ~rhs );
929 
930  if( !tryAssign( vector_, right, offset_ ) ) {
931  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
932  }
933 
934  decltype(auto) left( derestrict( *this ) );
935 
936  if( IsReference<Right>::value || right.canAlias( &vector_ ) ) {
937  const ResultType_<VT2> tmp( right );
938  reset();
939  assign( left, tmp );
940  }
941  else {
942  reset();
943  assign( left, right );
944  }
945 
946  BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
947 
948  return *this;
949 }
951 //*************************************************************************************************
952 
953 
954 //*************************************************************************************************
966 template< typename VT // Type of the sparse vector
967  , bool AF // Alignment flag
968  , bool TF > // Transpose flag
969 template< typename VT2 > // Type of the right-hand side vector
970 inline Subvector<VT,AF,TF,false>&
971  Subvector<VT,AF,TF,false>::operator+=( const Vector<VT2,TF>& rhs )
972 {
973  using blaze::assign;
974 
978 
979  using AddType = AddTrait_< ResultType, ResultType_<VT2> >;
980 
983 
984  if( size() != (~rhs).size() ) {
985  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
986  }
987 
988  const AddType tmp( *this + (~rhs) );
989 
990  if( !tryAssign( vector_, tmp, offset_ ) ) {
991  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
992  }
993 
994  decltype(auto) left( derestrict( *this ) );
995 
996  left.reset();
997  assign( left, tmp );
998 
999  BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1000 
1001  return *this;
1002 }
1004 //*************************************************************************************************
1005 
1006 
1007 //*************************************************************************************************
1019 template< typename VT // Type of the sparse vector
1020  , bool AF // Alignment flag
1021  , bool TF > // Transpose flag
1022 template< typename VT2 > // Type of the right-hand side vector
1023 inline Subvector<VT,AF,TF,false>&
1024  Subvector<VT,AF,TF,false>::operator-=( const Vector<VT2,TF>& rhs )
1025 {
1026  using blaze::assign;
1027 
1031 
1032  using SubType = SubTrait_< ResultType, ResultType_<VT2> >;
1033 
1036 
1037  if( size() != (~rhs).size() ) {
1038  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1039  }
1040 
1041  const SubType tmp( *this - (~rhs) );
1042 
1043  if( !tryAssign( vector_, tmp, offset_ ) ) {
1044  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1045  }
1046 
1047  decltype(auto) left( derestrict( *this ) );
1048 
1049  left.reset();
1050  assign( left, tmp );
1051 
1052  BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1053 
1054  return *this;
1055 }
1057 //*************************************************************************************************
1058 
1059 
1060 //*************************************************************************************************
1073 template< typename VT // Type of the sparse vector
1074  , bool AF // Alignment flag
1075  , bool TF > // Transpose flag
1076 template< typename VT2 > // Type of the right-hand side vector
1077 inline Subvector<VT,AF,TF,false>&
1078  Subvector<VT,AF,TF,false>::operator*=( const Vector<VT2,TF>& rhs )
1079 {
1080  using blaze::assign;
1081 
1085 
1086  using MultType = MultTrait_< ResultType, ResultType_<VT2> >;
1087 
1090 
1091  if( size() != (~rhs).size() ) {
1092  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1093  }
1094 
1095  const MultType tmp( *this * (~rhs) );
1096 
1097  if( !tryAssign( vector_, tmp, offset_ ) ) {
1098  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1099  }
1100 
1101  decltype(auto) left( derestrict( *this ) );
1102 
1103  left.reset();
1104  assign( left, tmp );
1105 
1106  BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1107 
1108  return *this;
1109 }
1111 //*************************************************************************************************
1112 
1113 
1114 //*************************************************************************************************
1126 template< typename VT // Type of the sparse vector
1127  , bool AF // Alignment flag
1128  , bool TF > // Transpose flag
1129 template< typename VT2 > // Type of the right-hand side dense vector
1130 inline Subvector<VT,AF,TF,false>&
1131  Subvector<VT,AF,TF,false>::operator/=( const DenseVector<VT2,TF>& rhs )
1132 {
1133  using blaze::assign;
1134 
1137  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT2> );
1139 
1140  using DivType = DivTrait_< ResultType, ResultType_<VT2> >;
1141 
1145 
1146  if( size() != (~rhs).size() ) {
1147  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1148  }
1149 
1150  const DivType tmp( *this / (~rhs) );
1151 
1152  if( !tryAssign( vector_, tmp, offset_ ) ) {
1153  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1154  }
1155 
1156  decltype(auto) left( derestrict( *this ) );
1157 
1158  left.reset();
1159  assign( left, tmp );
1160 
1161  BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1162 
1163  return *this;
1164 }
1166 //*************************************************************************************************
1167 
1168 
1169 //*************************************************************************************************
1182 template< typename VT // Type of the sparse vector
1183  , bool AF // Alignment flag
1184  , bool TF > // Transpose flag
1185 template< typename VT2 > // Type of the right-hand side vector
1186 inline Subvector<VT,AF,TF,false>&
1187  Subvector<VT,AF,TF,false>::operator%=( const Vector<VT2,TF>& rhs )
1188 {
1189  using blaze::assign;
1190 
1193 
1194  using CrossType = CrossTrait_< ResultType, ResultType_<VT2> >;
1195 
1199 
1200  if( size() != 3UL || (~rhs).size() != 3UL ) {
1201  BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
1202  }
1203 
1204  const CrossType tmp( *this % (~rhs) );
1205 
1206  if( !tryAssign( vector_, tmp, offset_ ) ) {
1207  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1208  }
1209 
1210  decltype(auto) left( derestrict( *this ) );
1211 
1212  left.reset();
1213  assign( left, tmp );
1214 
1215  BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1216 
1217  return *this;
1218 }
1220 //*************************************************************************************************
1221 
1222 
1223 //*************************************************************************************************
1235 template< typename VT // Type of the sparse vector
1236  , bool AF // Alignment flag
1237  , bool TF > // Transpose flag
1238 template< typename Other > // Data type of the right-hand side scalar
1239 inline EnableIf_<IsNumeric<Other>, Subvector<VT,AF,TF,false> >&
1240  Subvector<VT,AF,TF,false>::operator*=( Other rhs )
1241 {
1242  const Iterator last( end() );
1243  for( Iterator element=begin(); element!=last; ++element )
1244  element->value() *= rhs;
1245  return *this;
1246 }
1248 //*************************************************************************************************
1249 
1250 
1251 //*************************************************************************************************
1264 template< typename VT // Type of the sparse vector
1265  , bool AF // Alignment flag
1266  , bool TF > // Transpose flag
1267 template< typename Other > // Data type of the right-hand side scalar
1268 inline EnableIf_<IsNumeric<Other>, Subvector<VT,AF,TF,false> >&
1270 {
1271  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1272 
1273  using DT = DivTrait_<ElementType,Other>;
1274  using Tmp = If_< IsNumeric<DT>, DT, Other >;
1275 
1276  const Iterator last( end() );
1277 
1278  // Depending on the two involved data types, an integer division is applied or a
1279  // floating point division is selected.
1280  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
1281  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1282  for( Iterator element=begin(); element!=last; ++element )
1283  element->value() *= tmp;
1284  }
1285  else {
1286  for( Iterator element=begin(); element!=last; ++element )
1287  element->value() /= rhs;
1288  }
1289 
1290  return *this;
1291 }
1293 //*************************************************************************************************
1294 
1295 
1296 
1297 
1298 //=================================================================================================
1299 //
1300 // UTILITY FUNCTIONS
1301 //
1302 //=================================================================================================
1303 
1304 //*************************************************************************************************
1310 template< typename VT // Type of the sparse vector
1311  , bool AF // Alignment flag
1312  , bool TF > // Transpose flag
1313 inline typename Subvector<VT,AF,TF,false>::Operand
1314  Subvector<VT,AF,TF,false>::operand() const noexcept
1315 {
1316  return vector_;
1317 }
1319 //*************************************************************************************************
1320 
1321 
1322 //*************************************************************************************************
1328 template< typename VT // Type of the sparse vector
1329  , bool AF // Alignment flag
1330  , bool TF > // Transpose flag
1331 inline size_t Subvector<VT,AF,TF,false>::offset() const noexcept
1332 {
1333  return offset_;
1334 }
1336 //*************************************************************************************************
1337 
1338 
1339 //*************************************************************************************************
1345 template< typename VT // Type of the sparse vector
1346  , bool AF // Alignment flag
1347  , bool TF > // Transpose flag
1348 inline size_t Subvector<VT,AF,TF,false>::size() const noexcept
1349 {
1350  return size_;
1351 }
1353 //*************************************************************************************************
1354 
1355 
1356 //*************************************************************************************************
1362 template< typename VT // Type of the sparse vector
1363  , bool AF // Alignment flag
1364  , bool TF > // Transpose flag
1365 inline size_t Subvector<VT,AF,TF,false>::capacity() const noexcept
1366 {
1367  return nonZeros() + vector_.capacity() - vector_.nonZeros();
1368 }
1370 //*************************************************************************************************
1371 
1372 
1373 //*************************************************************************************************
1381 template< typename VT // Type of the sparse vector
1382  , bool AF // Alignment flag
1383  , bool TF > // Transpose flag
1384 inline size_t Subvector<VT,AF,TF,false>::nonZeros() const
1385 {
1386  return end() - begin();
1387 }
1389 //*************************************************************************************************
1390 
1391 
1392 //*************************************************************************************************
1398 template< typename VT // Type of the sparse vector
1399  , bool AF // Alignment flag
1400  , bool TF > // Transpose flag
1402 {
1403  vector_.erase( vector_.lowerBound( offset_ ), vector_.lowerBound( offset_ + size_ ) );
1404 }
1406 //*************************************************************************************************
1407 
1408 
1409 //*************************************************************************************************
1419 template< typename VT // Type of the sparse vector
1420  , bool AF // Alignment flag
1421  , bool TF > // Transpose flag
1422 void Subvector<VT,AF,TF,false>::reserve( size_t n )
1423 {
1424  const size_t current( capacity() );
1425 
1426  if( n > current ) {
1427  vector_.reserve( vector_.capacity() + n - current );
1428  }
1429 }
1431 //*************************************************************************************************
1432 
1433 
1434 
1435 
1436 //=================================================================================================
1437 //
1438 // INSERTION FUNCTIONS
1439 //
1440 //=================================================================================================
1441 
1442 //*************************************************************************************************
1454 template< typename VT // Type of the sparse vector
1455  , bool AF // Alignment flag
1456  , bool TF > // Transpose flag
1458  Subvector<VT,AF,TF,false>::set( size_t index, const ElementType& value )
1459 {
1460  return Iterator( vector_.set( offset_ + index, value ), offset_ );
1461 }
1463 //*************************************************************************************************
1464 
1465 
1466 //*************************************************************************************************
1479 template< typename VT // Type of the sparse vector
1480  , bool AF // Alignment flag
1481  , bool TF > // Transpose flag
1483  Subvector<VT,AF,TF,false>::insert( size_t index, const ElementType& value )
1484 {
1485  return Iterator( vector_.insert( offset_ + index, value ), offset_ );
1486 }
1488 //*************************************************************************************************
1489 
1490 
1491 //*************************************************************************************************
1516 template< typename VT // Type of the sparse vector
1517  , bool AF // Alignment flag
1518  , bool TF > // Transpose flag
1519 inline void Subvector<VT,AF,TF,false>::append( size_t index, const ElementType& value, bool check )
1520 {
1521  if( offset_ + size_ == vector_.size() )
1522  vector_.append( offset_ + index, value, check );
1523  else if( !check || !isDefault( value ) )
1524  vector_.insert( offset_ + index, value );
1525 }
1527 //*************************************************************************************************
1528 
1529 
1530 
1531 
1532 //=================================================================================================
1533 //
1534 // ERASE FUNCTIONS
1535 //
1536 //=================================================================================================
1537 
1538 //*************************************************************************************************
1547 template< typename VT // Type of the sparse vector
1548  , bool AF // Alignment flag
1549  , bool TF > // Transpose flag
1550 inline void Subvector<VT,AF,TF,false>::erase( size_t index )
1551 {
1552  vector_.erase( offset_ + index );
1553 }
1555 //*************************************************************************************************
1556 
1557 
1558 //*************************************************************************************************
1567 template< typename VT // Type of the sparse vector
1568  , bool AF // Alignment flag
1569  , bool TF > // Transpose flag
1570 inline typename Subvector<VT,AF,TF,false>::Iterator Subvector<VT,AF,TF,false>::erase( Iterator pos )
1571 {
1572  return Iterator( vector_.erase( pos.base() ), offset_ );
1573 }
1575 //*************************************************************************************************
1576 
1577 
1578 //*************************************************************************************************
1588 template< typename VT // Type of the sparse vector
1589  , bool AF // Alignment flag
1590  , bool TF > // Transpose flag
1592  Subvector<VT,AF,TF,false>::erase( Iterator first, Iterator last )
1593 {
1594  return Iterator( vector_.erase( first.base(), last.base() ), offset_ );
1595 }
1597 //*************************************************************************************************
1598 
1599 
1600 //*************************************************************************************************
1623 template< typename VT // Type of the sparse vector
1624  , bool AF // Alignment flag
1625  , bool TF > // Transpose flag
1626 template< typename Pred // Type of the unary predicate
1627  , typename > // Type restriction on the unary predicate
1628 inline void Subvector<VT,AF,TF,false>::erase( Pred predicate )
1629 {
1630  vector_.erase( begin().base(), end().base(), predicate );
1631 }
1633 //*************************************************************************************************
1634 
1635 
1636 //*************************************************************************************************
1662 template< typename VT // Type of the sparse vector
1663  , bool AF // Alignment flag
1664  , bool TF > // Transpose flag
1665 template< typename Pred > // Type of the unary predicate
1666 inline void Subvector<VT,AF,TF,false>::erase( Iterator first, Iterator last, Pred predicate )
1667 {
1668  vector_.erase( first.base(), last.base(), predicate );
1669 }
1671 //*************************************************************************************************
1672 
1673 
1674 
1675 
1676 //=================================================================================================
1677 //
1678 // LOOKUP FUNCTIONS
1679 //
1680 //=================================================================================================
1681 
1682 //*************************************************************************************************
1696 template< typename VT // Type of the sparse vector
1697  , bool AF // Alignment flag
1698  , bool TF > // Transpose flag
1700  Subvector<VT,AF,TF,false>::find( size_t index )
1701 {
1702  const Iterator_<VT> pos( vector_.find( offset_ + index ) );
1703 
1704  if( pos != vector_.end() )
1705  return Iterator( pos, offset_ );
1706  else
1707  return end();
1708 }
1710 //*************************************************************************************************
1711 
1712 
1713 //*************************************************************************************************
1727 template< typename VT // Type of the sparse vector
1728  , bool AF // Alignment flag
1729  , bool TF > // Transpose flag
1731  Subvector<VT,AF,TF,false>::find( size_t index ) const
1732 {
1733  const ConstIterator_<VT> pos( vector_.find( offset_ + index ) );
1734 
1735  if( pos != vector_.end() )
1736  return Iterator( pos, offset_ );
1737  else
1738  return end();
1739 }
1741 //*************************************************************************************************
1742 
1743 
1744 //*************************************************************************************************
1757 template< typename VT // Type of the sparse vector
1758  , bool AF // Alignment flag
1759  , bool TF > // Transpose flag
1761  Subvector<VT,AF,TF,false>::lowerBound( size_t index )
1762 {
1763  return Iterator( vector_.lowerBound( offset_ + index ), offset_ );
1764 }
1766 //*************************************************************************************************
1767 
1768 
1769 //*************************************************************************************************
1782 template< typename VT // Type of the sparse vector
1783  , bool AF // Alignment flag
1784  , bool TF > // Transpose flag
1786  Subvector<VT,AF,TF,false>::lowerBound( size_t index ) const
1787 {
1788  return ConstIterator( vector_.lowerBound( offset_ + index ), offset_ );
1789 }
1791 //*************************************************************************************************
1792 
1793 
1794 //*************************************************************************************************
1807 template< typename VT // Type of the sparse vector
1808  , bool AF // Alignment flag
1809  , bool TF > // Transpose flag
1811  Subvector<VT,AF,TF,false>::upperBound( size_t index )
1812 {
1813  return Iterator( vector_.upperBound( offset_ + index ), offset_ );
1814 }
1816 //*************************************************************************************************
1817 
1818 
1819 //*************************************************************************************************
1832 template< typename VT // Type of the sparse vector
1833  , bool AF // Alignment flag
1834  , bool TF > // Transpose flag
1836  Subvector<VT,AF,TF,false>::upperBound( size_t index ) const
1837 {
1838  return ConstIterator( vector_.upperBound( offset_ + index ), offset_ );
1839 }
1841 //*************************************************************************************************
1842 
1843 
1844 
1845 
1846 //=================================================================================================
1847 //
1848 // NUMERIC FUNCTIONS
1849 //
1850 //=================================================================================================
1851 
1852 //*************************************************************************************************
1863 template< typename VT // Type of the sparse vector
1864  , bool AF // Alignment flag
1865  , bool TF > // Transpose flag
1866 template< typename Other > // Data type of the scalar value
1867 inline Subvector<VT,AF,TF,false>& Subvector<VT,AF,TF,false>::scale( const Other& scalar )
1868 {
1869  for( Iterator element=begin(); element!=end(); ++element )
1870  element->value() *= scalar;
1871  return *this;
1872 }
1874 //*************************************************************************************************
1875 
1876 
1877 
1878 
1879 //=================================================================================================
1880 //
1881 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1882 //
1883 //=================================================================================================
1884 
1885 //*************************************************************************************************
1896 template< typename VT // Type of the sparse vector
1897  , bool AF // Alignment flag
1898  , bool TF > // Transpose flag
1899 template< typename Other > // Data type of the foreign expression
1900 inline bool Subvector<VT,AF,TF,false>::canAlias( const Other* alias ) const noexcept
1901 {
1902  return vector_.isAliased( alias );
1903 }
1905 //*************************************************************************************************
1906 
1907 
1908 //*************************************************************************************************
1919 template< typename VT // Type of the sparse vector
1920  , bool AF // Alignment flag
1921  , bool TF > // Transpose flag
1922 template< typename Other > // Data type of the foreign expression
1923 inline bool Subvector<VT,AF,TF,false>::isAliased( const Other* alias ) const noexcept
1924 {
1925  return vector_.isAliased( alias );
1926 }
1928 //*************************************************************************************************
1929 
1930 
1931 //*************************************************************************************************
1942 template< typename VT // Type of the sparse vector
1943  , bool AF // Alignment flag
1944  , bool TF > // Transpose flag
1945 inline bool Subvector<VT,AF,TF,false>::canSMPAssign() const noexcept
1946 {
1947  return false;
1948 }
1950 //*************************************************************************************************
1951 
1952 
1953 //*************************************************************************************************
1965 template< typename VT // Type of the sparse vector
1966  , bool AF // Alignment flag
1967  , bool TF > // Transpose flag
1968 template< typename VT2 > // Type of the right-hand side dense vector
1969 inline void Subvector<VT,AF,TF,false>::assign( const DenseVector<VT2,TF>& rhs )
1970 {
1971  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1972  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1973 
1974  reserve( (~rhs).size() );
1975 
1976  for( size_t i=0UL; i<size(); ++i ) {
1977  append( i, (~rhs)[i], true );
1978  }
1979 }
1981 //*************************************************************************************************
1982 
1983 
1984 //*************************************************************************************************
1996 template< typename VT // Type of the sparse vector
1997  , bool AF // Alignment flag
1998  , bool TF > // Transpose flag
1999 template< typename VT2 > // Type of the right-hand side sparse vector
2000 inline void Subvector<VT,AF,TF,false>::assign( const SparseVector<VT2,TF>& rhs )
2001 {
2002  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2003  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
2004 
2005  reserve( (~rhs).nonZeros() );
2006 
2007  for( ConstIterator_<VT2> element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
2008  append( element->index(), element->value(), true );
2009  }
2010 }
2012 //*************************************************************************************************
2013 
2014 
2015 //*************************************************************************************************
2027 template< typename VT // Type of the sparse vector
2028  , bool AF // Alignment flag
2029  , bool TF > // Transpose flag
2030 template< typename VT2 > // Type of the right-hand side dense vector
2031 inline void Subvector<VT,AF,TF,false>::addAssign( const DenseVector<VT2,TF>& rhs )
2032 {
2033  using AddType = AddTrait_< ResultType, ResultType_<VT2> >;
2034 
2038 
2039  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2040 
2041  const AddType tmp( serial( *this + (~rhs) ) );
2042  reset();
2043  assign( tmp );
2044 }
2046 //*************************************************************************************************
2047 
2048 
2049 //*************************************************************************************************
2061 template< typename VT // Type of the sparse vector
2062  , bool AF // Alignment flag
2063  , bool TF > // Transpose flag
2064 template< typename VT2 > // Type of the right-hand side sparse vector
2065 inline void Subvector<VT,AF,TF,false>::addAssign( const SparseVector<VT2,TF>& rhs )
2066 {
2067  using AddType = AddTrait_< ResultType, ResultType_<VT2> >;
2068 
2072 
2073  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2074 
2075  const AddType tmp( serial( *this + (~rhs) ) );
2076  reset();
2077  assign( tmp );
2078 }
2080 //*************************************************************************************************
2081 
2082 
2083 //*************************************************************************************************
2095 template< typename VT // Type of the sparse vector
2096  , bool AF // Alignment flag
2097  , bool TF > // Transpose flag
2098 template< typename VT2 > // Type of the right-hand side dense vector
2099 inline void Subvector<VT,AF,TF,false>::subAssign( const DenseVector<VT2,TF>& rhs )
2100 {
2101  using SubType = SubTrait_< ResultType, ResultType_<VT2> >;
2102 
2106 
2107  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2108 
2109  const SubType tmp( serial( *this - (~rhs) ) );
2110  reset();
2111  assign( tmp );
2112 }
2114 //*************************************************************************************************
2115 
2116 
2117 //*************************************************************************************************
2129 template< typename VT // Type of the sparse vector
2130  , bool AF // Alignment flag
2131  , bool TF > // Transpose flag
2132 template< typename VT2 > // Type of the right-hand side sparse vector
2133 inline void Subvector<VT,AF,TF,false>::subAssign( const SparseVector<VT2,TF>& rhs )
2134 {
2135  using SubType = SubTrait_< ResultType, ResultType_<VT2> >;
2136 
2140 
2141  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
2142 
2143  const SubType tmp( serial( *this - (~rhs) ) );
2144  reset();
2145  assign( tmp );
2146 }
2148 //*************************************************************************************************
2149 
2150 } // namespace blaze
2151 
2152 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
Header file for auxiliary alias declarations.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the alignment flag values.
Header file for the subtraction trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:356
Header file for basic type definitions.
Header file for the SparseVector base class.
Header file for the View base class.
Header file for the serial shim.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:265
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i...
Definition: Computation.h:81
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1411
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3078
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:198
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:560
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
Header file for the IsIntegral type trait.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3080
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3085
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:394
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:731
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3086
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.In case the given data type T is a transposition expression (i...
Definition: TransExpr.h:81
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1393
BLAZE_ALWAYS_INLINE 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:308
BLAZE_ALWAYS_INLINE 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:242
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the multiplication trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3084
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the If class template.
Header file for the IsFloatingPoint type trait.
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3077
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3081
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the implementation of the Subvector base template.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3087
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Header file for the subvector trait.
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional vector type...
Definition: SparseVector.h:61
Constraint on the data type.
Header file for the SparseElement base class.
Constraint on the data type.
Constraint on the data type.
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE 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:264
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:8893
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
Constraint on the data type.
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
Header file for the IsConst type trait.
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
Header file for the isDefault shim.
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:819
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
Header file for the IsReference type trait.
Header file for the RemoveReference type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3082
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional vector type...
Definition: DenseVector.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SUBVECTOR_TYPE(T)
Constraint on the data type.In case the given data type T is a subvector type (i.e. a dense or sparse subvector), a compilation error is created.
Definition: Subvector.h:81
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3083
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:252
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
Header file for the IsRestricted type trait.
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.In case the given data type T is not a dense or sparse vector type and in...
Definition: TransposeFlag.h:63
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the IsExpression type trait class.