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 ET > // Data type of the other matrix
126  struct Rebind {
128  typedef DiagonalMatrix< typename MT::template Rebind<ET>::Other > Other;
129  };
130  //**********************************************************************************************
131 
132  //**Compilation flags***************************************************************************
134  enum : bool { smpAssignable = false };
135  //**********************************************************************************************
136 
137  //**Constructors********************************************************************************
140  explicit inline DiagonalMatrix();
141  explicit inline DiagonalMatrix( size_t n );
142  explicit inline DiagonalMatrix( size_t n, size_t nonzeros );
143  explicit inline DiagonalMatrix( size_t n, const std::vector<size_t>& nonzeros );
144 
145  inline DiagonalMatrix( const DiagonalMatrix& m );
146  inline DiagonalMatrix( DiagonalMatrix&& m ) noexcept;
147 
148  template< typename MT2, bool SO2 >
149  inline DiagonalMatrix( const Matrix<MT2,SO2>& m );
151  //**********************************************************************************************
152 
153  //**Destructor**********************************************************************************
154  // No explicitly declared destructor.
155  //**********************************************************************************************
156 
157  //**Data access functions***********************************************************************
160  inline Reference operator()( size_t i, size_t j );
161  inline ConstReference operator()( size_t i, size_t j ) const;
162  inline Reference at( size_t i, size_t j );
163  inline ConstReference at( size_t i, size_t j ) const;
164  inline Iterator begin ( size_t i );
165  inline ConstIterator begin ( size_t i ) const;
166  inline ConstIterator cbegin( size_t i ) const;
167  inline Iterator end ( size_t i );
168  inline ConstIterator end ( size_t i ) const;
169  inline ConstIterator cend ( size_t i ) const;
171  //**********************************************************************************************
172 
173  //**Assignment operators************************************************************************
176  inline DiagonalMatrix& operator=( const DiagonalMatrix& rhs );
177  inline DiagonalMatrix& operator=( DiagonalMatrix&& rhs ) noexcept;
178 
179  template< typename MT2, bool SO2 >
180  inline DisableIf_< IsComputation<MT2>, DiagonalMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
181 
182  template< typename MT2, bool SO2 >
183  inline EnableIf_< IsComputation<MT2>, DiagonalMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
184 
185  template< typename MT2, bool SO2 >
186  inline DisableIf_< IsComputation<MT2>, DiagonalMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
187 
188  template< typename MT2, bool SO2 >
189  inline EnableIf_< IsComputation<MT2>, DiagonalMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
190 
191  template< typename MT2, bool SO2 >
192  inline DisableIf_< IsComputation<MT2>, DiagonalMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
193 
194  template< typename MT2, bool SO2 >
195  inline EnableIf_< IsComputation<MT2>, DiagonalMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
196 
197  template< typename MT2, bool SO2 >
198  inline DiagonalMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
199 
200  template< typename Other >
201  inline EnableIf_< IsNumeric<Other>, DiagonalMatrix >& operator*=( Other rhs );
202 
203  template< typename Other >
204  inline EnableIf_< IsNumeric<Other>, DiagonalMatrix >& operator/=( Other rhs );
206  //**********************************************************************************************
207 
208  //**Utility functions***************************************************************************
211  inline size_t rows() const noexcept;
212  inline size_t columns() const noexcept;
213  inline size_t capacity() const noexcept;
214  inline size_t capacity( size_t i ) const noexcept;
215  inline size_t nonZeros() const;
216  inline size_t nonZeros( size_t i ) const;
217  inline void reset();
218  inline void reset( size_t i );
219  inline void clear();
220  inline Iterator set( size_t i, size_t j, const ElementType& value );
221  inline Iterator insert( size_t i, size_t j, const ElementType& value );
222  inline void erase( size_t i, size_t j );
223  inline Iterator erase( size_t i, Iterator pos );
224  inline Iterator erase( size_t i, Iterator first, Iterator last );
225  inline void resize ( size_t n, bool preserve=true );
226  inline void reserve( size_t nonzeros );
227  inline void reserve( size_t i, size_t nonzeros );
228  inline void trim();
229  inline void trim( size_t i );
230  template< typename Other > inline DiagonalMatrix& scale( const Other& scalar );
231  template< typename Other > inline DiagonalMatrix& scaleDiagonal( Other scale );
232  inline void swap( DiagonalMatrix& m ) noexcept;
234  //**********************************************************************************************
235 
236  //**Lookup functions****************************************************************************
239  inline Iterator find ( size_t i, size_t j );
240  inline ConstIterator find ( size_t i, size_t j ) const;
241  inline Iterator lowerBound( size_t i, size_t j );
242  inline ConstIterator lowerBound( size_t i, size_t j ) const;
243  inline Iterator upperBound( size_t i, size_t j );
244  inline ConstIterator upperBound( size_t i, size_t j ) const;
246  //**********************************************************************************************
247 
248  //**Low-level utility functions*****************************************************************
251  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
252  inline void finalize( size_t i );
254  //**********************************************************************************************
255 
256  //**Debugging functions*************************************************************************
259  inline bool isIntact() const noexcept;
261  //**********************************************************************************************
262 
263  //**Expression template evaluation functions****************************************************
266  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
267  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
268 
269  inline bool canSMPAssign() const noexcept;
271  //**********************************************************************************************
272 
273  private:
274  //**Utility functions***************************************************************************
277  inline void resetNonDiagonal();
279  //**********************************************************************************************
280 
281  //**Member variables****************************************************************************
284  MT matrix_;
285 
286  //**********************************************************************************************
287 
288  //**Friend declarations*************************************************************************
289  template< typename MT2, bool SO2, bool DF2 >
290  friend bool isDefault( const DiagonalMatrix<MT2,SO2,DF2>& m );
291 
292  template< typename MT2, bool SO2, bool DF2 >
293  friend MT2& derestrict( DiagonalMatrix<MT2,SO2,DF2>& m );
294  //**********************************************************************************************
295 
296  //**Compile time checks*************************************************************************
309  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
310  //**********************************************************************************************
311 };
313 //*************************************************************************************************
314 
315 
316 
317 
318 //=================================================================================================
319 //
320 // CONSTRUCTORS
321 //
322 //=================================================================================================
323 
324 //*************************************************************************************************
328 template< typename MT // Type of the adapted sparse matrix
329  , bool SO > // Storage order of the adapted sparse matrix
330 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix()
331  : matrix_() // The adapted sparse matrix
332 {
333  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
334 }
336 //*************************************************************************************************
337 
338 
339 //*************************************************************************************************
347 template< typename MT // Type of the adapted sparse matrix
348  , bool SO > // Storage order of the adapted sparse matrix
349 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n )
350  : matrix_( n, n ) // The adapted sparse matrix
351 {
353 
354  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
355 }
357 //*************************************************************************************************
358 
359 
360 //*************************************************************************************************
369 template< typename MT // Type of the adapted sparse matrix
370  , bool SO > // Storage order of the adapted sparse matrix
371 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n, size_t nonzeros )
372  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
373 {
375 
376  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
377 }
379 //*************************************************************************************************
380 
381 
382 //*************************************************************************************************
393 template< typename MT // Type of the adapted sparse matrix
394  , bool SO > // Storage order of the adapted sparse matrix
395 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n, const std::vector<size_t>& nonzeros )
396  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
397 {
399 
400  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
401 }
403 //*************************************************************************************************
404 
405 
406 //*************************************************************************************************
412 template< typename MT // Type of the adapted sparse matrix
413  , bool SO > // Storage order of the adapted sparse matrix
414 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( const DiagonalMatrix& m )
415  : matrix_( m.matrix_ ) // The adapted sparse matrix
416 {
417  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
418  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
419 }
421 //*************************************************************************************************
422 
423 
424 //*************************************************************************************************
430 template< typename MT // Type of the adapted sparse matrix
431  , bool SO > // Storage order of the adapted sparse matrix
432 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( DiagonalMatrix&& m ) noexcept
433  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
434 {
435  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
436  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
437 }
439 //*************************************************************************************************
440 
441 
442 //*************************************************************************************************
452 template< typename MT // Type of the adapted sparse matrix
453  , bool SO > // Storage order of the adapted sparse matrix
454 template< typename MT2 // Type of the foreign matrix
455  , bool SO2 > // Storage order of the foreign matrix
456 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( const Matrix<MT2,SO2>& m )
457  : matrix_( ~m ) // The adapted sparse matrix
458 {
459  if( !IsDiagonal<MT2>::value && !isDiagonal( matrix_ ) ) {
460  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
461  }
462 
463  if( !IsDiagonal<MT2>::value )
464  resetNonDiagonal();
465 
466  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
467  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
468 }
470 //*************************************************************************************************
471 
472 
473 
474 
475 //=================================================================================================
476 //
477 // DATA ACCESS FUNCTIONS
478 //
479 //=================================================================================================
480 
481 //*************************************************************************************************
497 template< typename MT // Type of the adapted sparse matrix
498  , bool SO > // Storage order of the adapted sparse matrix
500  DiagonalMatrix<MT,SO,false>::operator()( size_t i, size_t j )
501 {
502  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
503  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
504 
505  return Reference( matrix_, i, j );
506 }
508 //*************************************************************************************************
509 
510 
511 //*************************************************************************************************
527 template< typename MT // Type of the adapted sparse matrix
528  , bool SO > // Storage order of the adapted sparse matrix
530  DiagonalMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
531 {
532  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
533  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
534 
535  return matrix_(i,j);
536 }
538 //*************************************************************************************************
539 
540 
541 //*************************************************************************************************
558 template< typename MT // Type of the adapted sparse matrix
559  , bool SO > // Storage order of the adapted sparse matrix
561  DiagonalMatrix<MT,SO,false>::at( size_t i, size_t j )
562 {
563  if( i >= rows() ) {
564  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
565  }
566  if( j >= columns() ) {
567  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
568  }
569  return (*this)(i,j);
570 }
572 //*************************************************************************************************
573 
574 
575 //*************************************************************************************************
592 template< typename MT // Type of the adapted sparse matrix
593  , bool SO > // Storage order of the adapted sparse matrix
595  DiagonalMatrix<MT,SO,false>::at( size_t i, size_t j ) const
596 {
597  if( i >= rows() ) {
598  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
599  }
600  if( j >= columns() ) {
601  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
602  }
603  return (*this)(i,j);
604 }
606 //*************************************************************************************************
607 
608 
609 //*************************************************************************************************
621 template< typename MT // Type of the adapted sparse matrix
622  , bool SO > // Storage order of the adapted sparse matrix
625 {
626  return matrix_.begin(i);
627 }
629 //*************************************************************************************************
630 
631 
632 //*************************************************************************************************
644 template< typename MT // Type of the adapted sparse matrix
645  , bool SO > // Storage order of the adapted sparse matrix
647  DiagonalMatrix<MT,SO,false>::begin( size_t i ) const
648 {
649  return matrix_.begin(i);
650 }
652 //*************************************************************************************************
653 
654 
655 //*************************************************************************************************
667 template< typename MT // Type of the adapted sparse matrix
668  , bool SO > // Storage order of the adapted sparse matrix
670  DiagonalMatrix<MT,SO,false>::cbegin( size_t i ) const
671 {
672  return matrix_.cbegin(i);
673 }
675 //*************************************************************************************************
676 
677 
678 //*************************************************************************************************
690 template< typename MT // Type of the adapted sparse matrix
691  , bool SO > // Storage order of the adapted sparse matrix
694 {
695  return matrix_.end(i);
696 }
698 //*************************************************************************************************
699 
700 
701 //*************************************************************************************************
713 template< typename MT // Type of the adapted sparse matrix
714  , bool SO > // Storage order of the adapted sparse matrix
716  DiagonalMatrix<MT,SO,false>::end( size_t i ) const
717 {
718  return matrix_.end(i);
719 }
721 //*************************************************************************************************
722 
723 
724 //*************************************************************************************************
736 template< typename MT // Type of the adapted sparse matrix
737  , bool SO > // Storage order of the adapted sparse matrix
739  DiagonalMatrix<MT,SO,false>::cend( size_t i ) const
740 {
741  return matrix_.cend(i);
742 }
744 //*************************************************************************************************
745 
746 
747 
748 
749 //=================================================================================================
750 //
751 // ASSIGNMENT OPERATORS
752 //
753 //=================================================================================================
754 
755 //*************************************************************************************************
765 template< typename MT // Type of the adapted sparse matrix
766  , bool SO > // Storage order of the adapted sparse matrix
767 inline DiagonalMatrix<MT,SO,false>&
768  DiagonalMatrix<MT,SO,false>::operator=( const DiagonalMatrix& rhs )
769 {
770  matrix_ = rhs.matrix_;
771 
772  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
773  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
774 
775  return *this;
776 }
778 //*************************************************************************************************
779 
780 
781 //*************************************************************************************************
788 template< typename MT // Type of the adapted sparse matrix
789  , bool SO > // Storage order of the adapted sparse matrix
790 inline DiagonalMatrix<MT,SO,false>&
791  DiagonalMatrix<MT,SO,false>::operator=( DiagonalMatrix&& rhs ) noexcept
792 {
793  matrix_ = std::move( rhs.matrix_ );
794 
795  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
796  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
797 
798  return *this;
799 }
801 //*************************************************************************************************
802 
803 
804 //*************************************************************************************************
817 template< typename MT // Type of the adapted sparse matrix
818  , bool SO > // Storage order of the adapted sparse matrix
819 template< typename MT2 // Type of the right-hand side matrix
820  , bool SO2 > // Storage order of the right-hand side matrix
821 inline DisableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >
822  DiagonalMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
823 {
824  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
825  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
826  }
827 
828  matrix_ = ~rhs;
829 
830  if( !IsDiagonal<MT2>::value )
831  resetNonDiagonal();
832 
833  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
834  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
835 
836  return *this;
837 }
839 //*************************************************************************************************
840 
841 
842 //*************************************************************************************************
855 template< typename MT // Type of the adapted sparse matrix
856  , bool SO > // Storage order of the adapted sparse matrix
857 template< typename MT2 // Type of the right-hand side matrix
858  , bool SO2 > // Storage order of the right-hand side matrix
859 inline EnableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >
860  DiagonalMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
861 {
862  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
863  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
864  }
865 
866  if( IsDiagonal<MT2>::value ) {
867  matrix_ = ~rhs;
868  }
869  else {
870  MT tmp( ~rhs );
871 
872  if( !isDiagonal( tmp ) ) {
873  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
874  }
875 
876  matrix_ = std::move( tmp );
877  }
878 
879  if( !IsDiagonal<MT2>::value )
880  resetNonDiagonal();
881 
882  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
883  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
884 
885  return *this;
886 }
888 //*************************************************************************************************
889 
890 
891 //*************************************************************************************************
904 template< typename MT // Type of the adapted sparse matrix
905  , bool SO > // Storage order of the adapted sparse matrix
906 template< typename MT2 // Type of the right-hand side matrix
907  , bool SO2 > // Storage order of the right-hand side matrix
908 inline DisableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >
909  DiagonalMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
910 {
911  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
912  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
913  }
914 
915  matrix_ += ~rhs;
916 
917  if( !IsDiagonal<MT2>::value )
918  resetNonDiagonal();
919 
920  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
921  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
922 
923  return *this;
924 }
926 //*************************************************************************************************
927 
928 
929 //*************************************************************************************************
942 template< typename MT // Type of the adapted sparse matrix
943  , bool SO > // Storage order of the adapted sparse matrix
944 template< typename MT2 // Type of the right-hand side matrix
945  , bool SO2 > // Storage order of the right-hand side matrix
946 inline EnableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >
947  DiagonalMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
948 {
949  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
950  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
951  }
952 
953  if( IsDiagonal<MT2>::value ) {
954  matrix_ += ~rhs;
955  }
956  else {
957  const ResultType_<MT2> tmp( ~rhs );
958 
959  if( !isDiagonal( tmp ) ) {
960  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
961  }
962 
963  matrix_ += tmp;
964  }
965 
966  if( !IsDiagonal<MT2>::value )
967  resetNonDiagonal();
968 
969  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
970  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
971 
972  return *this;
973 }
975 //*************************************************************************************************
976 
977 
978 //*************************************************************************************************
991 template< typename MT // Type of the adapted sparse matrix
992  , bool SO > // Storage order of the adapted sparse matrix
993 template< typename MT2 // Type of the right-hand side matrix
994  , bool SO2 > // Storage order of the right-hand side matrix
995 inline DisableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >
996  DiagonalMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
997 {
998  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
999  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1000  }
1001 
1002  matrix_ -= ~rhs;
1003 
1004  if( !IsDiagonal<MT2>::value )
1005  resetNonDiagonal();
1006 
1007  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1008  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1009 
1010  return *this;
1011 }
1013 //*************************************************************************************************
1014 
1015 
1016 //*************************************************************************************************
1029 template< typename MT // Type of the adapted sparse matrix
1030  , bool SO > // Storage order of the adapted sparse matrix
1031 template< typename MT2 // Type of the right-hand side matrix
1032  , bool SO2 > // Storage order of the right-hand side matrix
1033 inline EnableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >
1034  DiagonalMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1035 {
1036  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1037  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1038  }
1039 
1040  if( IsDiagonal<MT2>::value ) {
1041  matrix_ -= ~rhs;
1042  }
1043  else {
1044  const ResultType_<MT2> tmp( ~rhs );
1045 
1046  if( !isDiagonal( tmp ) ) {
1047  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1048  }
1049 
1050  matrix_ -= tmp;
1051  }
1052 
1053  if( !IsDiagonal<MT2>::value )
1054  resetNonDiagonal();
1055 
1056  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1057  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1058 
1059  return *this;
1060 }
1062 //*************************************************************************************************
1063 
1064 
1065 //*************************************************************************************************
1077 template< typename MT // Type of the adapted sparse matrix
1078  , bool SO > // Storage order of the adapted sparse matrix
1079 template< typename MT2 // Type of the right-hand side matrix
1080  , bool SO2 > // Storage order of the right-hand side matrix
1081 inline DiagonalMatrix<MT,SO,false>&
1082  DiagonalMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1083 {
1084  if( matrix_.rows() != (~rhs).columns() ) {
1085  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1086  }
1087 
1088  MT tmp( matrix_ * ~rhs );
1089 
1090  if( !isDiagonal( tmp ) ) {
1091  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1092  }
1093 
1094  matrix_ = std::move( tmp );
1095 
1096  if( !IsDiagonal<MT2>::value )
1097  resetNonDiagonal();
1098 
1099  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1100  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1101 
1102  return *this;
1103 }
1105 //*************************************************************************************************
1106 
1107 
1108 //*************************************************************************************************
1116 template< typename MT // Type of the adapted sparse matrix
1117  , bool SO > // Storage order of the adapted sparse matrix
1118 template< typename Other > // Data type of the right-hand side scalar
1119 inline EnableIf_< IsNumeric<Other>, DiagonalMatrix<MT,SO,false> >&
1121 {
1122  matrix_ *= rhs;
1123  return *this;
1124 }
1125 //*************************************************************************************************
1126 
1127 
1128 //*************************************************************************************************
1136 template< typename MT // Type of the adapted sparse matrix
1137  , bool SO > // Storage order of the adapted sparse matrix
1138 template< typename Other > // Data type of the right-hand side scalar
1139 inline EnableIf_< IsNumeric<Other>, DiagonalMatrix<MT,SO,false> >&
1141 {
1142  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1143 
1144  matrix_ /= rhs;
1145  return *this;
1146 }
1148 //*************************************************************************************************
1149 
1150 
1151 
1152 
1153 //=================================================================================================
1154 //
1155 // UTILITY FUNCTIONS
1156 //
1157 //=================================================================================================
1158 
1159 //*************************************************************************************************
1165 template< typename MT // Type of the adapted sparse matrix
1166  , bool SO > // Storage order of the adapted sparse matrix
1167 inline size_t DiagonalMatrix<MT,SO,false>::rows() const noexcept
1168 {
1169  return matrix_.rows();
1170 }
1172 //*************************************************************************************************
1173 
1174 
1175 //*************************************************************************************************
1181 template< typename MT // Type of the adapted sparse matrix
1182  , bool SO > // Storage order of the adapted sparse matrix
1183 inline size_t DiagonalMatrix<MT,SO,false>::columns() const noexcept
1184 {
1185  return matrix_.columns();
1186 }
1188 //*************************************************************************************************
1189 
1190 
1191 //*************************************************************************************************
1197 template< typename MT // Type of the adapted sparse matrix
1198  , bool SO > // Storage order of the adapted sparse matrix
1199 inline size_t DiagonalMatrix<MT,SO,false>::capacity() const noexcept
1200 {
1201  return matrix_.capacity();
1202 }
1204 //*************************************************************************************************
1205 
1206 
1207 //*************************************************************************************************
1219 template< typename MT // Type of the adapted sparse matrix
1220  , bool SO > // Storage order of the adapted sparse matrix
1221 inline size_t DiagonalMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1222 {
1223  return matrix_.capacity(i);
1224 }
1226 //*************************************************************************************************
1227 
1228 
1229 //*************************************************************************************************
1235 template< typename MT // Type of the adapted sparse matrix
1236  , bool SO > // Storage order of the adapted sparse matrix
1237 inline size_t DiagonalMatrix<MT,SO,false>::nonZeros() const
1238 {
1239  return matrix_.nonZeros();
1240 }
1242 //*************************************************************************************************
1243 
1244 
1245 //*************************************************************************************************
1257 template< typename MT // Type of the adapted sparse matrix
1258  , bool SO > // Storage order of the adapted sparse matrix
1259 inline size_t DiagonalMatrix<MT,SO,false>::nonZeros( size_t i ) const
1260 {
1261  return matrix_.nonZeros(i);
1262 }
1264 //*************************************************************************************************
1265 
1266 
1267 //*************************************************************************************************
1273 template< typename MT // Type of the adapted sparse matrix
1274  , bool SO > // Storage order of the adapted sparse matrix
1276 {
1277  matrix_.reset();
1278 }
1280 //*************************************************************************************************
1281 
1282 
1283 //*************************************************************************************************
1296 template< typename MT // Type of the adapted sparse matrix
1297  , bool SO > // Storage order of the adapted sparse matrix
1298 inline void DiagonalMatrix<MT,SO,false>::reset( size_t i )
1299 {
1300  matrix_.reset( i );
1301 }
1303 //*************************************************************************************************
1304 
1305 
1306 //*************************************************************************************************
1314 template< typename MT // Type of the adapted sparse matrix
1315  , bool SO > // Storage order of the adapted sparse matrix
1317 {
1318  using blaze::clear;
1319 
1320  clear( matrix_ );
1321 }
1323 //*************************************************************************************************
1324 
1325 
1326 //*************************************************************************************************
1342 template< typename MT // Type of the adapted sparse matrix
1343  , bool SO > // Storage order of the adapted sparse matrix
1345  DiagonalMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1346 {
1347  if( i < j ) {
1348  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1349  }
1350 
1351  return matrix_.set( i, j, value );
1352 }
1354 //*************************************************************************************************
1355 
1356 
1357 //*************************************************************************************************
1374 template< typename MT // Type of the adapted sparse matrix
1375  , bool SO > // Storage order of the adapted sparse matrix
1377  DiagonalMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1378 {
1379  if( i < j ) {
1380  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1381  }
1382 
1383  return matrix_.insert( i, j, value );
1384 }
1386 //*************************************************************************************************
1387 
1388 
1389 //*************************************************************************************************
1399 template< typename MT // Type of the adapted sparse matrix
1400  , bool SO > // Storage order of the adapted sparse matrix
1401 inline void DiagonalMatrix<MT,SO,false>::erase( size_t i, size_t j )
1402 {
1403  matrix_.erase( i, j );
1404 }
1406 //*************************************************************************************************
1407 
1408 
1409 //*************************************************************************************************
1421 template< typename MT // Type of the adapted sparse matrix
1422  , bool SO > // Storage order of the adapted sparse matrix
1424  DiagonalMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1425 {
1426  return matrix_.erase( i, pos );
1427 }
1429 //*************************************************************************************************
1430 
1431 
1432 //*************************************************************************************************
1446 template< typename MT // Type of the adapted sparse matrix
1447  , bool SO > // Storage order of the adapted sparse matrix
1449  DiagonalMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1450 {
1451  return matrix_.erase( i, first, last );
1452 }
1454 //*************************************************************************************************
1455 
1456 
1457 //*************************************************************************************************
1472 template< typename MT // Type of the adapted sparse matrix
1473  , bool SO > // Storage order of the adapted sparse matrix
1474 void DiagonalMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1475 {
1477 
1478  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1479 
1480  matrix_.resize( n, n, preserve );
1481 }
1483 //*************************************************************************************************
1484 
1485 
1486 //*************************************************************************************************
1497 template< typename MT // Type of the adapted sparse matrix
1498  , bool SO > // Storage order of the adapted sparse matrix
1499 inline void DiagonalMatrix<MT,SO,false>::reserve( size_t nonzeros )
1500 {
1501  matrix_.reserve( nonzeros );
1502 }
1504 //*************************************************************************************************
1505 
1506 
1507 //*************************************************************************************************
1521 template< typename MT // Type of the adapted sparse matrix
1522  , bool SO > // Storage order of the adapted sparse matrix
1523 inline void DiagonalMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1524 {
1525  matrix_.reserve( i, nonzeros );
1526 }
1528 //*************************************************************************************************
1529 
1530 
1531 //*************************************************************************************************
1542 template< typename MT // Type of the adapted sparse matrix
1543  , bool SO > // Storage order of the adapted sparse matrix
1544 inline void DiagonalMatrix<MT,SO,false>::trim()
1545 {
1546  matrix_.trim();
1547 }
1549 //*************************************************************************************************
1550 
1551 
1552 //*************************************************************************************************
1564 template< typename MT // Type of the adapted sparse matrix
1565  , bool SO > // Storage order of the adapted sparse matrix
1566 inline void DiagonalMatrix<MT,SO,false>::trim( size_t i )
1567 {
1568  matrix_.trim( i );
1569 }
1571 //*************************************************************************************************
1572 
1573 
1574 //*************************************************************************************************
1581 template< typename MT // Type of the adapted sparse matrix
1582  , bool SO > // Storage order of the adapted sparse matrix
1583 template< typename Other > // Data type of the scalar value
1584 inline DiagonalMatrix<MT,SO,false>&
1585  DiagonalMatrix<MT,SO,false>::scale( const Other& scalar )
1586 {
1587  matrix_.scale( scalar );
1588  return *this;
1589 }
1591 //*************************************************************************************************
1592 
1593 
1594 //*************************************************************************************************
1601 template< typename MT // Type of the adapted sparse matrix
1602  , bool SO > // Storage order of the adapted sparse matrix
1603 template< typename Other > // Data type of the scalar value
1604 inline DiagonalMatrix<MT,SO,false>&
1605  DiagonalMatrix<MT,SO,false>::scaleDiagonal( Other scalar )
1606 {
1607  matrix_.scaleDiagonal( scalar );
1608  return *this;
1609 }
1611 //*************************************************************************************************
1612 
1613 
1614 //*************************************************************************************************
1621 template< typename MT // Type of the adapted sparse matrix
1622  , bool SO > // Storage order of the adapted sparse matrix
1623 inline void DiagonalMatrix<MT,SO,false>::swap( DiagonalMatrix& m ) noexcept
1624 {
1625  using std::swap;
1626 
1627  swap( matrix_, m.matrix_ );
1628 }
1630 //*************************************************************************************************
1631 
1632 
1633 //*************************************************************************************************
1639 template< typename MT // Type of the adapted dense matrix
1640  , bool SO > // Storage order of the adapted dense matrix
1641 inline void DiagonalMatrix<MT,SO,false>::resetNonDiagonal()
1642 {
1643  for( size_t i=0UL; i<rows(); ++i ) {
1644  matrix_.erase( i, matrix_.begin( i ), matrix_.lowerBound( i, i ) );
1645  matrix_.erase( i, matrix_.upperBound( i, i ), matrix_.end( i ) );
1646  }
1647 }
1649 //*************************************************************************************************
1650 
1651 
1652 
1653 
1654 //=================================================================================================
1655 //
1656 // LOOKUP FUNCTIONS
1657 //
1658 //=================================================================================================
1659 
1660 //*************************************************************************************************
1676 template< typename MT // Type of the adapted sparse matrix
1677  , bool SO > // Storage order of the adapted sparse matrix
1679  DiagonalMatrix<MT,SO,false>::find( size_t i, size_t j )
1680 {
1681  return matrix_.find( i, j );
1682 }
1684 //*************************************************************************************************
1685 
1686 
1687 //*************************************************************************************************
1703 template< typename MT // Type of the adapted sparse matrix
1704  , bool SO > // Storage order of the adapted sparse matrix
1706  DiagonalMatrix<MT,SO,false>::find( size_t i, size_t j ) const
1707 {
1708  return matrix_.find( i, j );
1709 }
1711 //*************************************************************************************************
1712 
1713 
1714 //*************************************************************************************************
1730 template< typename MT // Type of the adapted sparse matrix
1731  , bool SO > // Storage order of the adapted sparse matrix
1733  DiagonalMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
1734 {
1735  return matrix_.lowerBound( i, j );
1736 }
1738 //*************************************************************************************************
1739 
1740 
1741 //*************************************************************************************************
1757 template< typename MT // Type of the adapted sparse matrix
1758  , bool SO > // Storage order of the adapted sparse matrix
1760  DiagonalMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
1761 {
1762  return matrix_.lowerBound( i, j );
1763 }
1765 //*************************************************************************************************
1766 
1767 
1768 //*************************************************************************************************
1784 template< typename MT // Type of the adapted sparse matrix
1785  , bool SO > // Storage order of the adapted sparse matrix
1787  DiagonalMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
1788 {
1789  return matrix_.upperBound( i, j );
1790 }
1792 //*************************************************************************************************
1793 
1794 
1795 //*************************************************************************************************
1811 template< typename MT // Type of the adapted sparse matrix
1812  , bool SO > // Storage order of the adapted sparse matrix
1814  DiagonalMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
1815 {
1816  return matrix_.upperBound( i, j );
1817 }
1819 //*************************************************************************************************
1820 
1821 
1822 
1823 
1824 //=================================================================================================
1825 //
1826 // LOW-LEVEL UTILITY FUNCTIONS
1827 //
1828 //=================================================================================================
1829 
1830 //*************************************************************************************************
1880 template< typename MT // Type of the adapted sparse matrix
1881  , bool SO > // Storage order of the adapted sparse matrix
1882 inline void DiagonalMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1883 {
1884  if( i < j ) {
1885  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1886  }
1887 
1888  matrix_.append( i, j, value, check );
1889 }
1891 //*************************************************************************************************
1892 
1893 
1894 //*************************************************************************************************
1908 template< typename MT // Type of the adapted sparse matrix
1909  , bool SO > // Storage order of the adapted sparse matrix
1910 inline void DiagonalMatrix<MT,SO,false>::finalize( size_t i )
1911 {
1912  matrix_.finalize( i );
1913 }
1915 //*************************************************************************************************
1916 
1917 
1918 
1919 
1920 //=================================================================================================
1921 //
1922 // DEBUGGING FUNCTIONS
1923 //
1924 //=================================================================================================
1925 
1926 //*************************************************************************************************
1936 template< typename MT // Type of the adapted sparse matrix
1937  , bool SO > // Storage order of the adapted sparse matrix
1938 inline bool DiagonalMatrix<MT,SO,false>::isIntact() const noexcept
1939 {
1940  using blaze::isIntact;
1941 
1942  return ( isIntact( matrix_ ) && isDiagonal( matrix_ ) );
1943 }
1945 //*************************************************************************************************
1946 
1947 
1948 
1949 
1950 //=================================================================================================
1951 //
1952 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1953 //
1954 //=================================================================================================
1955 
1956 //*************************************************************************************************
1967 template< typename MT // Type of the adapted sparse matrix
1968  , bool SO > // Storage order of the adapted sparse matrix
1969 template< typename Other > // Data type of the foreign expression
1970 inline bool DiagonalMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
1971 {
1972  return matrix_.canAlias( alias );
1973 }
1975 //*************************************************************************************************
1976 
1977 
1978 //*************************************************************************************************
1989 template< typename MT // Type of the adapted sparse matrix
1990  , bool SO > // Storage order of the adapted sparse matrix
1991 template< typename Other > // Data type of the foreign expression
1992 inline bool DiagonalMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
1993 {
1994  return matrix_.isAliased( alias );
1995 }
1997 //*************************************************************************************************
1998 
1999 
2000 //*************************************************************************************************
2011 template< typename MT // Type of the adapted sparse matrix
2012  , bool SO > // Storage order of the adapted sparse matrix
2013 inline bool DiagonalMatrix<MT,SO,false>::canSMPAssign() const noexcept
2014 {
2015  return matrix_.canSMPAssign();
2016 }
2018 //*************************************************************************************************
2019 
2020 } // namespace blaze
2021 
2022 #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
bool isDiagonal(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is diagonal.
Definition: DenseMatrix.h:1499
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:346
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:188
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:2643
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5077
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2636
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:384
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.
STL namespace.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2639
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:298
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:232
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
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:5148
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5131
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#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:330
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2640
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:538
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:254
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2641
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
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:2642
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:2646
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:258
Constraint on the data type.
Constraint on the data type.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:314
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:2637
#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 '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:2638
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
#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:609
#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