SparseNonNumeric.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_SPARSENONNUMERIC_H_
36 #define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_SPARSENONNUMERIC_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <utility>
45 #include <vector>
49 #include <blaze/math/Aliases.h>
59 #include <blaze/math/Exception.h>
61 #include <blaze/math/shims/Clear.h>
76 #include <blaze/util/Assert.h>
82 #include <blaze/util/DisableIf.h>
83 #include <blaze/util/EnableIf.h>
84 #include <blaze/util/mpl/If.h>
87 #include <blaze/util/Types.h>
88 #include <blaze/util/Unused.h>
89 
90 
91 namespace blaze {
92 
93 //=================================================================================================
94 //
95 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES WITH NON-NUMERIC ELEMENT TYPE
96 //
97 //=================================================================================================
98 
99 //*************************************************************************************************
107 template< typename MT // Type of the adapted sparse matrix
108  , bool SO > // Storage order of the adapted sparse matrix
109 class SymmetricMatrix<MT,SO,false,false>
110  : public SparseMatrix< SymmetricMatrix<MT,SO,false,false>, SO >
111 {
112  private:
113  //**Type definitions****************************************************************************
114  using OT = OppositeType_<MT>;
115  using TT = TransposeType_<MT>;
116  using ET = ElementType_<MT>;
117 
119  using MatrixType = typename MT::template Rebind< SharedValue<ET> >::Other;
120  //**********************************************************************************************
121 
122  public:
123  //**Type definitions****************************************************************************
124  using This = SymmetricMatrix<MT,SO,false,false>;
125  using BaseType = SparseMatrix<This,SO>;
126  using ResultType = This;
127  using OppositeType = SymmetricMatrix<OT,!SO,false,false>;
128  using TransposeType = SymmetricMatrix<TT,!SO,false,false>;
129  using ElementType = ET;
130  using ReturnType = ReturnType_<MT>;
131  using CompositeType = const This&;
132  using Reference = NonNumericProxy<MatrixType>;
133  using ConstReference = ConstReference_<MT>;
134  //**********************************************************************************************
135 
136  //**Rebind struct definition********************************************************************
139  template< typename NewType > // Data type of the other matrix
140  struct Rebind {
142  using Other = SymmetricMatrix< typename MT::template Rebind<NewType>::Other >;
143  };
144  //**********************************************************************************************
145 
146  //**Resize struct definition********************************************************************
149  template< size_t NewM // Number of rows of the other matrix
150  , size_t NewN > // Number of columns of the other matrix
151  struct Resize {
153  using Other = SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other >;
154  };
155  //**********************************************************************************************
156 
157  //**SharedElement class definition**************************************************************
160  template< typename IteratorType > // Type of the sparse matrix iterator
161  class SharedElement
162  : private SparseElement
163  {
164  public:
165  //**Type definitions*************************************************************************
166  using ValueType = ET;
167  using IndexType = size_t;
168  using Reference = ValueType&;
169  using ConstReference = const ValueType&;
170  using Pointer = SharedElement*;
171  using ConstPointer = const SharedElement*;
172  //*******************************************************************************************
173 
174  //**Constructor******************************************************************************
179  inline SharedElement( IteratorType pos )
180  : pos_( pos ) // Iterator to the current sparse symmetric matrix element
181  {}
182  //*******************************************************************************************
183 
184  //**Assignment operator**********************************************************************
190  template< typename T > inline SharedElement& operator=( const T& v ) {
191  *pos_->value() = v;
192  return *this;
193  }
194  //*******************************************************************************************
195 
196  //**Addition assignment operator*************************************************************
202  template< typename T > inline SharedElement& operator+=( const T& v ) {
203  *pos_->value() += v;
204  return *this;
205  }
206  //*******************************************************************************************
207 
208  //**Subtraction assignment operator**********************************************************
214  template< typename T > inline SharedElement& operator-=( const T& v ) {
215  *pos_->value() -= v;
216  return *this;
217  }
218  //*******************************************************************************************
219 
220  //**Multiplication assignment operator*******************************************************
226  template< typename T > inline SharedElement& operator*=( const T& v ) {
227  *pos_->value() *= v;
228  return *this;
229  }
230  //*******************************************************************************************
231 
232  //**Division assignment operator*************************************************************
238  template< typename T > inline SharedElement& operator/=( const T& v ) {
239  *pos_->value() /= v;
240  return *this;
241  }
242  //*******************************************************************************************
243 
244  //**Element access operator******************************************************************
249  inline Pointer operator->() {
250  return this;
251  }
252  //*******************************************************************************************
253 
254  //**Element access operator******************************************************************
259  inline ConstPointer operator->() const {
260  return this;
261  }
262  //*******************************************************************************************
263 
264  //**Value function***************************************************************************
269  inline Reference value() {
270  return *pos_->value();
271  }
272  //*******************************************************************************************
273 
274  //**Value function***************************************************************************
279  inline ConstReference value() const {
280  return *pos_->value();
281  }
282  //*******************************************************************************************
283 
284  //**Index function***************************************************************************
289  inline IndexType index() const {
290  return pos_->index();
291  }
292  //*******************************************************************************************
293 
294  private:
295  //**Member variables*************************************************************************
296  IteratorType pos_;
297  //*******************************************************************************************
298  };
299  //**********************************************************************************************
300 
301  //**SharedIterator class definition*************************************************************
304  template< typename SparseElementType // Type of the underlying sparse elements.
305  , typename IteratorType > // Type of the sparse matrix iterator
306  class SharedIterator
307  {
308  public:
309  //**Type definitions*************************************************************************
310  using IteratorCategory = std::forward_iterator_tag;
311  using ValueType = SparseElementType;
312  using PointerType = SparseElementType;
313  using ReferenceType = SparseElementType;
314  using DifferenceType = ptrdiff_t;
315 
316  // STL iterator requirements
317  using iterator_category = IteratorCategory;
318  using value_type = ValueType;
319  using pointer = PointerType;
320  using reference = ReferenceType;
321  using difference_type = DifferenceType;
322  //*******************************************************************************************
323 
324  //**Default constructor**********************************************************************
327  inline SharedIterator()
328  : pos_() // Iterator to the current sparse symmetric matrix element
329  {}
330  //*******************************************************************************************
331 
332  //**Constructor******************************************************************************
337  inline SharedIterator( IteratorType pos )
338  : pos_( pos ) // Iterator to the current sparse symmetric matrix element
339  {}
340  //*******************************************************************************************
341 
342  //**Constructor******************************************************************************
347  template< typename SparseElementType2, typename IteratorType2 >
348  inline SharedIterator( const SharedIterator<SparseElementType2,IteratorType2>& it )
349  : pos_( it.pos_ ) // Iterator to the current sparse symmetric matrix element
350  {}
351  //*******************************************************************************************
352 
353  //**Prefix increment operator****************************************************************
358  inline SharedIterator& operator++() {
359  ++pos_;
360  return *this;
361  }
362  //*******************************************************************************************
363 
364  //**Postfix increment operator***************************************************************
369  inline const SharedIterator operator++( int ) {
370  const SharedIterator tmp( *this );
371  ++(*this);
372  return tmp;
373  }
374  //*******************************************************************************************
375 
376  //**Element access operator******************************************************************
381  inline ReferenceType operator*() const {
382  return ReferenceType( pos_ );
383  }
384  //*******************************************************************************************
385 
386  //**Element access operator******************************************************************
391  inline PointerType operator->() const {
392  return PointerType( pos_ );
393  }
394  //*******************************************************************************************
395 
396  //**Equality operator************************************************************************
402  inline bool operator==( const SharedIterator& rhs ) const {
403  return pos_ == rhs.pos_;
404  }
405  //*******************************************************************************************
406 
407  //**Inequality operator**********************************************************************
413  inline bool operator!=( const SharedIterator& rhs ) const {
414  return !( *this == rhs );
415  }
416  //*******************************************************************************************
417 
418  //**Subtraction operator*********************************************************************
424  inline DifferenceType operator-( const SharedIterator& rhs ) const {
425  return pos_ - rhs.pos_;
426  }
427  //*******************************************************************************************
428 
429  //**Base function****************************************************************************
434  inline IteratorType base() const {
435  return pos_;
436  }
437  //*******************************************************************************************
438 
439  private:
440  //**Member variables*************************************************************************
441  IteratorType pos_;
442  //*******************************************************************************************
443 
444  //**Friend declarations**********************************************************************
445  template< typename SparseElementType2, typename IteratorType2 > friend class SharedIterator;
446  //*******************************************************************************************
447  };
448  //**********************************************************************************************
449 
450  //**Type definitions****************************************************************************
452  using Iterator = SharedIterator< SharedElement< Iterator_<MatrixType> >
453  , Iterator_<MatrixType> >;
454 
456  using ConstIterator = SharedIterator< const SharedElement< ConstIterator_<MatrixType> >
457  , ConstIterator_<MatrixType> >;
458  //**********************************************************************************************
459 
460  //**Compilation flags***************************************************************************
462  enum : bool { smpAssignable = false };
463  //**********************************************************************************************
464 
465  //**Constructors********************************************************************************
468  explicit inline SymmetricMatrix();
469  explicit inline SymmetricMatrix( size_t n );
470  explicit inline SymmetricMatrix( size_t n, size_t nonzeros );
471  explicit inline SymmetricMatrix( size_t n, const std::vector<size_t>& nonzeros );
472 
473  inline SymmetricMatrix( const SymmetricMatrix& m );
474  inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
475 
476  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,SO>& m );
477  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,!SO>& m );
479  //**********************************************************************************************
480 
481  //**Destructor**********************************************************************************
482  // No explicitly declared destructor.
483  //**********************************************************************************************
484 
485  //**Data access functions***********************************************************************
488  inline Reference operator()( size_t i, size_t j );
489  inline ConstReference operator()( size_t i, size_t j ) const;
490  inline Reference at( size_t i, size_t j );
491  inline ConstReference at( size_t i, size_t j ) const;
492  inline Iterator begin ( size_t i );
493  inline ConstIterator begin ( size_t i ) const;
494  inline ConstIterator cbegin( size_t i ) const;
495  inline Iterator end ( size_t i );
496  inline ConstIterator end ( size_t i ) const;
497  inline ConstIterator cend ( size_t i ) const;
499  //**********************************************************************************************
500 
501  //**Assignment operators************************************************************************
504  inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
505  inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
506 
507  template< typename MT2 >
508  inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
509 
510  template< typename MT2 >
511  inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
512 
513  template< typename MT2 >
514  inline SymmetricMatrix& operator=( const Matrix<MT2,!SO>& rhs );
515 
516  template< typename MT2 >
517  inline SymmetricMatrix& operator+=( const Matrix<MT2,SO>& rhs );
518 
519  template< typename MT2 >
520  inline SymmetricMatrix& operator+=( const Matrix<MT2,!SO>& rhs );
521 
522  template< typename MT2 >
523  inline SymmetricMatrix& operator-=( const Matrix<MT2,SO>& rhs );
524 
525  template< typename MT2 >
526  inline SymmetricMatrix& operator-=( const Matrix<MT2,!SO>& rhs );
527 
528  template< typename MT2 >
529  inline SymmetricMatrix& operator%=( const Matrix<MT2,SO>& rhs );
530 
531  template< typename MT2 >
532  inline SymmetricMatrix& operator%=( const Matrix<MT2,!SO>& rhs );
533 
534  template< typename ST >
535  inline EnableIf_< IsNumeric<ST>, SymmetricMatrix >& operator*=( ST rhs );
536 
537  template< typename ST >
538  inline EnableIf_< IsNumeric<ST>, SymmetricMatrix >& operator/=( ST rhs );
540  //**********************************************************************************************
541 
542  //**Utility functions***************************************************************************
545  inline size_t rows() const noexcept;
546  inline size_t columns() const noexcept;
547  inline size_t capacity() const noexcept;
548  inline size_t capacity( size_t i ) const noexcept;
549  inline size_t nonZeros() const;
550  inline size_t nonZeros( size_t i ) const;
551  inline void reset();
552  inline void reset( size_t i );
553  inline void clear();
554  inline void resize ( size_t n, bool preserve=true );
555  inline void reserve( size_t nonzeros );
556  inline void reserve( size_t i, size_t nonzeros );
557  inline void trim();
558  inline void trim( size_t i );
559  inline void shrinkToFit();
560  inline void swap( SymmetricMatrix& m ) noexcept;
562  //**********************************************************************************************
563 
564  //**Insertion functions*************************************************************************
567  inline Iterator set ( size_t i, size_t j, const ElementType& value );
568  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
569  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
570  inline void finalize( size_t i );
572  //**********************************************************************************************
573 
574  //**Erase functions*****************************************************************************
577  inline void erase( size_t i, size_t j );
578  inline Iterator erase( size_t i, Iterator pos );
579  inline Iterator erase( size_t i, Iterator first, Iterator last );
580 
581  template< typename Pred >
582  inline void erase( Pred predicate );
583 
584  template< typename Pred >
585  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
587  //**********************************************************************************************
588 
589  //**Lookup functions****************************************************************************
592  inline Iterator find ( size_t i, size_t j );
593  inline ConstIterator find ( size_t i, size_t j ) const;
594  inline Iterator lowerBound( size_t i, size_t j );
595  inline ConstIterator lowerBound( size_t i, size_t j ) const;
596  inline Iterator upperBound( size_t i, size_t j );
597  inline ConstIterator upperBound( size_t i, size_t j ) const;
599  //**********************************************************************************************
600 
601  //**Numeric functions***************************************************************************
604  inline SymmetricMatrix& transpose();
605  inline SymmetricMatrix& ctranspose();
606 
607  template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
609  //**********************************************************************************************
610 
611  //**Debugging functions*************************************************************************
614  inline bool isIntact() const noexcept;
616  //**********************************************************************************************
617 
618  //**Expression template evaluation functions****************************************************
621  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
622  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
623 
624  inline bool canSMPAssign() const noexcept;
626  //**********************************************************************************************
627 
628  private:
629  //**Expression template evaluation functions****************************************************
632  template< typename MT2 > void assign( DenseMatrix<MT2,SO>& rhs );
633  template< typename MT2 > void assign( const DenseMatrix<MT2,SO>& rhs );
634  template< typename MT2 > void assign( SparseMatrix<MT2,SO>& rhs );
635  template< typename MT2 > void assign( const SparseMatrix<MT2,SO>& rhs );
637  //**********************************************************************************************
638 
639  //**Member variables****************************************************************************
642  MatrixType matrix_;
643 
644  //**********************************************************************************************
645 
646  //**Friend declarations*************************************************************************
647  template< bool RF, typename MT2, bool SO2, bool DF2, bool NF2 >
648  friend bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
649  //**********************************************************************************************
650 
651  //**Compile time checks*************************************************************************
665  BLAZE_STATIC_ASSERT( ( Size<MT,0UL>::value == Size<MT,1UL>::value ) );
666  //**********************************************************************************************
667 };
669 //*************************************************************************************************
670 
671 
672 
673 
674 //=================================================================================================
675 //
676 // CONSTRUCTORS
677 //
678 //=================================================================================================
679 
680 //*************************************************************************************************
684 template< typename MT // Type of the adapted sparse matrix
685  , bool SO > // Storage order of the adapted sparse matrix
686 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix()
687  : matrix_() // The adapted sparse matrix
688 {
689  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
690 }
692 //*************************************************************************************************
693 
694 
695 //*************************************************************************************************
703 template< typename MT // Type of the adapted sparse matrix
704  , bool SO > // Storage order of the adapted sparse matrix
705 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n )
706  : matrix_( n, n ) // The adapted sparse matrix
707 {
709 
710  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
711 }
713 //*************************************************************************************************
714 
715 
716 //*************************************************************************************************
725 template< typename MT // Type of the adapted sparse matrix
726  , bool SO > // Storage order of the adapted sparse matrix
727 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n, size_t nonzeros )
728  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
729 {
731 
732  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
733 }
735 //*************************************************************************************************
736 
737 
738 //*************************************************************************************************
749 template< typename MT // Type of the adapted sparse matrix
750  , bool SO > // Storage order of the adapted sparse matrix
751 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n, const std::vector<size_t>& nonzeros )
752  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
753 {
755 
756  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
757 }
759 //*************************************************************************************************
760 
761 
762 //*************************************************************************************************
768 template< typename MT // Type of the adapted sparse matrix
769  , bool SO > // Storage order of the adapted sparse matrix
770 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const SymmetricMatrix& m )
771  : matrix_() // The adapted sparse matrix
772 {
773  using blaze::resize;
774 
775  resize( matrix_, m.rows(), m.columns() );
776  assign( m );
777 
778  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
779  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
780 }
782 //*************************************************************************************************
783 
784 
785 //*************************************************************************************************
791 template< typename MT // Type of the adapted sparse matrix
792  , bool SO > // Storage order of the adapted sparse matrix
793 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
794  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
795 {
796  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
797  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
798 }
800 //*************************************************************************************************
801 
802 
803 //*************************************************************************************************
813 template< typename MT // Type of the adapted sparse matrix
814  , bool SO > // Storage order of the adapted sparse matrix
815 template< typename MT2 > // Type of the foreign matrix
816 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const Matrix<MT2,SO>& m )
817  : matrix_() // The adapted sparse matrix
818 {
819  using blaze::resize;
820 
821  using RT = RemoveAdaptor_< ResultType_<MT2> >;
822  using Tmp = If_< IsComputation<MT2>, RT, const MT2& >;
823 
824  Tmp tmp( ~m );
825 
826  if( !IsSymmetric<MT2>::value && !isSymmetric( tmp ) ) {
827  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
828  }
829 
830  resize( matrix_, tmp.rows(), tmp.columns() );
831  assign( tmp );
832 
833  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
834  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
835 }
837 //*************************************************************************************************
838 
839 
840 //*************************************************************************************************
850 template< typename MT // Type of the adapted sparse matrix
851  , bool SO > // Storage order of the adapted sparse matrix
852 template< typename MT2 > // Type of the foreign matrix
853 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
854  : matrix_() // The adapted sparse matrix
855 {
856  using blaze::resize;
857 
858  using RT = RemoveAdaptor_< ResultType_<MT2> >;
859  using Tmp = If_< IsComputation<MT2>, RT, const MT2& >;
860 
861  Tmp tmp( ~m );
862 
863  if( !IsSymmetric<MT2>::value && !isSymmetric( tmp ) ) {
864  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
865  }
866 
867  resize( matrix_, tmp.rows(), tmp.columns() );
868  assign( trans( tmp ) );
869 
870  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
871  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
872 }
874 //*************************************************************************************************
875 
876 
877 
878 
879 //=================================================================================================
880 //
881 // DATA ACCESS FUNCTIONS
882 //
883 //=================================================================================================
884 
885 //*************************************************************************************************
900 template< typename MT // Type of the adapted sparse matrix
901  , bool SO > // Storage order of the adapted sparse matrix
903  SymmetricMatrix<MT,SO,false,false>::operator()( size_t i, size_t j )
904 {
905  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
906  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
907 
908  return Reference( matrix_, i, j );
909 }
911 //*************************************************************************************************
912 
913 
914 //*************************************************************************************************
929 template< typename MT // Type of the adapted sparse matrix
930  , bool SO > // Storage order of the adapted sparse matrix
932  SymmetricMatrix<MT,SO,false,false>::operator()( size_t i, size_t j ) const
933 {
934  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
935  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
936 
937  return *matrix_(i,j);
938 }
940 //*************************************************************************************************
941 
942 
943 //*************************************************************************************************
959 template< typename MT // Type of the adapted dense matrix
960  , bool SO > // Storage order of the adapted dense matrix
962  SymmetricMatrix<MT,SO,false,false>::at( size_t i, size_t j )
963 {
964  if( i >= rows() ) {
965  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
966  }
967  if( j >= columns() ) {
968  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
969  }
970  return (*this)(i,j);
971 }
973 //*************************************************************************************************
974 
975 
976 //*************************************************************************************************
992 template< typename MT // Type of the adapted dense matrix
993  , bool SO > // Storage order of the adapted dense matrix
995  SymmetricMatrix<MT,SO,false,false>::at( size_t i, size_t j ) const
996 {
997  if( i >= rows() ) {
998  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
999  }
1000  if( j >= columns() ) {
1001  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1002  }
1003  return (*this)(i,j);
1004 }
1006 //*************************************************************************************************
1007 
1008 
1009 //*************************************************************************************************
1021 template< typename MT // Type of the adapted sparse matrix
1022  , bool SO > // Storage order of the adapted sparse matrix
1025 {
1026  return Iterator( matrix_.begin(i) );
1027 }
1029 //*************************************************************************************************
1030 
1031 
1032 //*************************************************************************************************
1044 template< typename MT // Type of the adapted sparse matrix
1045  , bool SO > // Storage order of the adapted sparse matrix
1048 {
1049  return ConstIterator( matrix_.begin(i) );
1050 }
1052 //*************************************************************************************************
1053 
1054 
1055 //*************************************************************************************************
1067 template< typename MT // Type of the adapted sparse matrix
1068  , bool SO > // Storage order of the adapted sparse matrix
1071 {
1072  return ConstIterator( matrix_.cbegin(i) );
1073 }
1075 //*************************************************************************************************
1076 
1077 
1078 //*************************************************************************************************
1090 template< typename MT // Type of the adapted sparse matrix
1091  , bool SO > // Storage order of the adapted sparse matrix
1094 {
1095  return Iterator( matrix_.end(i) );
1096 }
1098 //*************************************************************************************************
1099 
1100 
1101 //*************************************************************************************************
1113 template< typename MT // Type of the adapted sparse matrix
1114  , bool SO > // Storage order of the adapted sparse matrix
1116  SymmetricMatrix<MT,SO,false,false>::end( size_t i ) const
1117 {
1118  return ConstIterator( matrix_.end(i) );
1119 }
1121 //*************************************************************************************************
1122 
1123 
1124 //*************************************************************************************************
1136 template< typename MT // Type of the adapted sparse matrix
1137  , bool SO > // Storage order of the adapted sparse matrix
1140 {
1141  return ConstIterator( matrix_.cend(i) );
1142 }
1144 //*************************************************************************************************
1145 
1146 
1147 
1148 
1149 //=================================================================================================
1150 //
1151 // ASSIGNMENT OPERATORS
1152 //
1153 //=================================================================================================
1154 
1155 //*************************************************************************************************
1165 template< typename MT // Type of the adapted sparse matrix
1166  , bool SO > // Storage order of the adapted sparse matrix
1167 inline SymmetricMatrix<MT,SO,false,false>&
1168  SymmetricMatrix<MT,SO,false,false>::operator=( const SymmetricMatrix& rhs )
1169 {
1170  using blaze::resize;
1171 
1172  if( &rhs == this ) return *this;
1173 
1174  resize( matrix_, rhs.rows(), rhs.columns() );
1175  reset();
1176  assign( rhs );
1177 
1178  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1179  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1180 
1181  return *this;
1182 }
1184 //*************************************************************************************************
1185 
1186 
1187 //*************************************************************************************************
1194 template< typename MT // Type of the adapted sparse matrix
1195  , bool SO > // Storage order of the adapted sparse matrix
1196 inline SymmetricMatrix<MT,SO,false,false>&
1197  SymmetricMatrix<MT,SO,false,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1198 {
1199  matrix_ = std::move( rhs.matrix_ );
1200 
1201  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1202  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1203 
1204  return *this;
1205 }
1207 //*************************************************************************************************
1208 
1209 
1210 //*************************************************************************************************
1224 template< typename MT // Type of the adapted sparse matrix
1225  , bool SO > // Storage order of the adapted sparse matrix
1226 template< typename MT2 > // Type of the right-hand side matrix
1227 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,false>& >
1228  SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,SO>& rhs )
1229 {
1230  using blaze::resize;
1231 
1232  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1233  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1234  }
1235 
1236  if( (~rhs).canAlias( this ) ) {
1237  SymmetricMatrix tmp( ~rhs );
1238  swap( tmp );
1239  }
1240  else {
1241  resize( matrix_, (~rhs).rows(), (~rhs).columns() );
1242  reset();
1243  assign( ~rhs );
1244  }
1245 
1246  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1247  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1248 
1249  return *this;
1250 }
1252 //*************************************************************************************************
1253 
1254 
1255 //*************************************************************************************************
1269 template< typename MT // Type of the adapted sparse matrix
1270  , bool SO > // Storage order of the adapted sparse matrix
1271 template< typename MT2 > // Type of the right-hand side matrix
1272 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,false>& >
1273  SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,SO>& rhs )
1274 {
1275  using blaze::resize;
1276 
1277  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1278  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1279  }
1280 
1281  const ResultType_<MT2> tmp( ~rhs );
1282 
1283  if( !IsSymmetric<MT2>::value && !isSymmetric( tmp ) ) {
1284  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1285  }
1286 
1287  resize( matrix_, tmp.rows(), tmp.columns() );
1288  reset();
1289  assign( tmp );
1290 
1291  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1292  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1293 
1294  return *this;
1295 }
1297 //*************************************************************************************************
1298 
1299 
1300 //*************************************************************************************************
1314 template< typename MT // Type of the adapted sparse matrix
1315  , bool SO > // Storage order of the adapted sparse matrix
1316 template< typename MT2 > // Type of the right-hand side matrix
1317 inline SymmetricMatrix<MT,SO,false,false>&
1318  SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,!SO>& rhs )
1319 {
1320  return this->operator=( trans( ~rhs ) );
1321 }
1323 //*************************************************************************************************
1324 
1325 
1326 //*************************************************************************************************
1339 template< typename MT // Type of the adapted sparse matrix
1340  , bool SO > // Storage order of the adapted sparse matrix
1341 template< typename MT2 > // Type of the right-hand side matrix
1342 inline SymmetricMatrix<MT,SO,false,false>&
1343  SymmetricMatrix<MT,SO,false,false>::operator+=( const Matrix<MT2,SO>& rhs )
1344 {
1345  using blaze::resize;
1346 
1347  using Tmp = AddTrait_< MT, ResultType_<MT2> >;
1348 
1349  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1350  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1351  }
1352 
1353  Tmp tmp( (*this) + ~rhs );
1354 
1355  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1356  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1357  }
1358 
1359  resize( matrix_, tmp.rows(), tmp.columns() );
1360  reset();
1361  assign( tmp );
1362 
1363  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1364  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1365 
1366  return *this;
1367 }
1369 //*************************************************************************************************
1370 
1371 
1372 //*************************************************************************************************
1386 template< typename MT // Type of the adapted sparse matrix
1387  , bool SO > // Storage order of the adapted sparse matrix
1388 template< typename MT2 > // Type of the right-hand side matrix
1389 inline SymmetricMatrix<MT,SO,false,false>&
1390  SymmetricMatrix<MT,SO,false,false>::operator+=( const Matrix<MT2,!SO>& rhs )
1391 {
1392  return this->operator+=( trans( ~rhs ) );
1393 }
1395 //*************************************************************************************************
1396 
1397 
1398 //*************************************************************************************************
1411 template< typename MT // Type of the adapted sparse matrix
1412  , bool SO > // Storage order of the adapted sparse matrix
1413 template< typename MT2 > // Type of the right-hand side matrix
1414 inline SymmetricMatrix<MT,SO,false,false>&
1415  SymmetricMatrix<MT,SO,false,false>::operator-=( const Matrix<MT2,SO>& rhs )
1416 {
1417  using blaze::resize;
1418 
1419  using Tmp = SubTrait_< MT, ResultType_<MT2> >;
1420 
1421  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1422  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1423  }
1424 
1425  Tmp tmp( (*this) - ~rhs );
1426 
1427  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1428  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1429  }
1430 
1431  resize( matrix_, tmp.rows(), tmp.columns() );
1432  reset();
1433  assign( tmp );
1434 
1435  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1436  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1437 
1438  return *this;
1439 }
1441 //*************************************************************************************************
1442 
1443 
1444 //*************************************************************************************************
1458 template< typename MT // Type of the adapted sparse matrix
1459  , bool SO > // Storage order of the adapted sparse matrix
1460 template< typename MT2 > // Type of the right-hand side matrix
1461 inline SymmetricMatrix<MT,SO,false,false>&
1462  SymmetricMatrix<MT,SO,false,false>::operator-=( const Matrix<MT2,!SO>& rhs )
1463 {
1464  return this->operator-=( trans( ~rhs ) );
1465 }
1467 //*************************************************************************************************
1468 
1469 
1470 //*************************************************************************************************
1483 template< typename MT // Type of the adapted sparse matrix
1484  , bool SO > // Storage order of the adapted sparse matrix
1485 template< typename MT2 > // Type of the right-hand side matrix
1486 inline SymmetricMatrix<MT,SO,false,false>&
1487  SymmetricMatrix<MT,SO,false,false>::operator%=( const Matrix<MT2,SO>& rhs )
1488 {
1489  using blaze::resize;
1490 
1491  using Tmp = SchurTrait_< MT, ResultType_<MT2> >;
1492 
1493  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1494  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1495  }
1496 
1497  Tmp tmp( (*this) % ~rhs );
1498 
1499  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1500  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1501  }
1502 
1503  resize( matrix_, tmp.rows(), tmp.columns() );
1504  reset();
1505  assign( tmp );
1506 
1507  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1508  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1509 
1510  return *this;
1511 }
1513 //*************************************************************************************************
1514 
1515 
1516 //*************************************************************************************************
1530 template< typename MT // Type of the adapted sparse matrix
1531  , bool SO > // Storage order of the adapted sparse matrix
1532 template< typename MT2 > // Type of the right-hand side matrix
1533 inline SymmetricMatrix<MT,SO,false,false>&
1534  SymmetricMatrix<MT,SO,false,false>::operator%=( const Matrix<MT2,!SO>& rhs )
1535 {
1536  return this->operator%=( trans( ~rhs ) );
1537 }
1539 //*************************************************************************************************
1540 
1541 
1542 //*************************************************************************************************
1550 template< typename MT // Type of the adapted sparse matrix
1551  , bool SO > // Storage order of the adapted sparse matrix
1552 template< typename ST > // Data type of the right-hand side scalar
1553 inline EnableIf_< IsNumeric<ST>, SymmetricMatrix<MT,SO,false,false> >&
1555 {
1556  for( size_t i=0UL; i<rows(); ++i ) {
1557  const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
1558  for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
1559  *element->value() *= rhs;
1560  }
1561 
1562  return *this;
1563 }
1565 //*************************************************************************************************
1566 
1567 
1568 //*************************************************************************************************
1576 template< typename MT // Type of the adapted sparse matrix
1577  , bool SO > // Storage order of the adapted sparse matrix
1578 template< typename ST > // Data type of the right-hand side scalar
1579 inline EnableIf_< IsNumeric<ST>, SymmetricMatrix<MT,SO,false,false> >&
1581 {
1582  BLAZE_USER_ASSERT( !isZero( rhs ), "Division by zero detected" );
1583 
1584  for( size_t i=0UL; i<rows(); ++i ) {
1585  const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
1586  for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
1587  *element->value() /= rhs;
1588  }
1589 
1590  return *this;
1591 }
1593 //*************************************************************************************************
1594 
1595 
1596 
1597 
1598 //=================================================================================================
1599 //
1600 // UTILITY FUNCTIONS
1601 //
1602 //=================================================================================================
1603 
1604 //*************************************************************************************************
1610 template< typename MT // Type of the adapted sparse matrix
1611  , bool SO > // Storage order of the adapted sparse matrix
1612 inline size_t SymmetricMatrix<MT,SO,false,false>::rows() const noexcept
1613 {
1614  return matrix_.rows();
1615 }
1617 //*************************************************************************************************
1618 
1619 
1620 //*************************************************************************************************
1626 template< typename MT // Type of the adapted sparse matrix
1627  , bool SO > // Storage order of the adapted sparse matrix
1628 inline size_t SymmetricMatrix<MT,SO,false,false>::columns() const noexcept
1629 {
1630  return matrix_.columns();
1631 }
1633 //*************************************************************************************************
1634 
1635 
1636 //*************************************************************************************************
1642 template< typename MT // Type of the adapted sparse matrix
1643  , bool SO > // Storage order of the adapted sparse matrix
1644 inline size_t SymmetricMatrix<MT,SO,false,false>::capacity() const noexcept
1645 {
1646  return matrix_.capacity();
1647 }
1649 //*************************************************************************************************
1650 
1651 
1652 //*************************************************************************************************
1663 template< typename MT // Type of the adapted sparse matrix
1664  , bool SO > // Storage order of the adapted sparse matrix
1665 inline size_t SymmetricMatrix<MT,SO,false,false>::capacity( size_t i ) const noexcept
1666 {
1667  return matrix_.capacity(i);
1668 }
1670 //*************************************************************************************************
1671 
1672 
1673 //*************************************************************************************************
1679 template< typename MT // Type of the adapted sparse matrix
1680  , bool SO > // Storage order of the adapted sparse matrix
1682 {
1683  return matrix_.nonZeros();
1684 }
1686 //*************************************************************************************************
1687 
1688 
1689 //*************************************************************************************************
1701 template< typename MT // Type of the adapted sparse matrix
1702  , bool SO > // Storage order of the adapted sparse matrix
1703 inline size_t SymmetricMatrix<MT,SO,false,false>::nonZeros( size_t i ) const
1704 {
1705  return matrix_.nonZeros(i);
1706 }
1708 //*************************************************************************************************
1709 
1710 
1711 //*************************************************************************************************
1717 template< typename MT // Type of the adapted sparse matrix
1718  , bool SO > // Storage order of the adapted sparse matrix
1720 {
1721  matrix_.reset();
1722 }
1724 //*************************************************************************************************
1725 
1726 
1727 //*************************************************************************************************
1767 template< typename MT // Type of the adapted sparse matrix
1768  , bool SO > // Storage order of the adapted sparse matrix
1769 inline void SymmetricMatrix<MT,SO,false,false>::reset( size_t i )
1770 {
1771  for( Iterator_<MatrixType> it=matrix_.begin(i); it!=matrix_.end(i); ++it )
1772  {
1773  const size_t j( it->index() );
1774 
1775  if( i == j )
1776  continue;
1777 
1778  if( SO ) {
1779  const Iterator_<MatrixType> pos( matrix_.find( i, j ) );
1780  BLAZE_INTERNAL_ASSERT( pos != matrix_.end( j ), "Missing element detected" );
1781  matrix_.erase( j, pos );
1782  }
1783  else {
1784  const Iterator_<MatrixType> pos( matrix_.find( j, i ) );
1785  BLAZE_INTERNAL_ASSERT( pos != matrix_.end( j ), "Missing element detected" );
1786  matrix_.erase( j, pos );
1787  }
1788  }
1789 
1790  matrix_.reset( i );
1791 }
1793 //*************************************************************************************************
1794 
1795 
1796 //*************************************************************************************************
1804 template< typename MT // Type of the adapted sparse matrix
1805  , bool SO > // Storage order of the adapted sparse matrix
1807 {
1808  using blaze::clear;
1809 
1810  clear( matrix_ );
1811 }
1813 //*************************************************************************************************
1814 
1815 
1816 //*************************************************************************************************
1831 template< typename MT // Type of the adapted sparse matrix
1832  , bool SO > // Storage order of the adapted sparse matrix
1833 void SymmetricMatrix<MT,SO,false,false>::resize( size_t n, bool preserve )
1834 {
1836 
1837  UNUSED_PARAMETER( preserve );
1838 
1839  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1840 
1841  matrix_.resize( n, n, true );
1842 }
1844 //*************************************************************************************************
1845 
1846 
1847 //*************************************************************************************************
1858 template< typename MT // Type of the adapted sparse matrix
1859  , bool SO > // Storage order of the adapted sparse matrix
1860 inline void SymmetricMatrix<MT,SO,false,false>::reserve( size_t nonzeros )
1861 {
1862  matrix_.reserve( nonzeros );
1863 }
1865 //*************************************************************************************************
1866 
1867 
1868 //*************************************************************************************************
1882 template< typename MT // Type of the adapted sparse matrix
1883  , bool SO > // Storage order of the adapted sparse matrix
1884 inline void SymmetricMatrix<MT,SO,false,false>::reserve( size_t i, size_t nonzeros )
1885 {
1886  matrix_.reserve( i, nonzeros );
1887 }
1889 //*************************************************************************************************
1890 
1891 
1892 //*************************************************************************************************
1903 template< typename MT // Type of the adapted sparse matrix
1904  , bool SO > // Storage order of the adapted sparse matrix
1905 inline void SymmetricMatrix<MT,SO,false,false>::trim()
1906 {
1907  matrix_.trim();
1908 }
1910 //*************************************************************************************************
1911 
1912 
1913 //*************************************************************************************************
1925 template< typename MT // Type of the adapted sparse matrix
1926  , bool SO > // Storage order of the adapted sparse matrix
1927 inline void SymmetricMatrix<MT,SO,false,false>::trim( size_t i )
1928 {
1929  matrix_.trim( i );
1930 }
1932 //*************************************************************************************************
1933 
1934 
1935 //*************************************************************************************************
1945 template< typename MT // Type of the adapted sparse matrix
1946  , bool SO > // Storage order of the adapted sparse matrix
1948 {
1949  matrix_.shrinkToFit();
1950 }
1952 //*************************************************************************************************
1953 
1954 
1955 //*************************************************************************************************
1962 template< typename MT // Type of the adapted sparse matrix
1963  , bool SO > // Storage order of the adapted sparse matrix
1964 inline void SymmetricMatrix<MT,SO,false,false>::swap( SymmetricMatrix& m ) noexcept
1965 {
1966  using std::swap;
1967 
1968  swap( matrix_, m.matrix_ );
1969 }
1971 //*************************************************************************************************
1972 
1973 
1974 
1975 
1976 //=================================================================================================
1977 //
1978 // INSERTION FUNCTIONS
1979 //
1980 //=================================================================================================
1981 
1982 //*************************************************************************************************
1996 template< typename MT // Type of the adapted sparse matrix
1997  , bool SO > // Storage order of the adapted sparse matrix
1999  SymmetricMatrix<MT,SO,false,false>::set( size_t i, size_t j, const ElementType& value )
2000 {
2001  SharedValue<ET> shared( value );
2002 
2003  if( i != j )
2004  matrix_.set( j, i, shared );
2005 
2006  return Iterator( matrix_.set( i, j, shared ) );
2007 }
2009 //*************************************************************************************************
2010 
2011 
2012 //*************************************************************************************************
2027 template< typename MT // Type of the adapted sparse matrix
2028  , bool SO > // Storage order of the adapted sparse matrix
2030  SymmetricMatrix<MT,SO,false,false>::insert( size_t i, size_t j, const ElementType& value )
2031 {
2032  SharedValue<ET> shared( value );
2033 
2034  if( i != j )
2035  matrix_.insert( j, i, shared );
2036 
2037  return Iterator( matrix_.insert( i, j, shared ) );
2038 }
2040 //*************************************************************************************************
2041 
2042 
2043 //*************************************************************************************************
2098 template< typename MT // Type of the adapted sparse matrix
2099  , bool SO > // Storage order of the adapted sparse matrix
2100 inline void SymmetricMatrix<MT,SO,false,false>::append( size_t i, size_t j, const ElementType& value, bool check )
2101 {
2102  SharedValue<ET> shared( value );
2103 
2104  matrix_.append( i, j, shared, check );
2105  if( i != j && ( !check || !isDefault<strict>( value ) ) )
2106  matrix_.insert( j, i, shared );
2107 }
2109 //*************************************************************************************************
2110 
2111 
2112 //*************************************************************************************************
2126 template< typename MT // Type of the adapted sparse matrix
2127  , bool SO > // Storage order of the adapted sparse matrix
2128 inline void SymmetricMatrix<MT,SO,false,false>::finalize( size_t i )
2129 {
2130  matrix_.trim( i );
2131 }
2133 //*************************************************************************************************
2134 
2135 
2136 
2137 
2138 //=================================================================================================
2139 //
2140 // ERASE FUNCTIONS
2141 //
2142 //=================================================================================================
2143 
2144 //*************************************************************************************************
2154 template< typename MT // Type of the adapted sparse matrix
2155  , bool SO > // Storage order of the adapted sparse matrix
2156 inline void SymmetricMatrix<MT,SO,false,false>::erase( size_t i, size_t j )
2157 {
2158  matrix_.erase( i, j );
2159  if( i != j )
2160  matrix_.erase( j, i );
2161 }
2163 //*************************************************************************************************
2164 
2165 
2166 //*************************************************************************************************
2178 template< typename MT // Type of the adapted sparse matrix
2179  , bool SO > // Storage order of the adapted sparse matrix
2181  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator pos )
2182 {
2183  if( pos == end( i ) )
2184  return pos;
2185 
2186  const size_t j( pos->index() );
2187 
2188  if( i == j )
2189  return Iterator( matrix_.erase( i, pos.base() ) );
2190 
2191  if( SO ) {
2192  BLAZE_INTERNAL_ASSERT( matrix_.find( i, j ) != matrix_.end( j ), "Missing element detected" );
2193  matrix_.erase( j, matrix_.find( i, j ) );
2194  return Iterator( matrix_.erase( i, pos.base() ) );
2195  }
2196  else {
2197  BLAZE_INTERNAL_ASSERT( matrix_.find( j, i ) != matrix_.end( j ), "Missing element detected" );
2198  matrix_.erase( j, matrix_.find( j, i ) );
2199  return Iterator( matrix_.erase( i, pos.base() ) );
2200  }
2201 }
2203 //*************************************************************************************************
2204 
2205 
2206 //*************************************************************************************************
2220 template< typename MT // Type of the adapted sparse matrix
2221  , bool SO > // Storage order of the adapted sparse matrix
2223  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator first, Iterator last )
2224 {
2225  for( Iterator it=first; it!=last; ++it )
2226  {
2227  const size_t j( it->index() );
2228 
2229  if( i == j )
2230  continue;
2231 
2232  if( SO ) {
2233  BLAZE_INTERNAL_ASSERT( matrix_.find( i, j ) != matrix_.end( j ), "Missing element detected" );
2234  matrix_.erase( i, j );
2235  }
2236  else {
2237  BLAZE_INTERNAL_ASSERT( matrix_.find( j, i ) != matrix_.end( j ), "Missing element detected" );
2238  matrix_.erase( j, i );
2239  }
2240  }
2241 
2242  return Iterator( matrix_.erase( i, first.base(), last.base() ) );
2243 }
2245 //*************************************************************************************************
2246 
2247 
2248 //*************************************************************************************************
2262 template< typename MT // Type of the adapted sparse matrix
2263  , bool SO > // Storage order of the adapted sparse matrix
2264 template< typename Pred > // Type of the unary predicate
2265 inline void SymmetricMatrix<MT,SO,false,false>::erase( Pred predicate )
2266 {
2267  matrix_.erase( [predicate=predicate]( const SharedValue<ET>& value ) {
2268  return predicate( *value );
2269  } );
2270 
2271  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2272 }
2274 //*************************************************************************************************
2275 
2276 
2277 //*************************************************************************************************
2296 template< typename MT // Type of the adapted sparse matrix
2297  , bool SO > // Storage order of the adapted sparse matrix
2298 template< typename Pred > // Type of the unary predicate
2299 inline void
2300  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
2301 {
2302  for( Iterator it=first; it!=last; ++it ) {
2303  const size_t j( it->index() );
2304  if( i != j && predicate( it->value() ) ) {
2305  if( SO )
2306  matrix_.erase( i, j );
2307  else
2308  matrix_.erase( j, i );
2309  }
2310  }
2311 
2312  matrix_.erase( i, first.base(), last.base(),
2313  [predicate=predicate]( const SharedValue<ET>& value ) {
2314  return predicate( *value );
2315  } );
2316 
2317  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2318 }
2320 //*************************************************************************************************
2321 
2322 
2323 
2324 
2325 //=================================================================================================
2326 //
2327 // LOOKUP FUNCTIONS
2328 //
2329 //=================================================================================================
2330 
2331 //*************************************************************************************************
2347 template< typename MT // Type of the adapted sparse matrix
2348  , bool SO > // Storage order of the adapted sparse matrix
2350  SymmetricMatrix<MT,SO,false,false>::find( size_t i, size_t j )
2351 {
2352  return Iterator( matrix_.find( i, j ) );
2353 }
2355 //*************************************************************************************************
2356 
2357 
2358 //*************************************************************************************************
2374 template< typename MT // Type of the adapted sparse matrix
2375  , bool SO > // Storage order of the adapted sparse matrix
2377  SymmetricMatrix<MT,SO,false,false>::find( size_t i, size_t j ) const
2378 {
2379  return ConstIterator( matrix_.find( i, j ) );
2380 }
2382 //*************************************************************************************************
2383 
2384 
2385 //*************************************************************************************************
2401 template< typename MT // Type of the adapted sparse matrix
2402  , bool SO > // Storage order of the adapted sparse matrix
2404  SymmetricMatrix<MT,SO,false,false>::lowerBound( size_t i, size_t j )
2405 {
2406  return Iterator( matrix_.lowerBound( i, j ) );
2407 }
2409 //*************************************************************************************************
2410 
2411 
2412 //*************************************************************************************************
2428 template< typename MT // Type of the adapted sparse matrix
2429  , bool SO > // Storage order of the adapted sparse matrix
2431  SymmetricMatrix<MT,SO,false,false>::lowerBound( size_t i, size_t j ) const
2432 {
2433  return ConstIterator( matrix_.lowerBound( i, j ) );
2434 }
2436 //*************************************************************************************************
2437 
2438 
2439 //*************************************************************************************************
2455 template< typename MT // Type of the adapted sparse matrix
2456  , bool SO > // Storage order of the adapted sparse matrix
2458  SymmetricMatrix<MT,SO,false,false>::upperBound( size_t i, size_t j )
2459 {
2460  return Iterator( matrix_.upperBound( i, j ) );
2461 }
2463 //*************************************************************************************************
2464 
2465 
2466 //*************************************************************************************************
2482 template< typename MT // Type of the adapted sparse matrix
2483  , bool SO > // Storage order of the adapted sparse matrix
2485  SymmetricMatrix<MT,SO,false,false>::upperBound( size_t i, size_t j ) const
2486 {
2487  return ConstIterator( matrix_.upperBound( i, j ) );
2488 }
2490 //*************************************************************************************************
2491 
2492 
2493 
2494 
2495 //=================================================================================================
2496 //
2497 // NUMERIC FUNCTIONS
2498 //
2499 //=================================================================================================
2500 
2501 //*************************************************************************************************
2507 template< typename MT // Type of the adapted sparse matrix
2508  , bool SO > // Storage order of the adapted sparse matrix
2509 inline SymmetricMatrix<MT,SO,false,false>& SymmetricMatrix<MT,SO,false,false>::transpose()
2510 {
2511  return *this;
2512 }
2514 //*************************************************************************************************
2515 
2516 
2517 //*************************************************************************************************
2523 template< typename MT // Type of the adapted sparse matrix
2524  , bool SO > // Storage order of the adapted sparse matrix
2525 inline SymmetricMatrix<MT,SO,false,false>& SymmetricMatrix<MT,SO,false,false>::ctranspose()
2526 {
2527  for( size_t i=0UL; i<rows(); ++i ) {
2528  const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
2529  for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
2530  conjugate( *element->value() );
2531  }
2532 
2533  return *this;
2534 }
2536 //*************************************************************************************************
2537 
2538 
2539 //*************************************************************************************************
2557 template< typename MT // Type of the adapted sparse matrix
2558  , bool SO > // Storage order of the adapted sparse matrix
2559 template< typename Other > // Data type of the scalar value
2560 inline SymmetricMatrix<MT,SO,false,false>&
2561  SymmetricMatrix<MT,SO,false,false>::scale( const Other& scalar )
2562 {
2563  for( size_t i=0UL; i<rows(); ++i ) {
2564  const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
2565  for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
2566  ( *element->value() ).scale( scalar );
2567  }
2568 
2569  return *this;
2570 }
2572 //*************************************************************************************************
2573 
2574 
2575 
2576 
2577 //=================================================================================================
2578 //
2579 // DEBUGGING FUNCTIONS
2580 //
2581 //=================================================================================================
2582 
2583 //*************************************************************************************************
2593 template< typename MT // Type of the adapted dense matrix
2594  , bool SO > // Storage order of the adapted dense matrix
2595 inline bool SymmetricMatrix<MT,SO,false,false>::isIntact() const noexcept
2596 {
2597  using blaze::isIntact;
2598 
2599  return ( isIntact( matrix_ ) && isSymmetric( matrix_ ) );
2600 }
2602 //*************************************************************************************************
2603 
2604 
2605 
2606 
2607 //=================================================================================================
2608 //
2609 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2610 //
2611 //=================================================================================================
2612 
2613 //*************************************************************************************************
2624 template< typename MT // Type of the adapted sparse matrix
2625  , bool SO > // Storage order of the adapted sparse matrix
2626 template< typename Other > // Data type of the foreign expression
2627 inline bool SymmetricMatrix<MT,SO,false,false>::canAlias( const Other* alias ) const noexcept
2628 {
2629  return matrix_.canAlias( alias );
2630 }
2632 //*************************************************************************************************
2633 
2634 
2635 //*************************************************************************************************
2646 template< typename MT // Type of the adapted sparse matrix
2647  , bool SO > // Storage order of the adapted sparse matrix
2648 template< typename Other > // Data type of the foreign expression
2649 inline bool SymmetricMatrix<MT,SO,false,false>::isAliased( const Other* alias ) const noexcept
2650 {
2651  return matrix_.isAliased( alias );
2652 }
2654 //*************************************************************************************************
2655 
2656 
2657 //*************************************************************************************************
2668 template< typename MT // Type of the adapted sparse matrix
2669  , bool SO > // Storage order of the adapted sparse matrix
2670 inline bool SymmetricMatrix<MT,SO,false,false>::canSMPAssign() const noexcept
2671 {
2672  return matrix_.canSMPAssign();
2673 }
2675 //*************************************************************************************************
2676 
2677 
2678 //*************************************************************************************************
2690 template< typename MT // Type of the adapted sparse matrix
2691  , bool SO > // Storage order of the adapted sparse matrix
2692 template< typename MT2 > // Type of the right-hand side dense matrix
2693 void SymmetricMatrix<MT,SO,false,false>::assign( DenseMatrix<MT2,SO>& rhs )
2694 {
2696 
2697  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2698  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2699 
2700  std::vector<size_t> nonzeros( rows(), 0UL );
2701  size_t sum( 0UL );
2702 
2703  for( size_t i=0UL; i<rows(); ++i ) {
2704  nonzeros[i] = (~rhs).nonZeros(i);
2705  sum += nonzeros[i];
2706  }
2707 
2708  matrix_.reserve( sum );
2709  for( size_t i=0UL; i<rows(); ++i ) {
2710  matrix_.reserve( i, nonzeros[i] );
2711  }
2712 
2713  for( size_t i=0UL; i<rows(); ++i ) {
2714  for( size_t j=i; j<columns(); ++j ) {
2715  if( !isDefault( (~rhs)(i,j) ) ) {
2716  SharedValue<ET> shared;
2717  *shared = std::move( (~rhs)(i,j) );
2718  matrix_.append( i, j, shared, false );
2719  if( i != j )
2720  matrix_.append( j, i, shared, false );
2721  }
2722  }
2723  }
2724 }
2726 //*************************************************************************************************
2727 
2728 
2729 //*************************************************************************************************
2741 template< typename MT // Type of the adapted sparse matrix
2742  , bool SO > // Storage order of the adapted sparse matrix
2743 template< typename MT2 > // Type of the right-hand side dense matrix
2744 void SymmetricMatrix<MT,SO,false,false>::assign( const DenseMatrix<MT2,SO>& rhs )
2745 {
2747 
2748  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2749  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2750 
2751  std::vector<size_t> nonzeros( rows(), 0UL );
2752  size_t sum( 0UL );
2753 
2754  for( size_t i=0UL; i<rows(); ++i ) {
2755  nonzeros[i] = (~rhs).nonZeros(i);
2756  sum += nonzeros[i];
2757  }
2758 
2759  matrix_.reserve( sum );
2760  for( size_t i=0UL; i<rows(); ++i ) {
2761  matrix_.reserve( i, nonzeros[i] );
2762  }
2763 
2764  for( size_t i=0UL; i<rows(); ++i ) {
2765  for( size_t j=i; j<columns(); ++j ) {
2766  if( !isDefault( (~rhs)(i,j) ) ) {
2767  const SharedValue<ET> shared( (~rhs)(i,j) );
2768  matrix_.append( i, j, shared, false );
2769  if( i != j )
2770  matrix_.append( j, i, shared, false );
2771  }
2772  }
2773  }
2774 }
2776 //*************************************************************************************************
2777 
2778 
2779 //*************************************************************************************************
2791 template< typename MT // Type of the adapted sparse matrix
2792  , bool SO > // Storage order of the adapted sparse matrix
2793 template< typename MT2 > // Type of the right-hand side sparse matrix
2794 void SymmetricMatrix<MT,SO,false,false>::assign( SparseMatrix<MT2,SO>& rhs )
2795 {
2797 
2798  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2799  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2800 
2801  std::vector<size_t> nonzeros( rows(), 0UL );
2802  size_t sum( 0UL );
2803 
2804  for( size_t i=0UL; i<rows(); ++i ) {
2805  nonzeros[i] = (~rhs).nonZeros(i);
2806  sum += nonzeros[i];
2807  }
2808 
2809  matrix_.reserve( sum );
2810  for( size_t i=0UL; i<rows(); ++i ) {
2811  matrix_.reserve( i, nonzeros[i] );
2812  }
2813 
2814  for( size_t i=0UL; i<rows(); ++i ) {
2815  for( Iterator_<MT2> it=(~rhs).lowerBound(i,i); it!=(~rhs).end(i); ++it ) {
2816  if( !isDefault( it->value() ) ) {
2817  SharedValue<ET> shared;
2818  *shared = std::move( it->value() );
2819  matrix_.append( i, it->index(), shared, false );
2820  if( i != it->index() )
2821  matrix_.append( it->index(), i, shared, false );
2822  }
2823  }
2824  }
2825 }
2827 //*************************************************************************************************
2828 
2829 
2830 //*************************************************************************************************
2842 template< typename MT // Type of the adapted sparse matrix
2843  , bool SO > // Storage order of the adapted sparse matrix
2844 template< typename MT2 > // Type of the right-hand side sparse matrix
2845 void SymmetricMatrix<MT,SO,false,false>::assign( const SparseMatrix<MT2,SO>& rhs )
2846 {
2848 
2849  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2850  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2851 
2852  std::vector<size_t> nonzeros( rows(), 0UL );
2853  size_t sum( 0UL );
2854 
2855  for( size_t i=0UL; i<rows(); ++i ) {
2856  nonzeros[i] = (~rhs).nonZeros(i);
2857  sum += nonzeros[i];
2858  }
2859 
2860  matrix_.reserve( sum );
2861  for( size_t i=0UL; i<rows(); ++i ) {
2862  matrix_.reserve( i, nonzeros[i] );
2863  }
2864 
2865  for( size_t i=0UL; i<rows(); ++i ) {
2866  for( ConstIterator_<MT2> it=(~rhs).lowerBound(i,i); it!=(~rhs).end(i); ++it ) {
2867  if( !isDefault( it->value() ) ) {
2868  const SharedValue<ET> shared( it->value() );
2869  matrix_.append( i, it->index(), shared, false );
2870  if( i != it->index() )
2871  matrix_.append( it->index(), i, shared, false );
2872  }
2873  }
2874  }
2875 }
2877 //*************************************************************************************************
2878 
2879 } // namespace blaze
2880 
2881 #endif
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Constraint on the data type.
Header file for auxiliary alias declarations.
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3077
Header file for the Schur product trait.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:522
Header file for basic type definitions.
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:63
#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
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3076
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:364
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3074
Constraint on the data type.
Header file for the SharedValue class.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
BLAZE_ALWAYS_INLINE void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:775
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5829
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3078
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:827
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3083
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
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:560
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:733
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3084
Constraint on the data type.
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:474
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:408
Header file for the implementation of the base template of the SymmetricMatrix.
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
Header file for utility functions for sparse matrices.
Header file for the IsSquare type trait.
Constraint on the data type.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:670
Header file for the DisableIf class template.
Header file for the multiplication trait.
Header file for the IsSymmetric type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3082
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5908
Header file for the If class template.
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5891
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3079
#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
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
Header file for the isZero shim.
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
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:506
Header file for the SparseElement base class.
Constraints on the storage order of matrix types.
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is a numeric (integral or floating point) d...
Definition: Numeric.h:81
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:714
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:430
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
Header file for the RemoveAdaptor type trait.
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
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:608
Header file for the NonNumericProxy class.
Header file for the conjugate shim.
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
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
BLAZE_ALWAYS_INLINE ValueType_< T > sum(const SIMDi8< T > &a) noexcept
Returns the sum of all elements in the 8-bit integral SIMD vector.
Definition: Reduction.h:65
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.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:272
Constraint on the data type.
Constraint on the data type.
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric< T >::value)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:841
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:490
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:789
EnableIf_< IsNumeric< ST >, MT &> operator/=(DenseMatrix< MT, SO > &mat, ST scalar)
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:655
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a &#39;res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3081
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:254
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
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
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
EnableIf_< IsNumeric< ST >, MT &> operator*=(DenseMatrix< MT, SO > &mat, ST scalar)
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:593
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:908
Header file for the Size type trait.
#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
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:801