Sparse.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_DIAGONALMATRIX_SPARSE_H_
36 #define _BLAZE_MATH_ADAPTORS_DIAGONALMATRIX_SPARSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <vector>
44 #include <utility>
47 #include <blaze/math/Aliases.h>
57 #include <blaze/math/Exception.h>
60 #include <blaze/math/shims/Clear.h>
67 #include <blaze/util/Assert.h>
72 #include <blaze/util/DisableIf.h>
73 #include <blaze/util/EnableIf.h>
75 #include <blaze/util/Types.h>
76 
77 
78 namespace blaze {
79 
80 //=================================================================================================
81 //
82 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
83 //
84 //=================================================================================================
85 
86 //*************************************************************************************************
94 template< typename MT // Type of the adapted sparse matrix
95  , bool SO > // Storage order of the adapted sparse matrix
96 class DiagonalMatrix<MT,SO,false>
97  : public SparseMatrix< DiagonalMatrix<MT,SO,false>, SO >
98 {
99  private:
100  //**Type definitions****************************************************************************
101  using OT = OppositeType_t<MT>;
102  using TT = TransposeType_t<MT>;
103  using ET = ElementType_t<MT>;
104  //**********************************************************************************************
105 
106  public:
107  //**Type definitions****************************************************************************
108  using This = DiagonalMatrix<MT,SO,false>;
109  using BaseType = SparseMatrix<This,SO>;
110  using ResultType = This;
111  using OppositeType = DiagonalMatrix<OT,!SO,false>;
112  using TransposeType = DiagonalMatrix<TT,!SO,false>;
113  using ElementType = ET;
114  using ReturnType = ReturnType_t<MT>;
115  using CompositeType = const This&;
116  using Reference = DiagonalProxy<MT>;
117  using ConstReference = ConstReference_t<MT>;
118  using Iterator = Iterator_t<MT>;
119  using ConstIterator = ConstIterator_t<MT>;
120  //**********************************************************************************************
121 
122  //**Rebind struct definition********************************************************************
125  template< typename NewType > // Data type of the other matrix
126  struct Rebind {
128  using Other = DiagonalMatrix< typename MT::template Rebind<NewType>::Other >;
129  };
130  //**********************************************************************************************
131 
132  //**Resize struct definition********************************************************************
135  template< size_t NewM // Number of rows of the other matrix
136  , size_t NewN > // Number of columns of the other matrix
137  struct Resize {
139  using Other = DiagonalMatrix< typename MT::template Resize<NewM,NewN>::Other >;
140  };
141  //**********************************************************************************************
142 
143  //**Compilation flags***************************************************************************
145  static constexpr bool smpAssignable = false;
146  //**********************************************************************************************
147 
148  //**Constructors********************************************************************************
151  explicit inline DiagonalMatrix();
152  explicit inline DiagonalMatrix( size_t n );
153  explicit inline DiagonalMatrix( size_t n, size_t nonzeros );
154  explicit inline DiagonalMatrix( size_t n, const std::vector<size_t>& nonzeros );
155  explicit inline DiagonalMatrix( initializer_list< initializer_list<ElementType> > list );
156 
157  inline DiagonalMatrix( const DiagonalMatrix& m );
158  inline DiagonalMatrix( DiagonalMatrix&& m ) noexcept;
159 
160  template< typename MT2, bool SO2 >
161  inline DiagonalMatrix( const Matrix<MT2,SO2>& m );
163  //**********************************************************************************************
164 
165  //**Destructor**********************************************************************************
168  ~DiagonalMatrix() = default;
170  //**********************************************************************************************
171 
172  //**Data access functions***********************************************************************
175  inline Reference operator()( size_t i, size_t j );
176  inline ConstReference operator()( size_t i, size_t j ) const;
177  inline Reference at( size_t i, size_t j );
178  inline ConstReference at( size_t i, size_t j ) const;
179  inline Iterator begin ( size_t i );
180  inline ConstIterator begin ( size_t i ) const;
181  inline ConstIterator cbegin( size_t i ) const;
182  inline Iterator end ( size_t i );
183  inline ConstIterator end ( size_t i ) const;
184  inline ConstIterator cend ( size_t i ) const;
186  //**********************************************************************************************
187 
188  //**Assignment operators************************************************************************
191  inline DiagonalMatrix& operator=( initializer_list< initializer_list<ElementType> > list );
192 
193  inline DiagonalMatrix& operator=( const DiagonalMatrix& rhs );
194  inline DiagonalMatrix& operator=( DiagonalMatrix&& rhs ) noexcept;
195 
196  template< typename MT2, bool SO2 >
197  inline auto operator=( const Matrix<MT2,SO2>& rhs )
198  -> DisableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >;
199 
200  template< typename MT2, bool SO2 >
201  inline auto operator=( const Matrix<MT2,SO2>& rhs )
202  -> EnableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >;
203 
204  template< typename MT2, bool SO2 >
205  inline auto operator+=( const Matrix<MT2,SO2>& rhs )
206  -> DisableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >;
207 
208  template< typename MT2, bool SO2 >
209  inline auto operator+=( const Matrix<MT2,SO2>& rhs )
210  -> EnableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >;
211 
212  template< typename MT2, bool SO2 >
213  inline auto operator-=( const Matrix<MT2,SO2>& rhs )
214  -> DisableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >;
215 
216  template< typename MT2, bool SO2 >
217  inline auto operator-=( const Matrix<MT2,SO2>& rhs )
218  -> EnableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >;
219 
220  template< typename MT2, bool SO2 >
221  inline auto operator%=( const Matrix<MT2,SO2>& rhs ) -> DiagonalMatrix&;
223  //**********************************************************************************************
224 
225  //**Utility functions***************************************************************************
228  inline size_t rows() const noexcept;
229  inline size_t columns() const noexcept;
230  inline size_t capacity() const noexcept;
231  inline size_t capacity( size_t i ) const noexcept;
232  inline size_t nonZeros() const;
233  inline size_t nonZeros( size_t i ) const;
234  inline void reset();
235  inline void reset( size_t i );
236  inline void clear();
237  inline void resize ( size_t n, bool preserve=true );
238  inline void reserve( size_t nonzeros );
239  inline void reserve( size_t i, size_t nonzeros );
240  inline void trim();
241  inline void trim( size_t i );
242  inline void shrinkToFit();
243  inline void swap( DiagonalMatrix& m ) noexcept;
245  //**********************************************************************************************
246 
247  //**Insertion functions*************************************************************************
250  inline Iterator set ( size_t i, size_t j, const ElementType& value );
251  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
252  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
253  inline void finalize( size_t i );
255  //**********************************************************************************************
256 
257  //**Erase functions*****************************************************************************
260  inline void erase( size_t i, size_t j );
261  inline Iterator erase( size_t i, Iterator pos );
262  inline Iterator erase( size_t i, Iterator first, Iterator last );
263 
264  template< typename Pred >
265  inline void erase( Pred predicate );
266 
267  template< typename Pred >
268  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
270  //**********************************************************************************************
271 
272  //**Lookup functions****************************************************************************
275  inline Iterator find ( size_t i, size_t j );
276  inline ConstIterator find ( size_t i, size_t j ) const;
277  inline Iterator lowerBound( size_t i, size_t j );
278  inline ConstIterator lowerBound( size_t i, size_t j ) const;
279  inline Iterator upperBound( size_t i, size_t j );
280  inline ConstIterator upperBound( size_t i, size_t j ) const;
282  //**********************************************************************************************
283 
284  //**Numeric functions***************************************************************************
287  template< typename Other > inline DiagonalMatrix& scale( const Other& scalar );
289  //**********************************************************************************************
290 
291  //**Debugging functions*************************************************************************
294  inline bool isIntact() const noexcept;
296  //**********************************************************************************************
297 
298  //**Expression template evaluation functions****************************************************
301  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
302  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
303 
304  inline bool canSMPAssign() const noexcept;
306  //**********************************************************************************************
307 
308  private:
309  //**Utility functions***************************************************************************
312  inline void resetNonDiagonal();
314  //**********************************************************************************************
315 
316  //**Member variables****************************************************************************
319  MT matrix_;
320 
321  //**********************************************************************************************
322 
323  //**Friend declarations*************************************************************************
324  template< bool RF, typename MT2, bool SO2, bool DF2 >
325  friend bool isDefault( const DiagonalMatrix<MT2,SO2,DF2>& m );
326 
327  template< typename MT2, bool SO2, bool DF2 >
328  friend MT2& derestrict( DiagonalMatrix<MT2,SO2,DF2>& m );
329  //**********************************************************************************************
330 
331  //**Compile time checks*************************************************************************
344  BLAZE_STATIC_ASSERT( ( Size_v<MT,0UL> == Size_v<MT,1UL> ) );
345  //**********************************************************************************************
346 };
348 //*************************************************************************************************
349 
350 
351 
352 
353 //=================================================================================================
354 //
355 // CONSTRUCTORS
356 //
357 //=================================================================================================
358 
359 //*************************************************************************************************
363 template< typename MT // Type of the adapted sparse matrix
364  , bool SO > // Storage order of the adapted sparse matrix
365 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix()
366  : matrix_() // The adapted sparse matrix
367 {
368  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
369 }
371 //*************************************************************************************************
372 
373 
374 //*************************************************************************************************
382 template< typename MT // Type of the adapted sparse matrix
383  , bool SO > // Storage order of the adapted sparse matrix
384 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n )
385  : matrix_( n, n ) // The adapted sparse matrix
386 {
388 
389  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
390 }
392 //*************************************************************************************************
393 
394 
395 //*************************************************************************************************
404 template< typename MT // Type of the adapted sparse matrix
405  , bool SO > // Storage order of the adapted sparse matrix
406 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n, size_t nonzeros )
407  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
408 {
410 
411  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
412 }
414 //*************************************************************************************************
415 
416 
417 //*************************************************************************************************
428 template< typename MT // Type of the adapted sparse matrix
429  , bool SO > // Storage order of the adapted sparse matrix
430 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n, const std::vector<size_t>& nonzeros )
431  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
432 {
434 
435  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
436 }
438 //*************************************************************************************************
439 
440 
441 //*************************************************************************************************
465 template< typename MT // Type of the adapted sparse matrix
466  , bool SO > // Storage order of the adapted sparse matrix
467 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( initializer_list< initializer_list<ElementType> > list )
468  : matrix_( list ) // The adapted sparse matrix
469 {
470  if( !isDiagonal( matrix_ ) ) {
471  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
472  }
473 
474  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
475 }
477 //*************************************************************************************************
478 
479 
480 //*************************************************************************************************
486 template< typename MT // Type of the adapted sparse matrix
487  , bool SO > // Storage order of the adapted sparse matrix
488 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( const DiagonalMatrix& m )
489  : matrix_( m.matrix_ ) // The adapted sparse matrix
490 {
491  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
492  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
493 }
495 //*************************************************************************************************
496 
497 
498 //*************************************************************************************************
504 template< typename MT // Type of the adapted sparse matrix
505  , bool SO > // Storage order of the adapted sparse matrix
506 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( DiagonalMatrix&& m ) noexcept
507  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
508 {
509  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
510  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
511 }
513 //*************************************************************************************************
514 
515 
516 //*************************************************************************************************
526 template< typename MT // Type of the adapted sparse matrix
527  , bool SO > // Storage order of the adapted sparse matrix
528 template< typename MT2 // Type of the foreign matrix
529  , bool SO2 > // Storage order of the foreign matrix
530 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( const Matrix<MT2,SO2>& m )
531  : matrix_( ~m ) // The adapted sparse matrix
532 {
533  if( !IsDiagonal_v<MT2> && !isDiagonal( matrix_ ) ) {
534  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
535  }
536 
537  if( !IsDiagonal_v<MT2> )
538  resetNonDiagonal();
539 
540  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
541  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
542 }
544 //*************************************************************************************************
545 
546 
547 
548 
549 //=================================================================================================
550 //
551 // DATA ACCESS FUNCTIONS
552 //
553 //=================================================================================================
554 
555 //*************************************************************************************************
571 template< typename MT // Type of the adapted sparse matrix
572  , bool SO > // Storage order of the adapted sparse matrix
574  DiagonalMatrix<MT,SO,false>::operator()( size_t i, size_t j )
575 {
576  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
577  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
578 
579  return Reference( matrix_, i, j );
580 }
582 //*************************************************************************************************
583 
584 
585 //*************************************************************************************************
601 template< typename MT // Type of the adapted sparse matrix
602  , bool SO > // Storage order of the adapted sparse matrix
604  DiagonalMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
605 {
606  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
607  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
608 
609  return matrix_(i,j);
610 }
612 //*************************************************************************************************
613 
614 
615 //*************************************************************************************************
632 template< typename MT // Type of the adapted sparse matrix
633  , bool SO > // Storage order of the adapted sparse matrix
635  DiagonalMatrix<MT,SO,false>::at( size_t i, size_t j )
636 {
637  if( i >= rows() ) {
638  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
639  }
640  if( j >= columns() ) {
641  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
642  }
643  return (*this)(i,j);
644 }
646 //*************************************************************************************************
647 
648 
649 //*************************************************************************************************
666 template< typename MT // Type of the adapted sparse matrix
667  , bool SO > // Storage order of the adapted sparse matrix
669  DiagonalMatrix<MT,SO,false>::at( size_t i, size_t j ) const
670 {
671  if( i >= rows() ) {
672  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
673  }
674  if( j >= columns() ) {
675  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
676  }
677  return (*this)(i,j);
678 }
680 //*************************************************************************************************
681 
682 
683 //*************************************************************************************************
695 template< typename MT // Type of the adapted sparse matrix
696  , bool SO > // Storage order of the adapted sparse matrix
699 {
700  return matrix_.begin(i);
701 }
703 //*************************************************************************************************
704 
705 
706 //*************************************************************************************************
718 template< typename MT // Type of the adapted sparse matrix
719  , bool SO > // Storage order of the adapted sparse matrix
721  DiagonalMatrix<MT,SO,false>::begin( size_t i ) const
722 {
723  return matrix_.begin(i);
724 }
726 //*************************************************************************************************
727 
728 
729 //*************************************************************************************************
741 template< typename MT // Type of the adapted sparse matrix
742  , bool SO > // Storage order of the adapted sparse matrix
744  DiagonalMatrix<MT,SO,false>::cbegin( size_t i ) const
745 {
746  return matrix_.cbegin(i);
747 }
749 //*************************************************************************************************
750 
751 
752 //*************************************************************************************************
764 template< typename MT // Type of the adapted sparse matrix
765  , bool SO > // Storage order of the adapted sparse matrix
768 {
769  return matrix_.end(i);
770 }
772 //*************************************************************************************************
773 
774 
775 //*************************************************************************************************
787 template< typename MT // Type of the adapted sparse matrix
788  , bool SO > // Storage order of the adapted sparse matrix
790  DiagonalMatrix<MT,SO,false>::end( size_t i ) const
791 {
792  return matrix_.end(i);
793 }
795 //*************************************************************************************************
796 
797 
798 //*************************************************************************************************
810 template< typename MT // Type of the adapted sparse matrix
811  , bool SO > // Storage order of the adapted sparse matrix
813  DiagonalMatrix<MT,SO,false>::cend( size_t i ) const
814 {
815  return matrix_.cend(i);
816 }
818 //*************************************************************************************************
819 
820 
821 
822 
823 //=================================================================================================
824 //
825 // ASSIGNMENT OPERATORS
826 //
827 //=================================================================================================
828 
829 //*************************************************************************************************
854 template< typename MT // Type of the adapted sparse matrix
855  , bool SO > // Storage order of the adapted sparse matrix
856 inline DiagonalMatrix<MT,SO,false>&
857  DiagonalMatrix<MT,SO,false>::operator=( initializer_list< initializer_list<ElementType> > list )
858 {
859  const InitializerMatrix<ElementType> tmp( list, list.size() );
860 
861  if( !isDiagonal( tmp ) ) {
862  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
863  }
864 
865  matrix_ = list;
866 
867  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
868  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
869 
870  return *this;
871 }
873 //*************************************************************************************************
874 
875 
876 //*************************************************************************************************
886 template< typename MT // Type of the adapted sparse matrix
887  , bool SO > // Storage order of the adapted sparse matrix
888 inline DiagonalMatrix<MT,SO,false>&
889  DiagonalMatrix<MT,SO,false>::operator=( const DiagonalMatrix& rhs )
890 {
891  matrix_ = rhs.matrix_;
892 
893  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
894  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
895 
896  return *this;
897 }
899 //*************************************************************************************************
900 
901 
902 //*************************************************************************************************
909 template< typename MT // Type of the adapted sparse matrix
910  , bool SO > // Storage order of the adapted sparse matrix
911 inline DiagonalMatrix<MT,SO,false>&
912  DiagonalMatrix<MT,SO,false>::operator=( DiagonalMatrix&& rhs ) noexcept
913 {
914  matrix_ = std::move( rhs.matrix_ );
915 
916  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
917  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
918 
919  return *this;
920 }
922 //*************************************************************************************************
923 
924 
925 //*************************************************************************************************
938 template< typename MT // Type of the adapted sparse matrix
939  , bool SO > // Storage order of the adapted sparse matrix
940 template< typename MT2 // Type of the right-hand side matrix
941  , bool SO2 > // Storage order of the right-hand side matrix
942 inline auto DiagonalMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
943  -> DisableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >
944 {
945  if( !IsDiagonal_v<MT2> && !isDiagonal( ~rhs ) ) {
946  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
947  }
948 
949  matrix_ = decldiag( ~rhs );
950 
951  if( !IsDiagonal_v<MT2> )
952  resetNonDiagonal();
953 
954  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
955  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
956 
957  return *this;
958 }
960 //*************************************************************************************************
961 
962 
963 //*************************************************************************************************
976 template< typename MT // Type of the adapted sparse matrix
977  , bool SO > // Storage order of the adapted sparse matrix
978 template< typename MT2 // Type of the right-hand side matrix
979  , bool SO2 > // Storage order of the right-hand side matrix
980 inline auto DiagonalMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
981  -> EnableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >
982 {
983  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
984  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
985  }
986 
987  if( IsDiagonal_v<MT2> ) {
988  matrix_ = ~rhs;
989  }
990  else {
991  MT tmp( ~rhs );
992 
993  if( !isDiagonal( tmp ) ) {
994  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
995  }
996 
997  matrix_ = std::move( tmp );
998  }
999 
1000  if( !IsDiagonal_v<MT2> )
1001  resetNonDiagonal();
1002 
1003  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1004  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1005 
1006  return *this;
1007 }
1009 //*************************************************************************************************
1010 
1011 
1012 //*************************************************************************************************
1025 template< typename MT // Type of the adapted sparse matrix
1026  , bool SO > // Storage order of the adapted sparse matrix
1027 template< typename MT2 // Type of the right-hand side matrix
1028  , bool SO2 > // Storage order of the right-hand side matrix
1029 inline auto DiagonalMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1030  -> DisableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >
1031 {
1032  if( !IsDiagonal_v<MT2> && !isDiagonal( ~rhs ) ) {
1033  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1034  }
1035 
1036  matrix_ += decldiag( ~rhs );
1037 
1038  if( !IsDiagonal_v<MT2> )
1039  resetNonDiagonal();
1040 
1041  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1042  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1043 
1044  return *this;
1045 }
1047 //*************************************************************************************************
1048 
1049 
1050 //*************************************************************************************************
1063 template< typename MT // Type of the adapted sparse matrix
1064  , bool SO > // Storage order of the adapted sparse matrix
1065 template< typename MT2 // Type of the right-hand side matrix
1066  , bool SO2 > // Storage order of the right-hand side matrix
1067 inline auto DiagonalMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1068  -> EnableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >
1069 {
1070  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1071  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1072  }
1073 
1074  if( IsDiagonal_v<MT2> ) {
1075  matrix_ += ~rhs;
1076  }
1077  else {
1078  const ResultType_t<MT2> tmp( ~rhs );
1079 
1080  if( !isDiagonal( tmp ) ) {
1081  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1082  }
1083 
1084  matrix_ += decldiag( tmp );
1085  }
1086 
1087  if( !IsDiagonal_v<MT2> )
1088  resetNonDiagonal();
1089 
1090  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1091  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1092 
1093  return *this;
1094 }
1096 //*************************************************************************************************
1097 
1098 
1099 //*************************************************************************************************
1112 template< typename MT // Type of the adapted sparse matrix
1113  , bool SO > // Storage order of the adapted sparse matrix
1114 template< typename MT2 // Type of the right-hand side matrix
1115  , bool SO2 > // Storage order of the right-hand side matrix
1116 inline auto DiagonalMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1117  -> DisableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >
1118 {
1119  if( !IsDiagonal_v<MT2> && !isDiagonal( ~rhs ) ) {
1120  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1121  }
1122 
1123  matrix_ -= decldiag( ~rhs );
1124 
1125  if( !IsDiagonal_v<MT2> )
1126  resetNonDiagonal();
1127 
1128  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1129  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1130 
1131  return *this;
1132 }
1134 //*************************************************************************************************
1135 
1136 
1137 //*************************************************************************************************
1150 template< typename MT // Type of the adapted sparse matrix
1151  , bool SO > // Storage order of the adapted sparse matrix
1152 template< typename MT2 // Type of the right-hand side matrix
1153  , bool SO2 > // Storage order of the right-hand side matrix
1154 inline auto DiagonalMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1155  -> EnableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >
1156 {
1157  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1158  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1159  }
1160 
1161  if( IsDiagonal_v<MT2> ) {
1162  matrix_ -= ~rhs;
1163  }
1164  else {
1165  const ResultType_t<MT2> tmp( ~rhs );
1166 
1167  if( !isDiagonal( tmp ) ) {
1168  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1169  }
1170 
1171  matrix_ -= decldiag( tmp );
1172  }
1173 
1174  if( !IsDiagonal_v<MT2> )
1175  resetNonDiagonal();
1176 
1177  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1178  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1179 
1180  return *this;
1181 }
1183 //*************************************************************************************************
1184 
1185 
1186 //*************************************************************************************************
1197 template< typename MT // Type of the adapted sparse matrix
1198  , bool SO > // Storage order of the adapted sparse matrix
1199 template< typename MT2 // Type of the right-hand side matrix
1200  , bool SO2 > // Storage order of the right-hand side matrix
1201 inline auto DiagonalMatrix<MT,SO,false>::operator%=( const Matrix<MT2,SO2>& rhs )
1202  -> DiagonalMatrix&
1203 {
1204  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1205  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1206  }
1207 
1208  matrix_ %= ~rhs;
1209 
1210  if( !IsDiagonal_v<MT2> )
1211  resetNonDiagonal();
1212 
1213  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1214  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1215 
1216  return *this;
1217 }
1219 //*************************************************************************************************
1220 
1221 
1222 
1223 
1224 //=================================================================================================
1225 //
1226 // UTILITY FUNCTIONS
1227 //
1228 //=================================================================================================
1229 
1230 //*************************************************************************************************
1236 template< typename MT // Type of the adapted sparse matrix
1237  , bool SO > // Storage order of the adapted sparse matrix
1238 inline size_t DiagonalMatrix<MT,SO,false>::rows() const noexcept
1239 {
1240  return matrix_.rows();
1241 }
1243 //*************************************************************************************************
1244 
1245 
1246 //*************************************************************************************************
1252 template< typename MT // Type of the adapted sparse matrix
1253  , bool SO > // Storage order of the adapted sparse matrix
1254 inline size_t DiagonalMatrix<MT,SO,false>::columns() const noexcept
1255 {
1256  return matrix_.columns();
1257 }
1259 //*************************************************************************************************
1260 
1261 
1262 //*************************************************************************************************
1268 template< typename MT // Type of the adapted sparse matrix
1269  , bool SO > // Storage order of the adapted sparse matrix
1270 inline size_t DiagonalMatrix<MT,SO,false>::capacity() const noexcept
1271 {
1272  return matrix_.capacity();
1273 }
1275 //*************************************************************************************************
1276 
1277 
1278 //*************************************************************************************************
1290 template< typename MT // Type of the adapted sparse matrix
1291  , bool SO > // Storage order of the adapted sparse matrix
1292 inline size_t DiagonalMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1293 {
1294  return matrix_.capacity(i);
1295 }
1297 //*************************************************************************************************
1298 
1299 
1300 //*************************************************************************************************
1306 template< typename MT // Type of the adapted sparse matrix
1307  , bool SO > // Storage order of the adapted sparse matrix
1308 inline size_t DiagonalMatrix<MT,SO,false>::nonZeros() const
1309 {
1310  return matrix_.nonZeros();
1311 }
1313 //*************************************************************************************************
1314 
1315 
1316 //*************************************************************************************************
1328 template< typename MT // Type of the adapted sparse matrix
1329  , bool SO > // Storage order of the adapted sparse matrix
1330 inline size_t DiagonalMatrix<MT,SO,false>::nonZeros( size_t i ) const
1331 {
1332  return matrix_.nonZeros(i);
1333 }
1335 //*************************************************************************************************
1336 
1337 
1338 //*************************************************************************************************
1344 template< typename MT // Type of the adapted sparse matrix
1345  , bool SO > // Storage order of the adapted sparse matrix
1347 {
1348  matrix_.reset();
1349 }
1351 //*************************************************************************************************
1352 
1353 
1354 //*************************************************************************************************
1367 template< typename MT // Type of the adapted sparse matrix
1368  , bool SO > // Storage order of the adapted sparse matrix
1369 inline void DiagonalMatrix<MT,SO,false>::reset( size_t i )
1370 {
1371  matrix_.reset( i );
1372 }
1374 //*************************************************************************************************
1375 
1376 
1377 //*************************************************************************************************
1385 template< typename MT // Type of the adapted sparse matrix
1386  , bool SO > // Storage order of the adapted sparse matrix
1388 {
1389  using blaze::clear;
1390 
1391  clear( matrix_ );
1392 }
1394 //*************************************************************************************************
1395 
1396 
1397 //*************************************************************************************************
1412 template< typename MT // Type of the adapted sparse matrix
1413  , bool SO > // Storage order of the adapted sparse matrix
1414 void DiagonalMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1415 {
1417 
1418  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1419 
1420  matrix_.resize( n, n, preserve );
1421 }
1423 //*************************************************************************************************
1424 
1425 
1426 //*************************************************************************************************
1437 template< typename MT // Type of the adapted sparse matrix
1438  , bool SO > // Storage order of the adapted sparse matrix
1439 inline void DiagonalMatrix<MT,SO,false>::reserve( size_t nonzeros )
1440 {
1441  matrix_.reserve( nonzeros );
1442 }
1444 //*************************************************************************************************
1445 
1446 
1447 //*************************************************************************************************
1461 template< typename MT // Type of the adapted sparse matrix
1462  , bool SO > // Storage order of the adapted sparse matrix
1463 inline void DiagonalMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1464 {
1465  matrix_.reserve( i, nonzeros );
1466 }
1468 //*************************************************************************************************
1469 
1470 
1471 //*************************************************************************************************
1482 template< typename MT // Type of the adapted sparse matrix
1483  , bool SO > // Storage order of the adapted sparse matrix
1484 inline void DiagonalMatrix<MT,SO,false>::trim()
1485 {
1486  matrix_.trim();
1487 }
1489 //*************************************************************************************************
1490 
1491 
1492 //*************************************************************************************************
1504 template< typename MT // Type of the adapted sparse matrix
1505  , bool SO > // Storage order of the adapted sparse matrix
1506 inline void DiagonalMatrix<MT,SO,false>::trim( size_t i )
1507 {
1508  matrix_.trim( i );
1509 }
1511 //*************************************************************************************************
1512 
1513 
1514 //*************************************************************************************************
1524 template< typename MT // Type of the adapted sparse matrix
1525  , bool SO > // Storage order of the adapted sparse matrix
1527 {
1528  matrix_.shrinkToFit();
1529 }
1531 //*************************************************************************************************
1532 
1533 
1534 //*************************************************************************************************
1541 template< typename MT // Type of the adapted sparse matrix
1542  , bool SO > // Storage order of the adapted sparse matrix
1543 inline void DiagonalMatrix<MT,SO,false>::swap( DiagonalMatrix& m ) noexcept
1544 {
1545  using std::swap;
1546 
1547  swap( matrix_, m.matrix_ );
1548 }
1550 //*************************************************************************************************
1551 
1552 
1553 //*************************************************************************************************
1559 template< typename MT // Type of the adapted sparse matrix
1560  , bool SO > // Storage order of the adapted sparse matrix
1561 inline void DiagonalMatrix<MT,SO,false>::resetNonDiagonal()
1562 {
1563  using blaze::erase;
1564 
1565  for( size_t i=0UL; i<rows(); ++i ) {
1566  erase( matrix_, i, matrix_.begin( i ), matrix_.lowerBound( i, i ) );
1567  erase( matrix_, i, matrix_.upperBound( i, i ), matrix_.end( i ) );
1568  }
1569 }
1571 //*************************************************************************************************
1572 
1573 
1574 
1575 
1576 //=================================================================================================
1577 //
1578 // INSERTION FUNCTIONS
1579 //
1580 //=================================================================================================
1581 
1582 //*************************************************************************************************
1598 template< typename MT // Type of the adapted sparse matrix
1599  , bool SO > // Storage order of the adapted sparse matrix
1601  DiagonalMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1602 {
1603  if( i < j ) {
1604  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1605  }
1606 
1607  return matrix_.set( i, j, value );
1608 }
1610 //*************************************************************************************************
1611 
1612 
1613 //*************************************************************************************************
1630 template< typename MT // Type of the adapted sparse matrix
1631  , bool SO > // Storage order of the adapted sparse matrix
1633  DiagonalMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1634 {
1635  if( i < j ) {
1636  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1637  }
1638 
1639  return matrix_.insert( i, j, value );
1640 }
1642 //*************************************************************************************************
1643 
1644 
1645 //*************************************************************************************************
1695 template< typename MT // Type of the adapted sparse matrix
1696  , bool SO > // Storage order of the adapted sparse matrix
1697 inline void DiagonalMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1698 {
1699  if( i < j ) {
1700  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1701  }
1702 
1703  matrix_.append( i, j, value, check );
1704 }
1706 //*************************************************************************************************
1707 
1708 
1709 //*************************************************************************************************
1723 template< typename MT // Type of the adapted sparse matrix
1724  , bool SO > // Storage order of the adapted sparse matrix
1725 inline void DiagonalMatrix<MT,SO,false>::finalize( size_t i )
1726 {
1727  matrix_.finalize( i );
1728 }
1730 //*************************************************************************************************
1731 
1732 
1733 
1734 
1735 //=================================================================================================
1736 //
1737 // ERASE FUNCTIONS
1738 //
1739 //=================================================================================================
1740 
1741 //*************************************************************************************************
1751 template< typename MT // Type of the adapted sparse matrix
1752  , bool SO > // Storage order of the adapted sparse matrix
1753 inline void DiagonalMatrix<MT,SO,false>::erase( size_t i, size_t j )
1754 {
1755  using blaze::erase;
1756 
1757  erase( matrix_, i, j );
1758 }
1760 //*************************************************************************************************
1761 
1762 
1763 //*************************************************************************************************
1775 template< typename MT // Type of the adapted sparse matrix
1776  , bool SO > // Storage order of the adapted sparse matrix
1778  DiagonalMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1779 {
1780  using blaze::erase;
1781 
1782  return erase( matrix_, i, pos );
1783 }
1785 //*************************************************************************************************
1786 
1787 
1788 //*************************************************************************************************
1802 template< typename MT // Type of the adapted sparse matrix
1803  , bool SO > // Storage order of the adapted sparse matrix
1805  DiagonalMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1806 {
1807  using blaze::erase;
1808 
1809  return erase( matrix_, i, first, last );
1810 }
1812 //*************************************************************************************************
1813 
1814 
1815 //*************************************************************************************************
1837 template< typename MT // Type of the adapted sparse matrix
1838  , bool SO > // Storage order of the adapted sparse matrix
1839 template< typename Pred > // Type of the unary predicate
1840 inline void DiagonalMatrix<MT,SO,false>::erase( Pred predicate )
1841 {
1842  using blaze::erase;
1843 
1844  erase( matrix_, predicate );
1845 
1846  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1847 }
1849 //*************************************************************************************************
1850 
1851 
1852 //*************************************************************************************************
1880 template< typename MT // Type of the adapted sparse matrix
1881  , bool SO > // Storage order of the adapted sparse matrix
1882 template< typename Pred > // Type of the unary predicate
1883 inline void DiagonalMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
1884 {
1885  using blaze::erase;
1886 
1887  erase( matrix_, i, first, last, predicate );
1888 
1889  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1890 }
1892 //*************************************************************************************************
1893 
1894 
1895 
1896 
1897 //=================================================================================================
1898 //
1899 // LOOKUP FUNCTIONS
1900 //
1901 //=================================================================================================
1902 
1903 //*************************************************************************************************
1919 template< typename MT // Type of the adapted sparse matrix
1920  , bool SO > // Storage order of the adapted sparse matrix
1922  DiagonalMatrix<MT,SO,false>::find( size_t i, size_t j )
1923 {
1924  return matrix_.find( i, j );
1925 }
1927 //*************************************************************************************************
1928 
1929 
1930 //*************************************************************************************************
1946 template< typename MT // Type of the adapted sparse matrix
1947  , bool SO > // Storage order of the adapted sparse matrix
1949  DiagonalMatrix<MT,SO,false>::find( size_t i, size_t j ) const
1950 {
1951  return matrix_.find( i, j );
1952 }
1954 //*************************************************************************************************
1955 
1956 
1957 //*************************************************************************************************
1973 template< typename MT // Type of the adapted sparse matrix
1974  , bool SO > // Storage order of the adapted sparse matrix
1976  DiagonalMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
1977 {
1978  return matrix_.lowerBound( i, j );
1979 }
1981 //*************************************************************************************************
1982 
1983 
1984 //*************************************************************************************************
2000 template< typename MT // Type of the adapted sparse matrix
2001  , bool SO > // Storage order of the adapted sparse matrix
2003  DiagonalMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
2004 {
2005  return matrix_.lowerBound( i, j );
2006 }
2008 //*************************************************************************************************
2009 
2010 
2011 //*************************************************************************************************
2027 template< typename MT // Type of the adapted sparse matrix
2028  , bool SO > // Storage order of the adapted sparse matrix
2030  DiagonalMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
2031 {
2032  return matrix_.upperBound( i, j );
2033 }
2035 //*************************************************************************************************
2036 
2037 
2038 //*************************************************************************************************
2054 template< typename MT // Type of the adapted sparse matrix
2055  , bool SO > // Storage order of the adapted sparse matrix
2057  DiagonalMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
2058 {
2059  return matrix_.upperBound( i, j );
2060 }
2062 //*************************************************************************************************
2063 
2064 
2065 
2066 
2067 //=================================================================================================
2068 //
2069 // NUMERIC FUNCTIONS
2070 //
2071 //=================================================================================================
2072 
2073 //*************************************************************************************************
2091 template< typename MT // Type of the adapted sparse matrix
2092  , bool SO > // Storage order of the adapted sparse matrix
2093 template< typename Other > // Data type of the scalar value
2094 inline DiagonalMatrix<MT,SO,false>&
2095  DiagonalMatrix<MT,SO,false>::scale( const Other& scalar )
2096 {
2097  matrix_.scale( scalar );
2098  return *this;
2099 }
2101 //*************************************************************************************************
2102 
2103 
2104 
2105 
2106 //=================================================================================================
2107 //
2108 // DEBUGGING FUNCTIONS
2109 //
2110 //=================================================================================================
2111 
2112 //*************************************************************************************************
2122 template< typename MT // Type of the adapted sparse matrix
2123  , bool SO > // Storage order of the adapted sparse matrix
2124 inline bool DiagonalMatrix<MT,SO,false>::isIntact() const noexcept
2125 {
2126  using blaze::isIntact;
2127 
2128  return ( isIntact( matrix_ ) && isDiagonal( matrix_ ) );
2129 }
2131 //*************************************************************************************************
2132 
2133 
2134 
2135 
2136 //=================================================================================================
2137 //
2138 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2139 //
2140 //=================================================================================================
2141 
2142 //*************************************************************************************************
2153 template< typename MT // Type of the adapted sparse matrix
2154  , bool SO > // Storage order of the adapted sparse matrix
2155 template< typename Other > // Data type of the foreign expression
2156 inline bool DiagonalMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2157 {
2158  return matrix_.canAlias( alias );
2159 }
2161 //*************************************************************************************************
2162 
2163 
2164 //*************************************************************************************************
2175 template< typename MT // Type of the adapted sparse matrix
2176  , bool SO > // Storage order of the adapted sparse matrix
2177 template< typename Other > // Data type of the foreign expression
2178 inline bool DiagonalMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2179 {
2180  return matrix_.isAliased( alias );
2181 }
2183 //*************************************************************************************************
2184 
2185 
2186 //*************************************************************************************************
2197 template< typename MT // Type of the adapted sparse matrix
2198  , bool SO > // Storage order of the adapted sparse matrix
2199 inline bool DiagonalMatrix<MT,SO,false>::canSMPAssign() const noexcept
2200 {
2201  return matrix_.canSMPAssign();
2202 }
2204 //*************************************************************************************************
2205 
2206 } // namespace blaze
2207 
2208 #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
Header file for auxiliary alias declarations.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3078
decltype(auto) decldiag(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as diagonal.
Definition: DMatDeclDiagExpr.h:975
#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
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.
#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 IsDiagonal type trait.
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.
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
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
bool isDiagonal(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is diagonal.
Definition: DenseMatrix.h:1539
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
Header file for the extended initializer_list functionality.
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
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
Header file for utility functions for sparse matrices.
Header file for the IsSquare type trait.
Constraint on the data type.
Header file for the implementation of a matrix representation of an initializer list.
Header file for the DisableIf class template.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3083
Header file for the DiagonalProxy class.
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
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
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
Constraint on the data type.
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
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 EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
#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
Header file for run time assertion macros.
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.
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
Header file for the implementation of the base template of the DiagonalMatrix.
#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
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
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.