Blaze  3.6
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>
60 #include <blaze/math/Exception.h>
62 #include <blaze/math/shims/Clear.h>
76 #include <blaze/util/Assert.h>
82 #include <blaze/util/DisableIf.h>
83 #include <blaze/util/EnableIf.h>
84 #include <blaze/util/MaybeUnused.h>
85 #include <blaze/util/mpl/If.h>
88 #include <blaze/util/Types.h>
89 
90 
91 namespace blaze {
92 
93 //=================================================================================================
94 //
95 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES WITH NON-NUMERIC ELEMENT TYPE
96 //
97 //=================================================================================================
98 
99 //*************************************************************************************************
107 template< typename MT // Type of the adapted sparse matrix
108  , bool SO > // Storage order of the adapted sparse matrix
109 class SymmetricMatrix<MT,SO,false,false>
110  : public SparseMatrix< SymmetricMatrix<MT,SO,false,false>, SO >
111 {
112  private:
113  //**Type definitions****************************************************************************
114  using OT = OppositeType_t<MT>;
115  using TT = TransposeType_t<MT>;
116  using ET = ElementType_t<MT>;
117 
119  using MatrixType = typename MT::template Rebind< SharedValue<ET> >::Other;
120  //**********************************************************************************************
121 
122  public:
123  //**Type definitions****************************************************************************
124  using This = SymmetricMatrix<MT,SO,false,false>;
125  using BaseType = SparseMatrix<This,SO>;
126  using ResultType = This;
127  using OppositeType = SymmetricMatrix<OT,!SO,false,false>;
128  using TransposeType = SymmetricMatrix<TT,!SO,false,false>;
129  using ElementType = ET;
130  using ReturnType = ReturnType_t<MT>;
131  using CompositeType = const This&;
132  using Reference = NonNumericProxy<MatrixType>;
133  using ConstReference = ConstReference_t<MT>;
134  //**********************************************************************************************
135 
136  //**Rebind struct definition********************************************************************
139  template< typename NewType > // Data type of the other matrix
140  struct Rebind {
142  using Other = SymmetricMatrix< typename MT::template Rebind<NewType>::Other >;
143  };
144  //**********************************************************************************************
145 
146  //**Resize struct definition********************************************************************
149  template< size_t NewM // Number of rows of the other matrix
150  , size_t NewN > // Number of columns of the other matrix
151  struct Resize {
153  using Other = SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other >;
154  };
155  //**********************************************************************************************
156 
157  //**SharedElement class definition**************************************************************
160  template< typename IteratorType > // Type of the sparse matrix iterator
161  class SharedElement
162  : private SparseElement
163  {
164  public:
165  //**Type definitions*************************************************************************
166  using ValueType = ET;
167  using IndexType = size_t;
168  using Reference = ValueType&;
169  using ConstReference = const ValueType&;
170  using Pointer = SharedElement*;
171  using ConstPointer = const SharedElement*;
172  //*******************************************************************************************
173 
174  //**Constructor******************************************************************************
179  inline SharedElement( IteratorType pos )
180  : pos_( pos ) // Iterator to the current sparse symmetric matrix element
181  {}
182  //*******************************************************************************************
183 
184  //**Assignment operator**********************************************************************
190  template< typename T > inline SharedElement& operator=( const T& v ) {
191  *pos_->value() = v;
192  return *this;
193  }
194  //*******************************************************************************************
195 
196  //**Addition assignment operator*************************************************************
202  template< typename T > inline SharedElement& operator+=( const T& v ) {
203  *pos_->value() += v;
204  return *this;
205  }
206  //*******************************************************************************************
207 
208  //**Subtraction assignment operator**********************************************************
214  template< typename T > inline SharedElement& operator-=( const T& v ) {
215  *pos_->value() -= v;
216  return *this;
217  }
218  //*******************************************************************************************
219 
220  //**Multiplication assignment operator*******************************************************
226  template< typename T > inline SharedElement& operator*=( const T& v ) {
227  *pos_->value() *= v;
228  return *this;
229  }
230  //*******************************************************************************************
231 
232  //**Division assignment operator*************************************************************
238  template< typename T > inline SharedElement& operator/=( const T& v ) {
239  *pos_->value() /= v;
240  return *this;
241  }
242  //*******************************************************************************************
243 
244  //**Element access operator******************************************************************
249  inline Pointer operator->() {
250  return this;
251  }
252  //*******************************************************************************************
253 
254  //**Element access operator******************************************************************
259  inline ConstPointer operator->() const {
260  return this;
261  }
262  //*******************************************************************************************
263 
264  //**Value function***************************************************************************
269  inline Reference value() {
270  return *pos_->value();
271  }
272  //*******************************************************************************************
273 
274  //**Value function***************************************************************************
279  inline ConstReference value() const {
280  return *pos_->value();
281  }
282  //*******************************************************************************************
283 
284  //**Index function***************************************************************************
289  inline IndexType index() const {
290  return pos_->index();
291  }
292  //*******************************************************************************************
293 
294  private:
295  //**Member variables*************************************************************************
296  IteratorType pos_;
297  //*******************************************************************************************
298  };
299  //**********************************************************************************************
300 
301  //**SharedIterator class definition*************************************************************
304  template< typename SparseElementType // Type of the underlying sparse elements.
305  , typename IteratorType > // Type of the sparse matrix iterator
306  class SharedIterator
307  {
308  public:
309  //**Type definitions*************************************************************************
310  using IteratorCategory = std::forward_iterator_tag;
311  using ValueType = SparseElementType;
312  using PointerType = SparseElementType;
313  using ReferenceType = SparseElementType;
314  using DifferenceType = ptrdiff_t;
315 
316  // STL iterator requirements
317  using iterator_category = IteratorCategory;
318  using value_type = ValueType;
319  using pointer = PointerType;
320  using reference = ReferenceType;
321  using difference_type = DifferenceType;
322  //*******************************************************************************************
323 
324  //**Default constructor**********************************************************************
327  inline SharedIterator()
328  : pos_() // Iterator to the current sparse symmetric matrix element
329  {}
330  //*******************************************************************************************
331 
332  //**Constructor******************************************************************************
337  inline SharedIterator( IteratorType pos )
338  : pos_( pos ) // Iterator to the current sparse symmetric matrix element
339  {}
340  //*******************************************************************************************
341 
342  //**Constructor******************************************************************************
347  template< typename SparseElementType2, typename IteratorType2 >
348  inline SharedIterator( const SharedIterator<SparseElementType2,IteratorType2>& it )
349  : pos_( it.pos_ ) // Iterator to the current sparse symmetric matrix element
350  {}
351  //*******************************************************************************************
352 
353  //**Prefix increment operator****************************************************************
358  inline SharedIterator& operator++() {
359  ++pos_;
360  return *this;
361  }
362  //*******************************************************************************************
363 
364  //**Postfix increment operator***************************************************************
369  inline const SharedIterator operator++( int ) {
370  const SharedIterator tmp( *this );
371  ++(*this);
372  return tmp;
373  }
374  //*******************************************************************************************
375 
376  //**Element access operator******************************************************************
381  inline ReferenceType operator*() const {
382  return ReferenceType( pos_ );
383  }
384  //*******************************************************************************************
385 
386  //**Element access operator******************************************************************
391  inline PointerType operator->() const {
392  return PointerType( pos_ );
393  }
394  //*******************************************************************************************
395 
396  //**Equality operator************************************************************************
402  inline bool operator==( const SharedIterator& rhs ) const {
403  return pos_ == rhs.pos_;
404  }
405  //*******************************************************************************************
406 
407  //**Inequality operator**********************************************************************
413  inline bool operator!=( const SharedIterator& rhs ) const {
414  return !( *this == rhs );
415  }
416  //*******************************************************************************************
417 
418  //**Subtraction operator*********************************************************************
424  inline DifferenceType operator-( const SharedIterator& rhs ) const {
425  return pos_ - rhs.pos_;
426  }
427  //*******************************************************************************************
428 
429  //**Base function****************************************************************************
434  inline IteratorType base() const {
435  return pos_;
436  }
437  //*******************************************************************************************
438 
439  private:
440  //**Member variables*************************************************************************
441  IteratorType pos_;
442  //*******************************************************************************************
443 
444  //**Friend declarations**********************************************************************
445  template< typename SparseElementType2, typename IteratorType2 > friend class SharedIterator;
446  //*******************************************************************************************
447  };
448  //**********************************************************************************************
449 
450  //**Type definitions****************************************************************************
452  using Iterator = SharedIterator< SharedElement< Iterator_t<MatrixType> >
453  , Iterator_t<MatrixType> >;
454 
456  using ConstIterator = SharedIterator< const SharedElement< ConstIterator_t<MatrixType> >
457  , ConstIterator_t<MatrixType> >;
458  //**********************************************************************************************
459 
460  //**Compilation flags***************************************************************************
462  static constexpr 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**********************************************************************************
484  ~SymmetricMatrix() = default;
486  //**********************************************************************************************
487 
488  //**Data access functions***********************************************************************
491  inline Reference operator()( size_t i, size_t j );
492  inline ConstReference operator()( size_t i, size_t j ) const;
493  inline Reference at( size_t i, size_t j );
494  inline ConstReference at( size_t i, size_t j ) const;
495  inline Iterator begin ( size_t i );
496  inline ConstIterator begin ( size_t i ) const;
497  inline ConstIterator cbegin( size_t i ) const;
498  inline Iterator end ( size_t i );
499  inline ConstIterator end ( size_t i ) const;
500  inline ConstIterator cend ( size_t i ) const;
502  //**********************************************************************************************
503 
504  //**Assignment operators************************************************************************
507  inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
508  inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
509 
510  template< typename MT2 >
511  inline auto operator=( const Matrix<MT2,SO>& rhs )
512  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
513 
514  template< typename MT2 >
515  inline auto operator=( const Matrix<MT2,SO>& rhs )
516  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
517 
518  template< typename MT2 >
519  inline auto operator=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
520 
521  template< typename MT2 >
522  inline auto operator+=( const Matrix<MT2,SO>& rhs ) -> SymmetricMatrix&;
523 
524  template< typename MT2 >
525  inline auto operator+=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
526 
527  template< typename MT2 >
528  inline auto operator-=( const Matrix<MT2,SO>& rhs ) -> SymmetricMatrix&;
529 
530  template< typename MT2 >
531  inline auto operator-=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
532 
533  template< typename MT2 >
534  inline auto operator%=( const Matrix<MT2,SO>& rhs ) -> SymmetricMatrix&;
535 
536  template< typename MT2 >
537  inline auto operator%=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
538 
539  template< typename ST >
540  inline auto operator*=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >;
541 
542  template< typename ST >
543  inline auto operator/=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >;
545  //**********************************************************************************************
546 
547  //**Utility functions***************************************************************************
550  inline size_t rows() const noexcept;
551  inline size_t columns() const noexcept;
552  inline size_t capacity() const noexcept;
553  inline size_t capacity( size_t i ) const noexcept;
554  inline size_t nonZeros() const;
555  inline size_t nonZeros( size_t i ) const;
556  inline void reset();
557  inline void reset( size_t i );
558  inline void clear();
559  inline void resize ( size_t n, bool preserve=true );
560  inline void reserve( size_t nonzeros );
561  inline void reserve( size_t i, size_t nonzeros );
562  inline void trim();
563  inline void trim( size_t i );
564  inline void shrinkToFit();
565  inline void swap( SymmetricMatrix& m ) noexcept;
567  //**********************************************************************************************
568 
569  //**Insertion functions*************************************************************************
572  inline Iterator set ( size_t i, size_t j, const ElementType& value );
573  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
574  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
575  inline void finalize( size_t i );
577  //**********************************************************************************************
578 
579  //**Erase functions*****************************************************************************
582  inline void erase( size_t i, size_t j );
583  inline Iterator erase( size_t i, Iterator pos );
584  inline Iterator erase( size_t i, Iterator first, Iterator last );
585 
586  template< typename Pred >
587  inline void erase( Pred predicate );
588 
589  template< typename Pred >
590  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
592  //**********************************************************************************************
593 
594  //**Lookup functions****************************************************************************
597  inline Iterator find ( size_t i, size_t j );
598  inline ConstIterator find ( size_t i, size_t j ) const;
599  inline Iterator lowerBound( size_t i, size_t j );
600  inline ConstIterator lowerBound( size_t i, size_t j ) const;
601  inline Iterator upperBound( size_t i, size_t j );
602  inline ConstIterator upperBound( size_t i, size_t j ) const;
604  //**********************************************************************************************
605 
606  //**Numeric functions***************************************************************************
609  inline SymmetricMatrix& transpose();
610  inline SymmetricMatrix& ctranspose();
611 
612  template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
614  //**********************************************************************************************
615 
616  //**Debugging functions*************************************************************************
619  inline bool isIntact() const noexcept;
621  //**********************************************************************************************
622 
623  //**Expression template evaluation functions****************************************************
626  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
627  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
628 
629  inline bool canSMPAssign() const noexcept;
631  //**********************************************************************************************
632 
633  private:
634  //**Expression template evaluation functions****************************************************
637  template< typename MT2 > void assign( DenseMatrix<MT2,SO>& rhs );
638  template< typename MT2 > void assign( const DenseMatrix<MT2,SO>& rhs );
639  template< typename MT2 > void assign( SparseMatrix<MT2,SO>& rhs );
640  template< typename MT2 > void assign( const SparseMatrix<MT2,SO>& rhs );
642  //**********************************************************************************************
643 
644  //**Member variables****************************************************************************
647  MatrixType matrix_;
648 
649  //**********************************************************************************************
650 
651  //**Friend declarations*************************************************************************
652  template< bool RF, typename MT2, bool SO2, bool DF2, bool NF2 >
653  friend bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
654  //**********************************************************************************************
655 
656  //**Compile time checks*************************************************************************
672  BLAZE_STATIC_ASSERT( ( Size_v<MT,0UL> == Size_v<MT,1UL> ) );
673  //**********************************************************************************************
674 };
676 //*************************************************************************************************
677 
678 
679 
680 
681 //=================================================================================================
682 //
683 // CONSTRUCTORS
684 //
685 //=================================================================================================
686 
687 //*************************************************************************************************
691 template< typename MT // Type of the adapted sparse matrix
692  , bool SO > // Storage order of the adapted sparse matrix
693 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix()
694  : matrix_() // The adapted sparse matrix
695 {
696  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
697 }
699 //*************************************************************************************************
700 
701 
702 //*************************************************************************************************
710 template< typename MT // Type of the adapted sparse matrix
711  , bool SO > // Storage order of the adapted sparse matrix
712 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n )
713  : matrix_( n, n ) // The adapted sparse matrix
714 {
716 
717  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
718 }
720 //*************************************************************************************************
721 
722 
723 //*************************************************************************************************
732 template< typename MT // Type of the adapted sparse matrix
733  , bool SO > // Storage order of the adapted sparse matrix
734 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n, size_t nonzeros )
735  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
736 {
738 
739  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
740 }
742 //*************************************************************************************************
743 
744 
745 //*************************************************************************************************
756 template< typename MT // Type of the adapted sparse matrix
757  , bool SO > // Storage order of the adapted sparse matrix
758 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n, const std::vector<size_t>& nonzeros )
759  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
760 {
762 
763  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
764 }
766 //*************************************************************************************************
767 
768 
769 //*************************************************************************************************
775 template< typename MT // Type of the adapted sparse matrix
776  , bool SO > // Storage order of the adapted sparse matrix
777 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const SymmetricMatrix& m )
778  : matrix_() // The adapted sparse matrix
779 {
780  using blaze::resize;
781 
782  resize( matrix_, m.rows(), m.columns() );
783  assign( m );
784 
785  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
786  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
787 }
789 //*************************************************************************************************
790 
791 
792 //*************************************************************************************************
798 template< typename MT // Type of the adapted sparse matrix
799  , bool SO > // Storage order of the adapted sparse matrix
800 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
801  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
802 {
803  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
804  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
805 }
807 //*************************************************************************************************
808 
809 
810 //*************************************************************************************************
820 template< typename MT // Type of the adapted sparse matrix
821  , bool SO > // Storage order of the adapted sparse matrix
822 template< typename MT2 > // Type of the foreign matrix
823 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const Matrix<MT2,SO>& m )
824  : matrix_() // The adapted sparse matrix
825 {
826  using blaze::resize;
827 
828  using RT = RemoveAdaptor_t< ResultType_t<MT2> >;
829  using Tmp = If_t< IsComputation_v<MT2>, RT, const MT2& >;
830 
831  Tmp tmp( ~m );
832 
833  if( !IsSymmetric_v<MT2> && !isSymmetric( tmp ) ) {
834  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
835  }
836 
837  resize( matrix_, tmp.rows(), tmp.columns() );
838  assign( tmp );
839 
840  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
841  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
842 }
844 //*************************************************************************************************
845 
846 
847 //*************************************************************************************************
857 template< typename MT // Type of the adapted sparse matrix
858  , bool SO > // Storage order of the adapted sparse matrix
859 template< typename MT2 > // Type of the foreign matrix
860 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
861  : matrix_() // The adapted sparse matrix
862 {
863  using blaze::resize;
864 
865  using RT = RemoveAdaptor_t< ResultType_t<MT2> >;
866  using Tmp = If_t< IsComputation_v<MT2>, RT, const MT2& >;
867 
868  Tmp tmp( ~m );
869 
870  if( !IsSymmetric_v<MT2> && !isSymmetric( tmp ) ) {
871  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
872  }
873 
874  resize( matrix_, tmp.rows(), tmp.columns() );
875  assign( trans( tmp ) );
876 
877  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
878  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
879 }
881 //*************************************************************************************************
882 
883 
884 
885 
886 //=================================================================================================
887 //
888 // DATA ACCESS FUNCTIONS
889 //
890 //=================================================================================================
891 
892 //*************************************************************************************************
907 template< typename MT // Type of the adapted sparse matrix
908  , bool SO > // Storage order of the adapted sparse matrix
909 inline typename SymmetricMatrix<MT,SO,false,false>::Reference
910  SymmetricMatrix<MT,SO,false,false>::operator()( size_t i, size_t j )
911 {
912  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
913  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
914 
915  return Reference( matrix_, i, j );
916 }
918 //*************************************************************************************************
919 
920 
921 //*************************************************************************************************
936 template< typename MT // Type of the adapted sparse matrix
937  , bool SO > // Storage order of the adapted sparse matrix
938 inline typename SymmetricMatrix<MT,SO,false,false>::ConstReference
939  SymmetricMatrix<MT,SO,false,false>::operator()( size_t i, size_t j ) const
940 {
941  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
942  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
943 
944  return *matrix_(i,j);
945 }
947 //*************************************************************************************************
948 
949 
950 //*************************************************************************************************
966 template< typename MT // Type of the adapted dense matrix
967  , bool SO > // Storage order of the adapted dense matrix
968 inline typename SymmetricMatrix<MT,SO,false,false>::Reference
969  SymmetricMatrix<MT,SO,false,false>::at( size_t i, size_t j )
970 {
971  if( i >= rows() ) {
972  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
973  }
974  if( j >= columns() ) {
975  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
976  }
977  return (*this)(i,j);
978 }
980 //*************************************************************************************************
981 
982 
983 //*************************************************************************************************
999 template< typename MT // Type of the adapted dense matrix
1000  , bool SO > // Storage order of the adapted dense matrix
1001 inline typename SymmetricMatrix<MT,SO,false,false>::ConstReference
1002  SymmetricMatrix<MT,SO,false,false>::at( size_t i, size_t j ) const
1003 {
1004  if( i >= rows() ) {
1005  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1006  }
1007  if( j >= columns() ) {
1008  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1009  }
1010  return (*this)(i,j);
1011 }
1013 //*************************************************************************************************
1014 
1015 
1016 //*************************************************************************************************
1028 template< typename MT // Type of the adapted sparse matrix
1029  , bool SO > // Storage order of the adapted sparse matrix
1030 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
1032 {
1033  return Iterator( matrix_.begin(i) );
1034 }
1036 //*************************************************************************************************
1037 
1038 
1039 //*************************************************************************************************
1051 template< typename MT // Type of the adapted sparse matrix
1052  , bool SO > // Storage order of the adapted sparse matrix
1053 inline typename SymmetricMatrix<MT,SO,false,false>::ConstIterator
1055 {
1056  return ConstIterator( matrix_.begin(i) );
1057 }
1059 //*************************************************************************************************
1060 
1061 
1062 //*************************************************************************************************
1074 template< typename MT // Type of the adapted sparse matrix
1075  , bool SO > // Storage order of the adapted sparse matrix
1076 inline typename SymmetricMatrix<MT,SO,false,false>::ConstIterator
1078 {
1079  return ConstIterator( matrix_.cbegin(i) );
1080 }
1082 //*************************************************************************************************
1083 
1084 
1085 //*************************************************************************************************
1097 template< typename MT // Type of the adapted sparse matrix
1098  , bool SO > // Storage order of the adapted sparse matrix
1099 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
1101 {
1102  return Iterator( matrix_.end(i) );
1103 }
1105 //*************************************************************************************************
1106 
1107 
1108 //*************************************************************************************************
1120 template< typename MT // Type of the adapted sparse matrix
1121  , bool SO > // Storage order of the adapted sparse matrix
1122 inline typename SymmetricMatrix<MT,SO,false,false>::ConstIterator
1123  SymmetricMatrix<MT,SO,false,false>::end( size_t i ) const
1124 {
1125  return ConstIterator( matrix_.end(i) );
1126 }
1128 //*************************************************************************************************
1129 
1130 
1131 //*************************************************************************************************
1143 template< typename MT // Type of the adapted sparse matrix
1144  , bool SO > // Storage order of the adapted sparse matrix
1145 inline typename SymmetricMatrix<MT,SO,false,false>::ConstIterator
1147 {
1148  return ConstIterator( matrix_.cend(i) );
1149 }
1151 //*************************************************************************************************
1152 
1153 
1154 
1155 
1156 //=================================================================================================
1157 //
1158 // ASSIGNMENT OPERATORS
1159 //
1160 //=================================================================================================
1161 
1162 //*************************************************************************************************
1172 template< typename MT // Type of the adapted sparse matrix
1173  , bool SO > // Storage order of the adapted sparse matrix
1174 inline SymmetricMatrix<MT,SO,false,false>&
1175  SymmetricMatrix<MT,SO,false,false>::operator=( const SymmetricMatrix& rhs )
1176 {
1177  using blaze::resize;
1178 
1179  if( &rhs == this ) return *this;
1180 
1181  resize( matrix_, rhs.rows(), rhs.columns() );
1182  reset();
1183  assign( rhs );
1184 
1185  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1186  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1187 
1188  return *this;
1189 }
1191 //*************************************************************************************************
1192 
1193 
1194 //*************************************************************************************************
1201 template< typename MT // Type of the adapted sparse matrix
1202  , bool SO > // Storage order of the adapted sparse matrix
1203 inline SymmetricMatrix<MT,SO,false,false>&
1204  SymmetricMatrix<MT,SO,false,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1205 {
1206  matrix_ = std::move( rhs.matrix_ );
1207 
1208  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1209  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1210 
1211  return *this;
1212 }
1214 //*************************************************************************************************
1215 
1216 
1217 //*************************************************************************************************
1231 template< typename MT // Type of the adapted sparse matrix
1232  , bool SO > // Storage order of the adapted sparse matrix
1233 template< typename MT2 > // Type of the right-hand side matrix
1234 inline auto SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,SO>& rhs )
1235  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1236 {
1237  using blaze::resize;
1238 
1239  if( !IsSymmetric_v<MT2> && !isSymmetric( ~rhs ) ) {
1240  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1241  }
1242 
1243  if( (~rhs).canAlias( this ) ) {
1244  SymmetricMatrix tmp( ~rhs );
1245  swap( tmp );
1246  }
1247  else {
1248  resize( matrix_, (~rhs).rows(), (~rhs).columns() );
1249  reset();
1250  assign( ~rhs );
1251  }
1252 
1253  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1254  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1255 
1256  return *this;
1257 }
1259 //*************************************************************************************************
1260 
1261 
1262 //*************************************************************************************************
1276 template< typename MT // Type of the adapted sparse matrix
1277  , bool SO > // Storage order of the adapted sparse matrix
1278 template< typename MT2 > // Type of the right-hand side matrix
1279 inline auto SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,SO>& rhs )
1280  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1281 {
1282  using blaze::resize;
1283 
1284  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1285  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1286  }
1287 
1288  const ResultType_t<MT2> tmp( ~rhs );
1289 
1290  if( !IsSymmetric_v<MT2> && !isSymmetric( tmp ) ) {
1291  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1292  }
1293 
1294  resize( matrix_, tmp.rows(), tmp.columns() );
1295  reset();
1296  assign( tmp );
1297 
1298  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1299  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1300 
1301  return *this;
1302 }
1304 //*************************************************************************************************
1305 
1306 
1307 //*************************************************************************************************
1321 template< typename MT // Type of the adapted sparse matrix
1322  , bool SO > // Storage order of the adapted sparse matrix
1323 template< typename MT2 > // Type of the right-hand side matrix
1324 inline auto SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,!SO>& rhs )
1325  -> SymmetricMatrix&
1326 {
1327  return this->operator=( trans( ~rhs ) );
1328 }
1330 //*************************************************************************************************
1331 
1332 
1333 //*************************************************************************************************
1346 template< typename MT // Type of the adapted sparse matrix
1347  , bool SO > // Storage order of the adapted sparse matrix
1348 template< typename MT2 > // Type of the right-hand side matrix
1349 inline auto SymmetricMatrix<MT,SO,false,false>::operator+=( const Matrix<MT2,SO>& rhs )
1350  -> SymmetricMatrix&
1351 {
1352  using blaze::resize;
1353 
1354  using Tmp = AddTrait_t< MT, ResultType_t<MT2> >;
1355 
1356  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1357  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1358  }
1359 
1360  Tmp tmp( (*this) + ~rhs );
1361 
1362  if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1363  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1364  }
1365 
1366  resize( matrix_, tmp.rows(), tmp.columns() );
1367  reset();
1368  assign( tmp );
1369 
1370  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1371  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1372 
1373  return *this;
1374 }
1376 //*************************************************************************************************
1377 
1378 
1379 //*************************************************************************************************
1393 template< typename MT // Type of the adapted sparse matrix
1394  , bool SO > // Storage order of the adapted sparse matrix
1395 template< typename MT2 > // Type of the right-hand side matrix
1396 inline auto SymmetricMatrix<MT,SO,false,false>::operator+=( const Matrix<MT2,!SO>& rhs )
1397  -> SymmetricMatrix&
1398 {
1399  return this->operator+=( trans( ~rhs ) );
1400 }
1402 //*************************************************************************************************
1403 
1404 
1405 //*************************************************************************************************
1418 template< typename MT // Type of the adapted sparse matrix
1419  , bool SO > // Storage order of the adapted sparse matrix
1420 template< typename MT2 > // Type of the right-hand side matrix
1421 inline auto SymmetricMatrix<MT,SO,false,false>::operator-=( const Matrix<MT2,SO>& rhs )
1422  -> SymmetricMatrix&
1423 {
1424  using blaze::resize;
1425 
1426  using Tmp = SubTrait_t< MT, ResultType_t<MT2> >;
1427 
1428  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1429  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1430  }
1431 
1432  Tmp tmp( (*this) - ~rhs );
1433 
1434  if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1435  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1436  }
1437 
1438  resize( matrix_, tmp.rows(), tmp.columns() );
1439  reset();
1440  assign( tmp );
1441 
1442  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1443  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1444 
1445  return *this;
1446 }
1448 //*************************************************************************************************
1449 
1450 
1451 //*************************************************************************************************
1465 template< typename MT // Type of the adapted sparse matrix
1466  , bool SO > // Storage order of the adapted sparse matrix
1467 template< typename MT2 > // Type of the right-hand side matrix
1468 inline auto SymmetricMatrix<MT,SO,false,false>::operator-=( const Matrix<MT2,!SO>& rhs )
1469  -> SymmetricMatrix&
1470 {
1471  return this->operator-=( trans( ~rhs ) );
1472 }
1474 //*************************************************************************************************
1475 
1476 
1477 //*************************************************************************************************
1490 template< typename MT // Type of the adapted sparse matrix
1491  , bool SO > // Storage order of the adapted sparse matrix
1492 template< typename MT2 > // Type of the right-hand side matrix
1493 inline auto SymmetricMatrix<MT,SO,false,false>::operator%=( const Matrix<MT2,SO>& rhs )
1494  -> SymmetricMatrix&
1495 {
1496  using blaze::resize;
1497 
1498  using Tmp = SchurTrait_t< MT, ResultType_t<MT2> >;
1499 
1500  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1501  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1502  }
1503 
1504  Tmp tmp( (*this) % ~rhs );
1505 
1506  if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1507  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1508  }
1509 
1510  resize( matrix_, tmp.rows(), tmp.columns() );
1511  reset();
1512  assign( tmp );
1513 
1514  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1515  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1516 
1517  return *this;
1518 }
1520 //*************************************************************************************************
1521 
1522 
1523 //*************************************************************************************************
1537 template< typename MT // Type of the adapted sparse matrix
1538  , bool SO > // Storage order of the adapted sparse matrix
1539 template< typename MT2 > // Type of the right-hand side matrix
1540 inline auto SymmetricMatrix<MT,SO,false,false>::operator%=( const Matrix<MT2,!SO>& rhs )
1541  -> SymmetricMatrix&
1542 {
1543  return this->operator%=( trans( ~rhs ) );
1544 }
1546 //*************************************************************************************************
1547 
1548 
1549 //*************************************************************************************************
1557 template< typename MT // Type of the adapted sparse matrix
1558  , bool SO > // Storage order of the adapted sparse matrix
1559 template< typename ST > // Data type of the right-hand side scalar
1561  -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1562 {
1563  for( size_t i=0UL; i<rows(); ++i ) {
1564  const auto last( matrix_.upperBound(i,i) );
1565  for( auto element=matrix_.begin(i); element!=last; ++element )
1566  *element->value() *= rhs;
1567  }
1568 
1569  return *this;
1570 }
1572 //*************************************************************************************************
1573 
1574 
1575 //*************************************************************************************************
1583 template< typename MT // Type of the adapted sparse matrix
1584  , bool SO > // Storage order of the adapted sparse matrix
1585 template< typename ST > // Data type of the right-hand side scalar
1587  -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1588 {
1589  BLAZE_USER_ASSERT( !isZero( rhs ), "Division by zero detected" );
1590 
1591  for( size_t i=0UL; i<rows(); ++i ) {
1592  const auto last( matrix_.upperBound(i,i) );
1593  for( auto element=matrix_.begin(i); element!=last; ++element )
1594  *element->value() /= rhs;
1595  }
1596 
1597  return *this;
1598 }
1600 //*************************************************************************************************
1601 
1602 
1603 
1604 
1605 //=================================================================================================
1606 //
1607 // UTILITY FUNCTIONS
1608 //
1609 //=================================================================================================
1610 
1611 //*************************************************************************************************
1617 template< typename MT // Type of the adapted sparse matrix
1618  , bool SO > // Storage order of the adapted sparse matrix
1619 inline size_t SymmetricMatrix<MT,SO,false,false>::rows() const noexcept
1620 {
1621  return matrix_.rows();
1622 }
1624 //*************************************************************************************************
1625 
1626 
1627 //*************************************************************************************************
1633 template< typename MT // Type of the adapted sparse matrix
1634  , bool SO > // Storage order of the adapted sparse matrix
1635 inline size_t SymmetricMatrix<MT,SO,false,false>::columns() const noexcept
1636 {
1637  return matrix_.columns();
1638 }
1640 //*************************************************************************************************
1641 
1642 
1643 //*************************************************************************************************
1649 template< typename MT // Type of the adapted sparse matrix
1650  , bool SO > // Storage order of the adapted sparse matrix
1651 inline size_t SymmetricMatrix<MT,SO,false,false>::capacity() const noexcept
1652 {
1653  return matrix_.capacity();
1654 }
1656 //*************************************************************************************************
1657 
1658 
1659 //*************************************************************************************************
1670 template< typename MT // Type of the adapted sparse matrix
1671  , bool SO > // Storage order of the adapted sparse matrix
1672 inline size_t SymmetricMatrix<MT,SO,false,false>::capacity( size_t i ) const noexcept
1673 {
1674  return matrix_.capacity(i);
1675 }
1677 //*************************************************************************************************
1678 
1679 
1680 //*************************************************************************************************
1686 template< typename MT // Type of the adapted sparse matrix
1687  , bool SO > // Storage order of the adapted sparse matrix
1689 {
1690  return matrix_.nonZeros();
1691 }
1693 //*************************************************************************************************
1694 
1695 
1696 //*************************************************************************************************
1708 template< typename MT // Type of the adapted sparse matrix
1709  , bool SO > // Storage order of the adapted sparse matrix
1710 inline size_t SymmetricMatrix<MT,SO,false,false>::nonZeros( size_t i ) const
1711 {
1712  return matrix_.nonZeros(i);
1713 }
1715 //*************************************************************************************************
1716 
1717 
1718 //*************************************************************************************************
1724 template< typename MT // Type of the adapted sparse matrix
1725  , bool SO > // Storage order of the adapted sparse matrix
1727 {
1728  matrix_.reset();
1729 }
1731 //*************************************************************************************************
1732 
1733 
1734 //*************************************************************************************************
1774 template< typename MT // Type of the adapted sparse matrix
1775  , bool SO > // Storage order of the adapted sparse matrix
1776 inline void SymmetricMatrix<MT,SO,false,false>::reset( size_t i )
1777 {
1778  using blaze::erase;
1779 
1780  for( auto it=matrix_.begin(i); it!=matrix_.end(i); ++it )
1781  {
1782  const size_t j( it->index() );
1783 
1784  if( i == j )
1785  continue;
1786 
1787  if( SO ) {
1788  const Iterator_t<MatrixType> pos( matrix_.find( i, j ) );
1789  BLAZE_INTERNAL_ASSERT( pos != matrix_.end( j ), "Missing element detected" );
1790  erase( matrix_, j, pos );
1791  }
1792  else {
1793  const Iterator_t<MatrixType> pos( matrix_.find( j, i ) );
1794  BLAZE_INTERNAL_ASSERT( pos != matrix_.end( j ), "Missing element detected" );
1795  erase( matrix_, j, pos );
1796  }
1797  }
1798 
1799  matrix_.reset( i );
1800 }
1802 //*************************************************************************************************
1803 
1804 
1805 //*************************************************************************************************
1813 template< typename MT // Type of the adapted sparse matrix
1814  , bool SO > // Storage order of the adapted sparse matrix
1816 {
1817  using blaze::clear;
1818 
1819  clear( matrix_ );
1820 }
1822 //*************************************************************************************************
1823 
1824 
1825 //*************************************************************************************************
1840 template< typename MT // Type of the adapted sparse matrix
1841  , bool SO > // Storage order of the adapted sparse matrix
1842 void SymmetricMatrix<MT,SO,false,false>::resize( size_t n, bool preserve )
1843 {
1845 
1846  MAYBE_UNUSED( preserve );
1847 
1848  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1849 
1850  matrix_.resize( n, n, true );
1851 }
1853 //*************************************************************************************************
1854 
1855 
1856 //*************************************************************************************************
1867 template< typename MT // Type of the adapted sparse matrix
1868  , bool SO > // Storage order of the adapted sparse matrix
1869 inline void SymmetricMatrix<MT,SO,false,false>::reserve( size_t nonzeros )
1870 {
1871  matrix_.reserve( nonzeros );
1872 }
1874 //*************************************************************************************************
1875 
1876 
1877 //*************************************************************************************************
1891 template< typename MT // Type of the adapted sparse matrix
1892  , bool SO > // Storage order of the adapted sparse matrix
1893 inline void SymmetricMatrix<MT,SO,false,false>::reserve( size_t i, size_t nonzeros )
1894 {
1895  matrix_.reserve( i, nonzeros );
1896 }
1898 //*************************************************************************************************
1899 
1900 
1901 //*************************************************************************************************
1912 template< typename MT // Type of the adapted sparse matrix
1913  , bool SO > // Storage order of the adapted sparse matrix
1914 inline void SymmetricMatrix<MT,SO,false,false>::trim()
1915 {
1916  matrix_.trim();
1917 }
1919 //*************************************************************************************************
1920 
1921 
1922 //*************************************************************************************************
1934 template< typename MT // Type of the adapted sparse matrix
1935  , bool SO > // Storage order of the adapted sparse matrix
1936 inline void SymmetricMatrix<MT,SO,false,false>::trim( size_t i )
1937 {
1938  matrix_.trim( i );
1939 }
1941 //*************************************************************************************************
1942 
1943 
1944 //*************************************************************************************************
1954 template< typename MT // Type of the adapted sparse matrix
1955  , bool SO > // Storage order of the adapted sparse matrix
1957 {
1958  matrix_.shrinkToFit();
1959 }
1961 //*************************************************************************************************
1962 
1963 
1964 //*************************************************************************************************
1971 template< typename MT // Type of the adapted sparse matrix
1972  , bool SO > // Storage order of the adapted sparse matrix
1973 inline void SymmetricMatrix<MT,SO,false,false>::swap( SymmetricMatrix& m ) noexcept
1974 {
1975  using std::swap;
1976 
1977  swap( matrix_, m.matrix_ );
1978 }
1980 //*************************************************************************************************
1981 
1982 
1983 
1984 
1985 //=================================================================================================
1986 //
1987 // INSERTION FUNCTIONS
1988 //
1989 //=================================================================================================
1990 
1991 //*************************************************************************************************
2005 template< typename MT // Type of the adapted sparse matrix
2006  , bool SO > // Storage order of the adapted sparse matrix
2007 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
2008  SymmetricMatrix<MT,SO,false,false>::set( size_t i, size_t j, const ElementType& value )
2009 {
2010  SharedValue<ET> shared( value );
2011 
2012  if( i != j )
2013  matrix_.set( j, i, shared );
2014 
2015  return Iterator( matrix_.set( i, j, shared ) );
2016 }
2018 //*************************************************************************************************
2019 
2020 
2021 //*************************************************************************************************
2036 template< typename MT // Type of the adapted sparse matrix
2037  , bool SO > // Storage order of the adapted sparse matrix
2038 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
2039  SymmetricMatrix<MT,SO,false,false>::insert( size_t i, size_t j, const ElementType& value )
2040 {
2041  SharedValue<ET> shared( value );
2042 
2043  if( i != j )
2044  matrix_.insert( j, i, shared );
2045 
2046  return Iterator( matrix_.insert( i, j, shared ) );
2047 }
2049 //*************************************************************************************************
2050 
2051 
2052 //*************************************************************************************************
2107 template< typename MT // Type of the adapted sparse matrix
2108  , bool SO > // Storage order of the adapted sparse matrix
2109 inline void SymmetricMatrix<MT,SO,false,false>::append( size_t i, size_t j, const ElementType& value, bool check )
2110 {
2111  SharedValue<ET> shared( value );
2112 
2113  matrix_.append( i, j, shared, check );
2114  if( i != j && ( !check || !isDefault<strict>( value ) ) )
2115  matrix_.insert( j, i, shared );
2116 }
2118 //*************************************************************************************************
2119 
2120 
2121 //*************************************************************************************************
2135 template< typename MT // Type of the adapted sparse matrix
2136  , bool SO > // Storage order of the adapted sparse matrix
2137 inline void SymmetricMatrix<MT,SO,false,false>::finalize( size_t i )
2138 {
2139  matrix_.trim( i );
2140 }
2142 //*************************************************************************************************
2143 
2144 
2145 
2146 
2147 //=================================================================================================
2148 //
2149 // ERASE FUNCTIONS
2150 //
2151 //=================================================================================================
2152 
2153 //*************************************************************************************************
2163 template< typename MT // Type of the adapted sparse matrix
2164  , bool SO > // Storage order of the adapted sparse matrix
2165 inline void SymmetricMatrix<MT,SO,false,false>::erase( size_t i, size_t j )
2166 {
2167  using blaze::erase;
2168 
2169  erase( matrix_, i, j );
2170  if( i != j )
2171  erase( matrix_, j, i );
2172 }
2174 //*************************************************************************************************
2175 
2176 
2177 //*************************************************************************************************
2189 template< typename MT // Type of the adapted sparse matrix
2190  , bool SO > // Storage order of the adapted sparse matrix
2191 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
2192  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator pos )
2193 {
2194  using blaze::erase;
2195 
2196  if( pos == end( i ) )
2197  return pos;
2198 
2199  const size_t j( pos->index() );
2200 
2201  if( i == j )
2202  return Iterator( erase( matrix_, i, pos.base() ) );
2203 
2204  if( SO ) {
2205  BLAZE_INTERNAL_ASSERT( matrix_.find( i, j ) != matrix_.end( j ), "Missing element detected" );
2206  erase( matrix_, j, matrix_.find( i, j ) );
2207  return Iterator( erase( matrix_, i, pos.base() ) );
2208  }
2209  else {
2210  BLAZE_INTERNAL_ASSERT( matrix_.find( j, i ) != matrix_.end( j ), "Missing element detected" );
2211  erase( matrix_, j, matrix_.find( j, i ) );
2212  return Iterator( erase( matrix_, i, pos.base() ) );
2213  }
2214 }
2216 //*************************************************************************************************
2217 
2218 
2219 //*************************************************************************************************
2233 template< typename MT // Type of the adapted sparse matrix
2234  , bool SO > // Storage order of the adapted sparse matrix
2235 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
2236  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator first, Iterator last )
2237 {
2238  using blaze::erase;
2239 
2240  for( auto it=first; it!=last; ++it )
2241  {
2242  const size_t j( it->index() );
2243 
2244  if( i == j )
2245  continue;
2246 
2247  if( SO ) {
2248  BLAZE_INTERNAL_ASSERT( matrix_.find( i, j ) != matrix_.end( j ), "Missing element detected" );
2249  erase( matrix_, i, j );
2250  }
2251  else {
2252  BLAZE_INTERNAL_ASSERT( matrix_.find( j, i ) != matrix_.end( j ), "Missing element detected" );
2253  erase( matrix_, j, i );
2254  }
2255  }
2256 
2257  return Iterator( erase( matrix_, i, first.base(), last.base() ) );
2258 }
2260 //*************************************************************************************************
2261 
2262 
2263 //*************************************************************************************************
2277 template< typename MT // Type of the adapted sparse matrix
2278  , bool SO > // Storage order of the adapted sparse matrix
2279 template< typename Pred > // Type of the unary predicate
2280 inline void SymmetricMatrix<MT,SO,false,false>::erase( Pred predicate )
2281 {
2282  using blaze::erase;
2283 
2284  erase( matrix_, [predicate=predicate]( const SharedValue<ET>& value ) {
2285  return predicate( *value );
2286  } );
2287 
2288  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2289 }
2291 //*************************************************************************************************
2292 
2293 
2294 //*************************************************************************************************
2313 template< typename MT // Type of the adapted sparse matrix
2314  , bool SO > // Storage order of the adapted sparse matrix
2315 template< typename Pred > // Type of the unary predicate
2316 inline void
2317  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
2318 {
2319  using blaze::erase;
2320 
2321  for( auto it=first; it!=last; ++it ) {
2322  const size_t j( it->index() );
2323  if( i != j && predicate( it->value() ) ) {
2324  if( SO )
2325  erase( matrix_, i, j );
2326  else
2327  erase( matrix_, j, i );
2328  }
2329  }
2330 
2331  erase( matrix_, i, first.base(), last.base(),
2332  [predicate=predicate]( const SharedValue<ET>& value ) {
2333  return predicate( *value );
2334  } );
2335 
2336  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2337 }
2339 //*************************************************************************************************
2340 
2341 
2342 
2343 
2344 //=================================================================================================
2345 //
2346 // LOOKUP FUNCTIONS
2347 //
2348 //=================================================================================================
2349 
2350 //*************************************************************************************************
2366 template< typename MT // Type of the adapted sparse matrix
2367  , bool SO > // Storage order of the adapted sparse matrix
2368 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
2369  SymmetricMatrix<MT,SO,false,false>::find( size_t i, size_t j )
2370 {
2371  return Iterator( matrix_.find( i, j ) );
2372 }
2374 //*************************************************************************************************
2375 
2376 
2377 //*************************************************************************************************
2393 template< typename MT // Type of the adapted sparse matrix
2394  , bool SO > // Storage order of the adapted sparse matrix
2395 inline typename SymmetricMatrix<MT,SO,false,false>::ConstIterator
2396  SymmetricMatrix<MT,SO,false,false>::find( size_t i, size_t j ) const
2397 {
2398  return ConstIterator( matrix_.find( i, j ) );
2399 }
2401 //*************************************************************************************************
2402 
2403 
2404 //*************************************************************************************************
2420 template< typename MT // Type of the adapted sparse matrix
2421  , bool SO > // Storage order of the adapted sparse matrix
2422 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
2423  SymmetricMatrix<MT,SO,false,false>::lowerBound( size_t i, size_t j )
2424 {
2425  return Iterator( matrix_.lowerBound( i, j ) );
2426 }
2428 //*************************************************************************************************
2429 
2430 
2431 //*************************************************************************************************
2447 template< typename MT // Type of the adapted sparse matrix
2448  , bool SO > // Storage order of the adapted sparse matrix
2449 inline typename SymmetricMatrix<MT,SO,false,false>::ConstIterator
2450  SymmetricMatrix<MT,SO,false,false>::lowerBound( size_t i, size_t j ) const
2451 {
2452  return ConstIterator( matrix_.lowerBound( i, j ) );
2453 }
2455 //*************************************************************************************************
2456 
2457 
2458 //*************************************************************************************************
2474 template< typename MT // Type of the adapted sparse matrix
2475  , bool SO > // Storage order of the adapted sparse matrix
2476 inline typename SymmetricMatrix<MT,SO,false,false>::Iterator
2477  SymmetricMatrix<MT,SO,false,false>::upperBound( size_t i, size_t j )
2478 {
2479  return Iterator( matrix_.upperBound( i, j ) );
2480 }
2482 //*************************************************************************************************
2483 
2484 
2485 //*************************************************************************************************
2501 template< typename MT // Type of the adapted sparse matrix
2502  , bool SO > // Storage order of the adapted sparse matrix
2503 inline typename SymmetricMatrix<MT,SO,false,false>::ConstIterator
2504  SymmetricMatrix<MT,SO,false,false>::upperBound( size_t i, size_t j ) const
2505 {
2506  return ConstIterator( matrix_.upperBound( i, j ) );
2507 }
2509 //*************************************************************************************************
2510 
2511 
2512 
2513 
2514 //=================================================================================================
2515 //
2516 // NUMERIC FUNCTIONS
2517 //
2518 //=================================================================================================
2519 
2520 //*************************************************************************************************
2526 template< typename MT // Type of the adapted sparse matrix
2527  , bool SO > // Storage order of the adapted sparse matrix
2528 inline SymmetricMatrix<MT,SO,false,false>& SymmetricMatrix<MT,SO,false,false>::transpose()
2529 {
2530  return *this;
2531 }
2533 //*************************************************************************************************
2534 
2535 
2536 //*************************************************************************************************
2542 template< typename MT // Type of the adapted sparse matrix
2543  , bool SO > // Storage order of the adapted sparse matrix
2544 inline SymmetricMatrix<MT,SO,false,false>& SymmetricMatrix<MT,SO,false,false>::ctranspose()
2545 {
2546  for( size_t i=0UL; i<rows(); ++i ) {
2547  const auto last( matrix_.upperBound(i,i) );
2548  for( auto element=matrix_.begin(i); element!=last; ++element )
2549  conjugate( *element->value() );
2550  }
2551 
2552  return *this;
2553 }
2555 //*************************************************************************************************
2556 
2557 
2558 //*************************************************************************************************
2576 template< typename MT // Type of the adapted sparse matrix
2577  , bool SO > // Storage order of the adapted sparse matrix
2578 template< typename Other > // Data type of the scalar value
2579 inline SymmetricMatrix<MT,SO,false,false>&
2580  SymmetricMatrix<MT,SO,false,false>::scale( const Other& scalar )
2581 {
2582  for( size_t i=0UL; i<rows(); ++i ) {
2583  const auto last( matrix_.upperBound(i,i) );
2584  for( auto element=matrix_.begin(i); element!=last; ++element )
2585  ( *element->value() ).scale( scalar );
2586  }
2587 
2588  return *this;
2589 }
2591 //*************************************************************************************************
2592 
2593 
2594 
2595 
2596 //=================================================================================================
2597 //
2598 // DEBUGGING FUNCTIONS
2599 //
2600 //=================================================================================================
2601 
2602 //*************************************************************************************************
2612 template< typename MT // Type of the adapted dense matrix
2613  , bool SO > // Storage order of the adapted dense matrix
2614 inline bool SymmetricMatrix<MT,SO,false,false>::isIntact() const noexcept
2615 {
2616  using blaze::isIntact;
2617 
2618  return ( isIntact( matrix_ ) && isSymmetric( matrix_ ) );
2619 }
2621 //*************************************************************************************************
2622 
2623 
2624 
2625 
2626 //=================================================================================================
2627 //
2628 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2629 //
2630 //=================================================================================================
2631 
2632 //*************************************************************************************************
2643 template< typename MT // Type of the adapted sparse matrix
2644  , bool SO > // Storage order of the adapted sparse matrix
2645 template< typename Other > // Data type of the foreign expression
2646 inline bool SymmetricMatrix<MT,SO,false,false>::canAlias( const Other* alias ) const noexcept
2647 {
2648  return matrix_.canAlias( alias );
2649 }
2651 //*************************************************************************************************
2652 
2653 
2654 //*************************************************************************************************
2665 template< typename MT // Type of the adapted sparse matrix
2666  , bool SO > // Storage order of the adapted sparse matrix
2667 template< typename Other > // Data type of the foreign expression
2668 inline bool SymmetricMatrix<MT,SO,false,false>::isAliased( const Other* alias ) const noexcept
2669 {
2670  return matrix_.isAliased( alias );
2671 }
2673 //*************************************************************************************************
2674 
2675 
2676 //*************************************************************************************************
2687 template< typename MT // Type of the adapted sparse matrix
2688  , bool SO > // Storage order of the adapted sparse matrix
2689 inline bool SymmetricMatrix<MT,SO,false,false>::canSMPAssign() const noexcept
2690 {
2691  return matrix_.canSMPAssign();
2692 }
2694 //*************************************************************************************************
2695 
2696 
2697 //*************************************************************************************************
2709 template< typename MT // Type of the adapted sparse matrix
2710  , bool SO > // Storage order of the adapted sparse matrix
2711 template< typename MT2 > // Type of the right-hand side dense matrix
2712 void SymmetricMatrix<MT,SO,false,false>::assign( DenseMatrix<MT2,SO>& rhs )
2713 {
2715 
2716  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2717  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2718 
2719  std::vector<size_t> nonzeros( rows(), 0UL );
2720  size_t sum( 0UL );
2721 
2722  for( size_t i=0UL; i<rows(); ++i ) {
2723  nonzeros[i] = (~rhs).nonZeros(i);
2724  sum += nonzeros[i];
2725  }
2726 
2727  matrix_.reserve( sum );
2728  for( size_t i=0UL; i<rows(); ++i ) {
2729  matrix_.reserve( i, nonzeros[i] );
2730  }
2731 
2732  for( size_t i=0UL; i<rows(); ++i ) {
2733  for( size_t j=i; j<columns(); ++j ) {
2734  if( !isDefault( (~rhs)(i,j) ) ) {
2735  SharedValue<ET> shared;
2736  *shared = std::move( (~rhs)(i,j) );
2737  matrix_.append( i, j, shared, false );
2738  if( i != j )
2739  matrix_.append( j, i, shared, false );
2740  }
2741  }
2742  }
2743 }
2745 //*************************************************************************************************
2746 
2747 
2748 //*************************************************************************************************
2760 template< typename MT // Type of the adapted sparse matrix
2761  , bool SO > // Storage order of the adapted sparse matrix
2762 template< typename MT2 > // Type of the right-hand side dense matrix
2763 void SymmetricMatrix<MT,SO,false,false>::assign( const DenseMatrix<MT2,SO>& rhs )
2764 {
2766 
2767  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2768  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2769 
2770  std::vector<size_t> nonzeros( rows(), 0UL );
2771  size_t sum( 0UL );
2772 
2773  for( size_t i=0UL; i<rows(); ++i ) {
2774  nonzeros[i] = (~rhs).nonZeros(i);
2775  sum += nonzeros[i];
2776  }
2777 
2778  matrix_.reserve( sum );
2779  for( size_t i=0UL; i<rows(); ++i ) {
2780  matrix_.reserve( i, nonzeros[i] );
2781  }
2782 
2783  for( size_t i=0UL; i<rows(); ++i ) {
2784  for( size_t j=i; j<columns(); ++j ) {
2785  if( !isDefault( (~rhs)(i,j) ) ) {
2786  const SharedValue<ET> shared( (~rhs)(i,j) );
2787  matrix_.append( i, j, shared, false );
2788  if( i != j )
2789  matrix_.append( j, i, shared, false );
2790  }
2791  }
2792  }
2793 }
2795 //*************************************************************************************************
2796 
2797 
2798 //*************************************************************************************************
2810 template< typename MT // Type of the adapted sparse matrix
2811  , bool SO > // Storage order of the adapted sparse matrix
2812 template< typename MT2 > // Type of the right-hand side sparse matrix
2813 void SymmetricMatrix<MT,SO,false,false>::assign( SparseMatrix<MT2,SO>& rhs )
2814 {
2816 
2817  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2818  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2819 
2820  std::vector<size_t> nonzeros( rows(), 0UL );
2821  size_t sum( 0UL );
2822 
2823  for( size_t i=0UL; i<rows(); ++i ) {
2824  nonzeros[i] = (~rhs).nonZeros(i);
2825  sum += nonzeros[i];
2826  }
2827 
2828  matrix_.reserve( sum );
2829  for( size_t i=0UL; i<rows(); ++i ) {
2830  matrix_.reserve( i, nonzeros[i] );
2831  }
2832 
2833  for( size_t i=0UL; i<rows(); ++i ) {
2834  for( auto it=(~rhs).lowerBound(i,i); it!=(~rhs).end(i); ++it ) {
2835  if( !isDefault( it->value() ) ) {
2836  SharedValue<ET> shared;
2837  *shared = std::move( it->value() );
2838  matrix_.append( i, it->index(), shared, false );
2839  if( i != it->index() )
2840  matrix_.append( it->index(), i, shared, false );
2841  }
2842  }
2843  }
2844 }
2846 //*************************************************************************************************
2847 
2848 
2849 //*************************************************************************************************
2861 template< typename MT // Type of the adapted sparse matrix
2862  , bool SO > // Storage order of the adapted sparse matrix
2863 template< typename MT2 > // Type of the right-hand side sparse matrix
2864 void SymmetricMatrix<MT,SO,false,false>::assign( const SparseMatrix<MT2,SO>& rhs )
2865 {
2867 
2868  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2869  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2870 
2871  std::vector<size_t> nonzeros( rows(), 0UL );
2872  size_t sum( 0UL );
2873 
2874  for( size_t i=0UL; i<rows(); ++i ) {
2875  nonzeros[i] = (~rhs).nonZeros(i);
2876  sum += nonzeros[i];
2877  }
2878 
2879  matrix_.reserve( sum );
2880  for( size_t i=0UL; i<rows(); ++i ) {
2881  matrix_.reserve( i, nonzeros[i] );
2882  }
2883 
2884  for( size_t i=0UL; i<rows(); ++i ) {
2885  for( auto it=(~rhs).lowerBound(i,i); it!=(~rhs).end(i); ++it ) {
2886  if( !isDefault( it->value() ) ) {
2887  const SharedValue<ET> shared( it->value() );
2888  matrix_.append( i, it->index(), shared, false );
2889  if( i != it->index() )
2890  matrix_.append( it->index(), i, shared, false );
2891  }
2892  }
2893  }
2894 }
2896 //*************************************************************************************************
2897 
2898 } // namespace blaze
2899 
2900 #endif
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T)
Constraint on the data type.In case the given data type T is a transformation expression (i....
Definition: Transformation.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type,...
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.
auto operator-=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Subtraction assignment operator for the subtraction of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:432
constexpr ptrdiff_t Size_v
Auxiliary variable template for the Size type trait.The Size_v variable template provides a convenien...
Definition: Size.h:176
Constraint on the data type.
Header file for the Schur product trait.
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,...
Definition: Assert.h:117
Header file for the subtraction trait.
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
Header file for basic type definitions.
constexpr 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:750
#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
Header file for the isZero shim.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i....
Definition: Computation.h:81
Constraint on the data type.
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
Header file for the SharedValue class.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:799
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
Header file for the MAYBE_UNUSED function template.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type,...
Definition: Volatile.h:79
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
Constraint on the data type.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
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:482
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:416
Header file for the implementation of the base template of the SymmetricMatrix.
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
Header file for utility functions for sparse matrices.
Header file for the IsSquare type trait.
Constraint on the data type.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:677
Header file for the DisableIf class template.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
Compile time assertion.
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:9091
#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
decltype(auto) sum(const DenseMatrix< MT, SO > &dm)
Reduces the given dense matrix by means of addition.
Definition: DMatReduceExpr.h:2147
auto operator+=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Addition assignment operator for the addition of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:370
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:253
Constraint on the data type.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
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
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
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:438
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:293
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:615
Header file for the NonNumericProxy class.
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( ).
Definition: DenseMatrix.h:558
#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,...
Definition: Symmetric.h:79
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric_v< T >)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
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,...
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:282
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
Constraint on the data type.
Constraint on the data type.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:1328
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VIEW_TYPE(T)
Constraint on the data type.In case the given data type T is a view type (i.e. a subvector,...
Definition: View.h:81
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
#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 'res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
auto operator *=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:494
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
#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,...
Definition: Hermitian.h:79
#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
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:951
Constraint on the data type.
Header file for the Size type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression,...
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
Header file for the clear shim.
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825