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  using OT = OppositeType_<MT>;
114  using TT = TransposeType_<MT>;
115  using ET = ElementType_<MT>;
116 
118  using MatrixType = typename MT::template Rebind< SharedValue<ET> >::Other;
119  //**********************************************************************************************
120 
121  public:
122  //**Type definitions****************************************************************************
123  using This = SymmetricMatrix<MT,SO,false,false>;
124  using BaseType = SparseMatrix<This,SO>;
125  using ResultType = This;
126  using OppositeType = SymmetricMatrix<OT,!SO,false,false>;
127  using TransposeType = SymmetricMatrix<TT,!SO,false,false>;
128  using ElementType = ET;
129  using ReturnType = ReturnType_<MT>;
130  using CompositeType = const This&;
131  using Reference = NonNumericProxy<MatrixType>;
132  using ConstReference = ConstReference_<MT>;
133  //**********************************************************************************************
134 
135  //**Rebind struct definition********************************************************************
138  template< typename NewType > // Data type of the other matrix
139  struct Rebind {
141  using Other = SymmetricMatrix< typename MT::template Rebind<NewType>::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  using Other = SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other >;
153  };
154  //**********************************************************************************************
155 
156  //**SharedElement class definition**************************************************************
159  template< typename IteratorType > // Type of the sparse matrix iterator
160  class SharedElement
161  : private SparseElement
162  {
163  public:
164  //**Type definitions*************************************************************************
165  using ValueType = ET;
166  using IndexType = size_t;
167  using Reference = ValueType&;
168  using ConstReference = const ValueType&;
169  using Pointer = SharedElement*;
170  using ConstPointer = const SharedElement*;
171  //*******************************************************************************************
172 
173  //**Constructor******************************************************************************
178  inline SharedElement( IteratorType pos )
179  : pos_( pos ) // Iterator to the current sparse symmetric matrix element
180  {}
181  //*******************************************************************************************
182 
183  //**Assignment operator**********************************************************************
189  template< typename T > inline SharedElement& operator=( const T& v ) {
190  *pos_->value() = v;
191  return *this;
192  }
193  //*******************************************************************************************
194 
195  //**Addition assignment operator*************************************************************
201  template< typename T > inline SharedElement& operator+=( const T& v ) {
202  *pos_->value() += v;
203  return *this;
204  }
205  //*******************************************************************************************
206 
207  //**Subtraction assignment operator**********************************************************
213  template< typename T > inline SharedElement& operator-=( const T& v ) {
214  *pos_->value() -= v;
215  return *this;
216  }
217  //*******************************************************************************************
218 
219  //**Multiplication assignment operator*******************************************************
225  template< typename T > inline SharedElement& operator*=( const T& v ) {
226  *pos_->value() *= v;
227  return *this;
228  }
229  //*******************************************************************************************
230 
231  //**Division assignment operator*************************************************************
237  template< typename T > inline SharedElement& operator/=( const T& v ) {
238  *pos_->value() /= v;
239  return *this;
240  }
241  //*******************************************************************************************
242 
243  //**Element access operator******************************************************************
248  inline Pointer operator->() {
249  return this;
250  }
251  //*******************************************************************************************
252 
253  //**Element access operator******************************************************************
258  inline ConstPointer operator->() const {
259  return this;
260  }
261  //*******************************************************************************************
262 
263  //**Value function***************************************************************************
268  inline Reference value() {
269  return *pos_->value();
270  }
271  //*******************************************************************************************
272 
273  //**Value function***************************************************************************
278  inline ConstReference value() const {
279  return *pos_->value();
280  }
281  //*******************************************************************************************
282 
283  //**Index function***************************************************************************
288  inline IndexType index() const {
289  return pos_->index();
290  }
291  //*******************************************************************************************
292 
293  private:
294  //**Member variables*************************************************************************
295  IteratorType pos_;
296  //*******************************************************************************************
297  };
298  //**********************************************************************************************
299 
300  //**SharedIterator class definition*************************************************************
303  template< typename SparseElementType // Type of the underlying sparse elements.
304  , typename IteratorType > // Type of the sparse matrix iterator
305  class SharedIterator
306  {
307  public:
308  //**Type definitions*************************************************************************
309  using IteratorCategory = std::forward_iterator_tag;
310  using ValueType = SparseElementType;
311  using PointerType = SparseElementType;
312  using ReferenceType = SparseElementType;
313  using DifferenceType = ptrdiff_t;
314 
315  // STL iterator requirements
316  using iterator_category = IteratorCategory;
317  using value_type = ValueType;
318  using pointer = PointerType;
319  using reference = ReferenceType;
320  using difference_type = DifferenceType;
321  //*******************************************************************************************
322 
323  //**Default constructor**********************************************************************
326  inline SharedIterator()
327  : pos_() // Iterator to the current sparse symmetric matrix element
328  {}
329  //*******************************************************************************************
330 
331  //**Constructor******************************************************************************
336  inline SharedIterator( IteratorType pos )
337  : pos_( pos ) // Iterator to the current sparse symmetric matrix element
338  {}
339  //*******************************************************************************************
340 
341  //**Constructor******************************************************************************
346  template< typename SparseElementType2, typename IteratorType2 >
347  inline SharedIterator( const SharedIterator<SparseElementType2,IteratorType2>& it )
348  : pos_( it.pos_ ) // Iterator to the current sparse symmetric matrix element
349  {}
350  //*******************************************************************************************
351 
352  //**Prefix increment operator****************************************************************
357  inline SharedIterator& operator++() {
358  ++pos_;
359  return *this;
360  }
361  //*******************************************************************************************
362 
363  //**Postfix increment operator***************************************************************
368  inline const SharedIterator operator++( int ) {
369  const SharedIterator tmp( *this );
370  ++(*this);
371  return tmp;
372  }
373  //*******************************************************************************************
374 
375  //**Element access operator******************************************************************
380  inline ReferenceType operator*() const {
381  return ReferenceType( pos_ );
382  }
383  //*******************************************************************************************
384 
385  //**Element access operator******************************************************************
390  inline PointerType operator->() const {
391  return PointerType( pos_ );
392  }
393  //*******************************************************************************************
394 
395  //**Equality operator************************************************************************
401  inline bool operator==( const SharedIterator& rhs ) const {
402  return pos_ == rhs.pos_;
403  }
404  //*******************************************************************************************
405 
406  //**Inequality operator**********************************************************************
412  inline bool operator!=( const SharedIterator& rhs ) const {
413  return !( *this == rhs );
414  }
415  //*******************************************************************************************
416 
417  //**Subtraction operator*********************************************************************
423  inline DifferenceType operator-( const SharedIterator& rhs ) const {
424  return pos_ - rhs.pos_;
425  }
426  //*******************************************************************************************
427 
428  //**Base function****************************************************************************
433  inline IteratorType base() const {
434  return pos_;
435  }
436  //*******************************************************************************************
437 
438  private:
439  //**Member variables*************************************************************************
440  IteratorType pos_;
441  //*******************************************************************************************
442 
443  //**Friend declarations**********************************************************************
444  template< typename SparseElementType2, typename IteratorType2 > friend class SharedIterator;
445  //*******************************************************************************************
446  };
447  //**********************************************************************************************
448 
449  //**Type definitions****************************************************************************
451  using Iterator = SharedIterator< SharedElement< Iterator_<MatrixType> >
452  , Iterator_<MatrixType> >;
453 
455  using ConstIterator = SharedIterator< const SharedElement< ConstIterator_<MatrixType> >
456  , ConstIterator_<MatrixType> >;
457  //**********************************************************************************************
458 
459  //**Compilation flags***************************************************************************
461  enum : bool { smpAssignable = false };
462  //**********************************************************************************************
463 
464  //**Constructors********************************************************************************
467  explicit inline SymmetricMatrix();
468  explicit inline SymmetricMatrix( size_t n );
469  explicit inline SymmetricMatrix( size_t n, size_t nonzeros );
470  explicit inline SymmetricMatrix( size_t n, const std::vector<size_t>& nonzeros );
471 
472  inline SymmetricMatrix( const SymmetricMatrix& m );
473  inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
474 
475  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,SO>& m );
476  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,!SO>& m );
478  //**********************************************************************************************
479 
480  //**Destructor**********************************************************************************
481  // No explicitly declared destructor.
482  //**********************************************************************************************
483 
484  //**Data access functions***********************************************************************
487  inline Reference operator()( size_t i, size_t j );
488  inline ConstReference operator()( size_t i, size_t j ) const;
489  inline Reference at( size_t i, size_t j );
490  inline ConstReference at( size_t i, size_t j ) const;
491  inline Iterator begin ( size_t i );
492  inline ConstIterator begin ( size_t i ) const;
493  inline ConstIterator cbegin( size_t i ) const;
494  inline Iterator end ( size_t i );
495  inline ConstIterator end ( size_t i ) const;
496  inline ConstIterator cend ( size_t i ) const;
498  //**********************************************************************************************
499 
500  //**Assignment operators************************************************************************
503  inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
504  inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
505 
506  template< typename MT2 >
507  inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
508 
509  template< typename MT2 >
510  inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
511 
512  template< typename MT2 >
513  inline SymmetricMatrix& operator=( const Matrix<MT2,!SO>& rhs );
514 
515  template< typename MT2 >
516  inline SymmetricMatrix& operator+=( const Matrix<MT2,SO>& rhs );
517 
518  template< typename MT2 >
519  inline SymmetricMatrix& operator+=( const Matrix<MT2,!SO>& rhs );
520 
521  template< typename MT2 >
522  inline SymmetricMatrix& operator-=( const Matrix<MT2,SO>& rhs );
523 
524  template< typename MT2 >
525  inline SymmetricMatrix& operator-=( const Matrix<MT2,!SO>& rhs );
526 
527  template< typename MT2 >
528  inline SymmetricMatrix& operator%=( const Matrix<MT2,SO>& rhs );
529 
530  template< typename MT2 >
531  inline SymmetricMatrix& operator%=( const Matrix<MT2,!SO>& rhs );
532 
533  template< typename MT2, bool SO2 >
534  inline SymmetricMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
535 
536  template< typename Other >
537  inline EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator*=( Other rhs );
538 
539  template< typename Other >
540  inline EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator/=( Other rhs );
542  //**********************************************************************************************
543 
544  //**Utility functions***************************************************************************
547  inline size_t rows() const noexcept;
548  inline size_t columns() const noexcept;
549  inline size_t capacity() const noexcept;
550  inline size_t capacity( size_t i ) const noexcept;
551  inline size_t nonZeros() const;
552  inline size_t nonZeros( size_t i ) const;
553  inline void reset();
554  inline void reset( size_t i );
555  inline void clear();
556  inline void resize ( size_t n, bool preserve=true );
557  inline void reserve( size_t nonzeros );
558  inline void reserve( size_t i, size_t nonzeros );
559  inline void trim();
560  inline void trim( size_t i );
561  inline void shrinkToFit();
562  inline void swap( SymmetricMatrix& m ) noexcept;
564  //**********************************************************************************************
565 
566  //**Insertion functions*************************************************************************
569  inline Iterator set ( size_t i, size_t j, const ElementType& value );
570  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
571  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
572  inline void finalize( size_t i );
574  //**********************************************************************************************
575 
576  //**Erase functions*****************************************************************************
579  inline void erase( size_t i, size_t j );
580  inline Iterator erase( size_t i, Iterator pos );
581  inline Iterator erase( size_t i, Iterator first, Iterator last );
582 
583  template< typename Pred >
584  inline void erase( Pred predicate );
585 
586  template< typename Pred >
587  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
589  //**********************************************************************************************
590 
591  //**Lookup functions****************************************************************************
594  inline Iterator find ( size_t i, size_t j );
595  inline ConstIterator find ( size_t i, size_t j ) const;
596  inline Iterator lowerBound( size_t i, size_t j );
597  inline ConstIterator lowerBound( size_t i, size_t j ) const;
598  inline Iterator upperBound( size_t i, size_t j );
599  inline ConstIterator upperBound( size_t i, size_t j ) const;
601  //**********************************************************************************************
602 
603  //**Numeric functions***************************************************************************
606  inline SymmetricMatrix& transpose();
607  inline SymmetricMatrix& ctranspose();
608 
609  template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
610  template< typename Other > inline SymmetricMatrix& scaleDiagonal( const Other& scale );
612  //**********************************************************************************************
613 
614  //**Debugging functions*************************************************************************
617  inline bool isIntact() const noexcept;
619  //**********************************************************************************************
620 
621  //**Expression template evaluation functions****************************************************
624  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
625  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
626 
627  inline bool canSMPAssign() const noexcept;
629  //**********************************************************************************************
630 
631  private:
632  //**Expression template evaluation functions****************************************************
635  template< typename MT2 > void assign( DenseMatrix<MT2,SO>& rhs );
636  template< typename MT2 > void assign( const DenseMatrix<MT2,SO>& rhs );
637  template< typename MT2 > void assign( SparseMatrix<MT2,SO>& rhs );
638  template< typename MT2 > void assign( const SparseMatrix<MT2,SO>& rhs );
640  //**********************************************************************************************
641 
642  //**Member variables****************************************************************************
645  MatrixType matrix_;
646 
647  //**********************************************************************************************
648 
649  //**Friend declarations*************************************************************************
650  template< bool RF, typename MT2, bool SO2, bool DF2, bool NF2 >
651  friend bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
652  //**********************************************************************************************
653 
654  //**Compile time checks*************************************************************************
668  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
669  //**********************************************************************************************
670 };
672 //*************************************************************************************************
673 
674 
675 
676 
677 //=================================================================================================
678 //
679 // CONSTRUCTORS
680 //
681 //=================================================================================================
682 
683 //*************************************************************************************************
687 template< typename MT // Type of the adapted sparse matrix
688  , bool SO > // Storage order of the adapted sparse matrix
689 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix()
690  : matrix_() // The adapted sparse matrix
691 {
692  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
693 }
695 //*************************************************************************************************
696 
697 
698 //*************************************************************************************************
706 template< typename MT // Type of the adapted sparse matrix
707  , bool SO > // Storage order of the adapted sparse matrix
708 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n )
709  : matrix_( n, n ) // The adapted sparse matrix
710 {
712 
713  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
714 }
716 //*************************************************************************************************
717 
718 
719 //*************************************************************************************************
728 template< typename MT // Type of the adapted sparse matrix
729  , bool SO > // Storage order of the adapted sparse matrix
730 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n, size_t nonzeros )
731  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
732 {
734 
735  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
736 }
738 //*************************************************************************************************
739 
740 
741 //*************************************************************************************************
752 template< typename MT // Type of the adapted sparse matrix
753  , bool SO > // Storage order of the adapted sparse matrix
754 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n, const std::vector<size_t>& nonzeros )
755  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
756 {
758 
759  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
760 }
762 //*************************************************************************************************
763 
764 
765 //*************************************************************************************************
771 template< typename MT // Type of the adapted sparse matrix
772  , bool SO > // Storage order of the adapted sparse matrix
773 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const SymmetricMatrix& m )
774  : matrix_() // The adapted sparse matrix
775 {
776  using blaze::resize;
777 
778  resize( matrix_, m.rows(), m.columns() );
779  assign( m );
780 
781  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
782  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
783 }
785 //*************************************************************************************************
786 
787 
788 //*************************************************************************************************
794 template< typename MT // Type of the adapted sparse matrix
795  , bool SO > // Storage order of the adapted sparse matrix
796 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
797  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
798 {
799  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
800  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
801 }
803 //*************************************************************************************************
804 
805 
806 //*************************************************************************************************
816 template< typename MT // Type of the adapted sparse matrix
817  , bool SO > // Storage order of the adapted sparse matrix
818 template< typename MT2 > // Type of the foreign matrix
819 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const Matrix<MT2,SO>& m )
820  : matrix_() // The adapted sparse matrix
821 {
822  using blaze::resize;
823 
824  using RT = RemoveAdaptor_< ResultType_<MT2> >;
825  using Tmp = If_< IsComputation<MT2>, RT, const MT2& >;
826 
827  Tmp tmp( ~m );
828 
829  if( !IsSymmetric<MT2>::value && !isSymmetric( tmp ) ) {
830  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
831  }
832 
833  resize( matrix_, tmp.rows(), tmp.columns() );
834  assign( tmp );
835 
836  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
837  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
838 }
840 //*************************************************************************************************
841 
842 
843 //*************************************************************************************************
853 template< typename MT // Type of the adapted sparse matrix
854  , bool SO > // Storage order of the adapted sparse matrix
855 template< typename MT2 > // Type of the foreign matrix
856 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
857  : matrix_() // The adapted sparse matrix
858 {
859  using blaze::resize;
860 
861  using RT = RemoveAdaptor_< ResultType_<MT2> >;
862  using Tmp = If_< IsComputation<MT2>, RT, const MT2& >;
863 
864  Tmp tmp( ~m );
865 
866  if( !IsSymmetric<MT2>::value && !isSymmetric( tmp ) ) {
867  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
868  }
869 
870  resize( matrix_, tmp.rows(), tmp.columns() );
871  assign( trans( tmp ) );
872 
873  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
874  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
875 }
877 //*************************************************************************************************
878 
879 
880 
881 
882 //=================================================================================================
883 //
884 // DATA ACCESS FUNCTIONS
885 //
886 //=================================================================================================
887 
888 //*************************************************************************************************
903 template< typename MT // Type of the adapted sparse matrix
904  , bool SO > // Storage order of the adapted sparse matrix
906  SymmetricMatrix<MT,SO,false,false>::operator()( size_t i, size_t j )
907 {
908  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
909  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
910 
911  return Reference( matrix_, i, j );
912 }
914 //*************************************************************************************************
915 
916 
917 //*************************************************************************************************
932 template< typename MT // Type of the adapted sparse matrix
933  , bool SO > // Storage order of the adapted sparse matrix
935  SymmetricMatrix<MT,SO,false,false>::operator()( size_t i, size_t j ) const
936 {
937  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
938  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
939 
940  return *matrix_(i,j);
941 }
943 //*************************************************************************************************
944 
945 
946 //*************************************************************************************************
962 template< typename MT // Type of the adapted dense matrix
963  , bool SO > // Storage order of the adapted dense matrix
965  SymmetricMatrix<MT,SO,false,false>::at( size_t i, size_t j )
966 {
967  if( i >= rows() ) {
968  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
969  }
970  if( j >= columns() ) {
971  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
972  }
973  return (*this)(i,j);
974 }
976 //*************************************************************************************************
977 
978 
979 //*************************************************************************************************
995 template< typename MT // Type of the adapted dense matrix
996  , bool SO > // Storage order of the adapted dense matrix
998  SymmetricMatrix<MT,SO,false,false>::at( size_t i, size_t j ) const
999 {
1000  if( i >= rows() ) {
1001  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1002  }
1003  if( j >= columns() ) {
1004  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1005  }
1006  return (*this)(i,j);
1007 }
1009 //*************************************************************************************************
1010 
1011 
1012 //*************************************************************************************************
1024 template< typename MT // Type of the adapted sparse matrix
1025  , bool SO > // Storage order of the adapted sparse matrix
1028 {
1029  return Iterator( matrix_.begin(i) );
1030 }
1032 //*************************************************************************************************
1033 
1034 
1035 //*************************************************************************************************
1047 template< typename MT // Type of the adapted sparse matrix
1048  , bool SO > // Storage order of the adapted sparse matrix
1051 {
1052  return ConstIterator( matrix_.begin(i) );
1053 }
1055 //*************************************************************************************************
1056 
1057 
1058 //*************************************************************************************************
1070 template< typename MT // Type of the adapted sparse matrix
1071  , bool SO > // Storage order of the adapted sparse matrix
1074 {
1075  return ConstIterator( matrix_.cbegin(i) );
1076 }
1078 //*************************************************************************************************
1079 
1080 
1081 //*************************************************************************************************
1093 template< typename MT // Type of the adapted sparse matrix
1094  , bool SO > // Storage order of the adapted sparse matrix
1097 {
1098  return Iterator( matrix_.end(i) );
1099 }
1101 //*************************************************************************************************
1102 
1103 
1104 //*************************************************************************************************
1116 template< typename MT // Type of the adapted sparse matrix
1117  , bool SO > // Storage order of the adapted sparse matrix
1119  SymmetricMatrix<MT,SO,false,false>::end( size_t i ) const
1120 {
1121  return ConstIterator( matrix_.end(i) );
1122 }
1124 //*************************************************************************************************
1125 
1126 
1127 //*************************************************************************************************
1139 template< typename MT // Type of the adapted sparse matrix
1140  , bool SO > // Storage order of the adapted sparse matrix
1143 {
1144  return ConstIterator( matrix_.cend(i) );
1145 }
1147 //*************************************************************************************************
1148 
1149 
1150 
1151 
1152 //=================================================================================================
1153 //
1154 // ASSIGNMENT OPERATORS
1155 //
1156 //=================================================================================================
1157 
1158 //*************************************************************************************************
1168 template< typename MT // Type of the adapted sparse matrix
1169  , bool SO > // Storage order of the adapted sparse matrix
1170 inline SymmetricMatrix<MT,SO,false,false>&
1171  SymmetricMatrix<MT,SO,false,false>::operator=( const SymmetricMatrix& rhs )
1172 {
1173  using blaze::resize;
1174 
1175  if( &rhs == this ) return *this;
1176 
1177  resize( matrix_, rhs.rows(), rhs.columns() );
1178  reset();
1179  assign( rhs );
1180 
1181  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1182  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1183 
1184  return *this;
1185 }
1187 //*************************************************************************************************
1188 
1189 
1190 //*************************************************************************************************
1197 template< typename MT // Type of the adapted sparse matrix
1198  , bool SO > // Storage order of the adapted sparse matrix
1199 inline SymmetricMatrix<MT,SO,false,false>&
1200  SymmetricMatrix<MT,SO,false,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1201 {
1202  matrix_ = std::move( rhs.matrix_ );
1203 
1204  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1205  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1206 
1207  return *this;
1208 }
1210 //*************************************************************************************************
1211 
1212 
1213 //*************************************************************************************************
1227 template< typename MT // Type of the adapted sparse matrix
1228  , bool SO > // Storage order of the adapted sparse matrix
1229 template< typename MT2 > // Type of the right-hand side matrix
1230 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,false>& >
1231  SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,SO>& rhs )
1232 {
1233  using blaze::resize;
1234 
1235  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1236  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1237  }
1238 
1239  if( (~rhs).canAlias( this ) ) {
1240  SymmetricMatrix tmp( ~rhs );
1241  swap( tmp );
1242  }
1243  else {
1244  resize( matrix_, (~rhs).rows(), (~rhs).columns() );
1245  reset();
1246  assign( ~rhs );
1247  }
1248 
1249  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1250  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1251 
1252  return *this;
1253 }
1255 //*************************************************************************************************
1256 
1257 
1258 //*************************************************************************************************
1272 template< typename MT // Type of the adapted sparse matrix
1273  , bool SO > // Storage order of the adapted sparse matrix
1274 template< typename MT2 > // Type of the right-hand side matrix
1275 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,false>& >
1276  SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,SO>& rhs )
1277 {
1278  using blaze::resize;
1279 
1280  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1281  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1282  }
1283 
1284  const ResultType_<MT2> tmp( ~rhs );
1285 
1286  if( !IsSymmetric<MT2>::value && !isSymmetric( tmp ) ) {
1287  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1288  }
1289 
1290  resize( matrix_, tmp.rows(), tmp.columns() );
1291  reset();
1292  assign( tmp );
1293 
1294  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1295  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1296 
1297  return *this;
1298 }
1300 //*************************************************************************************************
1301 
1302 
1303 //*************************************************************************************************
1317 template< typename MT // Type of the adapted sparse matrix
1318  , bool SO > // Storage order of the adapted sparse matrix
1319 template< typename MT2 > // Type of the right-hand side matrix
1320 inline SymmetricMatrix<MT,SO,false,false>&
1321  SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,!SO>& rhs )
1322 {
1323  return this->operator=( trans( ~rhs ) );
1324 }
1326 //*************************************************************************************************
1327 
1328 
1329 //*************************************************************************************************
1342 template< typename MT // Type of the adapted sparse matrix
1343  , bool SO > // Storage order of the adapted sparse matrix
1344 template< typename MT2 > // Type of the right-hand side matrix
1345 inline SymmetricMatrix<MT,SO,false,false>&
1346  SymmetricMatrix<MT,SO,false,false>::operator+=( const Matrix<MT2,SO>& rhs )
1347 {
1348  using blaze::resize;
1349 
1350  using Tmp = AddTrait_< MT, ResultType_<MT2> >;
1351 
1352  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1353  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1354  }
1355 
1356  Tmp tmp( (*this) + ~rhs );
1357 
1358  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1359  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1360  }
1361 
1362  resize( matrix_, tmp.rows(), tmp.columns() );
1363  reset();
1364  assign( tmp );
1365 
1366  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1367  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1368 
1369  return *this;
1370 }
1372 //*************************************************************************************************
1373 
1374 
1375 //*************************************************************************************************
1389 template< typename MT // Type of the adapted sparse matrix
1390  , bool SO > // Storage order of the adapted sparse matrix
1391 template< typename MT2 > // Type of the right-hand side matrix
1392 inline SymmetricMatrix<MT,SO,false,false>&
1393  SymmetricMatrix<MT,SO,false,false>::operator+=( const Matrix<MT2,!SO>& rhs )
1394 {
1395  return this->operator+=( trans( ~rhs ) );
1396 }
1398 //*************************************************************************************************
1399 
1400 
1401 //*************************************************************************************************
1414 template< typename MT // Type of the adapted sparse matrix
1415  , bool SO > // Storage order of the adapted sparse matrix
1416 template< typename MT2 > // Type of the right-hand side matrix
1417 inline SymmetricMatrix<MT,SO,false,false>&
1418  SymmetricMatrix<MT,SO,false,false>::operator-=( const Matrix<MT2,SO>& rhs )
1419 {
1420  using blaze::resize;
1421 
1422  using Tmp = SubTrait_< MT, ResultType_<MT2> >;
1423 
1424  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1425  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1426  }
1427 
1428  Tmp tmp( (*this) - ~rhs );
1429 
1430  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1431  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1432  }
1433 
1434  resize( matrix_, tmp.rows(), tmp.columns() );
1435  reset();
1436  assign( tmp );
1437 
1438  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1439  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1440 
1441  return *this;
1442 }
1444 //*************************************************************************************************
1445 
1446 
1447 //*************************************************************************************************
1461 template< typename MT // Type of the adapted sparse matrix
1462  , bool SO > // Storage order of the adapted sparse matrix
1463 template< typename MT2 > // Type of the right-hand side matrix
1464 inline SymmetricMatrix<MT,SO,false,false>&
1465  SymmetricMatrix<MT,SO,false,false>::operator-=( const Matrix<MT2,!SO>& rhs )
1466 {
1467  return this->operator-=( trans( ~rhs ) );
1468 }
1470 //*************************************************************************************************
1471 
1472 
1473 //*************************************************************************************************
1486 template< typename MT // Type of the adapted sparse matrix
1487  , bool SO > // Storage order of the adapted sparse matrix
1488 template< typename MT2 > // Type of the right-hand side matrix
1489 inline SymmetricMatrix<MT,SO,false,false>&
1490  SymmetricMatrix<MT,SO,false,false>::operator%=( const Matrix<MT2,SO>& rhs )
1491 {
1492  using blaze::resize;
1493 
1494  using Tmp = SchurTrait_< MT, ResultType_<MT2> >;
1495 
1496  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1497  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1498  }
1499 
1500  Tmp tmp( (*this) % ~rhs );
1501 
1502  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1503  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1504  }
1505 
1506  resize( matrix_, tmp.rows(), tmp.columns() );
1507  reset();
1508  assign( tmp );
1509 
1510  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1511  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1512 
1513  return *this;
1514 }
1516 //*************************************************************************************************
1517 
1518 
1519 //*************************************************************************************************
1533 template< typename MT // Type of the adapted sparse matrix
1534  , bool SO > // Storage order of the adapted sparse matrix
1535 template< typename MT2 > // Type of the right-hand side matrix
1536 inline SymmetricMatrix<MT,SO,false,false>&
1537  SymmetricMatrix<MT,SO,false,false>::operator%=( const Matrix<MT2,!SO>& rhs )
1538 {
1539  return this->operator%=( trans( ~rhs ) );
1540 }
1542 //*************************************************************************************************
1543 
1544 
1545 //*************************************************************************************************
1557 template< typename MT // Type of the adapted sparse matrix
1558  , bool SO > // Storage order of the adapted sparse matrix
1559 template< typename MT2 // Type of the right-hand side matrix
1560  , bool SO2 > // Storage order of the right-hand side matrix
1561 inline SymmetricMatrix<MT,SO,false,false>&
1562  SymmetricMatrix<MT,SO,false,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1563 {
1564  using blaze::resize;
1565 
1566  using Tmp = MultTrait_< MT, ResultType_<MT2> >;
1567 
1568  if( matrix_.rows() != (~rhs).columns() ) {
1569  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1570  }
1571 
1572  Tmp tmp( (*this) * ~rhs );
1573 
1574  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1575  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1576  }
1577 
1578  resize( matrix_, tmp.rows(), tmp.columns() );
1579  reset();
1580  assign( tmp );
1581 
1582  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1583  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1584 
1585  return *this;
1586 }
1588 //*************************************************************************************************
1589 
1590 
1591 //*************************************************************************************************
1599 template< typename MT // Type of the adapted sparse matrix
1600  , bool SO > // Storage order of the adapted sparse matrix
1601 template< typename Other > // Data type of the right-hand side scalar
1602 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,false,false> >&
1604 {
1605  for( size_t i=0UL; i<rows(); ++i ) {
1606  const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
1607  for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
1608  *element->value() *= rhs;
1609  }
1610 
1611  return *this;
1612 }
1614 //*************************************************************************************************
1615 
1616 
1617 //*************************************************************************************************
1625 template< typename MT // Type of the adapted sparse matrix
1626  , bool SO > // Storage order of the adapted sparse matrix
1627 template< typename Other > // Data type of the right-hand side scalar
1628 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,false,false> >&
1630 {
1631  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1632 
1633  for( size_t i=0UL; i<rows(); ++i ) {
1634  const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
1635  for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
1636  *element->value() /= rhs;
1637  }
1638 
1639  return *this;
1640 }
1642 //*************************************************************************************************
1643 
1644 
1645 
1646 
1647 //=================================================================================================
1648 //
1649 // UTILITY FUNCTIONS
1650 //
1651 //=================================================================================================
1652 
1653 //*************************************************************************************************
1659 template< typename MT // Type of the adapted sparse matrix
1660  , bool SO > // Storage order of the adapted sparse matrix
1661 inline size_t SymmetricMatrix<MT,SO,false,false>::rows() const noexcept
1662 {
1663  return matrix_.rows();
1664 }
1666 //*************************************************************************************************
1667 
1668 
1669 //*************************************************************************************************
1675 template< typename MT // Type of the adapted sparse matrix
1676  , bool SO > // Storage order of the adapted sparse matrix
1677 inline size_t SymmetricMatrix<MT,SO,false,false>::columns() const noexcept
1678 {
1679  return matrix_.columns();
1680 }
1682 //*************************************************************************************************
1683 
1684 
1685 //*************************************************************************************************
1691 template< typename MT // Type of the adapted sparse matrix
1692  , bool SO > // Storage order of the adapted sparse matrix
1693 inline size_t SymmetricMatrix<MT,SO,false,false>::capacity() const noexcept
1694 {
1695  return matrix_.capacity();
1696 }
1698 //*************************************************************************************************
1699 
1700 
1701 //*************************************************************************************************
1712 template< typename MT // Type of the adapted sparse matrix
1713  , bool SO > // Storage order of the adapted sparse matrix
1714 inline size_t SymmetricMatrix<MT,SO,false,false>::capacity( size_t i ) const noexcept
1715 {
1716  return matrix_.capacity(i);
1717 }
1719 //*************************************************************************************************
1720 
1721 
1722 //*************************************************************************************************
1728 template< typename MT // Type of the adapted sparse matrix
1729  , bool SO > // Storage order of the adapted sparse matrix
1731 {
1732  return matrix_.nonZeros();
1733 }
1735 //*************************************************************************************************
1736 
1737 
1738 //*************************************************************************************************
1750 template< typename MT // Type of the adapted sparse matrix
1751  , bool SO > // Storage order of the adapted sparse matrix
1752 inline size_t SymmetricMatrix<MT,SO,false,false>::nonZeros( size_t i ) const
1753 {
1754  return matrix_.nonZeros(i);
1755 }
1757 //*************************************************************************************************
1758 
1759 
1760 //*************************************************************************************************
1766 template< typename MT // Type of the adapted sparse matrix
1767  , bool SO > // Storage order of the adapted sparse matrix
1769 {
1770  matrix_.reset();
1771 }
1773 //*************************************************************************************************
1774 
1775 
1776 //*************************************************************************************************
1816 template< typename MT // Type of the adapted sparse matrix
1817  , bool SO > // Storage order of the adapted sparse matrix
1818 inline void SymmetricMatrix<MT,SO,false,false>::reset( size_t i )
1819 {
1820  for( Iterator_<MatrixType> it=matrix_.begin(i); it!=matrix_.end(i); ++it )
1821  {
1822  const size_t j( it->index() );
1823 
1824  if( i == j )
1825  continue;
1826 
1827  if( SO ) {
1828  const Iterator_<MatrixType> pos( matrix_.find( i, j ) );
1829  BLAZE_INTERNAL_ASSERT( pos != matrix_.end( j ), "Missing element detected" );
1830  matrix_.erase( j, pos );
1831  }
1832  else {
1833  const Iterator_<MatrixType> pos( matrix_.find( j, i ) );
1834  BLAZE_INTERNAL_ASSERT( pos != matrix_.end( j ), "Missing element detected" );
1835  matrix_.erase( j, pos );
1836  }
1837  }
1838 
1839  matrix_.reset( i );
1840 }
1842 //*************************************************************************************************
1843 
1844 
1845 //*************************************************************************************************
1853 template< typename MT // Type of the adapted sparse matrix
1854  , bool SO > // Storage order of the adapted sparse matrix
1856 {
1857  using blaze::clear;
1858 
1859  clear( matrix_ );
1860 }
1862 //*************************************************************************************************
1863 
1864 
1865 //*************************************************************************************************
1880 template< typename MT // Type of the adapted sparse matrix
1881  , bool SO > // Storage order of the adapted sparse matrix
1882 void SymmetricMatrix<MT,SO,false,false>::resize( size_t n, bool preserve )
1883 {
1885 
1886  UNUSED_PARAMETER( preserve );
1887 
1888  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1889 
1890  matrix_.resize( n, n, true );
1891 }
1893 //*************************************************************************************************
1894 
1895 
1896 //*************************************************************************************************
1907 template< typename MT // Type of the adapted sparse matrix
1908  , bool SO > // Storage order of the adapted sparse matrix
1909 inline void SymmetricMatrix<MT,SO,false,false>::reserve( size_t nonzeros )
1910 {
1911  matrix_.reserve( nonzeros );
1912 }
1914 //*************************************************************************************************
1915 
1916 
1917 //*************************************************************************************************
1931 template< typename MT // Type of the adapted sparse matrix
1932  , bool SO > // Storage order of the adapted sparse matrix
1933 inline void SymmetricMatrix<MT,SO,false,false>::reserve( size_t i, size_t nonzeros )
1934 {
1935  matrix_.reserve( i, nonzeros );
1936 }
1938 //*************************************************************************************************
1939 
1940 
1941 //*************************************************************************************************
1952 template< typename MT // Type of the adapted sparse matrix
1953  , bool SO > // Storage order of the adapted sparse matrix
1954 inline void SymmetricMatrix<MT,SO,false,false>::trim()
1955 {
1956  matrix_.trim();
1957 }
1959 //*************************************************************************************************
1960 
1961 
1962 //*************************************************************************************************
1974 template< typename MT // Type of the adapted sparse matrix
1975  , bool SO > // Storage order of the adapted sparse matrix
1976 inline void SymmetricMatrix<MT,SO,false,false>::trim( size_t i )
1977 {
1978  matrix_.trim( i );
1979 }
1981 //*************************************************************************************************
1982 
1983 
1984 //*************************************************************************************************
1994 template< typename MT // Type of the adapted sparse matrix
1995  , bool SO > // Storage order of the adapted sparse matrix
1997 {
1998  matrix_.shrinkToFit();
1999 }
2001 //*************************************************************************************************
2002 
2003 
2004 //*************************************************************************************************
2011 template< typename MT // Type of the adapted sparse matrix
2012  , bool SO > // Storage order of the adapted sparse matrix
2013 inline void SymmetricMatrix<MT,SO,false,false>::swap( SymmetricMatrix& m ) noexcept
2014 {
2015  using std::swap;
2016 
2017  swap( matrix_, m.matrix_ );
2018 }
2020 //*************************************************************************************************
2021 
2022 
2023 
2024 
2025 //=================================================================================================
2026 //
2027 // INSERTION FUNCTIONS
2028 //
2029 //=================================================================================================
2030 
2031 //*************************************************************************************************
2045 template< typename MT // Type of the adapted sparse matrix
2046  , bool SO > // Storage order of the adapted sparse matrix
2048  SymmetricMatrix<MT,SO,false,false>::set( size_t i, size_t j, const ElementType& value )
2049 {
2050  SharedValue<ET> shared( value );
2051 
2052  if( i != j )
2053  matrix_.set( j, i, shared );
2054 
2055  return Iterator( matrix_.set( i, j, shared ) );
2056 }
2058 //*************************************************************************************************
2059 
2060 
2061 //*************************************************************************************************
2076 template< typename MT // Type of the adapted sparse matrix
2077  , bool SO > // Storage order of the adapted sparse matrix
2079  SymmetricMatrix<MT,SO,false,false>::insert( size_t i, size_t j, const ElementType& value )
2080 {
2081  SharedValue<ET> shared( value );
2082 
2083  if( i != j )
2084  matrix_.insert( j, i, shared );
2085 
2086  return Iterator( matrix_.insert( i, j, shared ) );
2087 }
2089 //*************************************************************************************************
2090 
2091 
2092 //*************************************************************************************************
2147 template< typename MT // Type of the adapted sparse matrix
2148  , bool SO > // Storage order of the adapted sparse matrix
2149 inline void SymmetricMatrix<MT,SO,false,false>::append( size_t i, size_t j, const ElementType& value, bool check )
2150 {
2151  SharedValue<ET> shared( value );
2152 
2153  matrix_.append( i, j, shared, check );
2154  if( i != j && ( !check || !isDefault<strict>( value ) ) )
2155  matrix_.insert( j, i, shared );
2156 }
2158 //*************************************************************************************************
2159 
2160 
2161 //*************************************************************************************************
2175 template< typename MT // Type of the adapted sparse matrix
2176  , bool SO > // Storage order of the adapted sparse matrix
2177 inline void SymmetricMatrix<MT,SO,false,false>::finalize( size_t i )
2178 {
2179  matrix_.trim( i );
2180 }
2182 //*************************************************************************************************
2183 
2184 
2185 
2186 
2187 //=================================================================================================
2188 //
2189 // ERASE FUNCTIONS
2190 //
2191 //=================================================================================================
2192 
2193 //*************************************************************************************************
2203 template< typename MT // Type of the adapted sparse matrix
2204  , bool SO > // Storage order of the adapted sparse matrix
2205 inline void SymmetricMatrix<MT,SO,false,false>::erase( size_t i, size_t j )
2206 {
2207  matrix_.erase( i, j );
2208  if( i != j )
2209  matrix_.erase( j, i );
2210 }
2212 //*************************************************************************************************
2213 
2214 
2215 //*************************************************************************************************
2227 template< typename MT // Type of the adapted sparse matrix
2228  , bool SO > // Storage order of the adapted sparse matrix
2230  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator pos )
2231 {
2232  if( pos == end( i ) )
2233  return pos;
2234 
2235  const size_t j( pos->index() );
2236 
2237  if( i == j )
2238  return Iterator( matrix_.erase( i, pos.base() ) );
2239 
2240  if( SO ) {
2241  BLAZE_INTERNAL_ASSERT( matrix_.find( i, j ) != matrix_.end( j ), "Missing element detected" );
2242  matrix_.erase( j, matrix_.find( i, j ) );
2243  return Iterator( matrix_.erase( i, pos.base() ) );
2244  }
2245  else {
2246  BLAZE_INTERNAL_ASSERT( matrix_.find( j, i ) != matrix_.end( j ), "Missing element detected" );
2247  matrix_.erase( j, matrix_.find( j, i ) );
2248  return Iterator( matrix_.erase( i, pos.base() ) );
2249  }
2250 }
2252 //*************************************************************************************************
2253 
2254 
2255 //*************************************************************************************************
2269 template< typename MT // Type of the adapted sparse matrix
2270  , bool SO > // Storage order of the adapted sparse matrix
2272  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator first, Iterator last )
2273 {
2274  for( Iterator it=first; it!=last; ++it )
2275  {
2276  const size_t j( it->index() );
2277 
2278  if( i == j )
2279  continue;
2280 
2281  if( SO ) {
2282  BLAZE_INTERNAL_ASSERT( matrix_.find( i, j ) != matrix_.end( j ), "Missing element detected" );
2283  matrix_.erase( i, j );
2284  }
2285  else {
2286  BLAZE_INTERNAL_ASSERT( matrix_.find( j, i ) != matrix_.end( j ), "Missing element detected" );
2287  matrix_.erase( j, i );
2288  }
2289  }
2290 
2291  return Iterator( matrix_.erase( i, first.base(), last.base() ) );
2292 }
2294 //*************************************************************************************************
2295 
2296 
2297 //*************************************************************************************************
2311 template< typename MT // Type of the adapted sparse matrix
2312  , bool SO > // Storage order of the adapted sparse matrix
2313 template< typename Pred > // Type of the unary predicate
2314 inline void SymmetricMatrix<MT,SO,false,false>::erase( Pred predicate )
2315 {
2316  matrix_.erase( [predicate=predicate]( const SharedValue<ET>& value ) {
2317  return predicate( *value );
2318  } );
2319 
2320  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2321 }
2323 //*************************************************************************************************
2324 
2325 
2326 //*************************************************************************************************
2345 template< typename MT // Type of the adapted sparse matrix
2346  , bool SO > // Storage order of the adapted sparse matrix
2347 template< typename Pred > // Type of the unary predicate
2348 inline void
2349  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
2350 {
2351  for( Iterator it=first; it!=last; ++it ) {
2352  const size_t j( it->index() );
2353  if( i != j && predicate( it->value() ) ) {
2354  if( SO )
2355  matrix_.erase( i, j );
2356  else
2357  matrix_.erase( j, i );
2358  }
2359  }
2360 
2361  matrix_.erase( i, first.base(), last.base(),
2362  [predicate=predicate]( const SharedValue<ET>& value ) {
2363  return predicate( *value );
2364  } );
2365 
2366  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2367 }
2369 //*************************************************************************************************
2370 
2371 
2372 
2373 
2374 //=================================================================================================
2375 //
2376 // LOOKUP FUNCTIONS
2377 //
2378 //=================================================================================================
2379 
2380 //*************************************************************************************************
2396 template< typename MT // Type of the adapted sparse matrix
2397  , bool SO > // Storage order of the adapted sparse matrix
2399  SymmetricMatrix<MT,SO,false,false>::find( size_t i, size_t j )
2400 {
2401  return Iterator( matrix_.find( i, j ) );
2402 }
2404 //*************************************************************************************************
2405 
2406 
2407 //*************************************************************************************************
2423 template< typename MT // Type of the adapted sparse matrix
2424  , bool SO > // Storage order of the adapted sparse matrix
2426  SymmetricMatrix<MT,SO,false,false>::find( size_t i, size_t j ) const
2427 {
2428  return ConstIterator( matrix_.find( i, j ) );
2429 }
2431 //*************************************************************************************************
2432 
2433 
2434 //*************************************************************************************************
2450 template< typename MT // Type of the adapted sparse matrix
2451  , bool SO > // Storage order of the adapted sparse matrix
2453  SymmetricMatrix<MT,SO,false,false>::lowerBound( size_t i, size_t j )
2454 {
2455  return Iterator( matrix_.lowerBound( i, j ) );
2456 }
2458 //*************************************************************************************************
2459 
2460 
2461 //*************************************************************************************************
2477 template< typename MT // Type of the adapted sparse matrix
2478  , bool SO > // Storage order of the adapted sparse matrix
2480  SymmetricMatrix<MT,SO,false,false>::lowerBound( size_t i, size_t j ) const
2481 {
2482  return ConstIterator( matrix_.lowerBound( i, j ) );
2483 }
2485 //*************************************************************************************************
2486 
2487 
2488 //*************************************************************************************************
2504 template< typename MT // Type of the adapted sparse matrix
2505  , bool SO > // Storage order of the adapted sparse matrix
2507  SymmetricMatrix<MT,SO,false,false>::upperBound( size_t i, size_t j )
2508 {
2509  return Iterator( matrix_.upperBound( i, j ) );
2510 }
2512 //*************************************************************************************************
2513 
2514 
2515 //*************************************************************************************************
2531 template< typename MT // Type of the adapted sparse matrix
2532  , bool SO > // Storage order of the adapted sparse matrix
2534  SymmetricMatrix<MT,SO,false,false>::upperBound( size_t i, size_t j ) const
2535 {
2536  return ConstIterator( matrix_.upperBound( i, j ) );
2537 }
2539 //*************************************************************************************************
2540 
2541 
2542 
2543 
2544 //=================================================================================================
2545 //
2546 // NUMERIC FUNCTIONS
2547 //
2548 //=================================================================================================
2549 
2550 //*************************************************************************************************
2556 template< typename MT // Type of the adapted sparse matrix
2557  , bool SO > // Storage order of the adapted sparse matrix
2558 inline SymmetricMatrix<MT,SO,false,false>& SymmetricMatrix<MT,SO,false,false>::transpose()
2559 {
2560  return *this;
2561 }
2563 //*************************************************************************************************
2564 
2565 
2566 //*************************************************************************************************
2572 template< typename MT // Type of the adapted sparse matrix
2573  , bool SO > // Storage order of the adapted sparse matrix
2574 inline SymmetricMatrix<MT,SO,false,false>& SymmetricMatrix<MT,SO,false,false>::ctranspose()
2575 {
2576  for( size_t i=0UL; i<rows(); ++i ) {
2577  const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
2578  for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
2579  conjugate( *element->value() );
2580  }
2581 
2582  return *this;
2583 }
2585 //*************************************************************************************************
2586 
2587 
2588 //*************************************************************************************************
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 scalar value
2609 inline SymmetricMatrix<MT,SO,false,false>&
2610  SymmetricMatrix<MT,SO,false,false>::scale( const Other& scalar )
2611 {
2612  for( size_t i=0UL; i<rows(); ++i ) {
2613  const Iterator_<MatrixType> last( matrix_.upperBound(i,i) );
2614  for( Iterator_<MatrixType> element=matrix_.begin(i); element!=last; ++element )
2615  ( *element->value() ).scale( scalar );
2616  }
2617 
2618  return *this;
2619 }
2621 //*************************************************************************************************
2622 
2623 
2624 //*************************************************************************************************
2634 template< typename MT // Type of the adapted sparse matrix
2635  , bool SO > // Storage order of the adapted sparse matrix
2636 template< typename Other > // Data type of the scalar value
2637 inline SymmetricMatrix<MT,SO,false,false>&
2638  SymmetricMatrix<MT,SO,false,false>::scaleDiagonal( const Other& scalar )
2639 {
2640  matrix_.scaleDiagonal( scalar );
2641  return *this;
2642 }
2644 //*************************************************************************************************
2645 
2646 
2647 
2648 
2649 //=================================================================================================
2650 //
2651 // DEBUGGING FUNCTIONS
2652 //
2653 //=================================================================================================
2654 
2655 //*************************************************************************************************
2665 template< typename MT // Type of the adapted dense matrix
2666  , bool SO > // Storage order of the adapted dense matrix
2667 inline bool SymmetricMatrix<MT,SO,false,false>::isIntact() const noexcept
2668 {
2669  using blaze::isIntact;
2670 
2671  return ( isIntact( matrix_ ) && isSymmetric( matrix_ ) );
2672 }
2674 //*************************************************************************************************
2675 
2676 
2677 
2678 
2679 //=================================================================================================
2680 //
2681 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2682 //
2683 //=================================================================================================
2684 
2685 //*************************************************************************************************
2696 template< typename MT // Type of the adapted sparse matrix
2697  , bool SO > // Storage order of the adapted sparse matrix
2698 template< typename Other > // Data type of the foreign expression
2699 inline bool SymmetricMatrix<MT,SO,false,false>::canAlias( const Other* alias ) const noexcept
2700 {
2701  return matrix_.canAlias( alias );
2702 }
2704 //*************************************************************************************************
2705 
2706 
2707 //*************************************************************************************************
2718 template< typename MT // Type of the adapted sparse matrix
2719  , bool SO > // Storage order of the adapted sparse matrix
2720 template< typename Other > // Data type of the foreign expression
2721 inline bool SymmetricMatrix<MT,SO,false,false>::isAliased( const Other* alias ) const noexcept
2722 {
2723  return matrix_.isAliased( alias );
2724 }
2726 //*************************************************************************************************
2727 
2728 
2729 //*************************************************************************************************
2740 template< typename MT // Type of the adapted sparse matrix
2741  , bool SO > // Storage order of the adapted sparse matrix
2742 inline bool SymmetricMatrix<MT,SO,false,false>::canSMPAssign() const noexcept
2743 {
2744  return matrix_.canSMPAssign();
2745 }
2747 //*************************************************************************************************
2748 
2749 
2750 //*************************************************************************************************
2762 template< typename MT // Type of the adapted sparse matrix
2763  , bool SO > // Storage order of the adapted sparse matrix
2764 template< typename MT2 > // Type of the right-hand side dense matrix
2765 void SymmetricMatrix<MT,SO,false,false>::assign( DenseMatrix<MT2,SO>& rhs )
2766 {
2768 
2769  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2770  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2771 
2772  std::vector<size_t> nonzeros( rows(), 0UL );
2773  size_t sum( 0UL );
2774 
2775  for( size_t i=0UL; i<rows(); ++i ) {
2776  nonzeros[i] = (~rhs).nonZeros(i);
2777  sum += nonzeros[i];
2778  }
2779 
2780  matrix_.reserve( sum );
2781  for( size_t i=0UL; i<rows(); ++i ) {
2782  matrix_.reserve( i, nonzeros[i] );
2783  }
2784 
2785  for( size_t i=0UL; i<rows(); ++i ) {
2786  for( size_t j=i; j<columns(); ++j ) {
2787  if( !isDefault( (~rhs)(i,j) ) ) {
2788  SharedValue<ET> shared;
2789  *shared = std::move( (~rhs)(i,j) );
2790  matrix_.append( i, j, shared, false );
2791  if( i != j )
2792  matrix_.append( j, i, shared, false );
2793  }
2794  }
2795  }
2796 }
2798 //*************************************************************************************************
2799 
2800 
2801 //*************************************************************************************************
2813 template< typename MT // Type of the adapted sparse matrix
2814  , bool SO > // Storage order of the adapted sparse matrix
2815 template< typename MT2 > // Type of the right-hand side dense matrix
2816 void SymmetricMatrix<MT,SO,false,false>::assign( const DenseMatrix<MT2,SO>& rhs )
2817 {
2819 
2820  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2821  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2822 
2823  std::vector<size_t> nonzeros( rows(), 0UL );
2824  size_t sum( 0UL );
2825 
2826  for( size_t i=0UL; i<rows(); ++i ) {
2827  nonzeros[i] = (~rhs).nonZeros(i);
2828  sum += nonzeros[i];
2829  }
2830 
2831  matrix_.reserve( sum );
2832  for( size_t i=0UL; i<rows(); ++i ) {
2833  matrix_.reserve( i, nonzeros[i] );
2834  }
2835 
2836  for( size_t i=0UL; i<rows(); ++i ) {
2837  for( size_t j=i; j<columns(); ++j ) {
2838  if( !isDefault( (~rhs)(i,j) ) ) {
2839  const SharedValue<ET> shared( (~rhs)(i,j) );
2840  matrix_.append( i, j, shared, false );
2841  if( i != j )
2842  matrix_.append( j, i, shared, false );
2843  }
2844  }
2845  }
2846 }
2848 //*************************************************************************************************
2849 
2850 
2851 //*************************************************************************************************
2863 template< typename MT // Type of the adapted sparse matrix
2864  , bool SO > // Storage order of the adapted sparse matrix
2865 template< typename MT2 > // Type of the right-hand side sparse matrix
2866 void SymmetricMatrix<MT,SO,false,false>::assign( SparseMatrix<MT2,SO>& rhs )
2867 {
2869 
2870  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2871  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2872 
2873  std::vector<size_t> nonzeros( rows(), 0UL );
2874  size_t sum( 0UL );
2875 
2876  for( size_t i=0UL; i<rows(); ++i ) {
2877  nonzeros[i] = (~rhs).nonZeros(i);
2878  sum += nonzeros[i];
2879  }
2880 
2881  matrix_.reserve( sum );
2882  for( size_t i=0UL; i<rows(); ++i ) {
2883  matrix_.reserve( i, nonzeros[i] );
2884  }
2885 
2886  for( size_t i=0UL; i<rows(); ++i ) {
2887  for( Iterator_<MT2> it=(~rhs).lowerBound(i,i); it!=(~rhs).end(i); ++it ) {
2888  if( !isDefault( it->value() ) ) {
2889  SharedValue<ET> shared;
2890  *shared = std::move( it->value() );
2891  matrix_.append( i, it->index(), shared, false );
2892  if( i != it->index() )
2893  matrix_.append( it->index(), i, shared, false );
2894  }
2895  }
2896  }
2897 }
2899 //*************************************************************************************************
2900 
2901 
2902 //*************************************************************************************************
2914 template< typename MT // Type of the adapted sparse matrix
2915  , bool SO > // Storage order of the adapted sparse matrix
2916 template< typename MT2 > // Type of the right-hand side sparse matrix
2917 void SymmetricMatrix<MT,SO,false,false>::assign( const SparseMatrix<MT2,SO>& rhs )
2918 {
2920 
2921  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2922  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2923 
2924  std::vector<size_t> nonzeros( rows(), 0UL );
2925  size_t sum( 0UL );
2926 
2927  for( size_t i=0UL; i<rows(); ++i ) {
2928  nonzeros[i] = (~rhs).nonZeros(i);
2929  sum += nonzeros[i];
2930  }
2931 
2932  matrix_.reserve( sum );
2933  for( size_t i=0UL; i<rows(); ++i ) {
2934  matrix_.reserve( i, nonzeros[i] );
2935  }
2936 
2937  for( size_t i=0UL; i<rows(); ++i ) {
2938  for( ConstIterator_<MT2> it=(~rhs).lowerBound(i,i); it!=(~rhs).end(i); ++it ) {
2939  if( !isDefault( it->value() ) ) {
2940  const SharedValue<ET> shared( it->value() );
2941  matrix_.append( i, it->index(), shared, false );
2942  if( i != it->index() )
2943  matrix_.append( it->index(), i, shared, false );
2944  }
2945  }
2946  }
2947 }
2949 //*************************************************************************************************
2950 
2951 } // namespace blaze
2952 
2953 #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:3079
#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:356
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
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1411
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3078
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:198
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
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:560
BLAZE_ALWAYS_INLINE void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:609
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5845
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3080
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:661
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3085
#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:394
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:731
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3086
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1393
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:308
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:242
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.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3084
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:5924
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:5907
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3077
#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:3081
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the Columns type trait.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3087
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
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:340
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:548
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:264
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8893
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:580
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:270
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:700
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:324
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3082
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:790
#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:3083
#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:252
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
#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
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:742
#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:635