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_t<MT>;
114  using TT = TransposeType_t<MT>;
115  using ET = ElementType_t<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_t<MT>;
130  using CompositeType = const This&;
131  using Reference = NonNumericProxy<MatrixType>;
132  using ConstReference = ConstReference_t<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_t<MatrixType> >
452  , Iterator_t<MatrixType> >;
453 
455  using ConstIterator = SharedIterator< const SharedElement< ConstIterator_t<MatrixType> >
456  , ConstIterator_t<MatrixType> >;
457  //**********************************************************************************************
458 
459  //**Compilation flags***************************************************************************
461  static constexpr 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**********************************************************************************
483  ~SymmetricMatrix() = default;
485  //**********************************************************************************************
486 
487  //**Data access functions***********************************************************************
490  inline Reference operator()( size_t i, size_t j );
491  inline ConstReference operator()( size_t i, size_t j ) const;
492  inline Reference at( size_t i, size_t j );
493  inline ConstReference at( size_t i, size_t j ) const;
494  inline Iterator begin ( size_t i );
495  inline ConstIterator begin ( size_t i ) const;
496  inline ConstIterator cbegin( size_t i ) const;
497  inline Iterator end ( size_t i );
498  inline ConstIterator end ( size_t i ) const;
499  inline ConstIterator cend ( size_t i ) const;
501  //**********************************************************************************************
502 
503  //**Assignment operators************************************************************************
506  inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
507  inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
508 
509  template< typename MT2 >
510  inline auto operator=( const Matrix<MT2,SO>& rhs )
511  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
512 
513  template< typename MT2 >
514  inline auto operator=( const Matrix<MT2,SO>& rhs )
515  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
516 
517  template< typename MT2 >
518  inline auto operator=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
519 
520  template< typename MT2 >
521  inline auto operator+=( const Matrix<MT2,SO>& rhs ) -> SymmetricMatrix&;
522 
523  template< typename MT2 >
524  inline auto operator+=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
525 
526  template< typename MT2 >
527  inline auto operator-=( const Matrix<MT2,SO>& rhs ) -> SymmetricMatrix&;
528 
529  template< typename MT2 >
530  inline auto operator-=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
531 
532  template< typename MT2 >
533  inline auto operator%=( const Matrix<MT2,SO>& rhs ) -> SymmetricMatrix&;
534 
535  template< typename MT2 >
536  inline auto operator%=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
537 
538  template< typename ST >
539  inline auto operator*=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >;
540 
541  template< typename ST >
542  inline auto operator/=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >;
544  //**********************************************************************************************
545 
546  //**Utility functions***************************************************************************
549  inline size_t rows() const noexcept;
550  inline size_t columns() const noexcept;
551  inline size_t capacity() const noexcept;
552  inline size_t capacity( size_t i ) const noexcept;
553  inline size_t nonZeros() const;
554  inline size_t nonZeros( size_t i ) const;
555  inline void reset();
556  inline void reset( size_t i );
557  inline void clear();
558  inline void resize ( size_t n, bool preserve=true );
559  inline void reserve( size_t nonzeros );
560  inline void reserve( size_t i, size_t nonzeros );
561  inline void trim();
562  inline void trim( size_t i );
563  inline void shrinkToFit();
564  inline void swap( SymmetricMatrix& m ) noexcept;
566  //**********************************************************************************************
567 
568  //**Insertion functions*************************************************************************
571  inline Iterator set ( size_t i, size_t j, const ElementType& value );
572  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
573  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
574  inline void finalize( size_t i );
576  //**********************************************************************************************
577 
578  //**Erase functions*****************************************************************************
581  inline void erase( size_t i, size_t j );
582  inline Iterator erase( size_t i, Iterator pos );
583  inline Iterator erase( size_t i, Iterator first, Iterator last );
584 
585  template< typename Pred >
586  inline void erase( Pred predicate );
587 
588  template< typename Pred >
589  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
591  //**********************************************************************************************
592 
593  //**Lookup functions****************************************************************************
596  inline Iterator find ( size_t i, size_t j );
597  inline ConstIterator find ( size_t i, size_t j ) const;
598  inline Iterator lowerBound( size_t i, size_t j );
599  inline ConstIterator lowerBound( size_t i, size_t j ) const;
600  inline Iterator upperBound( size_t i, size_t j );
601  inline ConstIterator upperBound( size_t i, size_t j ) const;
603  //**********************************************************************************************
604 
605  //**Numeric functions***************************************************************************
608  inline SymmetricMatrix& transpose();
609  inline SymmetricMatrix& ctranspose();
610 
611  template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
613  //**********************************************************************************************
614 
615  //**Debugging functions*************************************************************************
618  inline bool isIntact() const noexcept;
620  //**********************************************************************************************
621 
622  //**Expression template evaluation functions****************************************************
625  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
626  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
627 
628  inline bool canSMPAssign() const noexcept;
630  //**********************************************************************************************
631 
632  private:
633  //**Expression template evaluation functions****************************************************
636  template< typename MT2 > void assign( DenseMatrix<MT2,SO>& rhs );
637  template< typename MT2 > void assign( const DenseMatrix<MT2,SO>& rhs );
638  template< typename MT2 > void assign( SparseMatrix<MT2,SO>& rhs );
639  template< typename MT2 > void assign( const SparseMatrix<MT2,SO>& rhs );
641  //**********************************************************************************************
642 
643  //**Member variables****************************************************************************
646  MatrixType matrix_;
647 
648  //**********************************************************************************************
649 
650  //**Friend declarations*************************************************************************
651  template< bool RF, typename MT2, bool SO2, bool DF2, bool NF2 >
652  friend bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
653  //**********************************************************************************************
654 
655  //**Compile time checks*************************************************************************
669  BLAZE_STATIC_ASSERT( ( Size_v<MT,0UL> == Size_v<MT,1UL> ) );
670  //**********************************************************************************************
671 };
673 //*************************************************************************************************
674 
675 
676 
677 
678 //=================================================================================================
679 //
680 // CONSTRUCTORS
681 //
682 //=================================================================================================
683 
684 //*************************************************************************************************
688 template< typename MT // Type of the adapted sparse matrix
689  , bool SO > // Storage order of the adapted sparse matrix
690 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix()
691  : matrix_() // The adapted sparse matrix
692 {
693  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
694 }
696 //*************************************************************************************************
697 
698 
699 //*************************************************************************************************
707 template< typename MT // Type of the adapted sparse matrix
708  , bool SO > // Storage order of the adapted sparse matrix
709 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n )
710  : matrix_( n, n ) // The adapted sparse matrix
711 {
713 
714  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
715 }
717 //*************************************************************************************************
718 
719 
720 //*************************************************************************************************
729 template< typename MT // Type of the adapted sparse matrix
730  , bool SO > // Storage order of the adapted sparse matrix
731 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n, size_t nonzeros )
732  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
733 {
735 
736  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
737 }
739 //*************************************************************************************************
740 
741 
742 //*************************************************************************************************
753 template< typename MT // Type of the adapted sparse matrix
754  , bool SO > // Storage order of the adapted sparse matrix
755 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( size_t n, const std::vector<size_t>& nonzeros )
756  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
757 {
759 
760  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
761 }
763 //*************************************************************************************************
764 
765 
766 //*************************************************************************************************
772 template< typename MT // Type of the adapted sparse matrix
773  , bool SO > // Storage order of the adapted sparse matrix
774 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const SymmetricMatrix& m )
775  : matrix_() // The adapted sparse matrix
776 {
777  using blaze::resize;
778 
779  resize( matrix_, m.rows(), m.columns() );
780  assign( m );
781 
782  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
783  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
784 }
786 //*************************************************************************************************
787 
788 
789 //*************************************************************************************************
795 template< typename MT // Type of the adapted sparse matrix
796  , bool SO > // Storage order of the adapted sparse matrix
797 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
798  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
799 {
800  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
801  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
802 }
804 //*************************************************************************************************
805 
806 
807 //*************************************************************************************************
817 template< typename MT // Type of the adapted sparse matrix
818  , bool SO > // Storage order of the adapted sparse matrix
819 template< typename MT2 > // Type of the foreign matrix
820 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const Matrix<MT2,SO>& m )
821  : matrix_() // The adapted sparse matrix
822 {
823  using blaze::resize;
824 
825  using RT = RemoveAdaptor_t< ResultType_t<MT2> >;
826  using Tmp = If_t< IsComputation_v<MT2>, RT, const MT2& >;
827 
828  Tmp tmp( ~m );
829 
830  if( !IsSymmetric_v<MT2> && !isSymmetric( tmp ) ) {
831  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
832  }
833 
834  resize( matrix_, tmp.rows(), tmp.columns() );
835  assign( tmp );
836 
837  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
838  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
839 }
841 //*************************************************************************************************
842 
843 
844 //*************************************************************************************************
854 template< typename MT // Type of the adapted sparse matrix
855  , bool SO > // Storage order of the adapted sparse matrix
856 template< typename MT2 > // Type of the foreign matrix
857 inline SymmetricMatrix<MT,SO,false,false>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
858  : matrix_() // The adapted sparse matrix
859 {
860  using blaze::resize;
861 
862  using RT = RemoveAdaptor_t< ResultType_t<MT2> >;
863  using Tmp = If_t< IsComputation_v<MT2>, RT, const MT2& >;
864 
865  Tmp tmp( ~m );
866 
867  if( !IsSymmetric_v<MT2> && !isSymmetric( tmp ) ) {
868  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
869  }
870 
871  resize( matrix_, tmp.rows(), tmp.columns() );
872  assign( trans( tmp ) );
873 
874  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
875  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
876 }
878 //*************************************************************************************************
879 
880 
881 
882 
883 //=================================================================================================
884 //
885 // DATA ACCESS FUNCTIONS
886 //
887 //=================================================================================================
888 
889 //*************************************************************************************************
904 template< typename MT // Type of the adapted sparse matrix
905  , bool SO > // Storage order of the adapted sparse matrix
907  SymmetricMatrix<MT,SO,false,false>::operator()( size_t i, size_t j )
908 {
909  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
910  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
911 
912  return Reference( matrix_, i, j );
913 }
915 //*************************************************************************************************
916 
917 
918 //*************************************************************************************************
933 template< typename MT // Type of the adapted sparse matrix
934  , bool SO > // Storage order of the adapted sparse matrix
936  SymmetricMatrix<MT,SO,false,false>::operator()( size_t i, size_t j ) const
937 {
938  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
939  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
940 
941  return *matrix_(i,j);
942 }
944 //*************************************************************************************************
945 
946 
947 //*************************************************************************************************
963 template< typename MT // Type of the adapted dense matrix
964  , bool SO > // Storage order of the adapted dense matrix
966  SymmetricMatrix<MT,SO,false,false>::at( size_t i, size_t j )
967 {
968  if( i >= rows() ) {
969  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
970  }
971  if( j >= columns() ) {
972  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
973  }
974  return (*this)(i,j);
975 }
977 //*************************************************************************************************
978 
979 
980 //*************************************************************************************************
996 template< typename MT // Type of the adapted dense matrix
997  , bool SO > // Storage order of the adapted dense matrix
999  SymmetricMatrix<MT,SO,false,false>::at( size_t i, size_t j ) const
1000 {
1001  if( i >= rows() ) {
1002  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1003  }
1004  if( j >= columns() ) {
1005  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1006  }
1007  return (*this)(i,j);
1008 }
1010 //*************************************************************************************************
1011 
1012 
1013 //*************************************************************************************************
1025 template< typename MT // Type of the adapted sparse matrix
1026  , bool SO > // Storage order of the adapted sparse matrix
1029 {
1030  return Iterator( matrix_.begin(i) );
1031 }
1033 //*************************************************************************************************
1034 
1035 
1036 //*************************************************************************************************
1048 template< typename MT // Type of the adapted sparse matrix
1049  , bool SO > // Storage order of the adapted sparse matrix
1052 {
1053  return ConstIterator( matrix_.begin(i) );
1054 }
1056 //*************************************************************************************************
1057 
1058 
1059 //*************************************************************************************************
1071 template< typename MT // Type of the adapted sparse matrix
1072  , bool SO > // Storage order of the adapted sparse matrix
1075 {
1076  return ConstIterator( matrix_.cbegin(i) );
1077 }
1079 //*************************************************************************************************
1080 
1081 
1082 //*************************************************************************************************
1094 template< typename MT // Type of the adapted sparse matrix
1095  , bool SO > // Storage order of the adapted sparse matrix
1098 {
1099  return Iterator( matrix_.end(i) );
1100 }
1102 //*************************************************************************************************
1103 
1104 
1105 //*************************************************************************************************
1117 template< typename MT // Type of the adapted sparse matrix
1118  , bool SO > // Storage order of the adapted sparse matrix
1120  SymmetricMatrix<MT,SO,false,false>::end( size_t i ) const
1121 {
1122  return ConstIterator( matrix_.end(i) );
1123 }
1125 //*************************************************************************************************
1126 
1127 
1128 //*************************************************************************************************
1140 template< typename MT // Type of the adapted sparse matrix
1141  , bool SO > // Storage order of the adapted sparse matrix
1144 {
1145  return ConstIterator( matrix_.cend(i) );
1146 }
1148 //*************************************************************************************************
1149 
1150 
1151 
1152 
1153 //=================================================================================================
1154 //
1155 // ASSIGNMENT OPERATORS
1156 //
1157 //=================================================================================================
1158 
1159 //*************************************************************************************************
1169 template< typename MT // Type of the adapted sparse matrix
1170  , bool SO > // Storage order of the adapted sparse matrix
1171 inline SymmetricMatrix<MT,SO,false,false>&
1172  SymmetricMatrix<MT,SO,false,false>::operator=( const SymmetricMatrix& rhs )
1173 {
1174  using blaze::resize;
1175 
1176  if( &rhs == this ) return *this;
1177 
1178  resize( matrix_, rhs.rows(), rhs.columns() );
1179  reset();
1180  assign( rhs );
1181 
1182  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1183  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1184 
1185  return *this;
1186 }
1188 //*************************************************************************************************
1189 
1190 
1191 //*************************************************************************************************
1198 template< typename MT // Type of the adapted sparse matrix
1199  , bool SO > // Storage order of the adapted sparse matrix
1200 inline SymmetricMatrix<MT,SO,false,false>&
1201  SymmetricMatrix<MT,SO,false,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1202 {
1203  matrix_ = std::move( rhs.matrix_ );
1204 
1205  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1206  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1207 
1208  return *this;
1209 }
1211 //*************************************************************************************************
1212 
1213 
1214 //*************************************************************************************************
1228 template< typename MT // Type of the adapted sparse matrix
1229  , bool SO > // Storage order of the adapted sparse matrix
1230 template< typename MT2 > // Type of the right-hand side matrix
1231 inline auto SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,SO>& rhs )
1232  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1233 {
1234  using blaze::resize;
1235 
1236  if( !IsSymmetric_v<MT2> && !isSymmetric( ~rhs ) ) {
1237  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1238  }
1239 
1240  if( (~rhs).canAlias( this ) ) {
1241  SymmetricMatrix tmp( ~rhs );
1242  swap( tmp );
1243  }
1244  else {
1245  resize( matrix_, (~rhs).rows(), (~rhs).columns() );
1246  reset();
1247  assign( ~rhs );
1248  }
1249 
1250  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1251  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1252 
1253  return *this;
1254 }
1256 //*************************************************************************************************
1257 
1258 
1259 //*************************************************************************************************
1273 template< typename MT // Type of the adapted sparse matrix
1274  , bool SO > // Storage order of the adapted sparse matrix
1275 template< typename MT2 > // Type of the right-hand side matrix
1276 inline auto SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,SO>& rhs )
1277  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1278 {
1279  using blaze::resize;
1280 
1281  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1282  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1283  }
1284 
1285  const ResultType_t<MT2> tmp( ~rhs );
1286 
1287  if( !IsSymmetric_v<MT2> && !isSymmetric( tmp ) ) {
1288  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1289  }
1290 
1291  resize( matrix_, tmp.rows(), tmp.columns() );
1292  reset();
1293  assign( tmp );
1294 
1295  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1296  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1297 
1298  return *this;
1299 }
1301 //*************************************************************************************************
1302 
1303 
1304 //*************************************************************************************************
1318 template< typename MT // Type of the adapted sparse matrix
1319  , bool SO > // Storage order of the adapted sparse matrix
1320 template< typename MT2 > // Type of the right-hand side matrix
1321 inline auto SymmetricMatrix<MT,SO,false,false>::operator=( const Matrix<MT2,!SO>& rhs )
1322  -> SymmetricMatrix&
1323 {
1324  return this->operator=( trans( ~rhs ) );
1325 }
1327 //*************************************************************************************************
1328 
1329 
1330 //*************************************************************************************************
1343 template< typename MT // Type of the adapted sparse matrix
1344  , bool SO > // Storage order of the adapted sparse matrix
1345 template< typename MT2 > // Type of the right-hand side matrix
1346 inline auto SymmetricMatrix<MT,SO,false,false>::operator+=( const Matrix<MT2,SO>& rhs )
1347  -> SymmetricMatrix&
1348 {
1349  using blaze::resize;
1350 
1351  using Tmp = AddTrait_t< MT, ResultType_t<MT2> >;
1352 
1353  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1354  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1355  }
1356 
1357  Tmp tmp( (*this) + ~rhs );
1358 
1359  if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1360  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1361  }
1362 
1363  resize( matrix_, tmp.rows(), tmp.columns() );
1364  reset();
1365  assign( tmp );
1366 
1367  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1368  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1369 
1370  return *this;
1371 }
1373 //*************************************************************************************************
1374 
1375 
1376 //*************************************************************************************************
1390 template< typename MT // Type of the adapted sparse matrix
1391  , bool SO > // Storage order of the adapted sparse matrix
1392 template< typename MT2 > // Type of the right-hand side matrix
1393 inline auto SymmetricMatrix<MT,SO,false,false>::operator+=( const Matrix<MT2,!SO>& rhs )
1394  -> SymmetricMatrix&
1395 {
1396  return this->operator+=( trans( ~rhs ) );
1397 }
1399 //*************************************************************************************************
1400 
1401 
1402 //*************************************************************************************************
1415 template< typename MT // Type of the adapted sparse matrix
1416  , bool SO > // Storage order of the adapted sparse matrix
1417 template< typename MT2 > // Type of the right-hand side matrix
1418 inline auto SymmetricMatrix<MT,SO,false,false>::operator-=( const Matrix<MT2,SO>& rhs )
1419  -> SymmetricMatrix&
1420 {
1421  using blaze::resize;
1422 
1423  using Tmp = SubTrait_t< MT, ResultType_t<MT2> >;
1424 
1425  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1426  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1427  }
1428 
1429  Tmp tmp( (*this) - ~rhs );
1430 
1431  if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1432  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1433  }
1434 
1435  resize( matrix_, tmp.rows(), tmp.columns() );
1436  reset();
1437  assign( tmp );
1438 
1439  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1440  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1441 
1442  return *this;
1443 }
1445 //*************************************************************************************************
1446 
1447 
1448 //*************************************************************************************************
1462 template< typename MT // Type of the adapted sparse matrix
1463  , bool SO > // Storage order of the adapted sparse matrix
1464 template< typename MT2 > // Type of the right-hand side matrix
1465 inline auto SymmetricMatrix<MT,SO,false,false>::operator-=( const Matrix<MT2,!SO>& rhs )
1466  -> SymmetricMatrix&
1467 {
1468  return this->operator-=( trans( ~rhs ) );
1469 }
1471 //*************************************************************************************************
1472 
1473 
1474 //*************************************************************************************************
1487 template< typename MT // Type of the adapted sparse matrix
1488  , bool SO > // Storage order of the adapted sparse matrix
1489 template< typename MT2 > // Type of the right-hand side matrix
1490 inline auto SymmetricMatrix<MT,SO,false,false>::operator%=( const Matrix<MT2,SO>& rhs )
1491  -> SymmetricMatrix&
1492 {
1493  using blaze::resize;
1494 
1495  using Tmp = SchurTrait_t< MT, ResultType_t<MT2> >;
1496 
1497  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1498  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1499  }
1500 
1501  Tmp tmp( (*this) % ~rhs );
1502 
1503  if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1504  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1505  }
1506 
1507  resize( matrix_, tmp.rows(), tmp.columns() );
1508  reset();
1509  assign( tmp );
1510 
1511  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1512  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1513 
1514  return *this;
1515 }
1517 //*************************************************************************************************
1518 
1519 
1520 //*************************************************************************************************
1534 template< typename MT // Type of the adapted sparse matrix
1535  , bool SO > // Storage order of the adapted sparse matrix
1536 template< typename MT2 > // Type of the right-hand side matrix
1537 inline auto SymmetricMatrix<MT,SO,false,false>::operator%=( const Matrix<MT2,!SO>& rhs )
1538  -> SymmetricMatrix&
1539 {
1540  return this->operator%=( trans( ~rhs ) );
1541 }
1543 //*************************************************************************************************
1544 
1545 
1546 //*************************************************************************************************
1554 template< typename MT // Type of the adapted sparse matrix
1555  , bool SO > // Storage order of the adapted sparse matrix
1556 template< typename ST > // Data type of the right-hand side scalar
1558  -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1559 {
1560  for( size_t i=0UL; i<rows(); ++i ) {
1561  const auto last( matrix_.upperBound(i,i) );
1562  for( auto element=matrix_.begin(i); element!=last; ++element )
1563  *element->value() *= rhs;
1564  }
1565 
1566  return *this;
1567 }
1569 //*************************************************************************************************
1570 
1571 
1572 //*************************************************************************************************
1580 template< typename MT // Type of the adapted sparse matrix
1581  , bool SO > // Storage order of the adapted sparse matrix
1582 template< typename ST > // Data type of the right-hand side scalar
1584  -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1585 {
1586  BLAZE_USER_ASSERT( !isZero( rhs ), "Division by zero detected" );
1587 
1588  for( size_t i=0UL; i<rows(); ++i ) {
1589  const auto last( matrix_.upperBound(i,i) );
1590  for( auto element=matrix_.begin(i); element!=last; ++element )
1591  *element->value() /= rhs;
1592  }
1593 
1594  return *this;
1595 }
1597 //*************************************************************************************************
1598 
1599 
1600 
1601 
1602 //=================================================================================================
1603 //
1604 // UTILITY FUNCTIONS
1605 //
1606 //=================================================================================================
1607 
1608 //*************************************************************************************************
1614 template< typename MT // Type of the adapted sparse matrix
1615  , bool SO > // Storage order of the adapted sparse matrix
1616 inline size_t SymmetricMatrix<MT,SO,false,false>::rows() const noexcept
1617 {
1618  return matrix_.rows();
1619 }
1621 //*************************************************************************************************
1622 
1623 
1624 //*************************************************************************************************
1630 template< typename MT // Type of the adapted sparse matrix
1631  , bool SO > // Storage order of the adapted sparse matrix
1632 inline size_t SymmetricMatrix<MT,SO,false,false>::columns() const noexcept
1633 {
1634  return matrix_.columns();
1635 }
1637 //*************************************************************************************************
1638 
1639 
1640 //*************************************************************************************************
1646 template< typename MT // Type of the adapted sparse matrix
1647  , bool SO > // Storage order of the adapted sparse matrix
1648 inline size_t SymmetricMatrix<MT,SO,false,false>::capacity() const noexcept
1649 {
1650  return matrix_.capacity();
1651 }
1653 //*************************************************************************************************
1654 
1655 
1656 //*************************************************************************************************
1667 template< typename MT // Type of the adapted sparse matrix
1668  , bool SO > // Storage order of the adapted sparse matrix
1669 inline size_t SymmetricMatrix<MT,SO,false,false>::capacity( size_t i ) const noexcept
1670 {
1671  return matrix_.capacity(i);
1672 }
1674 //*************************************************************************************************
1675 
1676 
1677 //*************************************************************************************************
1683 template< typename MT // Type of the adapted sparse matrix
1684  , bool SO > // Storage order of the adapted sparse matrix
1686 {
1687  return matrix_.nonZeros();
1688 }
1690 //*************************************************************************************************
1691 
1692 
1693 //*************************************************************************************************
1705 template< typename MT // Type of the adapted sparse matrix
1706  , bool SO > // Storage order of the adapted sparse matrix
1707 inline size_t SymmetricMatrix<MT,SO,false,false>::nonZeros( size_t i ) const
1708 {
1709  return matrix_.nonZeros(i);
1710 }
1712 //*************************************************************************************************
1713 
1714 
1715 //*************************************************************************************************
1721 template< typename MT // Type of the adapted sparse matrix
1722  , bool SO > // Storage order of the adapted sparse matrix
1724 {
1725  matrix_.reset();
1726 }
1728 //*************************************************************************************************
1729 
1730 
1731 //*************************************************************************************************
1771 template< typename MT // Type of the adapted sparse matrix
1772  , bool SO > // Storage order of the adapted sparse matrix
1773 inline void SymmetricMatrix<MT,SO,false,false>::reset( size_t i )
1774 {
1775  using blaze::erase;
1776 
1777  for( auto it=matrix_.begin(i); it!=matrix_.end(i); ++it )
1778  {
1779  const size_t j( it->index() );
1780 
1781  if( i == j )
1782  continue;
1783 
1784  if( SO ) {
1785  const Iterator_t<MatrixType> pos( matrix_.find( i, j ) );
1786  BLAZE_INTERNAL_ASSERT( pos != matrix_.end( j ), "Missing element detected" );
1787  erase( matrix_, j, pos );
1788  }
1789  else {
1790  const Iterator_t<MatrixType> pos( matrix_.find( j, i ) );
1791  BLAZE_INTERNAL_ASSERT( pos != matrix_.end( j ), "Missing element detected" );
1792  erase( matrix_, j, pos );
1793  }
1794  }
1795 
1796  matrix_.reset( i );
1797 }
1799 //*************************************************************************************************
1800 
1801 
1802 //*************************************************************************************************
1810 template< typename MT // Type of the adapted sparse matrix
1811  , bool SO > // Storage order of the adapted sparse matrix
1813 {
1814  using blaze::clear;
1815 
1816  clear( matrix_ );
1817 }
1819 //*************************************************************************************************
1820 
1821 
1822 //*************************************************************************************************
1837 template< typename MT // Type of the adapted sparse matrix
1838  , bool SO > // Storage order of the adapted sparse matrix
1839 void SymmetricMatrix<MT,SO,false,false>::resize( size_t n, bool preserve )
1840 {
1842 
1843  UNUSED_PARAMETER( preserve );
1844 
1845  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1846 
1847  matrix_.resize( n, n, true );
1848 }
1850 //*************************************************************************************************
1851 
1852 
1853 //*************************************************************************************************
1864 template< typename MT // Type of the adapted sparse matrix
1865  , bool SO > // Storage order of the adapted sparse matrix
1866 inline void SymmetricMatrix<MT,SO,false,false>::reserve( size_t nonzeros )
1867 {
1868  matrix_.reserve( nonzeros );
1869 }
1871 //*************************************************************************************************
1872 
1873 
1874 //*************************************************************************************************
1888 template< typename MT // Type of the adapted sparse matrix
1889  , bool SO > // Storage order of the adapted sparse matrix
1890 inline void SymmetricMatrix<MT,SO,false,false>::reserve( size_t i, size_t nonzeros )
1891 {
1892  matrix_.reserve( i, nonzeros );
1893 }
1895 //*************************************************************************************************
1896 
1897 
1898 //*************************************************************************************************
1909 template< typename MT // Type of the adapted sparse matrix
1910  , bool SO > // Storage order of the adapted sparse matrix
1911 inline void SymmetricMatrix<MT,SO,false,false>::trim()
1912 {
1913  matrix_.trim();
1914 }
1916 //*************************************************************************************************
1917 
1918 
1919 //*************************************************************************************************
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>::trim( size_t i )
1934 {
1935  matrix_.trim( i );
1936 }
1938 //*************************************************************************************************
1939 
1940 
1941 //*************************************************************************************************
1951 template< typename MT // Type of the adapted sparse matrix
1952  , bool SO > // Storage order of the adapted sparse matrix
1954 {
1955  matrix_.shrinkToFit();
1956 }
1958 //*************************************************************************************************
1959 
1960 
1961 //*************************************************************************************************
1968 template< typename MT // Type of the adapted sparse matrix
1969  , bool SO > // Storage order of the adapted sparse matrix
1970 inline void SymmetricMatrix<MT,SO,false,false>::swap( SymmetricMatrix& m ) noexcept
1971 {
1972  using std::swap;
1973 
1974  swap( matrix_, m.matrix_ );
1975 }
1977 //*************************************************************************************************
1978 
1979 
1980 
1981 
1982 //=================================================================================================
1983 //
1984 // INSERTION FUNCTIONS
1985 //
1986 //=================================================================================================
1987 
1988 //*************************************************************************************************
2002 template< typename MT // Type of the adapted sparse matrix
2003  , bool SO > // Storage order of the adapted sparse matrix
2005  SymmetricMatrix<MT,SO,false,false>::set( size_t i, size_t j, const ElementType& value )
2006 {
2007  SharedValue<ET> shared( value );
2008 
2009  if( i != j )
2010  matrix_.set( j, i, shared );
2011 
2012  return Iterator( matrix_.set( i, j, shared ) );
2013 }
2015 //*************************************************************************************************
2016 
2017 
2018 //*************************************************************************************************
2033 template< typename MT // Type of the adapted sparse matrix
2034  , bool SO > // Storage order of the adapted sparse matrix
2036  SymmetricMatrix<MT,SO,false,false>::insert( size_t i, size_t j, const ElementType& value )
2037 {
2038  SharedValue<ET> shared( value );
2039 
2040  if( i != j )
2041  matrix_.insert( j, i, shared );
2042 
2043  return Iterator( matrix_.insert( i, j, shared ) );
2044 }
2046 //*************************************************************************************************
2047 
2048 
2049 //*************************************************************************************************
2104 template< typename MT // Type of the adapted sparse matrix
2105  , bool SO > // Storage order of the adapted sparse matrix
2106 inline void SymmetricMatrix<MT,SO,false,false>::append( size_t i, size_t j, const ElementType& value, bool check )
2107 {
2108  SharedValue<ET> shared( value );
2109 
2110  matrix_.append( i, j, shared, check );
2111  if( i != j && ( !check || !isDefault<strict>( value ) ) )
2112  matrix_.insert( j, i, shared );
2113 }
2115 //*************************************************************************************************
2116 
2117 
2118 //*************************************************************************************************
2132 template< typename MT // Type of the adapted sparse matrix
2133  , bool SO > // Storage order of the adapted sparse matrix
2134 inline void SymmetricMatrix<MT,SO,false,false>::finalize( size_t i )
2135 {
2136  matrix_.trim( i );
2137 }
2139 //*************************************************************************************************
2140 
2141 
2142 
2143 
2144 //=================================================================================================
2145 //
2146 // ERASE FUNCTIONS
2147 //
2148 //=================================================================================================
2149 
2150 //*************************************************************************************************
2160 template< typename MT // Type of the adapted sparse matrix
2161  , bool SO > // Storage order of the adapted sparse matrix
2162 inline void SymmetricMatrix<MT,SO,false,false>::erase( size_t i, size_t j )
2163 {
2164  using blaze::erase;
2165 
2166  erase( matrix_, i, j );
2167  if( i != j )
2168  erase( matrix_, j, i );
2169 }
2171 //*************************************************************************************************
2172 
2173 
2174 //*************************************************************************************************
2186 template< typename MT // Type of the adapted sparse matrix
2187  , bool SO > // Storage order of the adapted sparse matrix
2189  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator pos )
2190 {
2191  using blaze::erase;
2192 
2193  if( pos == end( i ) )
2194  return pos;
2195 
2196  const size_t j( pos->index() );
2197 
2198  if( i == j )
2199  return Iterator( erase( matrix_, i, pos.base() ) );
2200 
2201  if( SO ) {
2202  BLAZE_INTERNAL_ASSERT( matrix_.find( i, j ) != matrix_.end( j ), "Missing element detected" );
2203  erase( matrix_, j, matrix_.find( i, j ) );
2204  return Iterator( erase( matrix_, i, pos.base() ) );
2205  }
2206  else {
2207  BLAZE_INTERNAL_ASSERT( matrix_.find( j, i ) != matrix_.end( j ), "Missing element detected" );
2208  erase( matrix_, j, matrix_.find( j, i ) );
2209  return Iterator( erase( matrix_, i, pos.base() ) );
2210  }
2211 }
2213 //*************************************************************************************************
2214 
2215 
2216 //*************************************************************************************************
2230 template< typename MT // Type of the adapted sparse matrix
2231  , bool SO > // Storage order of the adapted sparse matrix
2233  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator first, Iterator last )
2234 {
2235  using blaze::erase;
2236 
2237  for( auto it=first; it!=last; ++it )
2238  {
2239  const size_t j( it->index() );
2240 
2241  if( i == j )
2242  continue;
2243 
2244  if( SO ) {
2245  BLAZE_INTERNAL_ASSERT( matrix_.find( i, j ) != matrix_.end( j ), "Missing element detected" );
2246  erase( matrix_, i, j );
2247  }
2248  else {
2249  BLAZE_INTERNAL_ASSERT( matrix_.find( j, i ) != matrix_.end( j ), "Missing element detected" );
2250  erase( matrix_, j, i );
2251  }
2252  }
2253 
2254  return Iterator( erase( matrix_, i, first.base(), last.base() ) );
2255 }
2257 //*************************************************************************************************
2258 
2259 
2260 //*************************************************************************************************
2274 template< typename MT // Type of the adapted sparse matrix
2275  , bool SO > // Storage order of the adapted sparse matrix
2276 template< typename Pred > // Type of the unary predicate
2277 inline void SymmetricMatrix<MT,SO,false,false>::erase( Pred predicate )
2278 {
2279  using blaze::erase;
2280 
2281  erase( matrix_, [predicate=predicate]( const SharedValue<ET>& value ) {
2282  return predicate( *value );
2283  } );
2284 
2285  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2286 }
2288 //*************************************************************************************************
2289 
2290 
2291 //*************************************************************************************************
2310 template< typename MT // Type of the adapted sparse matrix
2311  , bool SO > // Storage order of the adapted sparse matrix
2312 template< typename Pred > // Type of the unary predicate
2313 inline void
2314  SymmetricMatrix<MT,SO,false,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
2315 {
2316  using blaze::erase;
2317 
2318  for( auto it=first; it!=last; ++it ) {
2319  const size_t j( it->index() );
2320  if( i != j && predicate( it->value() ) ) {
2321  if( SO )
2322  erase( matrix_, i, j );
2323  else
2324  erase( matrix_, j, i );
2325  }
2326  }
2327 
2328  erase( matrix_, i, first.base(), last.base(),
2329  [predicate=predicate]( const SharedValue<ET>& value ) {
2330  return predicate( *value );
2331  } );
2332 
2333  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2334 }
2336 //*************************************************************************************************
2337 
2338 
2339 
2340 
2341 //=================================================================================================
2342 //
2343 // LOOKUP FUNCTIONS
2344 //
2345 //=================================================================================================
2346 
2347 //*************************************************************************************************
2363 template< typename MT // Type of the adapted sparse matrix
2364  , bool SO > // Storage order of the adapted sparse matrix
2366  SymmetricMatrix<MT,SO,false,false>::find( size_t i, size_t j )
2367 {
2368  return Iterator( matrix_.find( i, j ) );
2369 }
2371 //*************************************************************************************************
2372 
2373 
2374 //*************************************************************************************************
2390 template< typename MT // Type of the adapted sparse matrix
2391  , bool SO > // Storage order of the adapted sparse matrix
2393  SymmetricMatrix<MT,SO,false,false>::find( size_t i, size_t j ) const
2394 {
2395  return ConstIterator( matrix_.find( i, j ) );
2396 }
2398 //*************************************************************************************************
2399 
2400 
2401 //*************************************************************************************************
2417 template< typename MT // Type of the adapted sparse matrix
2418  , bool SO > // Storage order of the adapted sparse matrix
2420  SymmetricMatrix<MT,SO,false,false>::lowerBound( size_t i, size_t j )
2421 {
2422  return Iterator( matrix_.lowerBound( i, j ) );
2423 }
2425 //*************************************************************************************************
2426 
2427 
2428 //*************************************************************************************************
2444 template< typename MT // Type of the adapted sparse matrix
2445  , bool SO > // Storage order of the adapted sparse matrix
2447  SymmetricMatrix<MT,SO,false,false>::lowerBound( size_t i, size_t j ) const
2448 {
2449  return ConstIterator( matrix_.lowerBound( i, j ) );
2450 }
2452 //*************************************************************************************************
2453 
2454 
2455 //*************************************************************************************************
2471 template< typename MT // Type of the adapted sparse matrix
2472  , bool SO > // Storage order of the adapted sparse matrix
2474  SymmetricMatrix<MT,SO,false,false>::upperBound( size_t i, size_t j )
2475 {
2476  return Iterator( matrix_.upperBound( i, j ) );
2477 }
2479 //*************************************************************************************************
2480 
2481 
2482 //*************************************************************************************************
2498 template< typename MT // Type of the adapted sparse matrix
2499  , bool SO > // Storage order of the adapted sparse matrix
2501  SymmetricMatrix<MT,SO,false,false>::upperBound( size_t i, size_t j ) const
2502 {
2503  return ConstIterator( matrix_.upperBound( i, j ) );
2504 }
2506 //*************************************************************************************************
2507 
2508 
2509 
2510 
2511 //=================================================================================================
2512 //
2513 // NUMERIC FUNCTIONS
2514 //
2515 //=================================================================================================
2516 
2517 //*************************************************************************************************
2523 template< typename MT // Type of the adapted sparse matrix
2524  , bool SO > // Storage order of the adapted sparse matrix
2525 inline SymmetricMatrix<MT,SO,false,false>& SymmetricMatrix<MT,SO,false,false>::transpose()
2526 {
2527  return *this;
2528 }
2530 //*************************************************************************************************
2531 
2532 
2533 //*************************************************************************************************
2539 template< typename MT // Type of the adapted sparse matrix
2540  , bool SO > // Storage order of the adapted sparse matrix
2541 inline SymmetricMatrix<MT,SO,false,false>& SymmetricMatrix<MT,SO,false,false>::ctranspose()
2542 {
2543  for( size_t i=0UL; i<rows(); ++i ) {
2544  const auto last( matrix_.upperBound(i,i) );
2545  for( auto element=matrix_.begin(i); element!=last; ++element )
2546  conjugate( *element->value() );
2547  }
2548 
2549  return *this;
2550 }
2552 //*************************************************************************************************
2553 
2554 
2555 //*************************************************************************************************
2573 template< typename MT // Type of the adapted sparse matrix
2574  , bool SO > // Storage order of the adapted sparse matrix
2575 template< typename Other > // Data type of the scalar value
2576 inline SymmetricMatrix<MT,SO,false,false>&
2577  SymmetricMatrix<MT,SO,false,false>::scale( const Other& scalar )
2578 {
2579  for( size_t i=0UL; i<rows(); ++i ) {
2580  const auto last( matrix_.upperBound(i,i) );
2581  for( auto element=matrix_.begin(i); element!=last; ++element )
2582  ( *element->value() ).scale( scalar );
2583  }
2584 
2585  return *this;
2586 }
2588 //*************************************************************************************************
2589 
2590 
2591 
2592 
2593 //=================================================================================================
2594 //
2595 // DEBUGGING FUNCTIONS
2596 //
2597 //=================================================================================================
2598 
2599 //*************************************************************************************************
2609 template< typename MT // Type of the adapted dense matrix
2610  , bool SO > // Storage order of the adapted dense matrix
2611 inline bool SymmetricMatrix<MT,SO,false,false>::isIntact() const noexcept
2612 {
2613  using blaze::isIntact;
2614 
2615  return ( isIntact( matrix_ ) && isSymmetric( matrix_ ) );
2616 }
2618 //*************************************************************************************************
2619 
2620 
2621 
2622 
2623 //=================================================================================================
2624 //
2625 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2626 //
2627 //=================================================================================================
2628 
2629 //*************************************************************************************************
2640 template< typename MT // Type of the adapted sparse matrix
2641  , bool SO > // Storage order of the adapted sparse matrix
2642 template< typename Other > // Data type of the foreign expression
2643 inline bool SymmetricMatrix<MT,SO,false,false>::canAlias( const Other* alias ) const noexcept
2644 {
2645  return matrix_.canAlias( alias );
2646 }
2648 //*************************************************************************************************
2649 
2650 
2651 //*************************************************************************************************
2662 template< typename MT // Type of the adapted sparse matrix
2663  , bool SO > // Storage order of the adapted sparse matrix
2664 template< typename Other > // Data type of the foreign expression
2665 inline bool SymmetricMatrix<MT,SO,false,false>::isAliased( const Other* alias ) const noexcept
2666 {
2667  return matrix_.isAliased( alias );
2668 }
2670 //*************************************************************************************************
2671 
2672 
2673 //*************************************************************************************************
2684 template< typename MT // Type of the adapted sparse matrix
2685  , bool SO > // Storage order of the adapted sparse matrix
2686 inline bool SymmetricMatrix<MT,SO,false,false>::canSMPAssign() const noexcept
2687 {
2688  return matrix_.canSMPAssign();
2689 }
2691 //*************************************************************************************************
2692 
2693 
2694 //*************************************************************************************************
2706 template< typename MT // Type of the adapted sparse matrix
2707  , bool SO > // Storage order of the adapted sparse matrix
2708 template< typename MT2 > // Type of the right-hand side dense matrix
2709 void SymmetricMatrix<MT,SO,false,false>::assign( DenseMatrix<MT2,SO>& rhs )
2710 {
2712 
2713  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2714  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2715 
2716  std::vector<size_t> nonzeros( rows(), 0UL );
2717  size_t sum( 0UL );
2718 
2719  for( size_t i=0UL; i<rows(); ++i ) {
2720  nonzeros[i] = (~rhs).nonZeros(i);
2721  sum += nonzeros[i];
2722  }
2723 
2724  matrix_.reserve( sum );
2725  for( size_t i=0UL; i<rows(); ++i ) {
2726  matrix_.reserve( i, nonzeros[i] );
2727  }
2728 
2729  for( size_t i=0UL; i<rows(); ++i ) {
2730  for( size_t j=i; j<columns(); ++j ) {
2731  if( !isDefault( (~rhs)(i,j) ) ) {
2732  SharedValue<ET> shared;
2733  *shared = std::move( (~rhs)(i,j) );
2734  matrix_.append( i, j, shared, false );
2735  if( i != j )
2736  matrix_.append( j, i, shared, false );
2737  }
2738  }
2739  }
2740 }
2742 //*************************************************************************************************
2743 
2744 
2745 //*************************************************************************************************
2757 template< typename MT // Type of the adapted sparse matrix
2758  , bool SO > // Storage order of the adapted sparse matrix
2759 template< typename MT2 > // Type of the right-hand side dense matrix
2760 void SymmetricMatrix<MT,SO,false,false>::assign( const DenseMatrix<MT2,SO>& rhs )
2761 {
2763 
2764  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2765  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2766 
2767  std::vector<size_t> nonzeros( rows(), 0UL );
2768  size_t sum( 0UL );
2769 
2770  for( size_t i=0UL; i<rows(); ++i ) {
2771  nonzeros[i] = (~rhs).nonZeros(i);
2772  sum += nonzeros[i];
2773  }
2774 
2775  matrix_.reserve( sum );
2776  for( size_t i=0UL; i<rows(); ++i ) {
2777  matrix_.reserve( i, nonzeros[i] );
2778  }
2779 
2780  for( size_t i=0UL; i<rows(); ++i ) {
2781  for( size_t j=i; j<columns(); ++j ) {
2782  if( !isDefault( (~rhs)(i,j) ) ) {
2783  const SharedValue<ET> shared( (~rhs)(i,j) );
2784  matrix_.append( i, j, shared, false );
2785  if( i != j )
2786  matrix_.append( j, i, shared, false );
2787  }
2788  }
2789  }
2790 }
2792 //*************************************************************************************************
2793 
2794 
2795 //*************************************************************************************************
2807 template< typename MT // Type of the adapted sparse matrix
2808  , bool SO > // Storage order of the adapted sparse matrix
2809 template< typename MT2 > // Type of the right-hand side sparse matrix
2810 void SymmetricMatrix<MT,SO,false,false>::assign( SparseMatrix<MT2,SO>& rhs )
2811 {
2813 
2814  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2815  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2816 
2817  std::vector<size_t> nonzeros( rows(), 0UL );
2818  size_t sum( 0UL );
2819 
2820  for( size_t i=0UL; i<rows(); ++i ) {
2821  nonzeros[i] = (~rhs).nonZeros(i);
2822  sum += nonzeros[i];
2823  }
2824 
2825  matrix_.reserve( sum );
2826  for( size_t i=0UL; i<rows(); ++i ) {
2827  matrix_.reserve( i, nonzeros[i] );
2828  }
2829 
2830  for( size_t i=0UL; i<rows(); ++i ) {
2831  for( auto it=(~rhs).lowerBound(i,i); it!=(~rhs).end(i); ++it ) {
2832  if( !isDefault( it->value() ) ) {
2833  SharedValue<ET> shared;
2834  *shared = std::move( it->value() );
2835  matrix_.append( i, it->index(), shared, false );
2836  if( i != it->index() )
2837  matrix_.append( it->index(), i, shared, false );
2838  }
2839  }
2840  }
2841 }
2843 //*************************************************************************************************
2844 
2845 
2846 //*************************************************************************************************
2858 template< typename MT // Type of the adapted sparse matrix
2859  , bool SO > // Storage order of the adapted sparse matrix
2860 template< typename MT2 > // Type of the right-hand side sparse matrix
2861 void SymmetricMatrix<MT,SO,false,false>::assign( const SparseMatrix<MT2,SO>& rhs )
2862 {
2864 
2865  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2866  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2867 
2868  std::vector<size_t> nonzeros( rows(), 0UL );
2869  size_t sum( 0UL );
2870 
2871  for( size_t i=0UL; i<rows(); ++i ) {
2872  nonzeros[i] = (~rhs).nonZeros(i);
2873  sum += nonzeros[i];
2874  }
2875 
2876  matrix_.reserve( sum );
2877  for( size_t i=0UL; i<rows(); ++i ) {
2878  matrix_.reserve( i, nonzeros[i] );
2879  }
2880 
2881  for( size_t i=0UL; i<rows(); ++i ) {
2882  for( auto it=(~rhs).lowerBound(i,i); it!=(~rhs).end(i); ++it ) {
2883  if( !isDefault( it->value() ) ) {
2884  const SharedValue<ET> shared( it->value() );
2885  matrix_.append( i, it->index(), shared, false );
2886  if( i != it->index() )
2887  matrix_.append( it->index(), i, shared, false );
2888  }
2889  }
2890  }
2891 }
2893 //*************************************************************************************************
2894 
2895 } // namespace blaze
2896 
2897 #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:3078
Header file for the Schur product trait.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
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:354
Header file for the UNUSED_PARAMETER function template.
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.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3077
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
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
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:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:799
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5828
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3079
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3084
#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
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
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:673
Header file for the DisableIf class template.
Header file for the IsSymmetric type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3083
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5907
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:5890
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
#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:3080
#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:2146
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
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.
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
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:8908
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:611
Header file for the NonNumericProxy class.
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
#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 T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
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, 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:281
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:539
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
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 &#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:3082
#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
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:290
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
#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
bool isDefault(const CompressedMatrix< Type, SO > &m)
Returns whether the given compressed matrix is in default state.
Definition: CompressedMatrix.h:5863
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
#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
Header file for the Size type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
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
Header file for the clear shim.
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825