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 <algorithm>
44 #include <vector>
56 #include <blaze/math/shims/Clear.h>
58 #include <blaze/math/shims/Move.h>
65 #include <blaze/util/Assert.h>
70 #include <blaze/util/DisableIf.h>
71 #include <blaze/util/EnableIf.h>
72 #include <blaze/util/Exception.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 typename MT::OppositeType OT;
102  typedef typename MT::TransposeType TT;
103  typedef typename MT::ElementType ET;
104  //**********************************************************************************************
105 
106  public:
107  //**Type definitions****************************************************************************
108  typedef DiagonalMatrix<MT,SO,false> This;
109  typedef This ResultType;
110  typedef DiagonalMatrix<OT,!SO,false> OppositeType;
111  typedef DiagonalMatrix<TT,!SO,false> TransposeType;
112  typedef ET ElementType;
113  typedef typename MT::ReturnType ReturnType;
114  typedef const This& CompositeType;
115  typedef DiagonalProxy<MT> Reference;
116  typedef typename MT::ConstReference ConstReference;
117  typedef typename MT::Iterator Iterator;
118  typedef typename MT::ConstIterator ConstIterator;
119  //**********************************************************************************************
120 
121  //**Rebind struct definition********************************************************************
124  template< typename ET > // Data type of the other matrix
125  struct Rebind {
127  typedef DiagonalMatrix< typename MT::template Rebind<ET>::Other > Other;
128  };
129  //**********************************************************************************************
130 
131  //**Compilation flags***************************************************************************
133  enum { smpAssignable = 0 };
134  //**********************************************************************************************
135 
136  //**Constructors********************************************************************************
139  explicit inline DiagonalMatrix();
140  explicit inline DiagonalMatrix( size_t n );
141  explicit inline DiagonalMatrix( size_t n, size_t nonzeros );
142  explicit inline DiagonalMatrix( size_t n, const std::vector<size_t>& nonzeros );
143 
144  inline DiagonalMatrix( const DiagonalMatrix& m );
145  template< typename MT2, bool SO2 > inline DiagonalMatrix( const Matrix<MT2,SO2>& m );
147  //**********************************************************************************************
148 
149  //**Destructor**********************************************************************************
150  // No explicitly declared destructor.
151  //**********************************************************************************************
152 
153  //**Data access functions***********************************************************************
156  inline Reference operator()( size_t i, size_t j );
157  inline ConstReference operator()( size_t i, size_t j ) const;
158  inline Reference at( size_t i, size_t j );
159  inline ConstReference at( size_t i, size_t j ) const;
160  inline Iterator begin ( size_t i );
161  inline ConstIterator begin ( size_t i ) const;
162  inline ConstIterator cbegin( size_t i ) const;
163  inline Iterator end ( size_t i );
164  inline ConstIterator end ( size_t i ) const;
165  inline ConstIterator cend ( size_t i ) const;
167  //**********************************************************************************************
168 
169  //**Assignment operators************************************************************************
172  inline DiagonalMatrix& operator=( const DiagonalMatrix& rhs );
173 
174  template< typename MT2, bool SO2 >
175  inline typename DisableIf< IsComputation<MT2>, DiagonalMatrix& >::Type
176  operator=( const Matrix<MT2,SO2>& rhs );
177 
178  template< typename MT2, bool SO2 >
179  inline typename EnableIf< IsComputation<MT2>, DiagonalMatrix& >::Type
180  operator=( const Matrix<MT2,SO2>& rhs );
181 
182  template< typename MT2, bool SO2 >
183  inline typename DisableIf< IsComputation<MT2>, DiagonalMatrix& >::Type
184  operator+=( const Matrix<MT2,SO2>& rhs );
185 
186  template< typename MT2, bool SO2 >
187  inline typename EnableIf< IsComputation<MT2>, DiagonalMatrix& >::Type
188  operator+=( const Matrix<MT2,SO2>& rhs );
189 
190  template< typename MT2, bool SO2 >
191  inline typename DisableIf< IsComputation<MT2>, DiagonalMatrix& >::Type
192  operator-=( const Matrix<MT2,SO2>& rhs );
193 
194  template< typename MT2, bool SO2 >
195  inline typename EnableIf< IsComputation<MT2>, DiagonalMatrix& >::Type
196  operator-=( const Matrix<MT2,SO2>& rhs );
197 
198  template< typename MT2, bool SO2 >
199  inline DiagonalMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
200 
201  template< typename Other >
202  inline typename EnableIf< IsNumeric<Other>, DiagonalMatrix >::Type&
203  operator*=( Other rhs );
204 
205  template< typename Other >
206  inline typename EnableIf< IsNumeric<Other>, DiagonalMatrix >::Type&
207  operator/=( Other rhs );
209  //**********************************************************************************************
210 
211  //**Utility functions***************************************************************************
214  inline size_t rows() const;
215  inline size_t columns() const;
216  inline size_t capacity() const;
217  inline size_t capacity( size_t i ) const;
218  inline size_t nonZeros() const;
219  inline size_t nonZeros( size_t i ) const;
220  inline void reset();
221  inline void reset( size_t i );
222  inline void clear();
223  inline Iterator set( size_t i, size_t j, const ElementType& value );
224  inline Iterator insert( size_t i, size_t j, const ElementType& value );
225  inline void erase( size_t i, size_t j );
226  inline Iterator erase( size_t i, Iterator pos );
227  inline Iterator erase( size_t i, Iterator first, Iterator last );
228  inline void resize ( size_t n, bool preserve=true );
229  inline void reserve( size_t nonzeros );
230  inline void reserve( size_t i, size_t nonzeros );
231  inline void trim();
232  inline void trim( size_t i );
233  template< typename Other > inline DiagonalMatrix& scale( const Other& scalar );
234  template< typename Other > inline DiagonalMatrix& scaleDiagonal( Other scale );
235  inline void swap( DiagonalMatrix& m ) /* throw() */;
237  //**********************************************************************************************
238 
239  //**Lookup functions****************************************************************************
242  inline Iterator find ( size_t i, size_t j );
243  inline ConstIterator find ( size_t i, size_t j ) const;
244  inline Iterator lowerBound( size_t i, size_t j );
245  inline ConstIterator lowerBound( size_t i, size_t j ) const;
246  inline Iterator upperBound( size_t i, size_t j );
247  inline ConstIterator upperBound( size_t i, size_t j ) const;
249  //**********************************************************************************************
250 
251  //**Low-level utility functions*****************************************************************
254  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
255  inline void finalize( size_t i );
257  //**********************************************************************************************
258 
259  //**Debugging functions*************************************************************************
262  inline bool isIntact() const;
264  //**********************************************************************************************
265 
266  //**Expression template evaluation functions****************************************************
269  template< typename Other > inline bool canAlias ( const Other* alias ) const;
270  template< typename Other > inline bool isAliased( const Other* alias ) const;
271 
272  inline bool canSMPAssign() const;
274  //**********************************************************************************************
275 
276  private:
277  //**Utility functions***************************************************************************
280  inline void resetNonDiagonal();
282  //**********************************************************************************************
283 
284  //**Member variables****************************************************************************
287  MT matrix_;
288 
289  //**********************************************************************************************
290 
291  //**Friend declarations*************************************************************************
292  template< typename MT2, bool SO2, bool DF2 >
293  friend bool isDefault( const DiagonalMatrix<MT2,SO2,DF2>& m );
294 
295  template< typename MT2, bool SO2, bool DF2 >
296  friend MT2& derestrict( DiagonalMatrix<MT2,SO2,DF2>& m );
297  //**********************************************************************************************
298 
299  //**Compile time checks*************************************************************************
312  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
313  //**********************************************************************************************
314 };
316 //*************************************************************************************************
317 
318 
319 
320 
321 //=================================================================================================
322 //
323 // CONSTRUCTORS
324 //
325 //=================================================================================================
326 
327 //*************************************************************************************************
331 template< typename MT // Type of the adapted sparse matrix
332  , bool SO > // Storage order of the adapted sparse matrix
333 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix()
334  : matrix_() // The adapted sparse matrix
335 {
336  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
337 }
339 //*************************************************************************************************
340 
341 
342 //*************************************************************************************************
350 template< typename MT // Type of the adapted sparse matrix
351  , bool SO > // Storage order of the adapted sparse matrix
352 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n )
353  : matrix_( n, n ) // The adapted sparse matrix
354 {
356 
357  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
358 }
360 //*************************************************************************************************
361 
362 
363 //*************************************************************************************************
372 template< typename MT // Type of the adapted sparse matrix
373  , bool SO > // Storage order of the adapted sparse matrix
374 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n, size_t nonzeros )
375  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
376 {
378 
379  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
380 }
382 //*************************************************************************************************
383 
384 
385 //*************************************************************************************************
396 template< typename MT // Type of the adapted sparse matrix
397  , bool SO > // Storage order of the adapted sparse matrix
398 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n, const std::vector<size_t>& nonzeros )
399  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
400 {
402 
403  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
404 }
406 //*************************************************************************************************
407 
408 
409 //*************************************************************************************************
415 template< typename MT // Type of the adapted sparse matrix
416  , bool SO > // Storage order of the adapted sparse matrix
417 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( const DiagonalMatrix& m )
418  : matrix_( m.matrix_ ) // The adapted sparse matrix
419 {
420  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
421  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
422 }
424 //*************************************************************************************************
425 
426 
427 //*************************************************************************************************
437 template< typename MT // Type of the adapted sparse matrix
438  , bool SO > // Storage order of the adapted sparse matrix
439 template< typename MT2 // Type of the foreign matrix
440  , bool SO2 > // Storage order of the foreign matrix
441 inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( const Matrix<MT2,SO2>& m )
442  : matrix_( ~m ) // The adapted sparse matrix
443 {
444  if( !IsDiagonal<MT2>::value && !isDiagonal( matrix_ ) ) {
445  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
446  }
447 
448  if( !IsDiagonal<MT2>::value )
449  resetNonDiagonal();
450 
451  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
452  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
453 }
455 //*************************************************************************************************
456 
457 
458 
459 
460 //=================================================================================================
461 //
462 // DATA ACCESS FUNCTIONS
463 //
464 //=================================================================================================
465 
466 //*************************************************************************************************
482 template< typename MT // Type of the adapted sparse matrix
483  , bool SO > // Storage order of the adapted sparse matrix
485  DiagonalMatrix<MT,SO,false>::operator()( size_t i, size_t j )
486 {
487  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
488  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
489 
490  return Reference( matrix_, i, j );
491 }
493 //*************************************************************************************************
494 
495 
496 //*************************************************************************************************
512 template< typename MT // Type of the adapted sparse matrix
513  , bool SO > // Storage order of the adapted sparse matrix
515  DiagonalMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
516 {
517  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
518  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
519 
520  return matrix_(i,j);
521 }
523 //*************************************************************************************************
524 
525 
526 //*************************************************************************************************
543 template< typename MT // Type of the adapted sparse matrix
544  , bool SO > // Storage order of the adapted sparse matrix
546  DiagonalMatrix<MT,SO,false>::at( size_t i, size_t j )
547 {
548  if( i >= rows() ) {
549  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
550  }
551  if( j >= columns() ) {
552  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
553  }
554  return (*this)(i,j);
555 }
557 //*************************************************************************************************
558 
559 
560 //*************************************************************************************************
577 template< typename MT // Type of the adapted sparse matrix
578  , bool SO > // Storage order of the adapted sparse matrix
580  DiagonalMatrix<MT,SO,false>::at( size_t i, size_t j ) const
581 {
582  if( i >= rows() ) {
583  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
584  }
585  if( j >= columns() ) {
586  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
587  }
588  return (*this)(i,j);
589 }
591 //*************************************************************************************************
592 
593 
594 //*************************************************************************************************
606 template< typename MT // Type of the adapted sparse matrix
607  , bool SO > // Storage order of the adapted sparse matrix
610 {
611  return matrix_.begin(i);
612 }
614 //*************************************************************************************************
615 
616 
617 //*************************************************************************************************
629 template< typename MT // Type of the adapted sparse matrix
630  , bool SO > // Storage order of the adapted sparse matrix
632  DiagonalMatrix<MT,SO,false>::begin( size_t i ) const
633 {
634  return matrix_.begin(i);
635 }
637 //*************************************************************************************************
638 
639 
640 //*************************************************************************************************
652 template< typename MT // Type of the adapted sparse matrix
653  , bool SO > // Storage order of the adapted sparse matrix
655  DiagonalMatrix<MT,SO,false>::cbegin( size_t i ) const
656 {
657  return matrix_.cbegin(i);
658 }
660 //*************************************************************************************************
661 
662 
663 //*************************************************************************************************
675 template< typename MT // Type of the adapted sparse matrix
676  , bool SO > // Storage order of the adapted sparse matrix
679 {
680  return matrix_.end(i);
681 }
683 //*************************************************************************************************
684 
685 
686 //*************************************************************************************************
698 template< typename MT // Type of the adapted sparse matrix
699  , bool SO > // Storage order of the adapted sparse matrix
701  DiagonalMatrix<MT,SO,false>::end( size_t i ) const
702 {
703  return matrix_.end(i);
704 }
706 //*************************************************************************************************
707 
708 
709 //*************************************************************************************************
721 template< typename MT // Type of the adapted sparse matrix
722  , bool SO > // Storage order of the adapted sparse matrix
724  DiagonalMatrix<MT,SO,false>::cend( size_t i ) const
725 {
726  return matrix_.cend(i);
727 }
729 //*************************************************************************************************
730 
731 
732 
733 
734 //=================================================================================================
735 //
736 // ASSIGNMENT OPERATORS
737 //
738 //=================================================================================================
739 
740 //*************************************************************************************************
750 template< typename MT // Type of the adapted sparse matrix
751  , bool SO > // Storage order of the adapted sparse matrix
752 inline DiagonalMatrix<MT,SO,false>&
753  DiagonalMatrix<MT,SO,false>::operator=( const DiagonalMatrix& rhs )
754 {
755  matrix_ = rhs.matrix_;
756 
757  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
758  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
759 
760  return *this;
761 }
763 //*************************************************************************************************
764 
765 
766 //*************************************************************************************************
779 template< typename MT // Type of the adapted sparse matrix
780  , bool SO > // Storage order of the adapted sparse matrix
781 template< typename MT2 // Type of the right-hand side matrix
782  , bool SO2 > // Storage order of the right-hand side matrix
783 inline typename DisableIf< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >::Type
784  DiagonalMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
785 {
786  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
787  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
788  }
789 
790  matrix_ = ~rhs;
791 
792  if( !IsDiagonal<MT2>::value )
793  resetNonDiagonal();
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 typename EnableIf< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >::Type
822  DiagonalMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
823 {
824  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
825  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
826  }
827 
828  if( IsDiagonal<MT2>::value ) {
829  matrix_ = ~rhs;
830  }
831  else {
832  MT tmp( ~rhs );
833 
834  if( !isDiagonal( tmp ) ) {
835  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
836  }
837 
838  move( matrix_, tmp );
839  }
840 
841  if( !IsDiagonal<MT2>::value )
842  resetNonDiagonal();
843 
844  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
845  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
846 
847  return *this;
848 }
850 //*************************************************************************************************
851 
852 
853 //*************************************************************************************************
866 template< typename MT // Type of the adapted sparse matrix
867  , bool SO > // Storage order of the adapted sparse matrix
868 template< typename MT2 // Type of the right-hand side matrix
869  , bool SO2 > // Storage order of the right-hand side matrix
870 inline typename DisableIf< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >::Type
871  DiagonalMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
872 {
873  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
874  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
875  }
876 
877  matrix_ += ~rhs;
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 typename EnableIf< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >::Type
909  DiagonalMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
910 {
911  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
912  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
913  }
914 
915  if( IsDiagonal<MT2>::value ) {
916  matrix_ += ~rhs;
917  }
918  else {
919  typename MT2::ResultType tmp( ~rhs );
920 
921  if( !isDiagonal( tmp ) ) {
922  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
923  }
924 
925  matrix_ += tmp;
926  }
927 
928  if( !IsDiagonal<MT2>::value )
929  resetNonDiagonal();
930 
931  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
932  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
933 
934  return *this;
935 }
937 //*************************************************************************************************
938 
939 
940 //*************************************************************************************************
953 template< typename MT // Type of the adapted sparse matrix
954  , bool SO > // Storage order of the adapted sparse matrix
955 template< typename MT2 // Type of the right-hand side matrix
956  , bool SO2 > // Storage order of the right-hand side matrix
957 inline typename DisableIf< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >::Type
958  DiagonalMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
959 {
960  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
961  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
962  }
963 
964  matrix_ -= ~rhs;
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 typename EnableIf< IsComputation<MT2>, DiagonalMatrix<MT,SO,false>& >::Type
996  DiagonalMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
997 {
998  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
999  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1000  }
1001 
1002  if( IsDiagonal<MT2>::value ) {
1003  matrix_ -= ~rhs;
1004  }
1005  else {
1006  typename MT2::ResultType tmp( ~rhs );
1007 
1008  if( !isDiagonal( tmp ) ) {
1009  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1010  }
1011 
1012  matrix_ -= tmp;
1013  }
1014 
1015  if( !IsDiagonal<MT2>::value )
1016  resetNonDiagonal();
1017 
1018  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1019  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1020 
1021  return *this;
1022 }
1024 //*************************************************************************************************
1025 
1026 
1027 //*************************************************************************************************
1039 template< typename MT // Type of the adapted sparse matrix
1040  , bool SO > // Storage order of the adapted sparse matrix
1041 template< typename MT2 // Type of the right-hand side matrix
1042  , bool SO2 > // Storage order of the right-hand side matrix
1043 inline DiagonalMatrix<MT,SO,false>&
1044  DiagonalMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1045 {
1046  if( matrix_.rows() != (~rhs).columns() ) {
1047  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1048  }
1049 
1050  MT tmp( matrix_ * ~rhs );
1051 
1052  if( !isDiagonal( tmp ) ) {
1053  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1054  }
1055 
1056  move( matrix_, tmp );
1057 
1058  if( !IsDiagonal<MT2>::value )
1059  resetNonDiagonal();
1060 
1061  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1062  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1063 
1064  return *this;
1065 }
1067 //*************************************************************************************************
1068 
1069 
1070 //*************************************************************************************************
1078 template< typename MT // Type of the adapted sparse matrix
1079  , bool SO > // Storage order of the adapted sparse matrix
1080 template< typename Other > // Data type of the right-hand side scalar
1081 inline typename EnableIf< IsNumeric<Other>, DiagonalMatrix<MT,SO,false> >::Type&
1082  DiagonalMatrix<MT,SO,false>::operator*=( Other rhs )
1083 {
1084  matrix_ *= rhs;
1085  return *this;
1086 }
1087 //*************************************************************************************************
1088 
1089 
1090 //*************************************************************************************************
1098 template< typename MT // Type of the adapted sparse matrix
1099  , bool SO > // Storage order of the adapted sparse matrix
1100 template< typename Other > // Data type of the right-hand side scalar
1101 inline typename EnableIf< IsNumeric<Other>, DiagonalMatrix<MT,SO,false> >::Type&
1102  DiagonalMatrix<MT,SO,false>::operator/=( Other rhs )
1103 {
1104  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1105 
1106  matrix_ /= rhs;
1107  return *this;
1108 }
1110 //*************************************************************************************************
1111 
1112 
1113 
1114 
1115 //=================================================================================================
1116 //
1117 // UTILITY FUNCTIONS
1118 //
1119 //=================================================================================================
1120 
1121 //*************************************************************************************************
1127 template< typename MT // Type of the adapted sparse matrix
1128  , bool SO > // Storage order of the adapted sparse matrix
1129 inline size_t DiagonalMatrix<MT,SO,false>::rows() const
1130 {
1131  return matrix_.rows();
1132 }
1134 //*************************************************************************************************
1135 
1136 
1137 //*************************************************************************************************
1143 template< typename MT // Type of the adapted sparse matrix
1144  , bool SO > // Storage order of the adapted sparse matrix
1145 inline size_t DiagonalMatrix<MT,SO,false>::columns() const
1146 {
1147  return matrix_.columns();
1148 }
1150 //*************************************************************************************************
1151 
1152 
1153 //*************************************************************************************************
1159 template< typename MT // Type of the adapted sparse matrix
1160  , bool SO > // Storage order of the adapted sparse matrix
1161 inline size_t DiagonalMatrix<MT,SO,false>::capacity() const
1162 {
1163  return matrix_.capacity();
1164 }
1166 //*************************************************************************************************
1167 
1168 
1169 //*************************************************************************************************
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>::capacity( size_t i ) const
1184 {
1185  return matrix_.capacity(i);
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>::nonZeros() const
1200 {
1201  return matrix_.nonZeros();
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>::nonZeros( size_t i ) const
1222 {
1223  return matrix_.nonZeros(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
1238 {
1239  matrix_.reset();
1240 }
1242 //*************************************************************************************************
1243 
1244 
1245 //*************************************************************************************************
1258 template< typename MT // Type of the adapted sparse matrix
1259  , bool SO > // Storage order of the adapted sparse matrix
1260 inline void DiagonalMatrix<MT,SO,false>::reset( size_t i )
1261 {
1262  matrix_.reset( i );
1263 }
1265 //*************************************************************************************************
1266 
1267 
1268 //*************************************************************************************************
1276 template< typename MT // Type of the adapted sparse matrix
1277  , bool SO > // Storage order of the adapted sparse matrix
1279 {
1280  using blaze::clear;
1281 
1282  clear( matrix_ );
1283 }
1285 //*************************************************************************************************
1286 
1287 
1288 //*************************************************************************************************
1304 template< typename MT // Type of the adapted sparse matrix
1305  , bool SO > // Storage order of the adapted sparse matrix
1307  DiagonalMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1308 {
1309  if( i < j ) {
1310  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1311  }
1312 
1313  return matrix_.set( i, j, value );
1314 }
1316 //*************************************************************************************************
1317 
1318 
1319 //*************************************************************************************************
1336 template< typename MT // Type of the adapted sparse matrix
1337  , bool SO > // Storage order of the adapted sparse matrix
1339  DiagonalMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1340 {
1341  if( i < j ) {
1342  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1343  }
1344 
1345  return matrix_.insert( i, j, value );
1346 }
1348 //*************************************************************************************************
1349 
1350 
1351 //*************************************************************************************************
1361 template< typename MT // Type of the adapted sparse matrix
1362  , bool SO > // Storage order of the adapted sparse matrix
1363 inline void DiagonalMatrix<MT,SO,false>::erase( size_t i, size_t j )
1364 {
1365  matrix_.erase( i, j );
1366 }
1368 //*************************************************************************************************
1369 
1370 
1371 //*************************************************************************************************
1383 template< typename MT // Type of the adapted sparse matrix
1384  , bool SO > // Storage order of the adapted sparse matrix
1386  DiagonalMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1387 {
1388  return matrix_.erase( i, pos );
1389 }
1391 //*************************************************************************************************
1392 
1393 
1394 //*************************************************************************************************
1408 template< typename MT // Type of the adapted sparse matrix
1409  , bool SO > // Storage order of the adapted sparse matrix
1411  DiagonalMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1412 {
1413  return matrix_.erase( i, first, last );
1414 }
1416 //*************************************************************************************************
1417 
1418 
1419 //*************************************************************************************************
1434 template< typename MT // Type of the adapted sparse matrix
1435  , bool SO > // Storage order of the adapted sparse matrix
1436 void DiagonalMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1437 {
1439 
1440  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1441 
1442  matrix_.resize( n, n, preserve );
1443 }
1445 //*************************************************************************************************
1446 
1447 
1448 //*************************************************************************************************
1459 template< typename MT // Type of the adapted sparse matrix
1460  , bool SO > // Storage order of the adapted sparse matrix
1461 inline void DiagonalMatrix<MT,SO,false>::reserve( size_t nonzeros )
1462 {
1463  matrix_.reserve( nonzeros );
1464 }
1466 //*************************************************************************************************
1467 
1468 
1469 //*************************************************************************************************
1483 template< typename MT // Type of the adapted sparse matrix
1484  , bool SO > // Storage order of the adapted sparse matrix
1485 inline void DiagonalMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1486 {
1487  matrix_.reserve( i, nonzeros );
1488 }
1490 //*************************************************************************************************
1491 
1492 
1493 //*************************************************************************************************
1504 template< typename MT // Type of the adapted sparse matrix
1505  , bool SO > // Storage order of the adapted sparse matrix
1506 inline void DiagonalMatrix<MT,SO,false>::trim()
1507 {
1508  matrix_.trim();
1509 }
1511 //*************************************************************************************************
1512 
1513 
1514 //*************************************************************************************************
1526 template< typename MT // Type of the adapted sparse matrix
1527  , bool SO > // Storage order of the adapted sparse matrix
1528 inline void DiagonalMatrix<MT,SO,false>::trim( size_t i )
1529 {
1530  matrix_.trim( i );
1531 }
1533 //*************************************************************************************************
1534 
1535 
1536 //*************************************************************************************************
1543 template< typename MT // Type of the adapted sparse matrix
1544  , bool SO > // Storage order of the adapted sparse matrix
1545 template< typename Other > // Data type of the scalar value
1546 inline DiagonalMatrix<MT,SO,false>&
1547  DiagonalMatrix<MT,SO,false>::scale( const Other& scalar )
1548 {
1549  matrix_.scale( scalar );
1550  return *this;
1551 }
1553 //*************************************************************************************************
1554 
1555 
1556 //*************************************************************************************************
1563 template< typename MT // Type of the adapted sparse matrix
1564  , bool SO > // Storage order of the adapted sparse matrix
1565 template< typename Other > // Data type of the scalar value
1566 inline DiagonalMatrix<MT,SO,false>&
1567  DiagonalMatrix<MT,SO,false>::scaleDiagonal( Other scalar )
1568 {
1569  matrix_.scaleDiagonal( scalar );
1570  return *this;
1571 }
1573 //*************************************************************************************************
1574 
1575 
1576 //*************************************************************************************************
1584 template< typename MT // Type of the adapted sparse matrix
1585  , bool SO > // Storage order of the adapted sparse matrix
1586 inline void DiagonalMatrix<MT,SO,false>::swap( DiagonalMatrix& m ) /* throw() */
1587 {
1588  using std::swap;
1589 
1590  swap( matrix_, m.matrix_ );
1591 }
1593 //*************************************************************************************************
1594 
1595 
1596 //*************************************************************************************************
1602 template< typename MT // Type of the adapted dense matrix
1603  , bool SO > // Storage order of the adapted dense matrix
1604 inline void DiagonalMatrix<MT,SO,false>::resetNonDiagonal()
1605 {
1606  for( size_t i=0UL; i<rows(); ++i ) {
1607  matrix_.erase( i, matrix_.begin( i ), matrix_.lowerBound( i, i ) );
1608  matrix_.erase( i, matrix_.upperBound( i, i ), matrix_.end( i ) );
1609  }
1610 }
1612 //*************************************************************************************************
1613 
1614 
1615 
1616 
1617 //=================================================================================================
1618 //
1619 // LOOKUP FUNCTIONS
1620 //
1621 //=================================================================================================
1622 
1623 //*************************************************************************************************
1639 template< typename MT // Type of the adapted sparse matrix
1640  , bool SO > // Storage order of the adapted sparse matrix
1642  DiagonalMatrix<MT,SO,false>::find( size_t i, size_t j )
1643 {
1644  return matrix_.find( i, j );
1645 }
1647 //*************************************************************************************************
1648 
1649 
1650 //*************************************************************************************************
1666 template< typename MT // Type of the adapted sparse matrix
1667  , bool SO > // Storage order of the adapted sparse matrix
1669  DiagonalMatrix<MT,SO,false>::find( size_t i, size_t j ) const
1670 {
1671  return matrix_.find( i, j );
1672 }
1674 //*************************************************************************************************
1675 
1676 
1677 //*************************************************************************************************
1693 template< typename MT // Type of the adapted sparse matrix
1694  , bool SO > // Storage order of the adapted sparse matrix
1696  DiagonalMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
1697 {
1698  return matrix_.lowerBound( i, j );
1699 }
1701 //*************************************************************************************************
1702 
1703 
1704 //*************************************************************************************************
1720 template< typename MT // Type of the adapted sparse matrix
1721  , bool SO > // Storage order of the adapted sparse matrix
1723  DiagonalMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
1724 {
1725  return matrix_.lowerBound( i, j );
1726 }
1728 //*************************************************************************************************
1729 
1730 
1731 //*************************************************************************************************
1747 template< typename MT // Type of the adapted sparse matrix
1748  , bool SO > // Storage order of the adapted sparse matrix
1750  DiagonalMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
1751 {
1752  return matrix_.upperBound( i, j );
1753 }
1755 //*************************************************************************************************
1756 
1757 
1758 //*************************************************************************************************
1774 template< typename MT // Type of the adapted sparse matrix
1775  , bool SO > // Storage order of the adapted sparse matrix
1777  DiagonalMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
1778 {
1779  return matrix_.upperBound( i, j );
1780 }
1782 //*************************************************************************************************
1783 
1784 
1785 
1786 
1787 //=================================================================================================
1788 //
1789 // LOW-LEVEL UTILITY FUNCTIONS
1790 //
1791 //=================================================================================================
1792 
1793 //*************************************************************************************************
1843 template< typename MT // Type of the adapted sparse matrix
1844  , bool SO > // Storage order of the adapted sparse matrix
1845 inline void DiagonalMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1846 {
1847  if( i < j ) {
1848  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1849  }
1850 
1851  matrix_.append( i, j, value, check );
1852 }
1854 //*************************************************************************************************
1855 
1856 
1857 //*************************************************************************************************
1871 template< typename MT // Type of the adapted sparse matrix
1872  , bool SO > // Storage order of the adapted sparse matrix
1873 inline void DiagonalMatrix<MT,SO,false>::finalize( size_t i )
1874 {
1875  matrix_.finalize( i );
1876 }
1878 //*************************************************************************************************
1879 
1880 
1881 
1882 
1883 //=================================================================================================
1884 //
1885 // DEBUGGING FUNCTIONS
1886 //
1887 //=================================================================================================
1888 
1889 //*************************************************************************************************
1899 template< typename MT // Type of the adapted sparse matrix
1900  , bool SO > // Storage order of the adapted sparse matrix
1901 inline bool DiagonalMatrix<MT,SO,false>::isIntact() const
1902 {
1903  using blaze::isIntact;
1904 
1905  return ( isIntact( matrix_ ) && isDiagonal( matrix_ ) );
1906 }
1908 //*************************************************************************************************
1909 
1910 
1911 
1912 
1913 //=================================================================================================
1914 //
1915 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1916 //
1917 //=================================================================================================
1918 
1919 //*************************************************************************************************
1930 template< typename MT // Type of the adapted sparse matrix
1931  , bool SO > // Storage order of the adapted sparse matrix
1932 template< typename Other > // Data type of the foreign expression
1933 inline bool DiagonalMatrix<MT,SO,false>::canAlias( const Other* alias ) const
1934 {
1935  return matrix_.canAlias( alias );
1936 }
1938 //*************************************************************************************************
1939 
1940 
1941 //*************************************************************************************************
1952 template< typename MT // Type of the adapted sparse matrix
1953  , bool SO > // Storage order of the adapted sparse matrix
1954 template< typename Other > // Data type of the foreign expression
1955 inline bool DiagonalMatrix<MT,SO,false>::isAliased( const Other* alias ) const
1956 {
1957  return matrix_.isAliased( alias );
1958 }
1960 //*************************************************************************************************
1961 
1962 
1963 //*************************************************************************************************
1974 template< typename MT // Type of the adapted sparse matrix
1975  , bool SO > // Storage order of the adapted sparse matrix
1976 inline bool DiagonalMatrix<MT,SO,false>::canSMPAssign() const
1977 {
1978  return matrix_.canSMPAssign();
1979 }
1981 //*************************************************************************************************
1982 
1983 } // namespace blaze
1984 
1985 #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:116
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type set(T value)
Sets all values in the vector to the given 2-byte integral value.
Definition: Set.h:73
#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:1511
Header file for the Rows type trait.
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix)
Checks if the given matrix is a square matrix.
Definition: Matrix.h:603
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:229
void move(CompressedMatrix< Type, SO > &dst, CompressedMatrix< Type, SO > &src)
Moving the contents of one compressed matrix to another.
Definition: CompressedMatrix.h:5016
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:292
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:250
#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:81
Header file for the IsDiagonal type trait.
Header file for the implementation of the base template of the DiagonalMatrix.
Constraint on the data type.
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:340
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:4926
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2582
#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:116
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:378
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2584
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:547
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
Compile time assertion.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4998
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:4980
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
#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:116
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
Header file for the Columns type trait.
Constraint on the data type.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2585
Constraints on the storage order of matrix types.
#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:118
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:187
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:532
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2590
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:527
Header file for the IsNumeric type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:116
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
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:118
#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:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2591
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:256
Header file for the move shim.
#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:79
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:118
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:237
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2589
#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:116
Header file for exception macros.
#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:143
#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:79