Dense.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_DIAGONALMATRIX_DENSE_H_
36 #define _BLAZE_MATH_ADAPTORS_DIAGONALMATRIX_DENSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <stdexcept>
56 #include <blaze/math/Intrinsics.h>
57 #include <blaze/math/shims/Clear.h>
59 #include <blaze/math/shims/Move.h>
66 #include <blaze/system/Inline.h>
67 #include <blaze/util/Assert.h>
73 #include <blaze/util/DisableIf.h>
74 #include <blaze/util/EnableIf.h>
75 #include <blaze/util/FalseType.h>
77 #include <blaze/util/TrueType.h>
78 #include <blaze/util/Types.h>
80 #include <blaze/util/Unused.h>
81 
82 
83 namespace blaze {
84 
85 //=================================================================================================
86 //
87 // CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES
88 //
89 //=================================================================================================
90 
91 //*************************************************************************************************
99 template< typename MT // Type of the adapted dense matrix
100  , bool SO > // Storage order of the adapted dense matrix
101 class DiagonalMatrix<MT,SO,true>
102  : public DenseMatrix< DiagonalMatrix<MT,SO,true>, SO >
103 {
104  private:
105  //**Type definitions****************************************************************************
106  typedef typename MT::OppositeType OT;
107  typedef typename MT::TransposeType TT;
108  typedef typename MT::ElementType ET;
109  typedef IntrinsicTrait<ET> IT;
110  //**********************************************************************************************
111 
112  public:
113  //**Type definitions****************************************************************************
114  typedef DiagonalMatrix<MT,SO,true> This;
115  typedef This ResultType;
116  typedef DiagonalMatrix<OT,!SO,true> OppositeType;
117  typedef DiagonalMatrix<TT,!SO,true> TransposeType;
118  typedef ET ElementType;
119  typedef typename MT::IntrinsicType IntrinsicType;
120  typedef typename MT::ReturnType ReturnType;
121  typedef const This& CompositeType;
122  typedef DiagonalProxy<MT> Reference;
123  typedef typename MT::ConstReference ConstReference;
124  typedef typename MT::Pointer Pointer;
125  typedef typename MT::ConstPointer ConstPointer;
126  typedef typename MT::ConstIterator ConstIterator;
127  //**********************************************************************************************
128 
129  //**Rebind struct definition********************************************************************
132  template< typename ET > // Data type of the other matrix
133  struct Rebind {
135  typedef DiagonalMatrix< typename MT::template Rebind<ET>::Other > Other;
136  };
137  //**********************************************************************************************
138 
139  //**Iterator class definition*******************************************************************
142  class Iterator
143  {
144  public:
145  //**Type definitions*************************************************************************
146  typedef std::random_access_iterator_tag IteratorCategory;
147  typedef typename MT::ElementType ValueType;
148  typedef DiagonalProxy<MT> PointerType;
149  typedef DiagonalProxy<MT> ReferenceType;
150  typedef ptrdiff_t DifferenceType;
151 
152  // STL iterator requirements
153  typedef IteratorCategory iterator_category;
154  typedef ValueType value_type;
155  typedef PointerType pointer;
156  typedef ReferenceType reference;
157  typedef DifferenceType difference_type;
158  //*******************************************************************************************
159 
160  //**Constructor******************************************************************************
163  inline Iterator()
164  : matrix_( NULL ) // Reference to the adapted dense matrix
165  , row_ ( 0UL ) // The current row index of the iterator
166  , column_( 0UL ) // The current column index of the iterator
167  {}
168  //*******************************************************************************************
169 
170  //**Constructor******************************************************************************
177  inline Iterator( MT& matrix, size_t row, size_t column )
178  : matrix_( &matrix ) // Reference to the adapted dense matrix
179  , row_ ( row ) // The current row-index of the iterator
180  , column_( column ) // The current column-index of the iterator
181  {}
182  //*******************************************************************************************
183 
184  //**Addition assignment operator*************************************************************
190  inline Iterator& operator+=( size_t inc ) {
191  ( SO )?( row_ += inc ):( column_ += inc );
192  return *this;
193  }
194  //*******************************************************************************************
195 
196  //**Subtraction assignment operator**********************************************************
202  inline Iterator& operator-=( size_t dec ) {
203  ( SO )?( row_ -= dec ):( column_ -= dec );
204  return *this;
205  }
206  //*******************************************************************************************
207 
208  //**Prefix increment operator****************************************************************
213  inline Iterator& operator++() {
214  ( SO )?( ++row_ ):( ++column_ );
215  return *this;
216  }
217  //*******************************************************************************************
218 
219  //**Postfix increment operator***************************************************************
224  inline const Iterator operator++( int ) {
225  const Iterator tmp( *this );
226  ++(*this);
227  return tmp;
228  }
229  //*******************************************************************************************
230 
231  //**Prefix decrement operator****************************************************************
236  inline Iterator& operator--() {
237  ( SO )?( --row_ ):( --column_ );
238  return *this;
239  }
240  //*******************************************************************************************
241 
242  //**Postfix decrement operator***************************************************************
247  inline const Iterator operator--( int ) {
248  const Iterator tmp( *this );
249  --(*this);
250  return tmp;
251  }
252  //*******************************************************************************************
253 
254  //**Element access operator******************************************************************
259  inline ReferenceType operator*() const {
260  return ReferenceType( *matrix_, row_, column_ );
261  }
262  //*******************************************************************************************
263 
264  //**Element access operator******************************************************************
269  inline PointerType operator->() const {
270  return PointerType( *matrix_, row_, column_ );
271  }
272  //*******************************************************************************************
273 
274  //**Conversion operator**********************************************************************
279  inline operator ConstIterator() const {
280  if( SO )
281  return matrix_->begin( column_ ) + row_;
282  else
283  return matrix_->begin( row_ ) + column_;
284  }
285  //*******************************************************************************************
286 
287  //**Equality operator************************************************************************
294  friend inline bool operator==( const Iterator& lhs, const Iterator& rhs ) {
295  return ( SO )?( lhs.row_ == rhs.row_ ):( lhs.column_ == rhs.column_ );
296  }
297  //*******************************************************************************************
298 
299  //**Equality operator************************************************************************
306  friend inline bool operator==( const Iterator& lhs, const ConstIterator& rhs ) {
307  return ( ConstIterator( lhs ) == rhs );
308  }
309  //*******************************************************************************************
310 
311  //**Equality operator************************************************************************
318  friend inline bool operator==( const ConstIterator& lhs, const Iterator& rhs ) {
319  return ( lhs == ConstIterator( rhs ) );
320  }
321  //*******************************************************************************************
322 
323  //**Inequality operator**********************************************************************
330  friend inline bool operator!=( const Iterator& lhs, const Iterator& rhs ) {
331  return ( SO )?( lhs.row_ != rhs.row_ ):( lhs.column_ != rhs.column_ );
332  }
333  //*******************************************************************************************
334 
335  //**Inequality operator**********************************************************************
342  friend inline bool operator!=( const Iterator& lhs, const ConstIterator& rhs ) {
343  return ( ConstIterator( lhs ) != rhs );
344  }
345  //*******************************************************************************************
346 
347  //**Inequality operator**********************************************************************
354  friend inline bool operator!=( const ConstIterator& lhs, const Iterator& rhs ) {
355  return ( lhs != ConstIterator( rhs ) );
356  }
357  //*******************************************************************************************
358 
359  //**Less-than operator***********************************************************************
366  friend inline bool operator<( const Iterator& lhs, const Iterator& rhs ) {
367  return ( SO )?( lhs.row_ < rhs.row_ ):( lhs.column_ < rhs.column_ );
368  }
369  //*******************************************************************************************
370 
371  //**Less-than operator***********************************************************************
378  friend inline bool operator<( const Iterator& lhs, const ConstIterator& rhs ) {
379  return ( ConstIterator( lhs ) < rhs );
380  }
381  //*******************************************************************************************
382 
383  //**Less-than operator***********************************************************************
390  friend inline bool operator<( const ConstIterator& lhs, const Iterator& rhs ) {
391  return ( lhs < ConstIterator( rhs ) );
392  }
393  //*******************************************************************************************
394 
395  //**Greater-than operator********************************************************************
402  friend inline bool operator>( const Iterator& lhs, const Iterator& rhs ) {
403  return ( SO )?( lhs.row_ > rhs.row_ ):( lhs.column_ > rhs.column_ );
404  }
405  //*******************************************************************************************
406 
407  //**Greater-than operator********************************************************************
414  friend inline bool operator>( const Iterator& lhs, const ConstIterator& rhs ) {
415  return ( ConstIterator( lhs ) > rhs );
416  }
417  //*******************************************************************************************
418 
419  //**Greater-than operator********************************************************************
426  friend inline bool operator>( const ConstIterator& lhs, const Iterator& rhs ) {
427  return ( lhs > ConstIterator( rhs ) );
428  }
429  //*******************************************************************************************
430 
431  //**Less-or-equal-than operator**************************************************************
438  friend inline bool operator<=( const Iterator& lhs, const Iterator& rhs ) {
439  return ( SO )?( lhs.row_ <= rhs.row_ ):( lhs.column_ <= rhs.column_ );
440  }
441  //*******************************************************************************************
442 
443  //**Less-or-equal-than operator**************************************************************
450  friend inline bool operator<=( const Iterator& lhs, const ConstIterator& rhs ) {
451  return ( ConstIterator( lhs ) <= rhs );
452  }
453  //*******************************************************************************************
454 
455  //**Less-or-equal-than operator**************************************************************
462  friend inline bool operator<=( const ConstIterator& lhs, const Iterator& rhs ) {
463  return ( lhs <= ConstIterator( rhs ) );
464  }
465  //*******************************************************************************************
466 
467  //**Greater-or-equal-than operator***********************************************************
474  friend inline bool operator>=( const Iterator& lhs, const Iterator& rhs ) {
475  return ( SO )?( lhs.row_ >= rhs.row_ ):( lhs.column_ >= rhs.column_ );
476  }
477  //*******************************************************************************************
478 
479  //**Greater-or-equal-than operator***********************************************************
486  friend inline bool operator>=( const Iterator& lhs, const ConstIterator& rhs ) {
487  return ( ConstIterator( lhs ) >= rhs );
488  }
489  //*******************************************************************************************
490 
491  //**Greater-or-equal-than operator***********************************************************
498  friend inline bool operator>=( const ConstIterator& lhs, const Iterator& rhs ) {
499  return ( lhs >= ConstIterator( rhs ) );
500  }
501  //*******************************************************************************************
502 
503  //**Subtraction operator*********************************************************************
509  inline DifferenceType operator-( const Iterator& rhs ) const {
510  return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
511  }
512  //*******************************************************************************************
513 
514  //**Addition operator************************************************************************
521  friend inline const Iterator operator+( const Iterator& it, size_t inc ) {
522  if( SO )
523  return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
524  else
525  return Iterator( *it.matrix_, it.row_, it.column_ + inc );
526  }
527  //*******************************************************************************************
528 
529  //**Addition operator************************************************************************
536  friend inline const Iterator operator+( size_t inc, const Iterator& it ) {
537  if( SO )
538  return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
539  else
540  return Iterator( *it.matrix_, it.row_, it.column_ + inc );
541  }
542  //*******************************************************************************************
543 
544  //**Subtraction operator*********************************************************************
551  friend inline const Iterator operator-( const Iterator& it, size_t dec ) {
552  if( SO )
553  return Iterator( *it.matrix_, it.row_ - dec, it.column_ );
554  else
555  return Iterator( *it.matrix_, it.row_, it.column_ - dec );
556  }
557  //*******************************************************************************************
558 
559  private:
560  //**Member variables*************************************************************************
561  MT* matrix_;
562  size_t row_;
563  size_t column_;
564  //*******************************************************************************************
565  };
566  //**********************************************************************************************
567 
568  //**Compilation flags***************************************************************************
570  enum { vectorizable = MT::vectorizable };
571 
573  enum { smpAssignable = MT::smpAssignable };
574  //**********************************************************************************************
575 
576  //**Constructors********************************************************************************
579  explicit inline DiagonalMatrix();
580  template< typename A1 > explicit inline DiagonalMatrix( const A1& a1 );
581  explicit inline DiagonalMatrix( size_t n, const ElementType& init );
582  inline DiagonalMatrix( const DiagonalMatrix& m );
584  //**********************************************************************************************
585 
586  //**Destructor**********************************************************************************
587  // No explicitly declared destructor.
588  //**********************************************************************************************
589 
590  //**Data access functions***********************************************************************
593  inline Reference operator()( size_t i, size_t j );
594  inline ConstReference operator()( size_t i, size_t j ) const;
595  inline ConstPointer data () const;
596  inline ConstPointer data ( size_t i ) const;
597  inline Iterator begin ( size_t i );
598  inline ConstIterator begin ( size_t i ) const;
599  inline ConstIterator cbegin( size_t i ) const;
600  inline Iterator end ( size_t i );
601  inline ConstIterator end ( size_t i ) const;
602  inline ConstIterator cend ( size_t i ) const;
604  //**********************************************************************************************
605 
606  //**Assignment operators************************************************************************
609  inline DiagonalMatrix& operator=( const ElementType& rhs );
610  inline DiagonalMatrix& operator=( const DiagonalMatrix& rhs );
611 
612  template< typename MT2, bool SO2 >
613  inline typename DisableIf< IsComputation<MT2>, DiagonalMatrix& >::Type
614  operator=( const Matrix<MT2,SO2>& rhs );
615 
616  template< typename MT2, bool SO2 >
617  inline typename EnableIf< IsComputation<MT2>, DiagonalMatrix& >::Type
618  operator=( const Matrix<MT2,SO2>& rhs );
619 
620  template< typename MT2, bool SO2 >
621  inline typename DisableIf< IsComputation<MT2>, DiagonalMatrix& >::Type
622  operator+=( const Matrix<MT2,SO2>& rhs );
623 
624  template< typename MT2, bool SO2 >
625  inline typename EnableIf< IsComputation<MT2>, DiagonalMatrix& >::Type
626  operator+=( const Matrix<MT2,SO2>& rhs );
627 
628  template< typename MT2, bool SO2 >
629  inline typename DisableIf< IsComputation<MT2>, DiagonalMatrix& >::Type
630  operator-=( const Matrix<MT2,SO2>& rhs );
631 
632  template< typename MT2, bool SO2 >
633  inline typename EnableIf< IsComputation<MT2>, DiagonalMatrix& >::Type
634  operator-=( const Matrix<MT2,SO2>& rhs );
635 
636  template< typename MT2, bool SO2 >
637  inline DiagonalMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
638 
639  template< typename Other >
640  inline typename EnableIf< IsNumeric<Other>, DiagonalMatrix >::Type&
641  operator*=( Other rhs );
642 
643  template< typename Other >
644  inline typename EnableIf< IsNumeric<Other>, DiagonalMatrix >::Type&
645  operator/=( Other rhs );
647  //**********************************************************************************************
648 
649  //**Utility functions***************************************************************************
652  inline size_t rows() const;
653  inline size_t columns() const;
654  inline size_t spacing() const;
655  inline size_t capacity() const;
656  inline size_t capacity( size_t i ) const;
657  inline size_t nonZeros() const;
658  inline size_t nonZeros( size_t i ) const;
659  inline void reset();
660  inline void reset( size_t i );
661  inline void clear();
662  void resize ( size_t n, bool preserve=true );
663  inline void extend ( size_t n, bool preserve=true );
664  inline void reserve( size_t elements );
665  template< typename Other > inline DiagonalMatrix& scale( const Other& scalar );
666  inline void swap( DiagonalMatrix& m ) /* throw() */;
668  //**********************************************************************************************
669 
670  //**Expression template evaluation functions****************************************************
673  template< typename Other > inline bool canAlias ( const Other* alias ) const;
674  template< typename Other > inline bool isAliased( const Other* alias ) const;
675 
676  inline bool isAligned () const;
677  inline bool canSMPAssign() const;
678 
679  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t i, size_t j ) const;
680  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t i, size_t j ) const;
682  //**********************************************************************************************
683 
684  private:
685  //**Construction functions**********************************************************************
688  inline const MT construct( size_t n , TrueType );
689  inline const MT construct( const ElementType& value, FalseType );
690 
691  template< typename MT2, bool SO2, typename T >
692  inline const MT construct( const Matrix<MT2,SO2>& m, T );
694  //**********************************************************************************************
695 
696  //**Member variables****************************************************************************
699  MT matrix_;
700 
701  //**********************************************************************************************
702 
703  //**Friend declarations*************************************************************************
704  template< typename MT2, bool SO2, bool DF2 >
705  friend bool isDefault( const DiagonalMatrix<MT2,SO2,DF2>& m );
706 
707  template< typename MT2, bool SO2, bool DF2 >
708  friend MT2& derestrict( DiagonalMatrix<MT2,SO2,DF2>& m );
709  //**********************************************************************************************
710 
711  //**Compile time checks*************************************************************************
723  BLAZE_STATIC_ASSERT( IsResizable<MT>::value || IsSquare<MT>::value );
724  //**********************************************************************************************
725 };
727 //*************************************************************************************************
728 
729 
730 
731 
732 //=================================================================================================
733 //
734 // CONSTRUCTORS
735 //
736 //=================================================================================================
737 
738 //*************************************************************************************************
742 template< typename MT // Type of the adapted dense matrix
743  , bool SO > // Storage order of the adapted dense matrix
744 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix()
745  : matrix_() // The adapted dense matrix
746 {
747  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
748 }
750 //*************************************************************************************************
751 
752 
753 //*************************************************************************************************
771 template< typename MT // Type of the adapted dense matrix
772  , bool SO > // Storage order of the adapted dense matrix
773 template< typename A1 > // Type of the constructor argument
774 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( const A1& a1 )
775  : matrix_( construct( a1, typename IsResizable<MT>::Type() ) ) // The adapted dense matrix
776 {
777  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
778 }
780 //*************************************************************************************************
781 
782 
783 //*************************************************************************************************
790 template< typename MT // Type of the adapted dense matrix
791  , bool SO > // Storage order of the adapted dense matrix
792 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( size_t n, const ElementType& init )
793  : matrix_( n, n, ElementType() ) // The adapted dense matrix
794 {
796 
797  for( size_t i=0UL; i<n; ++i )
798  matrix_(i,i) = init;
799 
800  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
801 }
803 //*************************************************************************************************
804 
805 
806 //*************************************************************************************************
812 template< typename MT // Type of the adapted dense matrix
813  , bool SO > // Storage order of the adapted dense matrix
814 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( const DiagonalMatrix& m )
815  : matrix_( m.matrix_ ) // The adapted dense matrix
816 {
817  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
818 }
820 //*************************************************************************************************
821 
822 
823 
824 
825 //=================================================================================================
826 //
827 // DATA ACCESS FUNCTIONS
828 //
829 //=================================================================================================
830 
831 //*************************************************************************************************
844 template< typename MT // Type of the adapted dense matrix
845  , bool SO > // Storage order of the adapted dense matrix
847  DiagonalMatrix<MT,SO,true>::operator()( size_t i, size_t j )
848 {
849  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
850  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
851 
852  return Reference( matrix_, i, j );
853 }
855 //*************************************************************************************************
856 
857 
858 //*************************************************************************************************
871 template< typename MT // Type of the adapted dense matrix
872  , bool SO > // Storage order of the adapted dense matrix
874  DiagonalMatrix<MT,SO,true>::operator()( size_t i, size_t j ) const
875 {
876  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
877  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
878 
879  return matrix_(i,j);
880 }
882 //*************************************************************************************************
883 
884 
885 //*************************************************************************************************
898 template< typename MT // Type of the adapted dense matrix
899  , bool SO > // Storage order of the adapted dense matrix
900 inline typename DiagonalMatrix<MT,SO,true>::ConstPointer
901  DiagonalMatrix<MT,SO,true>::data() const
902 {
903  return matrix_.data();
904 }
906 //*************************************************************************************************
907 
908 
909 //*************************************************************************************************
918 template< typename MT // Type of the adapted dense matrix
919  , bool SO > // Storage order of the adapted dense matrix
920 inline typename DiagonalMatrix<MT,SO,true>::ConstPointer
921  DiagonalMatrix<MT,SO,true>::data( size_t i ) const
922 {
923  return matrix_.data(i);
924 }
926 //*************************************************************************************************
927 
928 
929 //*************************************************************************************************
941 template< typename MT // Type of the adapted dense matrix
942  , bool SO > // Storage order of the adapted dense matrix
945 {
946  if( SO )
947  return Iterator( matrix_, 0UL, i );
948  else
949  return Iterator( matrix_, i, 0UL );
950 }
952 //*************************************************************************************************
953 
954 
955 //*************************************************************************************************
967 template< typename MT // Type of the adapted dense matrix
968  , bool SO > // Storage order of the adapted dense matrix
970  DiagonalMatrix<MT,SO,true>::begin( size_t i ) const
971 {
972  return matrix_.begin(i);
973 }
975 //*************************************************************************************************
976 
977 
978 //*************************************************************************************************
990 template< typename MT // Type of the adapted dense matrix
991  , bool SO > // Storage order of the adapted dense matrix
993  DiagonalMatrix<MT,SO,true>::cbegin( size_t i ) const
994 {
995  return matrix_.cbegin(i);
996 }
998 //*************************************************************************************************
999 
1000 
1001 //*************************************************************************************************
1013 template< typename MT // Type of the adapted dense matrix
1014  , bool SO > // Storage order of the adapted dense matrix
1017 {
1018  if( SO )
1019  return Iterator( matrix_, rows(), i );
1020  else
1021  return Iterator( matrix_, i, columns() );
1022 }
1024 //*************************************************************************************************
1025 
1026 
1027 //*************************************************************************************************
1039 template< typename MT // Type of the adapted dense matrix
1040  , bool SO > // Storage order of the adapted dense matrix
1042  DiagonalMatrix<MT,SO,true>::end( size_t i ) const
1043 {
1044  return matrix_.end(i);
1045 }
1047 //*************************************************************************************************
1048 
1049 
1050 //*************************************************************************************************
1062 template< typename MT // Type of the adapted dense matrix
1063  , bool SO > // Storage order of the adapted dense matrix
1065  DiagonalMatrix<MT,SO,true>::cend( size_t i ) const
1066 {
1067  return matrix_.cend(i);
1068 }
1070 //*************************************************************************************************
1071 
1072 
1073 
1074 
1075 //=================================================================================================
1076 //
1077 // ASSIGNMENT OPERATORS
1078 //
1079 //=================================================================================================
1080 
1081 //*************************************************************************************************
1088 template< typename MT // Type of the adapted dense matrix
1089  , bool SO > // Storage order of the adapted dense matrix
1090 inline DiagonalMatrix<MT,SO,true>&
1091  DiagonalMatrix<MT,SO,true>::operator=( const ElementType& rhs )
1092 {
1093  if( SO ) {
1094  for( size_t j=0UL; j<columns(); ++j )
1095  matrix_(j,j) = rhs;
1096  }
1097  else {
1098  for( size_t i=0UL; i<rows(); ++i )
1099  matrix_(i,i) = rhs;
1100  }
1101 
1102  return *this;
1103 }
1105 //*************************************************************************************************
1106 
1107 
1108 //*************************************************************************************************
1118 template< typename MT // Type of the adapted dense matrix
1119  , bool SO > // Storage order of the adapted dense matrix
1120 inline DiagonalMatrix<MT,SO,true>&
1121  DiagonalMatrix<MT,SO,true>::operator=( const DiagonalMatrix& rhs )
1122 {
1123  matrix_ = rhs.matrix_;
1124 
1125  return *this;
1126 }
1128 //*************************************************************************************************
1129 
1130 
1131 //*************************************************************************************************
1144 template< typename MT // Type of the adapted dense matrix
1145  , bool SO > // Storage order of the adapted dense matrix
1146 template< typename MT2 // Type of the right-hand side matrix
1147  , bool SO2 > // Storage order of the right-hand side matrix
1148 inline typename DisableIf< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >::Type
1149  DiagonalMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1150 {
1151  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) )
1152  throw std::invalid_argument( "Invalid assignment to diagonal matrix" );
1153 
1154  matrix_ = ~rhs;
1155 
1156  return *this;
1157 }
1159 //*************************************************************************************************
1160 
1161 
1162 //*************************************************************************************************
1175 template< typename MT // Type of the adapted dense matrix
1176  , bool SO > // Storage order of the adapted dense matrix
1177 template< typename MT2 // Type of the right-hand side matrix
1178  , bool SO2 > // Storage order of the right-hand side matrix
1179 inline typename EnableIf< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >::Type
1180  DiagonalMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1181 {
1182  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) )
1183  throw std::invalid_argument( "Invalid assignment to diagonal matrix" );
1184 
1185  if( IsDiagonal<MT2>::value ) {
1186  matrix_ = ~rhs;
1187  }
1188  else {
1189  MT tmp( ~rhs );
1190 
1191  if( !isDiagonal( tmp ) )
1192  throw std::invalid_argument( "Invalid assignment to diagonal matrix" );
1193 
1194  move( matrix_, tmp );
1195  }
1196 
1197  return *this;
1198 }
1200 //*************************************************************************************************
1201 
1202 
1203 //*************************************************************************************************
1216 template< typename MT // Type of the adapted dense matrix
1217  , bool SO > // Storage order of the adapted dense matrix
1218 template< typename MT2 // Type of the right-hand side matrix
1219  , bool SO2 > // Storage order of the right-hand side matrix
1220 inline typename DisableIf< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >::Type
1221  DiagonalMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1222 {
1223  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) )
1224  throw std::invalid_argument( "Invalid assignment to diagonal matrix" );
1225 
1226  matrix_ += ~rhs;
1227 
1228  return *this;
1229 }
1231 //*************************************************************************************************
1232 
1233 
1234 //*************************************************************************************************
1247 template< typename MT // Type of the adapted dense matrix
1248  , bool SO > // Storage order of the adapted dense matrix
1249 template< typename MT2 // Type of the right-hand side matrix
1250  , bool SO2 > // Storage order of the right-hand side matrix
1251 inline typename EnableIf< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >::Type
1252  DiagonalMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1253 {
1254  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) )
1255  throw std::invalid_argument( "Invalid assignment to diagonal matrix" );
1256 
1257  if( IsDiagonal<MT2>::value ) {
1258  matrix_ += ~rhs;
1259  }
1260  else {
1261  typename MT2::ResultType tmp( ~rhs );
1262 
1263  if( !isDiagonal( tmp ) )
1264  throw std::invalid_argument( "Invalid assignment to diagonal matrix" );
1265 
1266  matrix_ += tmp;
1267  }
1268 
1269  return *this;
1270 }
1272 //*************************************************************************************************
1273 
1274 
1275 //*************************************************************************************************
1288 template< typename MT // Type of the adapted dense matrix
1289  , bool SO > // Storage order of the adapted dense matrix
1290 template< typename MT2 // Type of the right-hand side matrix
1291  , bool SO2 > // Storage order of the right-hand side matrix
1292 inline typename DisableIf< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >::Type
1293  DiagonalMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1294 {
1295  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) )
1296  throw std::invalid_argument( "Invalid assignment to diagonal matrix" );
1297 
1298  matrix_ -= ~rhs;
1299 
1300  return *this;
1301 }
1303 //*************************************************************************************************
1304 
1305 
1306 //*************************************************************************************************
1319 template< typename MT // Type of the adapted dense matrix
1320  , bool SO > // Storage order of the adapted dense matrix
1321 template< typename MT2 // Type of the right-hand side matrix
1322  , bool SO2 > // Storage order of the right-hand side matrix
1323 inline typename EnableIf< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >::Type
1324  DiagonalMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1325 {
1326  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) )
1327  throw std::invalid_argument( "Invalid assignment to diagonal matrix" );
1328 
1329  if( IsDiagonal<MT2>::value ) {
1330  matrix_ -= ~rhs;
1331  }
1332  else {
1333  typename MT2::ResultType tmp( ~rhs );
1334 
1335  if( !isDiagonal( tmp ) )
1336  throw std::invalid_argument( "Invalid assignment to diagonal matrix" );
1337 
1338  matrix_ -= tmp;
1339  }
1340 
1341  return *this;
1342 }
1344 //*************************************************************************************************
1345 
1346 
1347 //*************************************************************************************************
1359 template< typename MT // Type of the adapted dense matrix
1360  , bool SO > // Storage order of the adapted dense matrix
1361 template< typename MT2 // Type of the right-hand side matrix
1362  , bool SO2 > // Storage order of the right-hand side matrix
1363 inline DiagonalMatrix<MT,SO,true>&
1364  DiagonalMatrix<MT,SO,true>::operator*=( const Matrix<MT2,SO2>& rhs )
1365 {
1366  if( matrix_.rows() != (~rhs).columns() )
1367  throw std::invalid_argument( "Invalid assignment to diagonal matrix" );
1368 
1369  MT tmp( matrix_ * ~rhs );
1370 
1371  if( !isDiagonal( tmp ) )
1372  throw std::invalid_argument( "Invalid assignment to diagonal matrix" );
1373 
1374  move( matrix_, tmp );
1375 
1376  return *this;
1377 }
1379 //*************************************************************************************************
1380 
1381 
1382 //*************************************************************************************************
1390 template< typename MT // Type of the adapted dense matrix
1391  , bool SO > // Storage order of the adapted dense matrix
1392 template< typename Other > // Data type of the right-hand side scalar
1393 inline typename EnableIf< IsNumeric<Other>, DiagonalMatrix<MT,SO,true> >::Type&
1394  DiagonalMatrix<MT,SO,true>::operator*=( Other rhs )
1395 {
1396  matrix_ *= rhs;
1397  return *this;
1398 }
1399 //*************************************************************************************************
1400 
1401 
1402 //*************************************************************************************************
1410 template< typename MT // Type of the adapted dense matrix
1411  , bool SO > // Storage order of the adapted dense matrix
1412 template< typename Other > // Data type of the right-hand side scalar
1413 inline typename EnableIf< IsNumeric<Other>, DiagonalMatrix<MT,SO,true> >::Type&
1414  DiagonalMatrix<MT,SO,true>::operator/=( Other rhs )
1415 {
1416  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1417 
1418  matrix_ /= rhs;
1419  return *this;
1420 }
1422 //*************************************************************************************************
1423 
1424 
1425 
1426 
1427 //=================================================================================================
1428 //
1429 // UTILITY FUNCTIONS
1430 //
1431 //=================================================================================================
1432 
1433 //*************************************************************************************************
1439 template< typename MT // Type of the adapted dense matrix
1440  , bool SO > // Storage order of the adapted dense matrix
1441 inline size_t DiagonalMatrix<MT,SO,true>::rows() const
1442 {
1443  return matrix_.rows();
1444 }
1446 //*************************************************************************************************
1447 
1448 
1449 //*************************************************************************************************
1455 template< typename MT // Type of the adapted dense matrix
1456  , bool SO > // Storage order of the adapted dense matrix
1457 inline size_t DiagonalMatrix<MT,SO,true>::columns() const
1458 {
1459  return matrix_.columns();
1460 }
1462 //*************************************************************************************************
1463 
1464 
1465 //*************************************************************************************************
1476 template< typename MT // Type of the adapted dense matrix
1477  , bool SO > // Storage order of the adapted dense matrix
1478 inline size_t DiagonalMatrix<MT,SO,true>::spacing() const
1479 {
1480  return matrix_.spacing();
1481 }
1483 //*************************************************************************************************
1484 
1485 
1486 //*************************************************************************************************
1492 template< typename MT // Type of the adapted dense matrix
1493  , bool SO > // Storage order of the adapted dense matrix
1494 inline size_t DiagonalMatrix<MT,SO,true>::capacity() const
1495 {
1496  return matrix_.capacity();
1497 }
1499 //*************************************************************************************************
1500 
1501 
1502 //*************************************************************************************************
1514 template< typename MT // Type of the adapted dense matrix
1515  , bool SO > // Storage order of the adapted dense matrix
1516 inline size_t DiagonalMatrix<MT,SO,true>::capacity( size_t i ) const
1517 {
1518  return matrix_.capacity(i);
1519 }
1521 //*************************************************************************************************
1522 
1523 
1524 //*************************************************************************************************
1530 template< typename MT // Type of the adapted dense matrix
1531  , bool SO > // Storage order of the adapted dense matrix
1532 inline size_t DiagonalMatrix<MT,SO,true>::nonZeros() const
1533 {
1534  return matrix_.nonZeros();
1535 }
1537 //*************************************************************************************************
1538 
1539 
1540 //*************************************************************************************************
1552 template< typename MT // Type of the adapted dense matrix
1553  , bool SO > // Storage order of the adapted dense matrix
1554 inline size_t DiagonalMatrix<MT,SO,true>::nonZeros( size_t i ) const
1555 {
1556  return matrix_.nonZeros(i);
1557 }
1559 //*************************************************************************************************
1560 
1561 
1562 //*************************************************************************************************
1568 template< typename MT // Type of the adapted dense matrix
1569  , bool SO > // Storage order of the adapted dense matrix
1571 {
1572  matrix_.reset();
1573 }
1575 //*************************************************************************************************
1576 
1577 
1578 //*************************************************************************************************
1591 template< typename MT // Type of the adapted dense matrix
1592  , bool SO > // Storage order of the adapted dense matrix
1593 inline void DiagonalMatrix<MT,SO,true>::reset( size_t i )
1594 {
1595  matrix_.reset( i );
1596 }
1598 //*************************************************************************************************
1599 
1600 
1601 //*************************************************************************************************
1613 template< typename MT // Type of the adapted dense matrix
1614  , bool SO > // Storage order of the adapted dense matrix
1616 {
1617  using blaze::clear;
1618 
1619  clear( matrix_ );
1620 }
1622 //*************************************************************************************************
1623 
1624 
1625 //*************************************************************************************************
1661 template< typename MT // Type of the adapted dense matrix
1662  , bool SO > // Storage order of the adapted dense matrix
1663 void DiagonalMatrix<MT,SO,true>::resize( size_t n, bool preserve )
1664 {
1666 
1667  UNUSED_PARAMETER( preserve );
1668 
1669  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1670 
1671  const size_t oldsize( matrix_.rows() );
1672 
1673  matrix_.resize( n, n, true );
1674 
1675  if( n > oldsize ) {
1676  const size_t increment( n - oldsize );
1677  submatrix( matrix_, 0UL, oldsize, n, increment ).reset();
1678  submatrix( matrix_, oldsize, 0UL, increment, increment ).reset();
1679  }
1680 }
1682 //*************************************************************************************************
1683 
1684 
1685 //*************************************************************************************************
1698 template< typename MT // Type of the adapted dense matrix
1699  , bool SO > // Storage order of the adapted dense matrix
1700 inline void DiagonalMatrix<MT,SO,true>::extend( size_t n, bool preserve )
1701 {
1703 
1704  UNUSED_PARAMETER( preserve );
1705 
1706  resize( rows() + n, true );
1707 }
1708 //*************************************************************************************************
1709 
1710 
1711 //*************************************************************************************************
1721 template< typename MT // Type of the adapted dense matrix
1722  , bool SO > // Storage order of the adapted dense matrix
1723 inline void DiagonalMatrix<MT,SO,true>::reserve( size_t elements )
1724 {
1725  matrix_.reserve( elements );
1726 }
1728 //*************************************************************************************************
1729 
1730 
1731 //*************************************************************************************************
1738 template< typename MT // Type of the adapted dense matrix
1739  , bool SO > // Storage order of the adapted dense matrix
1740 template< typename Other > // Data type of the scalar value
1741 inline DiagonalMatrix<MT,SO,true>& DiagonalMatrix<MT,SO,true>::scale( const Other& scalar )
1742 {
1743  matrix_.scale( scalar );
1744  return *this;
1745 }
1747 //*************************************************************************************************
1748 
1749 
1750 //*************************************************************************************************
1758 template< typename MT // Type of the adapted dense matrix
1759  , bool SO > // Storage order of the adapted dense matrix
1760 inline void DiagonalMatrix<MT,SO,true>::swap( DiagonalMatrix& m ) /* throw() */
1761 {
1762  using std::swap;
1763 
1764  swap( matrix_, m.matrix_ );
1765 }
1767 //*************************************************************************************************
1768 
1769 
1770 
1771 
1772 //=================================================================================================
1773 //
1774 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1775 //
1776 //=================================================================================================
1777 
1778 //*************************************************************************************************
1789 template< typename MT // Type of the adapted dense matrix
1790  , bool SO > // Storage order of the adapted dense matrix
1791 template< typename Other > // Data type of the foreign expression
1792 inline bool DiagonalMatrix<MT,SO,true>::canAlias( const Other* alias ) const
1793 {
1794  return matrix_.canAlias( alias );
1795 }
1797 //*************************************************************************************************
1798 
1799 
1800 //*************************************************************************************************
1811 template< typename MT // Type of the adapted dense matrix
1812  , bool SO > // Storage order of the adapted dense matrix
1813 template< typename Other > // Data type of the foreign expression
1814 inline bool DiagonalMatrix<MT,SO,true>::isAliased( const Other* alias ) const
1815 {
1816  return matrix_.isAliased( alias );
1817 }
1819 //*************************************************************************************************
1820 
1821 
1822 //*************************************************************************************************
1832 template< typename MT // Type of the adapted dense matrix
1833  , bool SO > // Storage order of the adapted dense matrix
1834 inline bool DiagonalMatrix<MT,SO,true>::isAligned() const
1835 {
1836  return matrix_.isAligned();
1837 }
1839 //*************************************************************************************************
1840 
1841 
1842 //*************************************************************************************************
1853 template< typename MT // Type of the adapted dense matrix
1854  , bool SO > // Storage order of the adapted dense matrix
1855 inline bool DiagonalMatrix<MT,SO,true>::canSMPAssign() const
1856 {
1857  return matrix_.canSMPAssign();
1858 }
1860 //*************************************************************************************************
1861 
1862 
1863 //*************************************************************************************************
1879 template< typename MT // Type of the adapted dense matrix
1880  , bool SO > // Storage order of the adapted dense matrix
1881 BLAZE_ALWAYS_INLINE typename DiagonalMatrix<MT,SO,true>::IntrinsicType
1882  DiagonalMatrix<MT,SO,true>::load( size_t i, size_t j ) const
1883 {
1884  return matrix_.load( i, j );
1885 }
1887 //*************************************************************************************************
1888 
1889 
1890 //*************************************************************************************************
1906 template< typename MT // Type of the adapted dense matrix
1907  , bool SO > // Storage order of the adapted dense matrix
1908 BLAZE_ALWAYS_INLINE typename DiagonalMatrix<MT,SO,true>::IntrinsicType
1909  DiagonalMatrix<MT,SO,true>::loadu( size_t i, size_t j ) const
1910 {
1911  return matrix_.loadu( i, j );
1912 }
1914 //*************************************************************************************************
1915 
1916 
1917 
1918 
1919 //=================================================================================================
1920 //
1921 // CONSTRUCTION FUNCTIONS
1922 //
1923 //=================================================================================================
1924 
1925 //*************************************************************************************************
1932 template< typename MT // Type of the adapted dense matrix
1933  , bool SO > // Storage order of the adapted dense matrix
1934 inline const MT DiagonalMatrix<MT,SO,true>::construct( size_t n, TrueType )
1935 {
1937 
1938  return MT( n, n, ElementType() );
1939 }
1941 //*************************************************************************************************
1942 
1943 
1944 //*************************************************************************************************
1951 template< typename MT // Type of the adapted dense matrix
1952  , bool SO > // Storage order of the adapted dense matrix
1953 inline const MT DiagonalMatrix<MT,SO,true>::construct( const ElementType& init, FalseType )
1954 {
1957 
1958  MT tmp;
1959 
1960  for( size_t i=0UL; i<tmp.rows(); ++i )
1961  tmp(i,i) = init;
1962 
1963  return tmp;
1964 }
1966 //*************************************************************************************************
1967 
1968 
1969 //*************************************************************************************************
1980 template< typename MT // Type of the adapted dense matrix
1981  , bool SO > // Storage order of the adapted dense matrix
1982 template< typename MT2 // Type of the foreign matrix
1983  , bool SO2 // Storage order of the foreign matrix
1984  , typename T > // Type of the third argument
1985 inline const MT DiagonalMatrix<MT,SO,true>::construct( const Matrix<MT2,SO2>& m, T )
1986 {
1987  const MT tmp( ~m );
1988 
1989  if( !IsDiagonal<MT2>::value && !isDiagonal( tmp ) )
1990  throw std::invalid_argument( "Invalid setup of diagonal matrix" );
1991 
1992  return tmp;
1993 }
1995 //*************************************************************************************************
1996 
1997 } // namespace blaze
1998 
1999 #endif
Constraint on the data type.
Header file for all restructuring submatrix functions.
#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_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:1431
Header file for the UNUSED_PARAMETER function template.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8247
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:902
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:237
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:300
bool operator<=(const NegativeAccuracy< A > &, const T &rhs)
Less-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:404
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:258
Header file for the FalseType type/value trait base class.
#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:242
Header file for the IsDiagonal type trait.
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:79
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:821
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2507
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:348
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:4762
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:103
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:366
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2501
bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:442
#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:386
#define BLAZE_CONSTRAINT_MUST_BE_SQUARE(T)
Constraint on the data type.In case the given data type T is not a square matrix type, a compilation error is created.
Definition: Square.h:78
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2503
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:861
Constraint on the data type.
Header file for the IsSquare type trait.
Constraint on the data type.
Constraint on the data type.
Header file for the DenseSubmatrix class template.
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
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type loadu(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loadu.h:76
Compile time assertion.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4807
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
#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
Header file for the DenseMatrix base class.
Constraint on the data type.
const DenseIterator< Type > operator+(const DenseIterator< Type > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:556
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2504
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:195
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:535
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2505
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2509
Header file for the EnableIf class template.
Header file for utility functions for dense matrices.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:841
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_int16_t >::Type load(const T *address)
Loads a vector of 2-byte integral values.
Definition: Load.h:79
Header file for the IsNumeric type trait.
const bool spacing
Adding an additional spacing line between two log messages.This setting gives the opportunity to add ...
Definition: Logging.h:70
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:103
#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:2506
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
const DenseIterator< Type > operator-(const DenseIterator< Type > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:585
#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
void move(DynamicMatrix< Type, SO > &dst, DynamicMatrix< Type, SO > &src)
Moving the contents of one dynamic matrix to another.
Definition: DynamicMatrix.h:4934
#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:2510
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_RESIZABLE(T)
Constraint on the data type.In case the given data type T is resizable, i.e. has a 'resize' member fu...
Definition: Resizable.h:118
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:200
Header file for all intrinsic functionality.
Header file for the move shim.
SubmatrixExprTrait< MT, unaligned >::Type submatrix(Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:143
bool operator<(const NegativeAccuracy< A > &lhs, const T &rhs)
Less-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:328
#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.
boost::false_type FalseType
Type/value traits base class.The FalseType class is used as base class for type traits and value trai...
Definition: FalseType.h:61
#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
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2502
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2508
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
#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
Header file for the IsResizable type trait.
System settings for the inline keywords.
#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
Header file for the TrueType type/value trait base class.