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/EnableIf.h>
70 #include <blaze/util/mpl/If.h>
71 #include <blaze/util/Types.h>
76 
77 
78 namespace blaze {
79 
80 //=================================================================================================
81 //
82 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE SUBVECTORS
83 //
84 //=================================================================================================
85 
86 //*************************************************************************************************
94 template< typename VT // Type of the sparse vector
95  , bool AF // Alignment flag
96  , bool TF > // Transpose flag
97 class Subvector<VT,AF,TF,false>
98  : public SparseVector< Subvector<VT,AF,TF,false>, TF >
99  , private View
100 {
101  private:
102  //**Type definitions****************************************************************************
104  typedef If_< IsExpression<VT>, VT, VT& > Operand;
105  //**********************************************************************************************
106 
107  public:
108  //**Type definitions****************************************************************************
109  typedef Subvector<VT,AF,TF,false> This;
110  typedef SparseVector<This,TF> BaseType;
111  typedef SubvectorTrait_<VT> ResultType;
112  typedef TransposeType_<ResultType> TransposeType;
113  typedef ElementType_<VT> ElementType;
114  typedef ReturnType_<VT> ReturnType;
115  typedef const Subvector& CompositeType;
116 
118  typedef ConstReference_<VT> ConstReference;
119 
121  typedef If_< IsConst<VT>, ConstReference, Reference_<VT> > Reference;
122  //**********************************************************************************************
123 
124  //**SubvectorElement class definition***********************************************************
127  template< typename VectorType // Type of the sparse vector
128  , typename IteratorType > // Type of the sparse vector iterator
129  class SubvectorElement : private SparseElement
130  {
131  private:
132  //*******************************************************************************************
134 
139  enum : bool { returnConst = IsConst<VectorType>::value };
140  //*******************************************************************************************
141 
142  //**Type definitions*************************************************************************
144  typedef typename std::iterator_traits<IteratorType>::value_type SET;
145 
146  typedef Reference_<SET> RT;
147  typedef ConstReference_<SET> CRT;
148  //*******************************************************************************************
149 
150  public:
151  //**Type definitions*************************************************************************
152  typedef ValueType_<SET> ValueType;
153  typedef size_t IndexType;
154  typedef IfTrue_<returnConst,CRT,RT> Reference;
155  typedef CRT ConstReference;
156  //*******************************************************************************************
157 
158  //**Constructor******************************************************************************
164  inline SubvectorElement( IteratorType pos, size_t offset )
165  : pos_ ( pos ) // Iterator to the current position within the sparse subvector
166  , offset_( offset ) // Offset within the according sparse vector
167  {}
168  //*******************************************************************************************
169 
170  //**Assignment operator**********************************************************************
176  template< typename T > inline SubvectorElement& operator=( const T& v ) {
177  *pos_ = v;
178  return *this;
179  }
180  //*******************************************************************************************
181 
182  //**Addition assignment operator*************************************************************
188  template< typename T > inline SubvectorElement& operator+=( const T& v ) {
189  *pos_ += v;
190  return *this;
191  }
192  //*******************************************************************************************
193 
194  //**Subtraction assignment operator**********************************************************
200  template< typename T > inline SubvectorElement& operator-=( const T& v ) {
201  *pos_ -= v;
202  return *this;
203  }
204  //*******************************************************************************************
205 
206  //**Multiplication assignment operator*******************************************************
212  template< typename T > inline SubvectorElement& operator*=( const T& v ) {
213  *pos_ *= v;
214  return *this;
215  }
216  //*******************************************************************************************
217 
218  //**Division assignment operator*************************************************************
224  template< typename T > inline SubvectorElement& operator/=( const T& v ) {
225  *pos_ /= v;
226  return *this;
227  }
228  //*******************************************************************************************
229 
230  //**Element access operator******************************************************************
235  inline const SubvectorElement* operator->() const {
236  return this;
237  }
238  //*******************************************************************************************
239 
240  //**Value function***************************************************************************
245  inline Reference value() const {
246  return pos_->value();
247  }
248  //*******************************************************************************************
249 
250  //**Index function***************************************************************************
255  inline IndexType index() const {
256  return pos_->index() - offset_;
257  }
258  //*******************************************************************************************
259 
260  private:
261  //**Member variables*************************************************************************
262  IteratorType pos_;
263  size_t offset_;
264  //*******************************************************************************************
265  };
266  //**********************************************************************************************
267 
268  //**SubvectorIterator class definition**********************************************************
271  template< typename VectorType // Type of the sparse vector
272  , typename IteratorType > // Type of the sparse vector iterator
273  class SubvectorIterator
274  {
275  public:
276  //**Type definitions*************************************************************************
277  typedef std::forward_iterator_tag IteratorCategory;
278  typedef SubvectorElement<VectorType,IteratorType> ValueType;
279  typedef ValueType PointerType;
280  typedef ValueType ReferenceType;
281  typedef ptrdiff_t DifferenceType;
282 
283  // STL iterator requirements
284  typedef IteratorCategory iterator_category;
285  typedef ValueType value_type;
286  typedef PointerType pointer;
287  typedef ReferenceType reference;
288  typedef DifferenceType difference_type;
289  //*******************************************************************************************
290 
291  //**Default constructor**********************************************************************
294  inline SubvectorIterator()
295  : pos_ () // Iterator to the current sparse element
296  , offset_() // The offset of the subvector within the sparse vector
297  {}
298  //*******************************************************************************************
299 
300  //**Constructor******************************************************************************
306  inline SubvectorIterator( IteratorType iterator, size_t index )
307  : pos_ ( iterator ) // Iterator to the current sparse element
308  , offset_( index ) // The offset of the subvector within the sparse vector
309  {}
310  //*******************************************************************************************
311 
312  //**Constructor******************************************************************************
317  template< typename VectorType2, typename IteratorType2 >
318  inline SubvectorIterator( const SubvectorIterator<VectorType2,IteratorType2>& it )
319  : pos_ ( it.base() ) // Iterator to the current sparse element.
320  , offset_( it.offset() ) // The offset of the subvector within the sparse vector
321  {}
322  //*******************************************************************************************
323 
324  //**Prefix increment operator****************************************************************
329  inline SubvectorIterator& operator++() {
330  ++pos_;
331  return *this;
332  }
333  //*******************************************************************************************
334 
335  //**Postfix increment operator***************************************************************
340  inline const SubvectorIterator operator++( int ) {
341  const SubvectorIterator tmp( *this );
342  ++(*this);
343  return tmp;
344  }
345  //*******************************************************************************************
346 
347  //**Element access operator******************************************************************
352  inline ReferenceType operator*() const {
353  return ReferenceType( pos_, offset_ );
354  }
355  //*******************************************************************************************
356 
357  //**Element access operator******************************************************************
362  inline PointerType operator->() const {
363  return PointerType( pos_, offset_ );
364  }
365  //*******************************************************************************************
366 
367  //**Equality operator************************************************************************
373  template< typename VectorType2, typename IteratorType2 >
374  inline bool operator==( const SubvectorIterator<VectorType2,IteratorType2>& rhs ) const {
375  return base() == rhs.base();
376  }
377  //*******************************************************************************************
378 
379  //**Inequality operator**********************************************************************
385  template< typename VectorType2, typename IteratorType2 >
386  inline bool operator!=( const SubvectorIterator<VectorType2,IteratorType2>& rhs ) const {
387  return !( *this == rhs );
388  }
389  //*******************************************************************************************
390 
391  //**Subtraction operator*********************************************************************
397  inline DifferenceType operator-( const SubvectorIterator& rhs ) const {
398  return pos_ - rhs.pos_;
399  }
400  //*******************************************************************************************
401 
402  //**Base function****************************************************************************
407  inline IteratorType base() const {
408  return pos_;
409  }
410  //*******************************************************************************************
411 
412  //**Offset function**************************************************************************
417  inline size_t offset() const noexcept {
418  return offset_;
419  }
420  //*******************************************************************************************
421 
422  private:
423  //**Member variables*************************************************************************
424  IteratorType pos_;
425  size_t offset_;
426  //*******************************************************************************************
427  };
428  //**********************************************************************************************
429 
430  //**Type definitions****************************************************************************
432  typedef SubvectorIterator< const VT, ConstIterator_<VT> > ConstIterator;
433 
435  typedef If_< IsConst<VT>, ConstIterator, SubvectorIterator< VT, Iterator_<VT> > > Iterator;
436  //**********************************************************************************************
437 
438  //**Compilation flags***************************************************************************
440  enum : bool { smpAssignable = VT::smpAssignable };
441  //**********************************************************************************************
442 
443  //**Constructors********************************************************************************
446  explicit inline Subvector( Operand vector, size_t index, size_t n );
447  // No explicitly declared copy constructor.
449  //**********************************************************************************************
450 
451  //**Destructor**********************************************************************************
452  // No explicitly declared destructor.
453  //**********************************************************************************************
454 
455  //**Data access functions***********************************************************************
458  inline Reference operator[]( size_t index );
459  inline ConstReference operator[]( size_t index ) const;
460  inline Reference at( size_t index );
461  inline ConstReference at( size_t index ) const;
462  inline Iterator begin ();
463  inline ConstIterator begin () const;
464  inline ConstIterator cbegin() const;
465  inline Iterator end ();
466  inline ConstIterator end () const;
467  inline ConstIterator cend () const;
469  //**********************************************************************************************
470 
471  //**Assignment operators************************************************************************
474  inline Subvector& operator= ( const Subvector& rhs );
475  template< typename VT2 > inline Subvector& operator= ( const Vector<VT2,TF>& rhs );
476  template< typename VT2 > inline Subvector& operator+=( const Vector<VT2,TF>& rhs );
477  template< typename VT2 > inline Subvector& operator-=( const Vector<VT2,TF>& rhs );
478  template< typename VT2 > inline Subvector& operator*=( const Vector<VT2,TF>& rhs );
479  template< typename VT2 > inline Subvector& operator/=( const DenseVector<VT2,TF>& rhs );
480 
481  template< typename Other >
482  inline EnableIf_<IsNumeric<Other>, Subvector >& operator*=( Other rhs );
483 
484  template< typename Other >
485  inline EnableIf_<IsNumeric<Other>, Subvector >& operator/=( Other rhs );
487  //**********************************************************************************************
488 
489  //**Utility functions***************************************************************************
492  inline size_t size() const noexcept;
493  inline size_t capacity() const noexcept;
494  inline size_t nonZeros() const;
495  inline void reset();
496  inline Iterator set ( size_t index, const ElementType& value );
497  inline Iterator insert ( size_t index, const ElementType& value );
498  inline void erase ( size_t index );
499  inline Iterator erase ( Iterator pos );
500  inline Iterator erase ( Iterator first, Iterator last );
501  inline void reserve( size_t n );
502  template< typename Other > inline Subvector& scale ( const Other& scalar );
504  //**********************************************************************************************
505 
506  //**Lookup functions****************************************************************************
509  inline Iterator find ( size_t index );
510  inline ConstIterator find ( size_t index ) const;
511  inline Iterator lowerBound( size_t index );
512  inline ConstIterator lowerBound( size_t index ) const;
513  inline Iterator upperBound( size_t index );
514  inline ConstIterator upperBound( size_t index ) const;
516  //**********************************************************************************************
517 
518  //**Low-level utility functions*****************************************************************
521  inline void append( size_t index, const ElementType& value, bool check=false );
523  //**********************************************************************************************
524 
525  //**Expression template evaluation functions****************************************************
528  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
529  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
530 
531  inline bool canSMPAssign() const noexcept;
532 
533  template< typename VT2 > inline void assign ( const DenseVector <VT2,TF>& rhs );
534  template< typename VT2 > inline void assign ( const SparseVector<VT2,TF>& rhs );
535  template< typename VT2 > inline void addAssign( const DenseVector <VT2,TF>& rhs );
536  template< typename VT2 > inline void addAssign( const SparseVector<VT2,TF>& rhs );
537  template< typename VT2 > inline void subAssign( const DenseVector <VT2,TF>& rhs );
538  template< typename VT2 > inline void subAssign( const SparseVector<VT2,TF>& rhs );
540  //**********************************************************************************************
541 
542  private:
543  //**Member variables****************************************************************************
546  Operand vector_;
547  const size_t offset_;
548  const size_t size_;
549 
550  //**********************************************************************************************
551 
552  //**Friend declarations*************************************************************************
553  template< bool AF1, typename VT2, bool AF2, bool TF2, bool DF2 >
554  friend const Subvector<VT2,AF1,TF2,DF2>
555  subvector( const Subvector<VT2,AF2,TF2,DF2>& sv, size_t index, size_t size );
556 
557  template< typename VT2, bool AF2, bool TF2, bool DF2 >
558  friend bool isIntact( const Subvector<VT2,AF2,TF2,DF2>& sv ) noexcept;
559 
560  template< typename VT2, bool AF2, bool TF2, bool DF2 >
561  friend bool isSame( const Subvector<VT2,AF2,TF2,DF2>& a, const Vector<VT2,TF2>& b ) noexcept;
562 
563  template< typename VT2, bool AF2, bool TF2, bool DF2 >
564  friend bool isSame( const Vector<VT2,TF2>& a, const Subvector<VT2,AF2,TF2,DF2>& b ) noexcept;
565 
566  template< typename VT2, bool AF2, bool TF2, bool DF2 >
567  friend bool isSame( const Subvector<VT2,AF2,TF2,DF2>& a, const Subvector<VT2,AF2,TF2,DF2>& b ) noexcept;
568 
569  template< typename VT2, bool AF2, bool TF2, bool DF2, typename VT3 >
570  friend bool tryAssign( const Subvector<VT2,AF2,TF2,DF2>& lhs, const Vector<VT3,TF2>& rhs, size_t index );
571 
572  template< typename VT2, bool AF2, bool TF2, bool DF2, typename VT3 >
573  friend bool tryAddAssign( const Subvector<VT2,AF2,TF2,DF2>& lhs, const Vector<VT3,TF2>& rhs, size_t index );
574 
575  template< typename VT2, bool AF2, bool TF2, bool DF2, typename VT3 >
576  friend bool trySubAssign( const Subvector<VT2,AF2,TF2,DF2>& lhs, const Vector<VT3,TF2>& rhs, size_t index );
577 
578  template< typename VT2, bool AF2, bool TF2, bool DF2, typename VT3 >
579  friend bool tryMultAssign( const Subvector<VT2,AF2,TF2,DF2>& lhs, const Vector<VT3,TF2>& rhs, size_t index );
580 
581  template< typename VT2, bool AF2, bool TF2, bool DF2 >
582  friend DerestrictTrait_< Subvector<VT2,AF2,TF2,DF2> > derestrict( Subvector<VT2,AF2,TF2,DF2>& sv );
583  //**********************************************************************************************
584 
585  //**Compile time checks*************************************************************************
591  //**********************************************************************************************
592 };
594 //*************************************************************************************************
595 
596 
597 
598 
599 //=================================================================================================
600 //
601 // CONSTRUCTOR
602 //
603 //=================================================================================================
604 
605 //*************************************************************************************************
618 template< typename VT // Type of the sparse vector
619  , bool AF // Alignment flag
620  , bool TF > // Transpose flag
621 inline Subvector<VT,AF,TF,false>::Subvector( Operand vector, size_t index, size_t n )
622  : vector_( vector ) // The sparse vector containing the subvector
623  , offset_( index ) // The offset of the subvector within the sparse vector
624  , size_ ( n ) // The size of the subvector
625 {
626  if( index + n > vector.size() ) {
627  BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
628  }
629 }
631 //*************************************************************************************************
632 
633 
634 
635 
636 //=================================================================================================
637 //
638 // DATA ACCESS FUNCTIONS
639 //
640 //=================================================================================================
641 
642 //*************************************************************************************************
652 template< typename VT // Type of the sparse vector
653  , bool AF // Alignment flag
654  , bool TF > // Transpose flag
656  Subvector<VT,AF,TF,false>::operator[]( size_t index )
657 {
658  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
659  return vector_[offset_+index];
660 }
662 //*************************************************************************************************
663 
664 
665 //*************************************************************************************************
675 template< typename VT // Type of the sparse vector
676  , bool AF // Alignment flag
677  , bool TF > // Transpose flag
679  Subvector<VT,AF,TF,false>::operator[]( size_t index ) const
680 {
681  BLAZE_USER_ASSERT( index < size(), "Invalid subvector access index" );
682  return const_cast<const VT&>( vector_ )[offset_+index];
683 }
685 //*************************************************************************************************
686 
687 
688 //*************************************************************************************************
699 template< typename VT // Type of the sparse vector
700  , bool AF // Alignment flag
701  , bool TF > // Transpose flag
703  Subvector<VT,AF,TF,false>::at( size_t index )
704 {
705  if( index >= size() ) {
706  BLAZE_THROW_OUT_OF_RANGE( "Invalid subvector access index" );
707  }
708  return (*this)[index];
709 }
711 //*************************************************************************************************
712 
713 
714 //*************************************************************************************************
725 template< typename VT // Type of the sparse vector
726  , bool AF // Alignment flag
727  , bool TF > // Transpose flag
729  Subvector<VT,AF,TF,false>::at( size_t index ) const
730 {
731  if( index >= size() ) {
732  BLAZE_THROW_OUT_OF_RANGE( "Invalid subvector access index" );
733  }
734  return (*this)[index];
735 }
737 //*************************************************************************************************
738 
739 
740 //*************************************************************************************************
748 template< typename VT // Type of the sparse vector
749  , bool AF // Alignment flag
750  , bool TF > // Transpose flag
752 {
753  if( offset_ == 0UL )
754  return Iterator( vector_.begin(), offset_ );
755  else
756  return Iterator( vector_.lowerBound( offset_ ), offset_ );
757 }
759 //*************************************************************************************************
760 
761 
762 //*************************************************************************************************
770 template< typename VT // Type of the sparse vector
771  , bool AF // Alignment flag
772  , bool TF > // Transpose flag
774 {
775  if( offset_ == 0UL )
776  return ConstIterator( vector_.cbegin(), offset_ );
777  else
778  return ConstIterator( vector_.lowerBound( offset_ ), offset_ );
779 }
781 //*************************************************************************************************
782 
783 
784 //*************************************************************************************************
792 template< typename VT // Type of the sparse vector
793  , bool AF // Alignment flag
794  , bool TF > // Transpose flag
796 {
797  if( offset_ == 0UL )
798  return ConstIterator( vector_.cbegin(), offset_ );
799  else
800  return ConstIterator( vector_.lowerBound( offset_ ), offset_ );
801 }
803 //*************************************************************************************************
804 
805 
806 //*************************************************************************************************
814 template< typename VT // Type of the sparse vector
815  , bool AF // Alignment flag
816  , bool TF > // Transpose flag
818 {
819  if( offset_ + size_ == vector_.size() )
820  return Iterator( vector_.end(), offset_ );
821  else
822  return Iterator( vector_.lowerBound( offset_ + size_ ), offset_ );
823 }
825 //*************************************************************************************************
826 
827 
828 //*************************************************************************************************
836 template< typename VT // Type of the sparse vector
837  , bool AF // Alignment flag
838  , bool TF > // Transpose flag
840 {
841  if( offset_ + size_ == vector_.size() )
842  return ConstIterator( vector_.cend(), offset_ );
843  else
844  return ConstIterator( vector_.lowerBound( offset_ + size_ ), offset_ );
845 }
847 //*************************************************************************************************
848 
849 
850 //*************************************************************************************************
858 template< typename VT // Type of the sparse vector
859  , bool AF // Alignment flag
860  , bool TF > // Transpose flag
862 {
863  if( offset_ + size_ == vector_.size() )
864  return ConstIterator( vector_.cend(), offset_ );
865  else
866  return ConstIterator( vector_.lowerBound( offset_ + size_ ), offset_ );
867 }
869 //*************************************************************************************************
870 
871 
872 
873 
874 //=================================================================================================
875 //
876 // ASSIGNMENT OPERATORS
877 //
878 //=================================================================================================
879 
880 //*************************************************************************************************
892 template< typename VT // Type of the sparse vector
893  , bool AF // Alignment flag
894  , bool TF > // Transpose flag
895 inline Subvector<VT,AF,TF,false>&
896  Subvector<VT,AF,TF,false>::operator=( const Subvector& rhs )
897 {
898  using blaze::assign;
899 
902 
903  if( this == &rhs || ( &vector_ == &rhs.vector_ && offset_ == rhs.offset_ ) )
904  return *this;
905 
906  if( size() != rhs.size() ) {
907  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
908  }
909 
910  if( !tryAssign( vector_, rhs, offset_ ) ) {
911  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
912  }
913 
914  DerestrictTrait_<This> left( derestrict( *this ) );
915 
916  if( rhs.canAlias( &vector_ ) ) {
917  const ResultType tmp( rhs );
918  reset();
919  assign( left, tmp );
920  }
921  else {
922  reset();
923  assign( left, rhs );
924  }
925 
926  BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
927 
928  return *this;
929 }
931 //*************************************************************************************************
932 
933 
934 //*************************************************************************************************
946 template< typename VT // Type of the sparse vector
947  , bool AF // Alignment flag
948  , bool TF > // Transpose flag
949 template< typename VT2 > // Type of the right-hand side vector
950 inline Subvector<VT,AF,TF,false>&
951  Subvector<VT,AF,TF,false>::operator=( const Vector<VT2,TF>& rhs )
952 {
953  using blaze::assign;
954 
957 
958  if( size() != (~rhs).size() ) {
959  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
960  }
961 
962  typedef If_< IsRestricted<VT>, CompositeType_<VT2>, const VT2& > Right;
963  Right right( ~rhs );
964 
965  if( !tryAssign( vector_, right, offset_ ) ) {
966  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
967  }
968 
969  DerestrictTrait_<This> left( derestrict( *this ) );
970 
971  if( IsReference<Right>::value || right.canAlias( &vector_ ) ) {
972  const ResultType_<VT2> tmp( right );
973  reset();
974  assign( left, tmp );
975  }
976  else {
977  reset();
978  assign( left, right );
979  }
980 
981  BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
982 
983  return *this;
984 }
986 //*************************************************************************************************
987 
988 
989 //*************************************************************************************************
1001 template< typename VT // Type of the sparse vector
1002  , bool AF // Alignment flag
1003  , bool TF > // Transpose flag
1004 template< typename VT2 > // Type of the right-hand side vector
1005 inline Subvector<VT,AF,TF,false>&
1006  Subvector<VT,AF,TF,false>::operator+=( const Vector<VT2,TF>& rhs )
1007 {
1008  using blaze::assign;
1009 
1013 
1014  typedef AddTrait_< ResultType, ResultType_<VT2> > AddType;
1015 
1018 
1019  if( size() != (~rhs).size() ) {
1020  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1021  }
1022 
1023  const AddType tmp( *this + (~rhs) );
1024 
1025  if( !tryAssign( vector_, tmp, offset_ ) ) {
1026  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1027  }
1028 
1029  DerestrictTrait_<This> left( derestrict( *this ) );
1030 
1031  left.reset();
1032  assign( left, tmp );
1033 
1034  BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1035 
1036  return *this;
1037 }
1039 //*************************************************************************************************
1040 
1041 
1042 //*************************************************************************************************
1054 template< typename VT // Type of the sparse vector
1055  , bool AF // Alignment flag
1056  , bool TF > // Transpose flag
1057 template< typename VT2 > // Type of the right-hand side vector
1058 inline Subvector<VT,AF,TF,false>&
1059  Subvector<VT,AF,TF,false>::operator-=( const Vector<VT2,TF>& rhs )
1060 {
1061  using blaze::assign;
1062 
1066 
1067  typedef SubTrait_< ResultType, ResultType_<VT2> > SubType;
1068 
1071 
1072  if( size() != (~rhs).size() ) {
1073  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1074  }
1075 
1076  const SubType tmp( *this - (~rhs) );
1077 
1078  if( !tryAssign( vector_, tmp, offset_ ) ) {
1079  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1080  }
1081 
1082  DerestrictTrait_<This> left( derestrict( *this ) );
1083 
1084  left.reset();
1085  assign( left, tmp );
1086 
1087  BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1088 
1089  return *this;
1090 }
1092 //*************************************************************************************************
1093 
1094 
1095 //*************************************************************************************************
1108 template< typename VT // Type of the sparse vector
1109  , bool AF // Alignment flag
1110  , bool TF > // Transpose flag
1111 template< typename VT2 > // Type of the right-hand side vector
1112 inline Subvector<VT,AF,TF,false>&
1113  Subvector<VT,AF,TF,false>::operator*=( const Vector<VT2,TF>& rhs )
1114 {
1115  using blaze::assign;
1116 
1120 
1121  typedef MultTrait_< ResultType, ResultType_<VT2> > MultType;
1122 
1125 
1126  if( size() != (~rhs).size() ) {
1127  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1128  }
1129 
1130  const MultType tmp( *this * (~rhs) );
1131 
1132  if( !tryAssign( vector_, tmp, offset_ ) ) {
1133  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1134  }
1135 
1136  DerestrictTrait_<This> left( derestrict( *this ) );
1137 
1138  left.reset();
1139  assign( left, tmp );
1140 
1141  BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1142 
1143  return *this;
1144 }
1146 //*************************************************************************************************
1147 
1148 
1149 //*************************************************************************************************
1161 template< typename VT // Type of the sparse vector
1162  , bool AF // Alignment flag
1163  , bool TF > // Transpose flag
1164 template< typename VT2 > // Type of the right-hand side dense vector
1165 inline Subvector<VT,AF,TF,false>&
1166  Subvector<VT,AF,TF,false>::operator/=( const DenseVector<VT2,TF>& rhs )
1167 {
1168  using blaze::assign;
1169 
1172  BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE ( ResultType_<VT2> );
1174 
1175  typedef DivTrait_< ResultType, ResultType_<VT2> > DivType;
1176 
1180 
1181  if( size() != (~rhs).size() ) {
1182  BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1183  }
1184 
1185  const DivType tmp( *this / (~rhs) );
1186 
1187  if( !tryAssign( vector_, tmp, offset_ ) ) {
1188  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted vector" );
1189  }
1190 
1191  DerestrictTrait_<This> left( derestrict( *this ) );
1192 
1193  left.reset();
1194  assign( left, tmp );
1195 
1196  BLAZE_INTERNAL_ASSERT( isIntact( vector_ ), "Invariant violation detected" );
1197 
1198  return *this;
1199 }
1201 //*************************************************************************************************
1202 
1203 
1204 //*************************************************************************************************
1216 template< typename VT // Type of the sparse vector
1217  , bool AF // Alignment flag
1218  , bool TF > // Transpose flag
1219 template< typename Other > // Data type of the right-hand side scalar
1220 inline EnableIf_<IsNumeric<Other>, Subvector<VT,AF,TF,false> >&
1222 {
1223  const Iterator last( end() );
1224  for( Iterator element=begin(); element!=last; ++element )
1225  element->value() *= rhs;
1226  return *this;
1227 }
1229 //*************************************************************************************************
1230 
1231 
1232 //*************************************************************************************************
1245 template< typename VT // Type of the sparse vector
1246  , bool AF // Alignment flag
1247  , bool TF > // Transpose flag
1248 template< typename Other > // Data type of the right-hand side scalar
1249 inline EnableIf_<IsNumeric<Other>, Subvector<VT,AF,TF,false> >&
1251 {
1252  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1253 
1254  typedef DivTrait_<ElementType,Other> DT;
1255  typedef If_< IsNumeric<DT>, DT, Other > Tmp;
1256 
1257  const Iterator last( end() );
1258 
1259  // Depending on the two involved data types, an integer division is applied or a
1260  // floating point division is selected.
1261  if( IsNumeric<DT>::value && IsFloatingPoint<DT>::value ) {
1262  const Tmp tmp( Tmp(1)/static_cast<Tmp>( rhs ) );
1263  for( Iterator element=begin(); element!=last; ++element )
1264  element->value() *= tmp;
1265  }
1266  else {
1267  for( Iterator element=begin(); element!=last; ++element )
1268  element->value() /= rhs;
1269  }
1270 
1271  return *this;
1272 }
1274 //*************************************************************************************************
1275 
1276 
1277 
1278 
1279 //=================================================================================================
1280 //
1281 // UTILITY FUNCTIONS
1282 //
1283 //=================================================================================================
1284 
1285 //*************************************************************************************************
1291 template< typename VT // Type of the sparse vector
1292  , bool AF // Alignment flag
1293  , bool TF > // Transpose flag
1294 inline size_t Subvector<VT,AF,TF,false>::size() const noexcept
1295 {
1296  return size_;
1297 }
1299 //*************************************************************************************************
1300 
1301 
1302 //*************************************************************************************************
1308 template< typename VT // Type of the sparse vector
1309  , bool AF // Alignment flag
1310  , bool TF > // Transpose flag
1311 inline size_t Subvector<VT,AF,TF,false>::capacity() const noexcept
1312 {
1313  return nonZeros() + vector_.capacity() - vector_.nonZeros();
1314 }
1316 //*************************************************************************************************
1317 
1318 
1319 //*************************************************************************************************
1327 template< typename VT // Type of the sparse vector
1328  , bool AF // Alignment flag
1329  , bool TF > // Transpose flag
1330 inline size_t Subvector<VT,AF,TF,false>::nonZeros() const
1331 {
1332  return end() - begin();
1333 }
1335 //*************************************************************************************************
1336 
1337 
1338 //*************************************************************************************************
1344 template< typename VT // Type of the sparse vector
1345  , bool AF // Alignment flag
1346  , bool TF > // Transpose flag
1348 {
1349  vector_.erase( vector_.lowerBound( offset_ ), vector_.lowerBound( offset_ + size_ ) );
1350 }
1352 //*************************************************************************************************
1353 
1354 
1355 //*************************************************************************************************
1367 template< typename VT // Type of the sparse vector
1368  , bool AF // Alignment flag
1369  , bool TF > // Transpose flag
1371  Subvector<VT,AF,TF,false>::set( size_t index, const ElementType& value )
1372 {
1373  return Iterator( vector_.set( offset_ + index, value ), offset_ );
1374 }
1376 //*************************************************************************************************
1377 
1378 
1379 //*************************************************************************************************
1392 template< typename VT // Type of the sparse vector
1393  , bool AF // Alignment flag
1394  , bool TF > // Transpose flag
1396  Subvector<VT,AF,TF,false>::insert( size_t index, const ElementType& value )
1397 {
1398  return Iterator( vector_.insert( offset_ + index, value ), offset_ );
1399 }
1401 //*************************************************************************************************
1402 
1403 
1404 //*************************************************************************************************
1413 template< typename VT // Type of the sparse vector
1414  , bool AF // Alignment flag
1415  , bool TF > // Transpose flag
1416 inline void Subvector<VT,AF,TF,false>::erase( size_t index )
1417 {
1418  vector_.erase( offset_ + index );
1419 }
1421 //*************************************************************************************************
1422 
1423 
1424 //*************************************************************************************************
1433 template< typename VT // Type of the sparse vector
1434  , bool AF // Alignment flag
1435  , bool TF > // Transpose flag
1436 inline typename Subvector<VT,AF,TF,false>::Iterator Subvector<VT,AF,TF,false>::erase( Iterator pos )
1437 {
1438  return Iterator( vector_.erase( pos.base() ), offset_ );
1439 }
1441 //*************************************************************************************************
1442 
1443 
1444 //*************************************************************************************************
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>::erase( Iterator first, Iterator last )
1459 {
1460  return Iterator( vector_.erase( first.base(), last.base() ), offset_ );
1461 }
1463 //*************************************************************************************************
1464 
1465 
1466 //*************************************************************************************************
1476 template< typename VT // Type of the sparse vector
1477  , bool AF // Alignment flag
1478  , bool TF > // Transpose flag
1479 void Subvector<VT,AF,TF,false>::reserve( size_t n )
1480 {
1481  const size_t current( capacity() );
1482 
1483  if( n > current ) {
1484  vector_.reserve( vector_.capacity() + n - current );
1485  }
1486 }
1488 //*************************************************************************************************
1489 
1490 
1491 //*************************************************************************************************
1498 template< typename VT // Type of the sparse vector
1499  , bool AF // Alignment flag
1500  , bool TF > // Transpose flag
1501 template< typename Other > // Data type of the scalar value
1502 inline Subvector<VT,AF,TF,false>& Subvector<VT,AF,TF,false>::scale( const Other& scalar )
1503 {
1504  for( Iterator element=begin(); element!=end(); ++element )
1505  element->value() *= scalar;
1506  return *this;
1507 }
1509 //*************************************************************************************************
1510 
1511 
1512 
1513 
1514 //=================================================================================================
1515 //
1516 // LOOKUP FUNCTIONS
1517 //
1518 //=================================================================================================
1519 
1520 //*************************************************************************************************
1534 template< typename VT // Type of the sparse vector
1535  , bool AF // Alignment flag
1536  , bool TF > // Transpose flag
1538  Subvector<VT,AF,TF,false>::find( size_t index )
1539 {
1540  const Iterator_<VT> pos( vector_.find( offset_ + index ) );
1541 
1542  if( pos != vector_.end() )
1543  return Iterator( pos, offset_ );
1544  else
1545  return end();
1546 }
1548 //*************************************************************************************************
1549 
1550 
1551 //*************************************************************************************************
1565 template< typename VT // Type of the sparse vector
1566  , bool AF // Alignment flag
1567  , bool TF > // Transpose flag
1569  Subvector<VT,AF,TF,false>::find( size_t index ) const
1570 {
1571  const ConstIterator_<VT> pos( vector_.find( offset_ + index ) );
1572 
1573  if( pos != vector_.end() )
1574  return Iterator( pos, offset_ );
1575  else
1576  return end();
1577 }
1579 //*************************************************************************************************
1580 
1581 
1582 //*************************************************************************************************
1595 template< typename VT // Type of the sparse vector
1596  , bool AF // Alignment flag
1597  , bool TF > // Transpose flag
1599  Subvector<VT,AF,TF,false>::lowerBound( size_t index )
1600 {
1601  return Iterator( vector_.lowerBound( offset_ + index ), offset_ );
1602 }
1604 //*************************************************************************************************
1605 
1606 
1607 //*************************************************************************************************
1620 template< typename VT // Type of the sparse vector
1621  , bool AF // Alignment flag
1622  , bool TF > // Transpose flag
1624  Subvector<VT,AF,TF,false>::lowerBound( size_t index ) const
1625 {
1626  return ConstIterator( vector_.lowerBound( offset_ + index ), offset_ );
1627 }
1629 //*************************************************************************************************
1630 
1631 
1632 //*************************************************************************************************
1645 template< typename VT // Type of the sparse vector
1646  , bool AF // Alignment flag
1647  , bool TF > // Transpose flag
1649  Subvector<VT,AF,TF,false>::upperBound( size_t index )
1650 {
1651  return Iterator( vector_.upperBound( offset_ + index ), offset_ );
1652 }
1654 //*************************************************************************************************
1655 
1656 
1657 //*************************************************************************************************
1670 template< typename VT // Type of the sparse vector
1671  , bool AF // Alignment flag
1672  , bool TF > // Transpose flag
1674  Subvector<VT,AF,TF,false>::upperBound( size_t index ) const
1675 {
1676  return ConstIterator( vector_.upperBound( offset_ + index ), offset_ );
1677 }
1679 //*************************************************************************************************
1680 
1681 
1682 
1683 
1684 //=================================================================================================
1685 //
1686 // LOW-LEVEL UTILITY FUNCTIONS
1687 //
1688 //=================================================================================================
1689 
1690 //*************************************************************************************************
1715 template< typename VT // Type of the sparse vector
1716  , bool AF // Alignment flag
1717  , bool TF > // Transpose flag
1718 inline void Subvector<VT,AF,TF,false>::append( size_t index, const ElementType& value, bool check )
1719 {
1720  if( offset_ + size_ == vector_.size() )
1721  vector_.append( offset_ + index, value, check );
1722  else if( !check || !isDefault( value ) )
1723  vector_.insert( offset_ + index, value );
1724 }
1726 //*************************************************************************************************
1727 
1728 
1729 
1730 
1731 //=================================================================================================
1732 //
1733 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1734 //
1735 //=================================================================================================
1736 
1737 //*************************************************************************************************
1748 template< typename VT // Type of the sparse vector
1749  , bool AF // Alignment flag
1750  , bool TF > // Transpose flag
1751 template< typename Other > // Data type of the foreign expression
1752 inline bool Subvector<VT,AF,TF,false>::canAlias( const Other* alias ) const noexcept
1753 {
1754  return vector_.isAliased( alias );
1755 }
1757 //*************************************************************************************************
1758 
1759 
1760 //*************************************************************************************************
1771 template< typename VT // Type of the sparse vector
1772  , bool AF // Alignment flag
1773  , bool TF > // Transpose flag
1774 template< typename Other > // Data type of the foreign expression
1775 inline bool Subvector<VT,AF,TF,false>::isAliased( const Other* alias ) const noexcept
1776 {
1777  return vector_.isAliased( alias );
1778 }
1780 //*************************************************************************************************
1781 
1782 
1783 //*************************************************************************************************
1794 template< typename VT // Type of the sparse vector
1795  , bool AF // Alignment flag
1796  , bool TF > // Transpose flag
1797 inline bool Subvector<VT,AF,TF,false>::canSMPAssign() const noexcept
1798 {
1799  return false;
1800 }
1802 //*************************************************************************************************
1803 
1804 
1805 //*************************************************************************************************
1817 template< typename VT // Type of the sparse vector
1818  , bool AF // Alignment flag
1819  , bool TF > // Transpose flag
1820 template< typename VT2 > // Type of the right-hand side dense vector
1821 inline void Subvector<VT,AF,TF,false>::assign( const DenseVector<VT2,TF>& rhs )
1822 {
1823  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1824  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1825 
1826  reserve( (~rhs).size() );
1827 
1828  for( size_t i=0UL; i<size(); ++i ) {
1829  append( i, (~rhs)[i], true );
1830  }
1831 }
1833 //*************************************************************************************************
1834 
1835 
1836 //*************************************************************************************************
1848 template< typename VT // Type of the sparse vector
1849  , bool AF // Alignment flag
1850  , bool TF > // Transpose flag
1851 template< typename VT2 > // Type of the right-hand side sparse vector
1852 inline void Subvector<VT,AF,TF,false>::assign( const SparseVector<VT2,TF>& rhs )
1853 {
1854  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1855  BLAZE_INTERNAL_ASSERT( nonZeros() == 0UL, "Invalid non-zero elements detected" );
1856 
1857  reserve( (~rhs).nonZeros() );
1858 
1859  for( ConstIterator_<VT2> element=(~rhs).begin(); element!=(~rhs).end(); ++element ) {
1860  append( element->index(), element->value(), true );
1861  }
1862 }
1864 //*************************************************************************************************
1865 
1866 
1867 //*************************************************************************************************
1879 template< typename VT // Type of the sparse vector
1880  , bool AF // Alignment flag
1881  , bool TF > // Transpose flag
1882 template< typename VT2 > // Type of the right-hand side dense vector
1883 inline void Subvector<VT,AF,TF,false>::addAssign( const DenseVector<VT2,TF>& rhs )
1884 {
1885  typedef AddTrait_< ResultType, ResultType_<VT2> > AddType;
1886 
1890 
1891  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1892 
1893  const AddType tmp( serial( *this + (~rhs) ) );
1894  reset();
1895  assign( tmp );
1896 }
1898 //*************************************************************************************************
1899 
1900 
1901 //*************************************************************************************************
1913 template< typename VT // Type of the sparse vector
1914  , bool AF // Alignment flag
1915  , bool TF > // Transpose flag
1916 template< typename VT2 > // Type of the right-hand side sparse vector
1917 inline void Subvector<VT,AF,TF,false>::addAssign( const SparseVector<VT2,TF>& rhs )
1918 {
1919  typedef AddTrait_< ResultType, ResultType_<VT2> > AddType;
1920 
1924 
1925  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1926 
1927  const AddType tmp( serial( *this + (~rhs) ) );
1928  reset();
1929  assign( tmp );
1930 }
1932 //*************************************************************************************************
1933 
1934 
1935 //*************************************************************************************************
1947 template< typename VT // Type of the sparse vector
1948  , bool AF // Alignment flag
1949  , bool TF > // Transpose flag
1950 template< typename VT2 > // Type of the right-hand side dense vector
1951 inline void Subvector<VT,AF,TF,false>::subAssign( const DenseVector<VT2,TF>& rhs )
1952 {
1953  typedef SubTrait_< ResultType, ResultType_<VT2> > SubType;
1954 
1958 
1959  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1960 
1961  const SubType tmp( serial( *this - (~rhs) ) );
1962  reset();
1963  assign( tmp );
1964 }
1966 //*************************************************************************************************
1967 
1968 
1969 //*************************************************************************************************
1981 template< typename VT // Type of the sparse vector
1982  , bool AF // Alignment flag
1983  , bool TF > // Transpose flag
1984 template< typename VT2 > // Type of the right-hand side sparse vector
1985 inline void Subvector<VT,AF,TF,false>::subAssign( const SparseVector<VT2,TF>& rhs )
1986 {
1987  typedef SubTrait_< ResultType, ResultType_<VT2> > SubType;
1988 
1992 
1993  BLAZE_INTERNAL_ASSERT( size() == (~rhs).size(), "Invalid vector sizes" );
1994 
1995  const SubType tmp( serial( *this - (~rhs) ) );
1996  reset();
1997  assign( tmp );
1998 }
2000 //*************************************************************************************************
2001 
2002 } // namespace blaze
2003 
2004 #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.
typename DerestrictTrait< T >::Type DerestrictTrait_
Auxiliary alias declaration for the DerestrictTrait type trait.The DerestrictTrait_ alias declaration...
Definition: DerestrictTrait.h:110
#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.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7800
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:346
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:653
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:258
#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:1339
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:188
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2643
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2636
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
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:384
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
#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:1321
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:298
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:232
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
SubvectorExprTrait_< VT, unaligned > subvector(Vector< VT, TF > &vector, size_t index, size_t size)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:152
Header file for the multiplication trait.
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.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#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.
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.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2640
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:254
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2641
Constraint on the data type.
Constraint on the data type.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
Header file for the EnableIf class template.
Header file for the DerestrictTrait 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
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2642
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:1285
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the division trait.
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
Header file for the isDefault shim.
#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.
#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
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2637
#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
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2638
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
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:1303
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.