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>
75 #include <blaze/util/Assert.h>
81 #include <blaze/util/DisableIf.h>
82 #include <blaze/util/EnableIf.h>
83 #include <blaze/util/mpl/If.h>
86 #include <blaze/util/Types.h>
87 #include <blaze/util/Unused.h>
88 
89 
90 namespace blaze {
91 
92 //=================================================================================================
93 //
94 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES WITH NON-NUMERIC ELEMENT TYPE
95 //
96 //=================================================================================================
97 
98 //*************************************************************************************************
106 template< typename MT // Type of the adapted sparse matrix
107  , bool SO > // Storage order of the adapted sparse matrix
108 class SymmetricMatrix<MT,SO,false,false>
109  : public SparseMatrix< SymmetricMatrix<MT,SO,false,false>, SO >
110 {
111  private:
112  //**Type definitions****************************************************************************
113  typedef OppositeType_<MT> OT;
114  typedef TransposeType_<MT> TT;
115  typedef ElementType_<MT> ET;
116 
118  typedef typename MT::template Rebind< SharedValue<ET> >::Other MatrixType;
119  //**********************************************************************************************
120 
121  public:
122  //**Type definitions****************************************************************************
123  typedef SymmetricMatrix<MT,SO,false,false> This;
124  typedef SparseMatrix<This,SO> BaseType;
125  typedef This ResultType;
126  typedef SymmetricMatrix<OT,!SO,false,false> OppositeType;
127  typedef SymmetricMatrix<TT,!SO,false,false> TransposeType;
128  typedef ET ElementType;
129  typedef ReturnType_<MT> ReturnType;
130  typedef const This& CompositeType;
131  typedef NonNumericProxy<MatrixType> Reference;
132  typedef ConstReference_<MT> ConstReference;
133  //**********************************************************************************************
134 
135  //**Rebind struct definition********************************************************************
138  template< typename NewType > // Data type of the other matrix
139  struct Rebind {
141  typedef SymmetricMatrix< typename MT::template Rebind<NewType>::Other > Other;
142  };
143  //**********************************************************************************************
144 
145  //**Resize struct definition********************************************************************
148  template< size_t NewM // Number of rows of the other matrix
149  , size_t NewN > // Number of columns of the other matrix
150  struct Resize {
152  typedef SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other > Other;
153  };
154  //**********************************************************************************************
155 
156  //**SharedElement class definition**************************************************************
159  template< typename IteratorType > // Type of the sparse matrix iterator
160  class SharedElement : private SparseElement
161  {
162  public:
163  //**Type definitions*************************************************************************
164  typedef ET ValueType;
165  typedef size_t IndexType;
166  typedef ValueType& Reference;
167  typedef const ValueType& ConstReference;
168  typedef SharedElement* Pointer;
169  typedef const SharedElement* ConstPointer;
170  //*******************************************************************************************
171 
172  //**Constructor******************************************************************************
177  inline SharedElement( IteratorType pos )
178  : pos_( pos ) // Iterator to the current sparse symmetric matrix element
179  {}
180  //*******************************************************************************************
181 
182  //**Assignment operator**********************************************************************
188  template< typename T > inline SharedElement& operator=( const T& v ) {
189  *pos_->value() = v;
190  return *this;
191  }
192  //*******************************************************************************************
193 
194  //**Addition assignment operator*************************************************************
200  template< typename T > inline SharedElement& operator+=( const T& v ) {
201  *pos_->value() += v;
202  return *this;
203  }
204  //*******************************************************************************************
205 
206  //**Subtraction assignment operator**********************************************************
212  template< typename T > inline SharedElement& operator-=( const T& v ) {
213  *pos_->value() -= v;
214  return *this;
215  }
216  //*******************************************************************************************
217 
218  //**Multiplication assignment operator*******************************************************
224  template< typename T > inline SharedElement& operator*=( const T& v ) {
225  *pos_->value() *= v;
226  return *this;
227  }
228  //*******************************************************************************************
229 
230  //**Division assignment operator*************************************************************
236  template< typename T > inline SharedElement& operator/=( const T& v ) {
237  *pos_->value() /= v;
238  return *this;
239  }
240  //*******************************************************************************************
241 
242  //**Element access operator******************************************************************
247  inline Pointer operator->() {
248  return this;
249  }
250  //*******************************************************************************************
251 
252  //**Element access operator******************************************************************
257  inline ConstPointer operator->() const {
258  return this;
259  }
260  //*******************************************************************************************
261 
262  //**Value function***************************************************************************
267  inline Reference value() {
268  return *pos_->value();
269  }
270  //*******************************************************************************************
271 
272  //**Value function***************************************************************************
277  inline ConstReference value() const {
278  return *pos_->value();
279  }
280  //*******************************************************************************************
281 
282  //**Index function***************************************************************************
287  inline IndexType index() const {
288  return pos_->index();
289  }
290  //*******************************************************************************************
291 
292  private:
293  //**Member variables*************************************************************************
294  IteratorType pos_;
295  //*******************************************************************************************
296  };
297  //**********************************************************************************************
298 
299  //**SharedIterator class definition*************************************************************
302  template< typename SparseElementType // Type of the underlying sparse elements.
303  , typename IteratorType > // Type of the sparse matrix iterator
304  class SharedIterator
305  {
306  public:
307  //**Type definitions*************************************************************************
308  typedef std::forward_iterator_tag IteratorCategory;
309  typedef SparseElementType ValueType;
310  typedef SparseElementType PointerType;
311  typedef SparseElementType ReferenceType;
312  typedef ptrdiff_t DifferenceType;
313 
314  // STL iterator requirements
315  typedef IteratorCategory iterator_category;
316  typedef ValueType value_type;
317  typedef PointerType pointer;
318  typedef ReferenceType reference;
319  typedef DifferenceType difference_type;
320  //*******************************************************************************************
321 
322  //**Default constructor**********************************************************************
325  inline SharedIterator()
326  : pos_() // Iterator to the current sparse symmetric matrix element
327  {}
328  //*******************************************************************************************
329 
330  //**Constructor******************************************************************************
335  inline SharedIterator( IteratorType pos )
336  : pos_( pos ) // Iterator to the current sparse symmetric matrix element
337  {}
338  //*******************************************************************************************
339 
340  //**Constructor******************************************************************************
345  template< typename SparseElementType2, typename IteratorType2 >
346  inline SharedIterator( const SharedIterator<SparseElementType2,IteratorType2>& it )
347  : pos_( it.pos_ ) // Iterator to the current sparse symmetric matrix element
348  {}
349  //*******************************************************************************************
350 
351  //**Prefix increment operator****************************************************************
356  inline SharedIterator& operator++() {
357  ++pos_;
358  return *this;
359  }
360  //*******************************************************************************************
361 
362  //**Postfix increment operator***************************************************************
367  inline const SharedIterator operator++( int ) {
368  const SharedIterator tmp( *this );
369  ++(*this);
370  return tmp;
371  }
372  //*******************************************************************************************
373 
374  //**Element access operator******************************************************************
379  inline ReferenceType operator*() const {
380  return ReferenceType( pos_ );
381  }
382  //*******************************************************************************************
383 
384  //**Element access operator******************************************************************
389  inline PointerType operator->() const {
390  return PointerType( pos_ );
391  }
392  //*******************************************************************************************
393 
394  //**Equality operator************************************************************************
400  inline bool operator==( const SharedIterator& rhs ) const {
401  return pos_ == rhs.pos_;
402  }
403  //*******************************************************************************************
404 
405  //**Inequality operator**********************************************************************
411  inline bool operator!=( const SharedIterator& rhs ) const {
412  return !( *this == rhs );
413  }
414  //*******************************************************************************************
415 
416  //**Subtraction operator*********************************************************************
422  inline DifferenceType operator-( const SharedIterator& rhs ) const {
423  return pos_ - rhs.pos_;
424  }
425  //*******************************************************************************************
426 
427  //**Base function****************************************************************************
432  inline IteratorType base() const {
433  return pos_;
434  }
435  //*******************************************************************************************
436 
437  private:
438  //**Member variables*************************************************************************
439  IteratorType pos_;
440  //*******************************************************************************************
441 
442  //**Friend declarations**********************************************************************
443  template< typename SparseElementType2, typename IteratorType2 > friend class SharedIterator;
444  //*******************************************************************************************
445  };
446  //**********************************************************************************************
447 
448  //**Type definitions****************************************************************************
450  typedef SharedIterator< SharedElement< Iterator_<MatrixType> >
451  , Iterator_<MatrixType>
452  > Iterator;
453 
455  typedef SharedIterator< const SharedElement< ConstIterator_<MatrixType> >
456  , ConstIterator_<MatrixType>
457  > ConstIterator;
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, bool SO2 >
529  inline SymmetricMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
530 
531  template< typename Other >
532  inline EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator*=( Other rhs );
533 
534  template< typename Other >
535  inline EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator/=( Other rhs );
537  //**********************************************************************************************
538 
539  //**Utility functions***************************************************************************
542  inline size_t rows() const noexcept;
543  inline size_t columns() const noexcept;
544  inline size_t capacity() const noexcept;
545  inline size_t capacity( size_t i ) const noexcept;
546  inline size_t nonZeros() const;
547  inline size_t nonZeros( size_t i ) const;
548  inline void reset();
549  inline void reset( size_t i );
550  inline void clear();
551  inline void resize ( size_t n, bool preserve=true );
552  inline void reserve( size_t nonzeros );
553  inline void reserve( size_t i, size_t nonzeros );
554  inline void trim();
555  inline void trim( size_t i );
556  inline void swap( SymmetricMatrix& m ) noexcept;
558  //**********************************************************************************************
559 
560  //**Insertion functions*************************************************************************
563  inline Iterator set ( size_t i, size_t j, const ElementType& value );
564  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
565  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
566  inline void finalize( size_t i );
568  //**********************************************************************************************
569 
570  //**Erase functions*****************************************************************************
573  inline void erase( size_t i, size_t j );
574  inline Iterator erase( size_t i, Iterator pos );
575  inline Iterator erase( size_t i, Iterator first, Iterator last );
576 
577  template< typename Pred >
578  inline void erase( Pred predicate );
579 
580  template< typename Pred >
581  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
583  //**********************************************************************************************
584 
585  //**Lookup functions****************************************************************************
588  inline Iterator find ( size_t i, size_t j );
589  inline ConstIterator find ( size_t i, size_t j ) const;
590  inline Iterator lowerBound( size_t i, size_t j );
591  inline ConstIterator lowerBound( size_t i, size_t j ) const;
592  inline Iterator upperBound( size_t i, size_t j );
593  inline ConstIterator upperBound( size_t i, size_t j ) const;
595  //**********************************************************************************************
596 
597  //**Numeric functions***************************************************************************
600  inline SymmetricMatrix& transpose();
601  inline SymmetricMatrix& ctranspose();
602 
603  template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
604  template< typename Other > inline SymmetricMatrix& scaleDiagonal( const Other& scale );
606  //**********************************************************************************************
607 
608  //**Debugging functions*************************************************************************
611  inline bool isIntact() const noexcept;
613  //**********************************************************************************************
614 
615  //**Expression template evaluation functions****************************************************
618  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
619  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
620 
621  inline bool canSMPAssign() const noexcept;
623  //**********************************************************************************************
624 
625  private:
626  //**Expression template evaluation functions****************************************************
629  template< typename MT2 > void assign( DenseMatrix<MT2,SO>& rhs );
630  template< typename MT2 > void assign( const DenseMatrix<MT2,SO>& rhs );
631  template< typename MT2 > void assign( SparseMatrix<MT2,SO>& rhs );
632  template< typename MT2 > void assign( const SparseMatrix<MT2,SO>& rhs );
634  //**********************************************************************************************
635 
636  //**Member variables****************************************************************************
639  MatrixType matrix_;
640 
641  //**********************************************************************************************
642 
643  //**Friend declarations*************************************************************************
644  template< bool RF, typename MT2, bool SO2, bool DF2, bool NF2 >
645  friend bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
646  //**********************************************************************************************
647 
648  //**Compile time checks*************************************************************************
662  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
663  //**********************************************************************************************
664 };
666 //*************************************************************************************************
667 
668 
669 
670 
671 //=================================================================================================
672 //
673 // CONSTRUCTORS
674 //
675 //=================================================================================================
676 
677 //*************************************************************************************************
681 template< typename MT // Type of the adapted sparse matrix
682  , bool SO > // Storage order of the adapted sparse matrix
683 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix()
684  : matrix_() // The adapted sparse matrix
685 {
686  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
687 }
689 //*************************************************************************************************
690 
691 
692 //*************************************************************************************************
700 template< typename MT // Type of the adapted sparse matrix
701  , bool SO > // Storage order of the adapted sparse matrix
702 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n )
703  : matrix_( n, n ) // The adapted sparse matrix
704 {
706 
707  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
708 }
710 //*************************************************************************************************
711 
712 
713 //*************************************************************************************************
722 template< typename MT // Type of the adapted sparse matrix
723  , bool SO > // Storage order of the adapted sparse matrix
724 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n, size_t nonzeros )
725  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
726 {
728 
729  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
730 }
732 //*************************************************************************************************
733 
734 
735 //*************************************************************************************************
746 template< typename MT // Type of the adapted sparse matrix
747  , bool SO > // Storage order of the adapted sparse matrix
748 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n, const std::vector<size_t>& nonzeros )
749  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
750 {
752 
753  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
754 }
756 //*************************************************************************************************
757 
758 
759 //*************************************************************************************************
765 template< typename MT // Type of the adapted sparse matrix
766  , bool SO > // Storage order of the adapted sparse matrix
767 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const SymmetricMatrix& m )
768  : matrix_() // The adapted sparse matrix
769 {
770  using blaze::resize;
771 
772  resize( matrix_, m.rows(), m.columns() );
773  assign( m );
774 
775  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
776  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
777 }
779 //*************************************************************************************************
780 
781 
782 //*************************************************************************************************
788 template< typename MT // Type of the adapted sparse matrix
789  , bool SO > // Storage order of the adapted sparse matrix
790 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
791  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
792 {
793  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
794  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
795 }
797 //*************************************************************************************************
798 
799 
800 //*************************************************************************************************
810 template< typename MT // Type of the adapted sparse matrix
811  , bool SO > // Storage order of the adapted sparse matrix
812 template< typename MT2 > // Type of the foreign matrix
813 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const Matrix<MT2,SO>& m )
814  : matrix_() // The adapted sparse matrix
815 {
816  using blaze::resize;
817 
818  typedef RemoveAdaptor_< ResultType_<MT2> > RT;
819  typedef If_< IsComputation<MT2>, RT, const MT2& > Tmp;
820 
821  Tmp tmp( ~m );
822 
823  if( !IsSymmetric<MT2>::value && !isSymmetric( tmp ) ) {
824  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
825  }
826 
827  resize( matrix_, tmp.rows(), tmp.columns() );
828  assign( tmp );
829 
830  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
831  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
832 }
834 //*************************************************************************************************
835 
836 
837 //*************************************************************************************************
847 template< typename MT // Type of the adapted sparse matrix
848  , bool SO > // Storage order of the adapted sparse matrix
849 template< typename MT2 > // Type of the foreign matrix
850 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
851  : matrix_() // The adapted sparse matrix
852 {
853  using blaze::resize;
854 
855  typedef RemoveAdaptor_< ResultType_<MT2> > RT;
856  typedef If_< IsComputation<MT2>, RT, const MT2& > Tmp;
857 
858  Tmp tmp( ~m );
859 
860  if( !IsSymmetric<MT2>::value && !isSymmetric( tmp ) ) {
861  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
862  }
863 
864  resize( matrix_, tmp.rows(), tmp.columns() );
865  assign( trans( tmp ) );
866 
867  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
868  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
869 }
871 //*************************************************************************************************
872 
873 
874 
875 
876 //=================================================================================================
877 //
878 // DATA ACCESS FUNCTIONS
879 //
880 //=================================================================================================
881 
882 //*************************************************************************************************
897 template< typename MT // Type of the adapted sparse matrix
898  , bool SO > // Storage order of the adapted sparse matrix
900  SymmetricMatrix<MT,SO,false,false>::operator()( size_t i, size_t j )
901 {
902  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
903  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
904 
905  return Reference( matrix_, i, j );
906 }
908 //*************************************************************************************************
909 
910 
911 //*************************************************************************************************
926 template< typename MT // Type of the adapted sparse matrix
927  , bool SO > // Storage order of the adapted sparse matrix
929  SymmetricMatrix<MT,SO,false,false>::operator()( size_t i, size_t j ) const
930 {
931  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
932  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
933 
934  return *matrix_(i,j);
935 }
937 //*************************************************************************************************
938 
939 
940 //*************************************************************************************************
956 template< typename MT // Type of the adapted dense matrix
957  , bool SO > // Storage order of the adapted dense matrix
959  SymmetricMatrix<MT,SO,false,false>::at( size_t i, size_t j )
960 {
961  if( i >= rows() ) {
962  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
963  }
964  if( j >= columns() ) {
965  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
966  }
967  return (*this)(i,j);
968 }
970 //*************************************************************************************************
971 
972 
973 //*************************************************************************************************
989 template< typename MT // Type of the adapted dense matrix
990  , bool SO > // Storage order of the adapted dense matrix
992  SymmetricMatrix<MT,SO,false,false>::at( size_t i, size_t j ) const
993 {
994  if( i >= rows() ) {
995  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
996  }
997  if( j >= columns() ) {
998  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
999  }
1000  return (*this)(i,j);
1001 }
1003 //*************************************************************************************************
1004 
1005 
1006 //*************************************************************************************************
1018 template< typename MT // Type of the adapted sparse matrix
1019  , bool SO > // Storage order of the adapted sparse matrix
1022 {
1023  return Iterator( matrix_.begin(i) );
1024 }
1026 //*************************************************************************************************
1027 
1028 
1029 //*************************************************************************************************
1041 template< typename MT // Type of the adapted sparse matrix
1042  , bool SO > // Storage order of the adapted sparse matrix
1045 {
1046  return ConstIterator( matrix_.begin(i) );
1047 }
1049 //*************************************************************************************************
1050 
1051 
1052 //*************************************************************************************************
1064 template< typename MT // Type of the adapted sparse matrix
1065  , bool SO > // Storage order of the adapted sparse matrix
1068 {
1069  return ConstIterator( matrix_.cbegin(i) );
1070 }
1072 //*************************************************************************************************
1073 
1074 
1075 //*************************************************************************************************
1087 template< typename MT // Type of the adapted sparse matrix
1088  , bool SO > // Storage order of the adapted sparse matrix
1091 {
1092  return Iterator( matrix_.end(i) );
1093 }
1095 //*************************************************************************************************
1096 
1097 
1098 //*************************************************************************************************
1110 template< typename MT // Type of the adapted sparse matrix
1111  , bool SO > // Storage order of the adapted sparse matrix
1113  SymmetricMatrix<MT,SO,false,false>::end( size_t i ) const
1114 {
1115  return ConstIterator( matrix_.end(i) );
1116 }
1118 //*************************************************************************************************
1119 
1120 
1121 //*************************************************************************************************
1133 template< typename MT // Type of the adapted sparse matrix
1134  , bool SO > // Storage order of the adapted sparse matrix
1137 {
1138  return ConstIterator( matrix_.cend(i) );
1139 }
1141 //*************************************************************************************************
1142 
1143 
1144 
1145 
1146 //=================================================================================================
1147 //
1148 // ASSIGNMENT OPERATORS
1149 //
1150 //=================================================================================================
1151 
1152 //*************************************************************************************************
1162 template< typename MT // Type of the adapted sparse matrix
1163  , bool SO > // Storage order of the adapted sparse matrix
1164 inline SymmetricMatrix<MT,SO,false,false>&
1165  SymmetricMatrix<MT,SO,false,false>::operator=( const SymmetricMatrix& rhs )
1166 {
1167  using blaze::resize;
1168 
1169  if( &rhs == this ) return *this;
1170 
1171  resize( matrix_, rhs.rows(), rhs.columns() );
1172  reset();
1173  assign( rhs );
1174 
1175  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1176  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1177 
1178  return *this;
1179 }
1181 //*************************************************************************************************
1182 
1183 
1184 //*************************************************************************************************
1191 template< typename MT // Type of the adapted sparse matrix
1192  , bool SO > // Storage order of the adapted sparse matrix
1193 inline SymmetricMatrix<MT,SO,false,false>&
1194  SymmetricMatrix<MT,SO,false,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1195 {
1196  matrix_ = std::move( rhs.matrix_ );
1197 
1198  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1199  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1200 
1201  return *this;
1202 }
1204 //*************************************************************************************************
1205 
1206 
1207 //*************************************************************************************************
1221 template< typename MT // Type of the adapted sparse matrix
1222  , bool SO > // Storage order of the adapted sparse matrix
1223 template< typename MT2 > // Type of the right-hand side matrix
1224 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,false>& >
1225  SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,SO>& rhs )
1226 {
1227  using blaze::resize;
1228 
1229  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1230  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1231  }
1232 
1233  if( (~rhs).canAlias( this ) ) {
1234  SymmetricMatrix tmp( ~rhs );
1235  swap( tmp );
1236  }
1237  else {
1238  resize( matrix_, (~rhs).rows(), (~rhs).columns() );
1239  reset();
1240  assign( ~rhs );
1241  }
1242 
1243  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1244  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1245 
1246  return *this;
1247 }
1249 //*************************************************************************************************
1250 
1251 
1252 //*************************************************************************************************
1266 template< typename MT // Type of the adapted sparse matrix
1267  , bool SO > // Storage order of the adapted sparse matrix
1268 template< typename MT2 > // Type of the right-hand side matrix
1269 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,false>& >
1270  SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,SO>& rhs )
1271 {
1272  using blaze::resize;
1273 
1274  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1275  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1276  }
1277 
1278  const ResultType_<MT2> tmp( ~rhs );
1279 
1280  if( !IsSymmetric<MT2>::value && !isSymmetric( tmp ) ) {
1281  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1282  }
1283 
1284  resize( matrix_, tmp.rows(), tmp.columns() );
1285  reset();
1286  assign( tmp );
1287 
1288  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1289  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1290 
1291  return *this;
1292 }
1294 //*************************************************************************************************
1295 
1296 
1297 //*************************************************************************************************
1311 template< typename MT // Type of the adapted sparse matrix
1312  , bool SO > // Storage order of the adapted sparse matrix
1313 template< typename MT2 > // Type of the right-hand side matrix
1314 inline SymmetricMatrix<MT,SO,false,false>&
1315  SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,!SO>& rhs )
1316 {
1317  return this->operator=( trans( ~rhs ) );
1318 }
1320 //*************************************************************************************************
1321 
1322 
1323 //*************************************************************************************************
1336 template< typename MT // Type of the adapted sparse matrix
1337  , bool SO > // Storage order of the adapted sparse matrix
1338 template< typename MT2 > // Type of the right-hand side matrix
1339 inline SymmetricMatrix<MT,SO,false,false>&
1340  SymmetricMatrix<MT,SO,false,false>::operator+=( const Matrix<MT2,SO>& rhs )
1341 {
1342  using blaze::resize;
1343 
1344  typedef AddTrait_< MT, ResultType_<MT2> > Tmp;
1345 
1346  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1347  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1348  }
1349 
1350  Tmp tmp( (*this) + ~rhs );
1351 
1352  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1353  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1354  }
1355 
1356  resize( matrix_, tmp.rows(), tmp.columns() );
1357  reset();
1358  assign( tmp );
1359 
1360  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1361  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1362 
1363  return *this;
1364 }
1366 //*************************************************************************************************
1367 
1368 
1369 //*************************************************************************************************
1383 template< typename MT // Type of the adapted sparse matrix
1384  , bool SO > // Storage order of the adapted sparse matrix
1385 template< typename MT2 > // Type of the right-hand side matrix
1386 inline SymmetricMatrix<MT,SO,false,false>&
1387  SymmetricMatrix<MT,SO,false,false>::operator+=( const Matrix<MT2,!SO>& rhs )
1388 {
1389  return this->operator+=( trans( ~rhs ) );
1390 }
1392 //*************************************************************************************************
1393 
1394 
1395 //*************************************************************************************************
1408 template< typename MT // Type of the adapted sparse matrix
1409  , bool SO > // Storage order of the adapted sparse matrix
1410 template< typename MT2 > // Type of the right-hand side matrix
1411 inline SymmetricMatrix<MT,SO,false,false>&
1412  SymmetricMatrix<MT,SO,false,false>::operator-=( const Matrix<MT2,SO>& rhs )
1413 {
1414  using blaze::resize;
1415 
1416  typedef SubTrait_< MT, ResultType_<MT2> > Tmp;
1417 
1418  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1419  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1420  }
1421 
1422  Tmp tmp( (*this) - ~rhs );
1423 
1424  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1425  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1426  }
1427 
1428  resize( matrix_, tmp.rows(), tmp.columns() );
1429  reset();
1430  assign( tmp );
1431 
1432  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1433  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1434 
1435  return *this;
1436 }
1438 //*************************************************************************************************
1439 
1440 
1441 //*************************************************************************************************
1455 template< typename MT // Type of the adapted sparse matrix
1456  , bool SO > // Storage order of the adapted sparse matrix
1457 template< typename MT2 > // Type of the right-hand side matrix
1458 inline SymmetricMatrix<MT,SO,false,false>&
1459  SymmetricMatrix<MT,SO,false,false>::operator-=( const Matrix<MT2,!SO>& rhs )
1460 {
1461  return this->operator-=( trans( ~rhs ) );
1462 }
1464 //*************************************************************************************************
1465 
1466 
1467 //*************************************************************************************************
1479 template< typename MT // Type of the adapted sparse matrix
1480  , bool SO > // Storage order of the adapted sparse matrix
1481 template< typename MT2 // Type of the right-hand side matrix
1482  , bool SO2 > // Storage order of the right-hand side matrix
1483 inline SymmetricMatrix<MT,SO,false,false>&
1484  SymmetricMatrix<MT,SO,false,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1485 {
1486  using blaze::resize;
1487 
1488  typedef MultTrait_< MT, ResultType_<MT2> > Tmp;
1489 
1490  if( matrix_.rows() != (~rhs).columns() ) {
1491  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1492  }
1493 
1494  Tmp tmp( (*this) * ~rhs );
1495 
1496  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1497  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1498  }
1499 
1500  resize( matrix_, tmp.rows(), tmp.columns() );
1501  reset();
1502  assign( tmp );
1503 
1504  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1505  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1506 
1507  return *this;
1508 }
1510 //*************************************************************************************************
1511 
1512 
1513 //*************************************************************************************************
1521 template< typename MT // Type of the adapted sparse matrix
1522  , bool SO > // Storage order of the adapted sparse matrix
1523 template< typename Other > // Data type of the right-hand side scalar
1524 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,false,false> >&
1526 {
1527  for( size_t i=0UL; i<rows(); ++i ) {
1528  const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
1529  for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
1530  *element->value() *= rhs;
1531  }
1532 
1533  return *this;
1534 }
1536 //*************************************************************************************************
1537 
1538 
1539 //*************************************************************************************************
1547 template< typename MT // Type of the adapted sparse matrix
1548  , bool SO > // Storage order of the adapted sparse matrix
1549 template< typename Other > // Data type of the right-hand side scalar
1550 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,false,false> >&
1552 {
1553  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1554 
1555  for( size_t i=0UL; i<rows(); ++i ) {
1556  const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
1557  for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
1558  *element->value() /= rhs;
1559  }
1560 
1561  return *this;
1562 }
1564 //*************************************************************************************************
1565 
1566 
1567 
1568 
1569 //=================================================================================================
1570 //
1571 // UTILITY FUNCTIONS
1572 //
1573 //=================================================================================================
1574 
1575 //*************************************************************************************************
1581 template< typename MT // Type of the adapted sparse matrix
1582  , bool SO > // Storage order of the adapted sparse matrix
1583 inline size_t SymmetricMatrix<MT,SO,false,false>::rows() const noexcept
1584 {
1585  return matrix_.rows();
1586 }
1588 //*************************************************************************************************
1589 
1590 
1591 //*************************************************************************************************
1597 template< typename MT // Type of the adapted sparse matrix
1598  , bool SO > // Storage order of the adapted sparse matrix
1599 inline size_t SymmetricMatrix<MT,SO,false,false>::columns() const noexcept
1600 {
1601  return matrix_.columns();
1602 }
1604 //*************************************************************************************************
1605 
1606 
1607 //*************************************************************************************************
1613 template< typename MT // Type of the adapted sparse matrix
1614  , bool SO > // Storage order of the adapted sparse matrix
1615 inline size_t SymmetricMatrix<MT,SO,false,false>::capacity() const noexcept
1616 {
1617  return matrix_.capacity();
1618 }
1620 //*************************************************************************************************
1621 
1622 
1623 //*************************************************************************************************
1634 template< typename MT // Type of the adapted sparse matrix
1635  , bool SO > // Storage order of the adapted sparse matrix
1636 inline size_t SymmetricMatrix<MT,SO,false,false>::capacity( size_t i ) const noexcept
1637 {
1638  return matrix_.capacity(i);
1639 }
1641 //*************************************************************************************************
1642 
1643 
1644 //*************************************************************************************************
1650 template< typename MT // Type of the adapted sparse matrix
1651  , bool SO > // Storage order of the adapted sparse matrix
1653 {
1654  return matrix_.nonZeros();
1655 }
1657 //*************************************************************************************************
1658 
1659 
1660 //*************************************************************************************************
1672 template< typename MT // Type of the adapted sparse matrix
1673  , bool SO > // Storage order of the adapted sparse matrix
1674 inline size_t SymmetricMatrix<MT,SO,false,false>::nonZeros( size_t i ) const
1675 {
1676  return matrix_.nonZeros(i);
1677 }
1679 //*************************************************************************************************
1680 
1681 
1682 //*************************************************************************************************
1688 template< typename MT // Type of the adapted sparse matrix
1689  , bool SO > // Storage order of the adapted sparse matrix
1691 {
1692  matrix_.reset();
1693 }
1695 //*************************************************************************************************
1696 
1697 
1698 //*************************************************************************************************
1738 template< typename MT // Type of the adapted sparse matrix
1739  , bool SO > // Storage order of the adapted sparse matrix
1740 inline void SymmetricMatrix<MT,SO,false,false>::reset( size_t i )
1741 {
1742  for( Iterator_<MatrixType> it=matrix_.begin(i); it!=matrix_.end(i); ++it )
1743  {
1744  const size_t j( it->index() );
1745 
1746  if( i == j )
1747  continue;
1748 
1749  if( SO ) {
1750  const Iterator_<MatrixType> pos( matrix_.find( i, j ) );
1751  BLAZE_INTERNAL_ASSERT( pos != matrix_.end( j ), "Missing element detected" );
1752  matrix_.erase( j, pos );
1753  }
1754  else {
1755  const Iterator_<MatrixType> pos( matrix_.find( j, i ) );
1756  BLAZE_INTERNAL_ASSERT( pos != matrix_.end( j ), "Missing element detected" );
1757  matrix_.erase( j, pos );
1758  }
1759  }
1760 
1761  matrix_.reset( i );
1762 }
1764 //*************************************************************************************************
1765 
1766 
1767 //*************************************************************************************************
1775 template< typename MT // Type of the adapted sparse matrix
1776  , bool SO > // Storage order of the adapted sparse matrix
1778 {
1779  using blaze::clear;
1780 
1781  clear( matrix_ );
1782 }
1784 //*************************************************************************************************
1785 
1786 
1787 //*************************************************************************************************
1802 template< typename MT // Type of the adapted sparse matrix
1803  , bool SO > // Storage order of the adapted sparse matrix
1804 void SymmetricMatrix<MT,SO,false,false>::resize( size_t n, bool preserve )
1805 {
1807 
1808  UNUSED_PARAMETER( preserve );
1809 
1810  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1811 
1812  matrix_.resize( n, n, true );
1813 }
1815 //*************************************************************************************************
1816 
1817 
1818 //*************************************************************************************************
1829 template< typename MT // Type of the adapted sparse matrix
1830  , bool SO > // Storage order of the adapted sparse matrix
1831 inline void SymmetricMatrix<MT,SO,false,false>::reserve( size_t nonzeros )
1832 {
1833  matrix_.reserve( nonzeros );
1834 }
1836 //*************************************************************************************************
1837 
1838 
1839 //*************************************************************************************************
1853 template< typename MT // Type of the adapted sparse matrix
1854  , bool SO > // Storage order of the adapted sparse matrix
1855 inline void SymmetricMatrix<MT,SO,false,false>::reserve( size_t i, size_t nonzeros )
1856 {
1857  matrix_.reserve( i, nonzeros );
1858 }
1860 //*************************************************************************************************
1861 
1862 
1863 //*************************************************************************************************
1874 template< typename MT // Type of the adapted sparse matrix
1875  , bool SO > // Storage order of the adapted sparse matrix
1876 inline void SymmetricMatrix<MT,SO,false,false>::trim()
1877 {
1878  matrix_.trim();
1879 }
1881 //*************************************************************************************************
1882 
1883 
1884 //*************************************************************************************************
1896 template< typename MT // Type of the adapted sparse matrix
1897  , bool SO > // Storage order of the adapted sparse matrix
1898 inline void SymmetricMatrix<MT,SO,false,false>::trim( size_t i )
1899 {
1900  matrix_.trim( i );
1901 }
1903 //*************************************************************************************************
1904 
1905 
1906 //*************************************************************************************************
1913 template< typename MT // Type of the adapted sparse matrix
1914  , bool SO > // Storage order of the adapted sparse matrix
1915 inline void SymmetricMatrix<MT,SO,false,false>::swap( SymmetricMatrix& m ) noexcept
1916 {
1917  using std::swap;
1918 
1919  swap( matrix_, m.matrix_ );
1920 }
1922 //*************************************************************************************************
1923 
1924 
1925 
1926 
1927 //=================================================================================================
1928 //
1929 // INSERTION FUNCTIONS
1930 //
1931 //=================================================================================================
1932 
1933 //*************************************************************************************************
1947 template< typename MT // Type of the adapted sparse matrix
1948  , bool SO > // Storage order of the adapted sparse matrix
1950  SymmetricMatrix<MT,SO,false,false>::set( size_t i, size_t j, const ElementType& value )
1951 {
1952  SharedValue<ET> shared( value );
1953 
1954  if( i != j )
1955  matrix_.set( j, i, shared );
1956 
1957  return Iterator( matrix_.set( i, j, shared ) );
1958 }
1960 //*************************************************************************************************
1961 
1962 
1963 //*************************************************************************************************
1978 template< typename MT // Type of the adapted sparse matrix
1979  , bool SO > // Storage order of the adapted sparse matrix
1981  SymmetricMatrix<MT,SO,false,false>::insert( size_t i, size_t j, const ElementType& value )
1982 {
1983  SharedValue<ET> shared( value );
1984 
1985  if( i != j )
1986  matrix_.insert( j, i, shared );
1987 
1988  return Iterator( matrix_.insert( i, j, shared ) );
1989 }
1991 //*************************************************************************************************
1992 
1993 
1994 //*************************************************************************************************
2049 template< typename MT // Type of the adapted sparse matrix
2050  , bool SO > // Storage order of the adapted sparse matrix
2051 inline void SymmetricMatrix<MT,SO,false,false>::append( size_t i, size_t j, const ElementType& value, bool check )
2052 {
2053  SharedValue<ET> shared( value );
2054 
2055  matrix_.append( i, j, shared, check );
2056  if( i != j && ( !check || !isDefault( value ) ) )
2057  matrix_.insert( j, i, shared );
2058 }
2060 //*************************************************************************************************
2061 
2062 
2063 //*************************************************************************************************
2077 template< typename MT // Type of the adapted sparse matrix
2078  , bool SO > // Storage order of the adapted sparse matrix
2079 inline void SymmetricMatrix<MT,SO,false,false>::finalize( size_t i )
2080 {
2081  matrix_.trim( i );
2082 }
2084 //*************************************************************************************************
2085 
2086 
2087 
2088 
2089 //=================================================================================================
2090 //
2091 // ERASE FUNCTIONS
2092 //
2093 //=================================================================================================
2094 
2095 //*************************************************************************************************
2105 template< typename MT // Type of the adapted sparse matrix
2106  , bool SO > // Storage order of the adapted sparse matrix
2107 inline void SymmetricMatrix<MT,SO,false,false>::erase( size_t i, size_t j )
2108 {
2109  matrix_.erase( i, j );
2110  if( i != j )
2111  matrix_.erase( j, i );
2112 }
2114 //*************************************************************************************************
2115 
2116 
2117 //*************************************************************************************************
2129 template< typename MT // Type of the adapted sparse matrix
2130  , bool SO > // Storage order of the adapted sparse matrix
2132  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator pos )
2133 {
2134  if( pos == end( i ) )
2135  return pos;
2136 
2137  const size_t j( pos->index() );
2138 
2139  if( i == j )
2140  return Iterator( matrix_.erase( i, pos.base() ) );
2141 
2142  if( SO ) {
2143  BLAZE_INTERNAL_ASSERT( matrix_.find( i, j ) != matrix_.end( j ), "Missing element detected" );
2144  matrix_.erase( j, matrix_.find( i, j ) );
2145  return Iterator( matrix_.erase( i, pos.base() ) );
2146  }
2147  else {
2148  BLAZE_INTERNAL_ASSERT( matrix_.find( j, i ) != matrix_.end( j ), "Missing element detected" );
2149  matrix_.erase( j, matrix_.find( j, i ) );
2150  return Iterator( matrix_.erase( i, pos.base() ) );
2151  }
2152 }
2154 //*************************************************************************************************
2155 
2156 
2157 //*************************************************************************************************
2171 template< typename MT // Type of the adapted sparse matrix
2172  , bool SO > // Storage order of the adapted sparse matrix
2174  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator first, Iterator last )
2175 {
2176  for( Iterator it=first; it!=last; ++it )
2177  {
2178  const size_t j( it->index() );
2179 
2180  if( i == j )
2181  continue;
2182 
2183  if( SO ) {
2184  BLAZE_INTERNAL_ASSERT( matrix_.find( i, j ) != matrix_.end( j ), "Missing element detected" );
2185  matrix_.erase( i, j );
2186  }
2187  else {
2188  BLAZE_INTERNAL_ASSERT( matrix_.find( j, i ) != matrix_.end( j ), "Missing element detected" );
2189  matrix_.erase( j, i );
2190  }
2191  }
2192 
2193  return Iterator( matrix_.erase( i, first.base(), last.base() ) );
2194 }
2196 //*************************************************************************************************
2197 
2198 
2199 //*************************************************************************************************
2213 template< typename MT // Type of the adapted sparse matrix
2214  , bool SO > // Storage order of the adapted sparse matrix
2215 template< typename Pred > // Type of the unary predicate
2216 inline void SymmetricMatrix<MT,SO,false,false>::erase( Pred predicate )
2217 {
2218  matrix_.erase( [predicate=predicate]( const SharedValue<ET>& value ) {
2219  return predicate( *value );
2220  } );
2221 
2222  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2223 }
2225 //*************************************************************************************************
2226 
2227 
2228 //*************************************************************************************************
2247 template< typename MT // Type of the adapted sparse matrix
2248  , bool SO > // Storage order of the adapted sparse matrix
2249 template< typename Pred > // Type of the unary predicate
2250 inline void
2251  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
2252 {
2253  for( Iterator it=first; it!=last; ++it ) {
2254  const size_t j( it->index() );
2255  if( i != j && predicate( it->value() ) ) {
2256  if( SO )
2257  matrix_.erase( i, j );
2258  else
2259  matrix_.erase( j, i );
2260  }
2261  }
2262 
2263  matrix_.erase( i, first.base(), last.base(),
2264  [predicate=predicate]( const SharedValue<ET>& value ) {
2265  return predicate( *value );
2266  } );
2267 
2268  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2269 }
2271 //*************************************************************************************************
2272 
2273 
2274 
2275 
2276 //=================================================================================================
2277 //
2278 // LOOKUP FUNCTIONS
2279 //
2280 //=================================================================================================
2281 
2282 //*************************************************************************************************
2298 template< typename MT // Type of the adapted sparse matrix
2299  , bool SO > // Storage order of the adapted sparse matrix
2301  SymmetricMatrix<MT,SO,false,false>::find( size_t i, size_t j )
2302 {
2303  return Iterator( matrix_.find( i, j ) );
2304 }
2306 //*************************************************************************************************
2307 
2308 
2309 //*************************************************************************************************
2325 template< typename MT // Type of the adapted sparse matrix
2326  , bool SO > // Storage order of the adapted sparse matrix
2328  SymmetricMatrix<MT,SO,false,false>::find( size_t i, size_t j ) const
2329 {
2330  return ConstIterator( matrix_.find( i, j ) );
2331 }
2333 //*************************************************************************************************
2334 
2335 
2336 //*************************************************************************************************
2352 template< typename MT // Type of the adapted sparse matrix
2353  , bool SO > // Storage order of the adapted sparse matrix
2355  SymmetricMatrix<MT,SO,false,false>::lowerBound( size_t i, size_t j )
2356 {
2357  return Iterator( matrix_.lowerBound( i, j ) );
2358 }
2360 //*************************************************************************************************
2361 
2362 
2363 //*************************************************************************************************
2379 template< typename MT // Type of the adapted sparse matrix
2380  , bool SO > // Storage order of the adapted sparse matrix
2382  SymmetricMatrix<MT,SO,false,false>::lowerBound( size_t i, size_t j ) const
2383 {
2384  return ConstIterator( matrix_.lowerBound( i, j ) );
2385 }
2387 //*************************************************************************************************
2388 
2389 
2390 //*************************************************************************************************
2406 template< typename MT // Type of the adapted sparse matrix
2407  , bool SO > // Storage order of the adapted sparse matrix
2409  SymmetricMatrix<MT,SO,false,false>::upperBound( size_t i, size_t j )
2410 {
2411  return Iterator( matrix_.upperBound( i, j ) );
2412 }
2414 //*************************************************************************************************
2415 
2416 
2417 //*************************************************************************************************
2433 template< typename MT // Type of the adapted sparse matrix
2434  , bool SO > // Storage order of the adapted sparse matrix
2436  SymmetricMatrix<MT,SO,false,false>::upperBound( size_t i, size_t j ) const
2437 {
2438  return ConstIterator( matrix_.upperBound( i, j ) );
2439 }
2441 //*************************************************************************************************
2442 
2443 
2444 
2445 
2446 //=================================================================================================
2447 //
2448 // NUMERIC FUNCTIONS
2449 //
2450 //=================================================================================================
2451 
2452 //*************************************************************************************************
2458 template< typename MT // Type of the adapted sparse matrix
2459  , bool SO > // Storage order of the adapted sparse matrix
2460 inline SymmetricMatrix<MT,SO,false,false>& SymmetricMatrix<MT,SO,false,false>::transpose()
2461 {
2462  return *this;
2463 }
2465 //*************************************************************************************************
2466 
2467 
2468 //*************************************************************************************************
2474 template< typename MT // Type of the adapted sparse matrix
2475  , bool SO > // Storage order of the adapted sparse matrix
2476 inline SymmetricMatrix<MT,SO,false,false>& SymmetricMatrix<MT,SO,false,false>::ctranspose()
2477 {
2478  for( size_t i=0UL; i<rows(); ++i ) {
2479  const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
2480  for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
2481  conjugate( *element->value() );
2482  }
2483 
2484  return *this;
2485 }
2487 //*************************************************************************************************
2488 
2489 
2490 //*************************************************************************************************
2497 template< typename MT // Type of the adapted sparse matrix
2498  , bool SO > // Storage order of the adapted sparse matrix
2499 template< typename Other > // Data type of the scalar value
2500 inline SymmetricMatrix<MT,SO,false,false>&
2501  SymmetricMatrix<MT,SO,false,false>::scale( const Other& scalar )
2502 {
2503  for( size_t i=0UL; i<rows(); ++i ) {
2504  const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
2505  for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
2506  ( *element->value() ).scale( scalar );
2507  }
2508 
2509  return *this;
2510 }
2512 //*************************************************************************************************
2513 
2514 
2515 //*************************************************************************************************
2522 template< typename MT // Type of the adapted sparse matrix
2523  , bool SO > // Storage order of the adapted sparse matrix
2524 template< typename Other > // Data type of the scalar value
2525 inline SymmetricMatrix<MT,SO,false,false>&
2526  SymmetricMatrix<MT,SO,false,false>::scaleDiagonal( const Other& scalar )
2527 {
2528  matrix_.scaleDiagonal( scalar );
2529  return *this;
2530 }
2532 //*************************************************************************************************
2533 
2534 
2535 
2536 
2537 //=================================================================================================
2538 //
2539 // DEBUGGING FUNCTIONS
2540 //
2541 //=================================================================================================
2542 
2543 //*************************************************************************************************
2553 template< typename MT // Type of the adapted dense matrix
2554  , bool SO > // Storage order of the adapted dense matrix
2555 inline bool SymmetricMatrix<MT,SO,false,false>::isIntact() const noexcept
2556 {
2557  using blaze::isIntact;
2558 
2559  return ( isIntact( matrix_ ) && isSymmetric( matrix_ ) );
2560 }
2562 //*************************************************************************************************
2563 
2564 
2565 
2566 
2567 //=================================================================================================
2568 //
2569 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2570 //
2571 //=================================================================================================
2572 
2573 //*************************************************************************************************
2584 template< typename MT // Type of the adapted sparse matrix
2585  , bool SO > // Storage order of the adapted sparse matrix
2586 template< typename Other > // Data type of the foreign expression
2587 inline bool SymmetricMatrix<MT,SO,false,false>::canAlias( const Other* alias ) const noexcept
2588 {
2589  return matrix_.canAlias( alias );
2590 }
2592 //*************************************************************************************************
2593 
2594 
2595 //*************************************************************************************************
2606 template< typename MT // Type of the adapted sparse matrix
2607  , bool SO > // Storage order of the adapted sparse matrix
2608 template< typename Other > // Data type of the foreign expression
2609 inline bool SymmetricMatrix<MT,SO,false,false>::isAliased( const Other* alias ) const noexcept
2610 {
2611  return matrix_.isAliased( alias );
2612 }
2614 //*************************************************************************************************
2615 
2616 
2617 //*************************************************************************************************
2628 template< typename MT // Type of the adapted sparse matrix
2629  , bool SO > // Storage order of the adapted sparse matrix
2630 inline bool SymmetricMatrix<MT,SO,false,false>::canSMPAssign() const noexcept
2631 {
2632  return matrix_.canSMPAssign();
2633 }
2635 //*************************************************************************************************
2636 
2637 
2638 //*************************************************************************************************
2650 template< typename MT // Type of the adapted sparse matrix
2651  , bool SO > // Storage order of the adapted sparse matrix
2652 template< typename MT2 > // Type of the right-hand side dense matrix
2653 void SymmetricMatrix<MT,SO,false,false>::assign( DenseMatrix<MT2,SO>& rhs )
2654 {
2656 
2657  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2658  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2659 
2660  std::vector<size_t> nonzeros( rows(), 0UL );
2661  size_t sum( 0UL );
2662 
2663  for( size_t i=0UL; i<rows(); ++i ) {
2664  nonzeros[i] = (~rhs).nonZeros(i);
2665  sum += nonzeros[i];
2666  }
2667 
2668  matrix_.reserve( sum );
2669  for( size_t i=0UL; i<rows(); ++i ) {
2670  matrix_.reserve( i, nonzeros[i] );
2671  }
2672 
2673  for( size_t i=0UL; i<rows(); ++i ) {
2674  for( size_t j=i; j<columns(); ++j ) {
2675  if( !isDefault( (~rhs)(i,j) ) ) {
2676  SharedValue<ET> shared;
2677  *shared = std::move( (~rhs)(i,j) );
2678  matrix_.append( i, j, shared, false );
2679  if( i != j )
2680  matrix_.append( j, i, shared, false );
2681  }
2682  }
2683  }
2684 }
2686 //*************************************************************************************************
2687 
2688 
2689 //*************************************************************************************************
2701 template< typename MT // Type of the adapted sparse matrix
2702  , bool SO > // Storage order of the adapted sparse matrix
2703 template< typename MT2 > // Type of the right-hand side dense matrix
2704 void SymmetricMatrix<MT,SO,false,false>::assign( const DenseMatrix<MT2,SO>& rhs )
2705 {
2707 
2708  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2709  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2710 
2711  std::vector<size_t> nonzeros( rows(), 0UL );
2712  size_t sum( 0UL );
2713 
2714  for( size_t i=0UL; i<rows(); ++i ) {
2715  nonzeros[i] = (~rhs).nonZeros(i);
2716  sum += nonzeros[i];
2717  }
2718 
2719  matrix_.reserve( sum );
2720  for( size_t i=0UL; i<rows(); ++i ) {
2721  matrix_.reserve( i, nonzeros[i] );
2722  }
2723 
2724  for( size_t i=0UL; i<rows(); ++i ) {
2725  for( size_t j=i; j<columns(); ++j ) {
2726  if( !isDefault( (~rhs)(i,j) ) ) {
2727  const SharedValue<ET> shared( (~rhs)(i,j) );
2728  matrix_.append( i, j, shared, false );
2729  if( i != j )
2730  matrix_.append( j, i, shared, false );
2731  }
2732  }
2733  }
2734 }
2736 //*************************************************************************************************
2737 
2738 
2739 //*************************************************************************************************
2751 template< typename MT // Type of the adapted sparse matrix
2752  , bool SO > // Storage order of the adapted sparse matrix
2753 template< typename MT2 > // Type of the right-hand side sparse matrix
2754 void SymmetricMatrix<MT,SO,false,false>::assign( SparseMatrix<MT2,SO>& rhs )
2755 {
2757 
2758  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2759  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2760 
2761  std::vector<size_t> nonzeros( rows(), 0UL );
2762  size_t sum( 0UL );
2763 
2764  for( size_t i=0UL; i<rows(); ++i ) {
2765  nonzeros[i] = (~rhs).nonZeros(i);
2766  sum += nonzeros[i];
2767  }
2768 
2769  matrix_.reserve( sum );
2770  for( size_t i=0UL; i<rows(); ++i ) {
2771  matrix_.reserve( i, nonzeros[i] );
2772  }
2773 
2774  for( size_t i=0UL; i<rows(); ++i ) {
2775  for( Iterator_<MT2> it=(~rhs).lowerBound(i,i); it!=(~rhs).end(i); ++it ) {
2776  if( !isDefault( it->value() ) ) {
2777  SharedValue<ET> shared;
2778  *shared = std::move( it->value() );
2779  matrix_.append( i, it->index(), shared, false );
2780  if( i != it->index() )
2781  matrix_.append( it->index(), i, shared, false );
2782  }
2783  }
2784  }
2785 }
2787 //*************************************************************************************************
2788 
2789 
2790 //*************************************************************************************************
2802 template< typename MT // Type of the adapted sparse matrix
2803  , bool SO > // Storage order of the adapted sparse matrix
2804 template< typename MT2 > // Type of the right-hand side sparse matrix
2805 void SymmetricMatrix<MT,SO,false,false>::assign( const SparseMatrix<MT2,SO>& rhs )
2806 {
2808 
2809  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2810  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2811 
2812  std::vector<size_t> nonzeros( rows(), 0UL );
2813  size_t sum( 0UL );
2814 
2815  for( size_t i=0UL; i<rows(); ++i ) {
2816  nonzeros[i] = (~rhs).nonZeros(i);
2817  sum += nonzeros[i];
2818  }
2819 
2820  matrix_.reserve( sum );
2821  for( size_t i=0UL; i<rows(); ++i ) {
2822  matrix_.reserve( i, nonzeros[i] );
2823  }
2824 
2825  for( size_t i=0UL; i<rows(); ++i ) {
2826  for( ConstIterator_<MT2> it=(~rhs).lowerBound(i,i); it!=(~rhs).end(i); ++it ) {
2827  if( !isDefault( it->value() ) ) {
2828  const SharedValue<ET> shared( it->value() );
2829  matrix_.append( i, it->index(), shared, false );
2830  if( i != it->index() )
2831  matrix_.append( it->index(), i, shared, false );
2832  }
2833  }
2834  }
2835 }
2837 //*************************************************************************************************
2838 
2839 } // namespace blaze
2840 
2841 #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.
#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 Rows type trait.
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:352
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE const complex< int8_t > sum(const SIMDcint8 &a) noexcept
Returns the sum of all elements in the 8-bit integral complex SIMD vector.
Definition: Reduction.h:63
#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
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
Constraint on the data type.
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:194
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:533
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2935
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5556
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:596
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2928
#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:390
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
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
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2931
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:304
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:238
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.
Header file for the DisableIf class template.
Header file for the multiplication trait.
Header file for the IsSymmetric type trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5635
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:5618
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2939
#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
#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 Columns type trait.
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:336
Header file for the SparseElement base class.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2932
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:544
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:260
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:2933
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
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2937
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
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
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2934
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.
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
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2938
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:267
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:697
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:320
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2929
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE(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
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:733
Header file for the IsComputation type trait class.
#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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2930
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:249
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2936
#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:1303
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
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:677
const DMatDMatMultExpr< T1, T2, false, false, false, false > 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:7505
#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:570