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>
56 #include <blaze/math/Exception.h>
58 #include <blaze/math/shims/Clear.h>
66 #include <blaze/util/Assert.h>
71 #include <blaze/util/DisableIf.h>
72 #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  typedef OppositeType_<MT> OT;
102  typedef TransposeType_<MT> TT;
103  typedef ElementType_<MT> ET;
104  //**********************************************************************************************
105 
106  public:
107  //**Type definitions****************************************************************************
108  typedef DiagonalMatrix<MT,SO,false> This;
109  typedef SparseMatrix<This,SO> BaseType;
110  typedef This ResultType;
111  typedef DiagonalMatrix<OT,!SO,false> OppositeType;
112  typedef DiagonalMatrix<TT,!SO,false> TransposeType;
113  typedef ET ElementType;
114  typedef ReturnType_<MT> ReturnType;
115  typedef const This& CompositeType;
116  typedef DiagonalProxy<MT> Reference;
117  typedef ConstReference_<MT> ConstReference;
118  typedef Iterator_<MT> Iterator;
119  typedef ConstIterator_<MT> ConstIterator;
120  //**********************************************************************************************
121 
122  //**Rebind struct definition********************************************************************
125  template< typename NewType > // Data type of the other matrix
126  struct Rebind {
128  typedef DiagonalMatrix< typename MT::template Rebind<NewType>::Other > 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  typedef DiagonalMatrix< typename MT::template Resize<NewM,NewN>::Other > Other;
140  };
141  //**********************************************************************************************
142 
143  //**Compilation flags***************************************************************************
145  enum : 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 
156  inline DiagonalMatrix( const DiagonalMatrix& m );
157  inline DiagonalMatrix( DiagonalMatrix&& m ) noexcept;
158 
159  template< typename MT2, bool SO2 >
160  inline DiagonalMatrix( const Matrix<MT2,SO2>& m );
162  //**********************************************************************************************
163 
164  //**Destructor**********************************************************************************
165  // No explicitly declared destructor.
166  //**********************************************************************************************
167 
168  //**Data access functions***********************************************************************
171  inline Reference operator()( size_t i, size_t j );
172  inline ConstReference operator()( size_t i, size_t j ) const;
173  inline Reference at( size_t i, size_t j );
174  inline ConstReference at( size_t i, size_t j ) const;
175  inline Iterator begin ( size_t i );
176  inline ConstIterator begin ( size_t i ) const;
177  inline ConstIterator cbegin( size_t i ) const;
178  inline Iterator end ( size_t i );
179  inline ConstIterator end ( size_t i ) const;
180  inline ConstIterator cend ( size_t i ) const;
182  //**********************************************************************************************
183 
184  //**Assignment operators************************************************************************
187  inline DiagonalMatrix& operator=( const DiagonalMatrix& rhs );
188  inline DiagonalMatrix& operator=( DiagonalMatrix&& rhs ) noexcept;
189 
190  template< typename MT2, bool SO2 >
191  inline DisableIf_< IsComputation<MT2>, DiagonalMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
192 
193  template< typename MT2, bool SO2 >
194  inline EnableIf_< IsComputation<MT2>, DiagonalMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
195 
196  template< typename MT2, bool SO2 >
197  inline DisableIf_< IsComputation<MT2>, DiagonalMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
198 
199  template< typename MT2, bool SO2 >
200  inline EnableIf_< IsComputation<MT2>, DiagonalMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
201 
202  template< typename MT2, bool SO2 >
203  inline DisableIf_< IsComputation<MT2>, DiagonalMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
204 
205  template< typename MT2, bool SO2 >
206  inline EnableIf_< IsComputation<MT2>, DiagonalMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
207 
208  template< typename MT2, bool SO2 >
209  inline DiagonalMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
210 
211  template< typename Other >
212  inline EnableIf_< IsNumeric<Other>, DiagonalMatrix >& operator*=( Other rhs );
213 
214  template< typename Other >
215  inline EnableIf_< IsNumeric<Other>, DiagonalMatrix >& operator/=( Other rhs );
217  //**********************************************************************************************
218 
219  //**Utility functions***************************************************************************
222  inline size_t rows() const noexcept;
223  inline size_t columns() const noexcept;
224  inline size_t capacity() const noexcept;
225  inline size_t capacity( size_t i ) const noexcept;
226  inline size_t nonZeros() const;
227  inline size_t nonZeros( size_t i ) const;
228  inline void reset();
229  inline void reset( size_t i );
230  inline void clear();
231  inline void resize ( size_t n, bool preserve=true );
232  inline void reserve( size_t nonzeros );
233  inline void reserve( size_t i, size_t nonzeros );
234  inline void trim();
235  inline void trim( size_t i );
236  inline void swap( DiagonalMatrix& m ) noexcept;
238  //**********************************************************************************************
239 
240  //**Insertion functions*************************************************************************
243  inline Iterator set ( size_t i, size_t j, const ElementType& value );
244  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
245  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
246  inline void finalize( size_t i );
248  //**********************************************************************************************
249 
250  //**Erase functions*****************************************************************************
253  inline void erase( size_t i, size_t j );
254  inline Iterator erase( size_t i, Iterator pos );
255  inline Iterator erase( size_t i, Iterator first, Iterator last );
256 
257  template< typename Pred >
258  inline void erase( Pred predicate );
259 
260  template< typename Pred >
261  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
263  //**********************************************************************************************
264 
265  //**Lookup functions****************************************************************************
268  inline Iterator find ( size_t i, size_t j );
269  inline ConstIterator find ( size_t i, size_t j ) const;
270  inline Iterator lowerBound( size_t i, size_t j );
271  inline ConstIterator lowerBound( size_t i, size_t j ) const;
272  inline Iterator upperBound( size_t i, size_t j );
273  inline ConstIterator upperBound( size_t i, size_t j ) const;
275  //**********************************************************************************************
276 
277  //**Numeric functions***************************************************************************
280  template< typename Other > inline DiagonalMatrix& scale( const Other& scalar );
281  template< typename Other > inline DiagonalMatrix& scaleDiagonal( const Other& scale );
283  //**********************************************************************************************
284 
285  //**Debugging functions*************************************************************************
288  inline bool isIntact() const noexcept;
290  //**********************************************************************************************
291 
292  //**Expression template evaluation functions****************************************************
295  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
296  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
297 
298  inline bool canSMPAssign() const noexcept;
300  //**********************************************************************************************
301 
302  private:
303  //**Utility functions***************************************************************************
306  inline void resetNonDiagonal();
308  //**********************************************************************************************
309 
310  //**Member variables****************************************************************************
313  MT matrix_;
314 
315  //**********************************************************************************************
316 
317  //**Friend declarations*************************************************************************
318  template< bool RF, typename MT2, bool SO2, bool DF2 >
319  friend bool isDefault( const DiagonalMatrix<MT2,SO2,DF2>& m );
320 
321  template< typename MT2, bool SO2, bool DF2 >
322  friend MT2& derestrict( DiagonalMatrix<MT2,SO2,DF2>& m );
323  //**********************************************************************************************
324 
325  //**Compile time checks*************************************************************************
338  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
339  //**********************************************************************************************
340 };
342 //*************************************************************************************************
343 
344 
345 
346 
347 //=================================================================================================
348 //
349 // CONSTRUCTORS
350 //
351 //=================================================================================================
352 
353 //*************************************************************************************************
357 template< typename MT // Type of the adapted sparse matrix
358  , bool SO > // Storage order of the adapted sparse matrix
359 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix()
360  : matrix_() // The adapted sparse matrix
361 {
362  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
363 }
365 //*************************************************************************************************
366 
367 
368 //*************************************************************************************************
376 template< typename MT // Type of the adapted sparse matrix
377  , bool SO > // Storage order of the adapted sparse matrix
378 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n )
379  : matrix_( n, n ) // The adapted sparse matrix
380 {
382 
383  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
384 }
386 //*************************************************************************************************
387 
388 
389 //*************************************************************************************************
398 template< typename MT // Type of the adapted sparse matrix
399  , bool SO > // Storage order of the adapted sparse matrix
400 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n, size_t nonzeros )
401  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
402 {
404 
405  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
406 }
408 //*************************************************************************************************
409 
410 
411 //*************************************************************************************************
422 template< typename MT // Type of the adapted sparse matrix
423  , bool SO > // Storage order of the adapted sparse matrix
424 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n, const std::vector<size_t>& nonzeros )
425  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
426 {
428 
429  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
430 }
432 //*************************************************************************************************
433 
434 
435 //*************************************************************************************************
441 template< typename MT // Type of the adapted sparse matrix
442  , bool SO > // Storage order of the adapted sparse matrix
443 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( const DiagonalMatrix& m )
444  : matrix_( m.matrix_ ) // The adapted sparse matrix
445 {
446  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
447  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
448 }
450 //*************************************************************************************************
451 
452 
453 //*************************************************************************************************
459 template< typename MT // Type of the adapted sparse matrix
460  , bool SO > // Storage order of the adapted sparse matrix
461 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( DiagonalMatrix&& m ) noexcept
462  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
463 {
464  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
465  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
466 }
468 //*************************************************************************************************
469 
470 
471 //*************************************************************************************************
481 template< typename MT // Type of the adapted sparse matrix
482  , bool SO > // Storage order of the adapted sparse matrix
483 template< typename MT2 // Type of the foreign matrix
484  , bool SO2 > // Storage order of the foreign matrix
485 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( const Matrix<MT2,SO2>& m )
486  : matrix_( ~m ) // The adapted sparse matrix
487 {
488  if( !IsDiagonal<MT2>::value && !isDiagonal( matrix_ ) ) {
489  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
490  }
491 
492  if( !IsDiagonal<MT2>::value )
493  resetNonDiagonal();
494 
495  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
496  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
497 }
499 //*************************************************************************************************
500 
501 
502 
503 
504 //=================================================================================================
505 //
506 // DATA ACCESS FUNCTIONS
507 //
508 //=================================================================================================
509 
510 //*************************************************************************************************
526 template< typename MT // Type of the adapted sparse matrix
527  , bool SO > // Storage order of the adapted sparse matrix
529  DiagonalMatrix<MT,SO,false>::operator()( size_t i, size_t j )
530 {
531  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
532  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
533 
534  return Reference( matrix_, i, j );
535 }
537 //*************************************************************************************************
538 
539 
540 //*************************************************************************************************
556 template< typename MT // Type of the adapted sparse matrix
557  , bool SO > // Storage order of the adapted sparse matrix
559  DiagonalMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
560 {
561  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
562  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
563 
564  return matrix_(i,j);
565 }
567 //*************************************************************************************************
568 
569 
570 //*************************************************************************************************
587 template< typename MT // Type of the adapted sparse matrix
588  , bool SO > // Storage order of the adapted sparse matrix
590  DiagonalMatrix<MT,SO,false>::at( size_t i, size_t j )
591 {
592  if( i >= rows() ) {
593  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
594  }
595  if( j >= columns() ) {
596  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
597  }
598  return (*this)(i,j);
599 }
601 //*************************************************************************************************
602 
603 
604 //*************************************************************************************************
621 template< typename MT // Type of the adapted sparse matrix
622  , bool SO > // Storage order of the adapted sparse matrix
624  DiagonalMatrix<MT,SO,false>::at( size_t i, size_t j ) const
625 {
626  if( i >= rows() ) {
627  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
628  }
629  if( j >= columns() ) {
630  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
631  }
632  return (*this)(i,j);
633 }
635 //*************************************************************************************************
636 
637 
638 //*************************************************************************************************
650 template< typename MT // Type of the adapted sparse matrix
651  , bool SO > // Storage order of the adapted sparse matrix
654 {
655  return matrix_.begin(i);
656 }
658 //*************************************************************************************************
659 
660 
661 //*************************************************************************************************
673 template< typename MT // Type of the adapted sparse matrix
674  , bool SO > // Storage order of the adapted sparse matrix
676  DiagonalMatrix<MT,SO,false>::begin( size_t i ) const
677 {
678  return matrix_.begin(i);
679 }
681 //*************************************************************************************************
682 
683 
684 //*************************************************************************************************
696 template< typename MT // Type of the adapted sparse matrix
697  , bool SO > // Storage order of the adapted sparse matrix
699  DiagonalMatrix<MT,SO,false>::cbegin( size_t i ) const
700 {
701  return matrix_.cbegin(i);
702 }
704 //*************************************************************************************************
705 
706 
707 //*************************************************************************************************
719 template< typename MT // Type of the adapted sparse matrix
720  , bool SO > // Storage order of the adapted sparse matrix
723 {
724  return matrix_.end(i);
725 }
727 //*************************************************************************************************
728 
729 
730 //*************************************************************************************************
742 template< typename MT // Type of the adapted sparse matrix
743  , bool SO > // Storage order of the adapted sparse matrix
745  DiagonalMatrix<MT,SO,false>::end( size_t i ) const
746 {
747  return matrix_.end(i);
748 }
750 //*************************************************************************************************
751 
752 
753 //*************************************************************************************************
765 template< typename MT // Type of the adapted sparse matrix
766  , bool SO > // Storage order of the adapted sparse matrix
768  DiagonalMatrix<MT,SO,false>::cend( size_t i ) const
769 {
770  return matrix_.cend(i);
771 }
773 //*************************************************************************************************
774 
775 
776 
777 
778 //=================================================================================================
779 //
780 // ASSIGNMENT OPERATORS
781 //
782 //=================================================================================================
783 
784 //*************************************************************************************************
794 template< typename MT // Type of the adapted sparse matrix
795  , bool SO > // Storage order of the adapted sparse matrix
796 inline DiagonalMatrix<MT,SO,false>&
797  DiagonalMatrix<MT,SO,false>::operator=( const DiagonalMatrix& rhs )
798 {
799  matrix_ = rhs.matrix_;
800 
801  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
802  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
803 
804  return *this;
805 }
807 //*************************************************************************************************
808 
809 
810 //*************************************************************************************************
817 template< typename MT // Type of the adapted sparse matrix
818  , bool SO > // Storage order of the adapted sparse matrix
819 inline DiagonalMatrix<MT,SO,false>&
820  DiagonalMatrix<MT,SO,false>::operator=( DiagonalMatrix&& rhs ) noexcept
821 {
822  matrix_ = std::move( rhs.matrix_ );
823 
824  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
825  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
826 
827  return *this;
828 }
830 //*************************************************************************************************
831 
832 
833 //*************************************************************************************************
846 template< typename MT // Type of the adapted sparse matrix
847  , bool SO > // Storage order of the adapted sparse matrix
848 template< typename MT2 // Type of the right-hand side matrix
849  , bool SO2 > // Storage order of the right-hand side matrix
850 inline DisableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >
851  DiagonalMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
852 {
853  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
854  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
855  }
856 
857  matrix_ = ~rhs;
858 
859  if( !IsDiagonal<MT2>::value )
860  resetNonDiagonal();
861 
862  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
863  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
864 
865  return *this;
866 }
868 //*************************************************************************************************
869 
870 
871 //*************************************************************************************************
884 template< typename MT // Type of the adapted sparse matrix
885  , bool SO > // Storage order of the adapted sparse matrix
886 template< typename MT2 // Type of the right-hand side matrix
887  , bool SO2 > // Storage order of the right-hand side matrix
888 inline EnableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >
889  DiagonalMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
890 {
891  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
892  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
893  }
894 
895  if( IsDiagonal<MT2>::value ) {
896  matrix_ = ~rhs;
897  }
898  else {
899  MT tmp( ~rhs );
900 
901  if( !isDiagonal( tmp ) ) {
902  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
903  }
904 
905  matrix_ = std::move( tmp );
906  }
907 
908  if( !IsDiagonal<MT2>::value )
909  resetNonDiagonal();
910 
911  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
912  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
913 
914  return *this;
915 }
917 //*************************************************************************************************
918 
919 
920 //*************************************************************************************************
933 template< typename MT // Type of the adapted sparse matrix
934  , bool SO > // Storage order of the adapted sparse matrix
935 template< typename MT2 // Type of the right-hand side matrix
936  , bool SO2 > // Storage order of the right-hand side matrix
937 inline DisableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >
938  DiagonalMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
939 {
940  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
941  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
942  }
943 
944  matrix_ += ~rhs;
945 
946  if( !IsDiagonal<MT2>::value )
947  resetNonDiagonal();
948 
949  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
950  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
951 
952  return *this;
953 }
955 //*************************************************************************************************
956 
957 
958 //*************************************************************************************************
971 template< typename MT // Type of the adapted sparse matrix
972  , bool SO > // Storage order of the adapted sparse matrix
973 template< typename MT2 // Type of the right-hand side matrix
974  , bool SO2 > // Storage order of the right-hand side matrix
975 inline EnableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >
976  DiagonalMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
977 {
978  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
979  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
980  }
981 
982  if( IsDiagonal<MT2>::value ) {
983  matrix_ += ~rhs;
984  }
985  else {
986  const ResultType_<MT2> tmp( ~rhs );
987 
988  if( !isDiagonal( tmp ) ) {
989  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
990  }
991 
992  matrix_ += tmp;
993  }
994 
995  if( !IsDiagonal<MT2>::value )
996  resetNonDiagonal();
997 
998  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
999  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1000 
1001  return *this;
1002 }
1004 //*************************************************************************************************
1005 
1006 
1007 //*************************************************************************************************
1020 template< typename MT // Type of the adapted sparse matrix
1021  , bool SO > // Storage order of the adapted sparse matrix
1022 template< typename MT2 // Type of the right-hand side matrix
1023  , bool SO2 > // Storage order of the right-hand side matrix
1024 inline DisableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >
1025  DiagonalMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1026 {
1027  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
1028  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1029  }
1030 
1031  matrix_ -= ~rhs;
1032 
1033  if( !IsDiagonal<MT2>::value )
1034  resetNonDiagonal();
1035 
1036  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1037  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1038 
1039  return *this;
1040 }
1042 //*************************************************************************************************
1043 
1044 
1045 //*************************************************************************************************
1058 template< typename MT // Type of the adapted sparse matrix
1059  , bool SO > // Storage order of the adapted sparse matrix
1060 template< typename MT2 // Type of the right-hand side matrix
1061  , bool SO2 > // Storage order of the right-hand side matrix
1062 inline EnableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >
1063  DiagonalMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1064 {
1065  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1066  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1067  }
1068 
1069  if( IsDiagonal<MT2>::value ) {
1070  matrix_ -= ~rhs;
1071  }
1072  else {
1073  const ResultType_<MT2> tmp( ~rhs );
1074 
1075  if( !isDiagonal( tmp ) ) {
1076  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1077  }
1078 
1079  matrix_ -= tmp;
1080  }
1081 
1082  if( !IsDiagonal<MT2>::value )
1083  resetNonDiagonal();
1084 
1085  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1086  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1087 
1088  return *this;
1089 }
1091 //*************************************************************************************************
1092 
1093 
1094 //*************************************************************************************************
1106 template< typename MT // Type of the adapted sparse matrix
1107  , bool SO > // Storage order of the adapted sparse matrix
1108 template< typename MT2 // Type of the right-hand side matrix
1109  , bool SO2 > // Storage order of the right-hand side matrix
1110 inline DiagonalMatrix<MT,SO,false>&
1111  DiagonalMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1112 {
1113  if( matrix_.rows() != (~rhs).columns() ) {
1114  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1115  }
1116 
1117  MT tmp( matrix_ * ~rhs );
1118 
1119  if( !isDiagonal( tmp ) ) {
1120  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1121  }
1122 
1123  matrix_ = std::move( tmp );
1124 
1125  if( !IsDiagonal<MT2>::value )
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 //*************************************************************************************************
1145 template< typename MT // Type of the adapted sparse matrix
1146  , bool SO > // Storage order of the adapted sparse matrix
1147 template< typename Other > // Data type of the right-hand side scalar
1148 inline EnableIf_< IsNumeric<Other>, DiagonalMatrix<MT,SO,false> >&
1150 {
1151  matrix_ *= rhs;
1152  return *this;
1153 }
1154 //*************************************************************************************************
1155 
1156 
1157 //*************************************************************************************************
1165 template< typename MT // Type of the adapted sparse matrix
1166  , bool SO > // Storage order of the adapted sparse matrix
1167 template< typename Other > // Data type of the right-hand side scalar
1168 inline EnableIf_< IsNumeric<Other>, DiagonalMatrix<MT,SO,false> >&
1170 {
1171  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1172 
1173  matrix_ /= rhs;
1174  return *this;
1175 }
1177 //*************************************************************************************************
1178 
1179 
1180 
1181 
1182 //=================================================================================================
1183 //
1184 // UTILITY FUNCTIONS
1185 //
1186 //=================================================================================================
1187 
1188 //*************************************************************************************************
1194 template< typename MT // Type of the adapted sparse matrix
1195  , bool SO > // Storage order of the adapted sparse matrix
1196 inline size_t DiagonalMatrix<MT,SO,false>::rows() const noexcept
1197 {
1198  return matrix_.rows();
1199 }
1201 //*************************************************************************************************
1202 
1203 
1204 //*************************************************************************************************
1210 template< typename MT // Type of the adapted sparse matrix
1211  , bool SO > // Storage order of the adapted sparse matrix
1212 inline size_t DiagonalMatrix<MT,SO,false>::columns() const noexcept
1213 {
1214  return matrix_.columns();
1215 }
1217 //*************************************************************************************************
1218 
1219 
1220 //*************************************************************************************************
1226 template< typename MT // Type of the adapted sparse matrix
1227  , bool SO > // Storage order of the adapted sparse matrix
1228 inline size_t DiagonalMatrix<MT,SO,false>::capacity() const noexcept
1229 {
1230  return matrix_.capacity();
1231 }
1233 //*************************************************************************************************
1234 
1235 
1236 //*************************************************************************************************
1248 template< typename MT // Type of the adapted sparse matrix
1249  , bool SO > // Storage order of the adapted sparse matrix
1250 inline size_t DiagonalMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1251 {
1252  return matrix_.capacity(i);
1253 }
1255 //*************************************************************************************************
1256 
1257 
1258 //*************************************************************************************************
1264 template< typename MT // Type of the adapted sparse matrix
1265  , bool SO > // Storage order of the adapted sparse matrix
1266 inline size_t DiagonalMatrix<MT,SO,false>::nonZeros() const
1267 {
1268  return matrix_.nonZeros();
1269 }
1271 //*************************************************************************************************
1272 
1273 
1274 //*************************************************************************************************
1286 template< typename MT // Type of the adapted sparse matrix
1287  , bool SO > // Storage order of the adapted sparse matrix
1288 inline size_t DiagonalMatrix<MT,SO,false>::nonZeros( size_t i ) const
1289 {
1290  return matrix_.nonZeros(i);
1291 }
1293 //*************************************************************************************************
1294 
1295 
1296 //*************************************************************************************************
1302 template< typename MT // Type of the adapted sparse matrix
1303  , bool SO > // Storage order of the adapted sparse matrix
1305 {
1306  matrix_.reset();
1307 }
1309 //*************************************************************************************************
1310 
1311 
1312 //*************************************************************************************************
1325 template< typename MT // Type of the adapted sparse matrix
1326  , bool SO > // Storage order of the adapted sparse matrix
1327 inline void DiagonalMatrix<MT,SO,false>::reset( size_t i )
1328 {
1329  matrix_.reset( i );
1330 }
1332 //*************************************************************************************************
1333 
1334 
1335 //*************************************************************************************************
1343 template< typename MT // Type of the adapted sparse matrix
1344  , bool SO > // Storage order of the adapted sparse matrix
1346 {
1347  using blaze::clear;
1348 
1349  clear( matrix_ );
1350 }
1352 //*************************************************************************************************
1353 
1354 
1355 //*************************************************************************************************
1370 template< typename MT // Type of the adapted sparse matrix
1371  , bool SO > // Storage order of the adapted sparse matrix
1372 void DiagonalMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1373 {
1375 
1376  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1377 
1378  matrix_.resize( n, n, preserve );
1379 }
1381 //*************************************************************************************************
1382 
1383 
1384 //*************************************************************************************************
1395 template< typename MT // Type of the adapted sparse matrix
1396  , bool SO > // Storage order of the adapted sparse matrix
1397 inline void DiagonalMatrix<MT,SO,false>::reserve( size_t nonzeros )
1398 {
1399  matrix_.reserve( nonzeros );
1400 }
1402 //*************************************************************************************************
1403 
1404 
1405 //*************************************************************************************************
1419 template< typename MT // Type of the adapted sparse matrix
1420  , bool SO > // Storage order of the adapted sparse matrix
1421 inline void DiagonalMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1422 {
1423  matrix_.reserve( i, nonzeros );
1424 }
1426 //*************************************************************************************************
1427 
1428 
1429 //*************************************************************************************************
1440 template< typename MT // Type of the adapted sparse matrix
1441  , bool SO > // Storage order of the adapted sparse matrix
1442 inline void DiagonalMatrix<MT,SO,false>::trim()
1443 {
1444  matrix_.trim();
1445 }
1447 //*************************************************************************************************
1448 
1449 
1450 //*************************************************************************************************
1462 template< typename MT // Type of the adapted sparse matrix
1463  , bool SO > // Storage order of the adapted sparse matrix
1464 inline void DiagonalMatrix<MT,SO,false>::trim( size_t i )
1465 {
1466  matrix_.trim( i );
1467 }
1469 //*************************************************************************************************
1470 
1471 
1472 //*************************************************************************************************
1479 template< typename MT // Type of the adapted sparse matrix
1480  , bool SO > // Storage order of the adapted sparse matrix
1481 inline void DiagonalMatrix<MT,SO,false>::swap( DiagonalMatrix& m ) noexcept
1482 {
1483  using std::swap;
1484 
1485  swap( matrix_, m.matrix_ );
1486 }
1488 //*************************************************************************************************
1489 
1490 
1491 //*************************************************************************************************
1497 template< typename MT // Type of the adapted dense matrix
1498  , bool SO > // Storage order of the adapted dense matrix
1499 inline void DiagonalMatrix<MT,SO,false>::resetNonDiagonal()
1500 {
1501  for( size_t i=0UL; i<rows(); ++i ) {
1502  matrix_.erase( i, matrix_.begin( i ), matrix_.lowerBound( i, i ) );
1503  matrix_.erase( i, matrix_.upperBound( i, i ), matrix_.end( i ) );
1504  }
1505 }
1507 //*************************************************************************************************
1508 
1509 
1510 
1511 
1512 //=================================================================================================
1513 //
1514 // INSERTION FUNCTIONS
1515 //
1516 //=================================================================================================
1517 
1518 //*************************************************************************************************
1534 template< typename MT // Type of the adapted sparse matrix
1535  , bool SO > // Storage order of the adapted sparse matrix
1537  DiagonalMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1538 {
1539  if( i < j ) {
1540  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1541  }
1542 
1543  return matrix_.set( i, j, value );
1544 }
1546 //*************************************************************************************************
1547 
1548 
1549 //*************************************************************************************************
1566 template< typename MT // Type of the adapted sparse matrix
1567  , bool SO > // Storage order of the adapted sparse matrix
1569  DiagonalMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1570 {
1571  if( i < j ) {
1572  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1573  }
1574 
1575  return matrix_.insert( i, j, value );
1576 }
1578 //*************************************************************************************************
1579 
1580 
1581 //*************************************************************************************************
1631 template< typename MT // Type of the adapted sparse matrix
1632  , bool SO > // Storage order of the adapted sparse matrix
1633 inline void DiagonalMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1634 {
1635  if( i < j ) {
1636  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1637  }
1638 
1639  matrix_.append( i, j, value, check );
1640 }
1642 //*************************************************************************************************
1643 
1644 
1645 //*************************************************************************************************
1659 template< typename MT // Type of the adapted sparse matrix
1660  , bool SO > // Storage order of the adapted sparse matrix
1661 inline void DiagonalMatrix<MT,SO,false>::finalize( size_t i )
1662 {
1663  matrix_.finalize( i );
1664 }
1666 //*************************************************************************************************
1667 
1668 
1669 
1670 
1671 //=================================================================================================
1672 //
1673 // ERASE FUNCTIONS
1674 //
1675 //=================================================================================================
1676 
1677 //*************************************************************************************************
1687 template< typename MT // Type of the adapted sparse matrix
1688  , bool SO > // Storage order of the adapted sparse matrix
1689 inline void DiagonalMatrix<MT,SO,false>::erase( size_t i, size_t j )
1690 {
1691  matrix_.erase( i, j );
1692 }
1694 //*************************************************************************************************
1695 
1696 
1697 //*************************************************************************************************
1709 template< typename MT // Type of the adapted sparse matrix
1710  , bool SO > // Storage order of the adapted sparse matrix
1712  DiagonalMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1713 {
1714  return matrix_.erase( i, pos );
1715 }
1717 //*************************************************************************************************
1718 
1719 
1720 //*************************************************************************************************
1734 template< typename MT // Type of the adapted sparse matrix
1735  , bool SO > // Storage order of the adapted sparse matrix
1737  DiagonalMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1738 {
1739  return matrix_.erase( i, first, last );
1740 }
1742 //*************************************************************************************************
1743 
1744 
1745 //*************************************************************************************************
1767 template< typename MT // Type of the adapted sparse matrix
1768  , bool SO > // Storage order of the adapted sparse matrix
1769 template< typename Pred > // Type of the unary predicate
1770 inline void DiagonalMatrix<MT,SO,false>::erase( Pred predicate )
1771 {
1772  matrix_.erase( predicate );
1773 
1774  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1775 }
1777 //*************************************************************************************************
1778 
1779 
1780 //*************************************************************************************************
1808 template< typename MT // Type of the adapted sparse matrix
1809  , bool SO > // Storage order of the adapted sparse matrix
1810 template< typename Pred > // Type of the unary predicate
1811 inline void DiagonalMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
1812 {
1813  matrix_.erase( i, first, last, predicate );
1814 
1815  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1816 }
1818 //*************************************************************************************************
1819 
1820 
1821 
1822 
1823 //=================================================================================================
1824 //
1825 // LOOKUP FUNCTIONS
1826 //
1827 //=================================================================================================
1828 
1829 //*************************************************************************************************
1845 template< typename MT // Type of the adapted sparse matrix
1846  , bool SO > // Storage order of the adapted sparse matrix
1848  DiagonalMatrix<MT,SO,false>::find( size_t i, size_t j )
1849 {
1850  return matrix_.find( i, j );
1851 }
1853 //*************************************************************************************************
1854 
1855 
1856 //*************************************************************************************************
1872 template< typename MT // Type of the adapted sparse matrix
1873  , bool SO > // Storage order of the adapted sparse matrix
1875  DiagonalMatrix<MT,SO,false>::find( size_t i, size_t j ) const
1876 {
1877  return matrix_.find( i, j );
1878 }
1880 //*************************************************************************************************
1881 
1882 
1883 //*************************************************************************************************
1899 template< typename MT // Type of the adapted sparse matrix
1900  , bool SO > // Storage order of the adapted sparse matrix
1902  DiagonalMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
1903 {
1904  return matrix_.lowerBound( i, j );
1905 }
1907 //*************************************************************************************************
1908 
1909 
1910 //*************************************************************************************************
1926 template< typename MT // Type of the adapted sparse matrix
1927  , bool SO > // Storage order of the adapted sparse matrix
1929  DiagonalMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
1930 {
1931  return matrix_.lowerBound( i, j );
1932 }
1934 //*************************************************************************************************
1935 
1936 
1937 //*************************************************************************************************
1953 template< typename MT // Type of the adapted sparse matrix
1954  , bool SO > // Storage order of the adapted sparse matrix
1956  DiagonalMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
1957 {
1958  return matrix_.upperBound( i, j );
1959 }
1961 //*************************************************************************************************
1962 
1963 
1964 //*************************************************************************************************
1980 template< typename MT // Type of the adapted sparse matrix
1981  , bool SO > // Storage order of the adapted sparse matrix
1983  DiagonalMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
1984 {
1985  return matrix_.upperBound( i, j );
1986 }
1988 //*************************************************************************************************
1989 
1990 
1991 
1992 
1993 //=================================================================================================
1994 //
1995 // NUMERIC FUNCTIONS
1996 //
1997 //=================================================================================================
1998 
1999 //*************************************************************************************************
2006 template< typename MT // Type of the adapted sparse matrix
2007  , bool SO > // Storage order of the adapted sparse matrix
2008 template< typename Other > // Data type of the scalar value
2009 inline DiagonalMatrix<MT,SO,false>&
2010  DiagonalMatrix<MT,SO,false>::scale( const Other& scalar )
2011 {
2012  matrix_.scale( scalar );
2013  return *this;
2014 }
2016 //*************************************************************************************************
2017 
2018 
2019 //*************************************************************************************************
2026 template< typename MT // Type of the adapted sparse matrix
2027  , bool SO > // Storage order of the adapted sparse matrix
2028 template< typename Other > // Data type of the scalar value
2029 inline DiagonalMatrix<MT,SO,false>&
2030  DiagonalMatrix<MT,SO,false>::scaleDiagonal( const Other& scalar )
2031 {
2032  matrix_.scaleDiagonal( scalar );
2033  return *this;
2034 }
2036 //*************************************************************************************************
2037 
2038 
2039 
2040 
2041 //=================================================================================================
2042 //
2043 // DEBUGGING FUNCTIONS
2044 //
2045 //=================================================================================================
2046 
2047 //*************************************************************************************************
2057 template< typename MT // Type of the adapted sparse matrix
2058  , bool SO > // Storage order of the adapted sparse matrix
2059 inline bool DiagonalMatrix<MT,SO,false>::isIntact() const noexcept
2060 {
2061  using blaze::isIntact;
2062 
2063  return ( isIntact( matrix_ ) && isDiagonal( matrix_ ) );
2064 }
2066 //*************************************************************************************************
2067 
2068 
2069 
2070 
2071 //=================================================================================================
2072 //
2073 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2074 //
2075 //=================================================================================================
2076 
2077 //*************************************************************************************************
2088 template< typename MT // Type of the adapted sparse matrix
2089  , bool SO > // Storage order of the adapted sparse matrix
2090 template< typename Other > // Data type of the foreign expression
2091 inline bool DiagonalMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2092 {
2093  return matrix_.canAlias( alias );
2094 }
2096 //*************************************************************************************************
2097 
2098 
2099 //*************************************************************************************************
2110 template< typename MT // Type of the adapted sparse matrix
2111  , bool SO > // Storage order of the adapted sparse matrix
2112 template< typename Other > // Data type of the foreign expression
2113 inline bool DiagonalMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2114 {
2115  return matrix_.isAliased( alias );
2116 }
2118 //*************************************************************************************************
2119 
2120 
2121 //*************************************************************************************************
2132 template< typename MT // Type of the adapted sparse matrix
2133  , bool SO > // Storage order of the adapted sparse matrix
2134 inline bool DiagonalMatrix<MT,SO,false>::canSMPAssign() const noexcept
2135 {
2136  return matrix_.canSMPAssign();
2137 }
2139 //*************************************************************************************************
2140 
2141 } // namespace blaze
2142 
2143 #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.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the Rows type trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:352
Header file for basic type definitions.
#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.
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
Constraint on the data type.
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:194
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2935
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5556
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2928
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
bool isDiagonal(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is diagonal.
Definition: DenseMatrix.h:1577
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:390
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2931
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:304
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:238
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
Header file for utility functions for sparse matrices.
Header file for the IsSquare type trait.
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the DiagonalProxy class.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5635
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5618
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2939
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the Columns type trait.
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:336
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2932
Constraints on the storage order of matrix types.
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:81
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:544
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:260
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:2933
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2937
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2934
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2938
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:267
Constraint on the data type.
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:320
Header file for the implementation of the base template of the DiagonalMatrix.
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2929
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a &#39;res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2930
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:249
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2936
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:677
#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