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 <iterator>
44 #include <utility>
47 #include <blaze/math/Aliases.h>
59 #include <blaze/math/Exception.h>
62 #include <blaze/math/shims/Clear.h>
73 #include <blaze/math/views/Band.h>
75 #include <blaze/system/Inline.h>
76 #include <blaze/util/Assert.h>
82 #include <blaze/util/DisableIf.h>
83 #include <blaze/util/EnableIf.h>
84 #include <blaze/util/FalseType.h>
85 #include <blaze/util/mpl/And.h>
86 #include <blaze/util/mpl/If.h>
87 #include <blaze/util/mpl/Or.h>
89 #include <blaze/util/TrueType.h>
90 #include <blaze/util/Types.h>
95 #include <blaze/util/Unused.h>
96 
97 
98 namespace blaze {
99 
100 //=================================================================================================
101 //
102 // CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES
103 //
104 //=================================================================================================
105 
106 //*************************************************************************************************
114 template< typename MT // Type of the adapted dense matrix
115  , bool SO > // Storage order of the adapted dense matrix
116 class DiagonalMatrix<MT,SO,true>
117  : public DenseMatrix< DiagonalMatrix<MT,SO,true>, SO >
118 {
119  private:
120  //**Type definitions****************************************************************************
121  using OT = OppositeType_<MT>;
122  using TT = TransposeType_<MT>;
123  using ET = ElementType_<MT>;
124  //**********************************************************************************************
125 
126  public:
127  //**Type definitions****************************************************************************
128  using This = DiagonalMatrix<MT,SO,true>;
129  using BaseType = DenseMatrix<This,SO>;
130  using ResultType = This;
131  using OppositeType = DiagonalMatrix<OT,!SO,true>;
132  using TransposeType = DiagonalMatrix<TT,!SO,true>;
133  using ElementType = ET;
134  using SIMDType = SIMDType_<MT>;
135  using ReturnType = ReturnType_<MT>;
136  using CompositeType = const This&;
137  using Reference = DiagonalProxy<MT>;
138  using ConstReference = ConstReference_<MT>;
139  using Pointer = Pointer_<MT>;
140  using ConstPointer = ConstPointer_<MT>;
141  using ConstIterator = ConstIterator_<MT>;
142  //**********************************************************************************************
143 
144  //**Rebind struct definition********************************************************************
147  template< typename NewType > // Data type of the other matrix
148  struct Rebind {
150  using Other = DiagonalMatrix< typename MT::template Rebind<NewType>::Other >;
151  };
152  //**********************************************************************************************
153 
154  //**Resize struct definition********************************************************************
157  template< size_t NewM // Number of rows of the other matrix
158  , size_t NewN > // Number of columns of the other matrix
159  struct Resize {
161  using Other = DiagonalMatrix< typename MT::template Resize<NewM,NewN>::Other >;
162  };
163  //**********************************************************************************************
164 
165  //**Iterator class definition*******************************************************************
168  class Iterator
169  {
170  public:
171  //**Type definitions*************************************************************************
172  using IteratorCategory = std::random_access_iterator_tag;
173  using ValueType = ElementType_<MT>;
174  using PointerType = DiagonalProxy<MT>;
175  using ReferenceType = DiagonalProxy<MT>;
176  using DifferenceType = ptrdiff_t;
177 
178  // STL iterator requirements
179  using iterator_category = IteratorCategory;
180  using value_type = ValueType;
181  using pointer = PointerType;
182  using reference = ReferenceType;
183  using difference_type = DifferenceType;
184  //*******************************************************************************************
185 
186  //**Constructor******************************************************************************
189  inline Iterator() noexcept
190  : matrix_( nullptr ) // Reference to the adapted dense matrix
191  , row_ ( 0UL ) // The current row index of the iterator
192  , column_( 0UL ) // The current column index of the iterator
193  {}
194  //*******************************************************************************************
195 
196  //**Constructor******************************************************************************
203  inline Iterator( MT& matrix, size_t row, size_t column ) noexcept
204  : matrix_( &matrix ) // Reference to the adapted dense matrix
205  , row_ ( row ) // The current row-index of the iterator
206  , column_( column ) // The current column-index of the iterator
207  {}
208  //*******************************************************************************************
209 
210  //**Addition assignment operator*************************************************************
216  inline Iterator& operator+=( size_t inc ) noexcept {
217  ( SO )?( row_ += inc ):( column_ += inc );
218  return *this;
219  }
220  //*******************************************************************************************
221 
222  //**Subtraction assignment operator**********************************************************
228  inline Iterator& operator-=( size_t dec ) noexcept {
229  ( SO )?( row_ -= dec ):( column_ -= dec );
230  return *this;
231  }
232  //*******************************************************************************************
233 
234  //**Prefix increment operator****************************************************************
239  inline Iterator& operator++() noexcept {
240  ( SO )?( ++row_ ):( ++column_ );
241  return *this;
242  }
243  //*******************************************************************************************
244 
245  //**Postfix increment operator***************************************************************
250  inline const Iterator operator++( int ) noexcept {
251  const Iterator tmp( *this );
252  ++(*this);
253  return tmp;
254  }
255  //*******************************************************************************************
256 
257  //**Prefix decrement operator****************************************************************
262  inline Iterator& operator--() noexcept {
263  ( SO )?( --row_ ):( --column_ );
264  return *this;
265  }
266  //*******************************************************************************************
267 
268  //**Postfix decrement operator***************************************************************
273  inline const Iterator operator--( int ) noexcept {
274  const Iterator tmp( *this );
275  --(*this);
276  return tmp;
277  }
278  //*******************************************************************************************
279 
280  //**Element access operator******************************************************************
285  inline ReferenceType operator*() const {
286  return ReferenceType( *matrix_, row_, column_ );
287  }
288  //*******************************************************************************************
289 
290  //**Element access operator******************************************************************
295  inline PointerType operator->() const {
296  return PointerType( *matrix_, row_, column_ );
297  }
298  //*******************************************************************************************
299 
300  //**Load function****************************************************************************
310  inline SIMDType load() const {
311  return (*matrix_).load(row_,column_);
312  }
313  //*******************************************************************************************
314 
315  //**Loada function***************************************************************************
325  inline SIMDType loada() const {
326  return (*matrix_).loada(row_,column_);
327  }
328  //*******************************************************************************************
329 
330  //**Loadu function***************************************************************************
340  inline SIMDType loadu() const {
341  return (*matrix_).loadu(row_,column_);
342  }
343  //*******************************************************************************************
344 
345  //**Conversion operator**********************************************************************
350  inline operator ConstIterator() const {
351  if( SO )
352  return matrix_->begin( column_ ) + row_;
353  else
354  return matrix_->begin( row_ ) + column_;
355  }
356  //*******************************************************************************************
357 
358  //**Equality operator************************************************************************
365  friend inline bool operator==( const Iterator& lhs, const Iterator& rhs ) noexcept {
366  return ( SO )?( lhs.row_ == rhs.row_ ):( lhs.column_ == rhs.column_ );
367  }
368  //*******************************************************************************************
369 
370  //**Equality operator************************************************************************
377  friend inline bool operator==( const Iterator& lhs, const ConstIterator& rhs ) {
378  return ( ConstIterator( lhs ) == rhs );
379  }
380  //*******************************************************************************************
381 
382  //**Equality operator************************************************************************
389  friend inline bool operator==( const ConstIterator& lhs, const Iterator& rhs ) {
390  return ( lhs == ConstIterator( rhs ) );
391  }
392  //*******************************************************************************************
393 
394  //**Inequality operator**********************************************************************
401  friend inline bool operator!=( const Iterator& lhs, const Iterator& rhs ) noexcept {
402  return ( SO )?( lhs.row_ != rhs.row_ ):( lhs.column_ != rhs.column_ );
403  }
404  //*******************************************************************************************
405 
406  //**Inequality operator**********************************************************************
413  friend inline bool operator!=( const Iterator& lhs, const ConstIterator& rhs ) {
414  return ( ConstIterator( lhs ) != rhs );
415  }
416  //*******************************************************************************************
417 
418  //**Inequality operator**********************************************************************
425  friend inline bool operator!=( const ConstIterator& lhs, const Iterator& rhs ) {
426  return ( lhs != ConstIterator( rhs ) );
427  }
428  //*******************************************************************************************
429 
430  //**Less-than operator***********************************************************************
437  friend inline bool operator<( const Iterator& lhs, const Iterator& rhs ) noexcept {
438  return ( SO )?( lhs.row_ < rhs.row_ ):( lhs.column_ < rhs.column_ );
439  }
440  //*******************************************************************************************
441 
442  //**Less-than operator***********************************************************************
449  friend inline bool operator<( const Iterator& lhs, const ConstIterator& rhs ) {
450  return ( ConstIterator( lhs ) < rhs );
451  }
452  //*******************************************************************************************
453 
454  //**Less-than operator***********************************************************************
461  friend inline bool operator<( const ConstIterator& lhs, const Iterator& rhs ) {
462  return ( lhs < ConstIterator( rhs ) );
463  }
464  //*******************************************************************************************
465 
466  //**Greater-than operator********************************************************************
473  friend inline bool operator>( const Iterator& lhs, const Iterator& rhs ) noexcept {
474  return ( SO )?( lhs.row_ > rhs.row_ ):( lhs.column_ > rhs.column_ );
475  }
476  //*******************************************************************************************
477 
478  //**Greater-than operator********************************************************************
485  friend inline bool operator>( const Iterator& lhs, const ConstIterator& rhs ) {
486  return ( ConstIterator( lhs ) > rhs );
487  }
488  //*******************************************************************************************
489 
490  //**Greater-than operator********************************************************************
497  friend inline bool operator>( const ConstIterator& lhs, const Iterator& rhs ) {
498  return ( lhs > ConstIterator( rhs ) );
499  }
500  //*******************************************************************************************
501 
502  //**Less-or-equal-than operator**************************************************************
509  friend inline bool operator<=( const Iterator& lhs, const Iterator& rhs ) noexcept {
510  return ( SO )?( lhs.row_ <= rhs.row_ ):( lhs.column_ <= rhs.column_ );
511  }
512  //*******************************************************************************************
513 
514  //**Less-or-equal-than operator**************************************************************
521  friend inline bool operator<=( const Iterator& lhs, const ConstIterator& rhs ) {
522  return ( ConstIterator( lhs ) <= rhs );
523  }
524  //*******************************************************************************************
525 
526  //**Less-or-equal-than operator**************************************************************
533  friend inline bool operator<=( const ConstIterator& lhs, const Iterator& rhs ) {
534  return ( lhs <= ConstIterator( rhs ) );
535  }
536  //*******************************************************************************************
537 
538  //**Greater-or-equal-than operator***********************************************************
545  friend inline bool operator>=( const Iterator& lhs, const Iterator& rhs ) noexcept {
546  return ( SO )?( lhs.row_ >= rhs.row_ ):( lhs.column_ >= rhs.column_ );
547  }
548  //*******************************************************************************************
549 
550  //**Greater-or-equal-than operator***********************************************************
557  friend inline bool operator>=( const Iterator& lhs, const ConstIterator& rhs ) {
558  return ( ConstIterator( lhs ) >= rhs );
559  }
560  //*******************************************************************************************
561 
562  //**Greater-or-equal-than operator***********************************************************
569  friend inline bool operator>=( const ConstIterator& lhs, const Iterator& rhs ) {
570  return ( lhs >= ConstIterator( rhs ) );
571  }
572  //*******************************************************************************************
573 
574  //**Subtraction operator*********************************************************************
580  inline DifferenceType operator-( const Iterator& rhs ) const noexcept {
581  return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
582  }
583  //*******************************************************************************************
584 
585  //**Addition operator************************************************************************
592  friend inline const Iterator operator+( const Iterator& it, size_t inc ) noexcept {
593  if( SO )
594  return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
595  else
596  return Iterator( *it.matrix_, it.row_, it.column_ + inc );
597  }
598  //*******************************************************************************************
599 
600  //**Addition operator************************************************************************
607  friend inline const Iterator operator+( size_t inc, const Iterator& it ) noexcept {
608  if( SO )
609  return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
610  else
611  return Iterator( *it.matrix_, it.row_, it.column_ + inc );
612  }
613  //*******************************************************************************************
614 
615  //**Subtraction operator*********************************************************************
622  friend inline const Iterator operator-( const Iterator& it, size_t dec ) noexcept {
623  if( SO )
624  return Iterator( *it.matrix_, it.row_ - dec, it.column_ );
625  else
626  return Iterator( *it.matrix_, it.row_, it.column_ - dec );
627  }
628  //*******************************************************************************************
629 
630  private:
631  //**Member variables*************************************************************************
632  MT* matrix_;
633  size_t row_;
634  size_t column_;
635  //*******************************************************************************************
636  };
637  //**********************************************************************************************
638 
639  //**Compilation flags***************************************************************************
641  enum : bool { simdEnabled = MT::simdEnabled };
642 
644  enum : bool { smpAssignable = MT::smpAssignable };
645  //**********************************************************************************************
646 
647  //**Constructors********************************************************************************
650  explicit inline DiagonalMatrix();
651  template< typename A1 > explicit inline DiagonalMatrix( const A1& a1 );
652  explicit inline DiagonalMatrix( size_t n, const ElementType& init );
653 
654  explicit inline DiagonalMatrix( initializer_list< initializer_list<ElementType> > list );
655 
656  template< typename Other >
657  explicit inline DiagonalMatrix( size_t n, const Other* array );
658 
659  template< typename Other, size_t N >
660  explicit inline DiagonalMatrix( const Other (&array)[N][N] );
661 
662  explicit inline DiagonalMatrix( ElementType* ptr, size_t n );
663  explicit inline DiagonalMatrix( ElementType* ptr, size_t n, size_t nn );
664 
665  inline DiagonalMatrix( const DiagonalMatrix& m );
666  inline DiagonalMatrix( DiagonalMatrix&& m ) noexcept;
668  //**********************************************************************************************
669 
670  //**Destructor**********************************************************************************
671  // No explicitly declared destructor.
672  //**********************************************************************************************
673 
674  //**Data access functions***********************************************************************
677  inline Reference operator()( size_t i, size_t j );
678  inline ConstReference operator()( size_t i, size_t j ) const;
679  inline Reference at( size_t i, size_t j );
680  inline ConstReference at( size_t i, size_t j ) const;
681  inline ConstPointer data () const noexcept;
682  inline ConstPointer data ( size_t i ) const noexcept;
683  inline Iterator begin ( size_t i );
684  inline ConstIterator begin ( size_t i ) const;
685  inline ConstIterator cbegin( size_t i ) const;
686  inline Iterator end ( size_t i );
687  inline ConstIterator end ( size_t i ) const;
688  inline ConstIterator cend ( size_t i ) const;
690  //**********************************************************************************************
691 
692  //**Assignment operators************************************************************************
695  inline DiagonalMatrix& operator=( const ElementType& rhs );
696  inline DiagonalMatrix& operator=( initializer_list< initializer_list<ElementType> > list );
697 
698  template< typename Other, size_t N >
699  inline DiagonalMatrix& operator=( const Other (&array)[N][N] );
700 
701  inline DiagonalMatrix& operator=( const DiagonalMatrix& rhs );
702  inline DiagonalMatrix& operator=( DiagonalMatrix&& rhs ) noexcept;
703 
704  template< typename MT2, bool SO2 >
705  inline DisableIf_< IsComputation<MT2>, DiagonalMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
706 
707  template< typename MT2, bool SO2 >
708  inline EnableIf_< IsComputation<MT2>, DiagonalMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
709 
710  template< typename MT2, bool SO2 >
711  inline DisableIf_< IsComputation<MT2>, DiagonalMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
712 
713  template< typename MT2, bool SO2 >
714  inline EnableIf_< IsComputation<MT2>, DiagonalMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
715 
716  template< typename MT2, bool SO2 >
717  inline DisableIf_< IsComputation<MT2>, DiagonalMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
718 
719  template< typename MT2, bool SO2 >
720  inline EnableIf_< IsComputation<MT2>, DiagonalMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
721 
722  template< typename MT2, bool SO2 >
723  inline DiagonalMatrix& operator%=( const Matrix<MT2,SO2>& rhs );
724 
725  template< typename ST >
726  inline EnableIf_< IsNumeric<ST>, DiagonalMatrix >& operator*=( ST rhs );
727 
728  template< typename ST >
729  inline EnableIf_< IsNumeric<ST>, DiagonalMatrix >& operator/=( ST rhs );
731  //**********************************************************************************************
732 
733  //**Utility functions***************************************************************************
736  inline size_t rows() const noexcept;
737  inline size_t columns() const noexcept;
738  inline size_t spacing() const noexcept;
739  inline size_t capacity() const noexcept;
740  inline size_t capacity( size_t i ) const noexcept;
741  inline size_t nonZeros() const;
742  inline size_t nonZeros( size_t i ) const;
743  inline void reset();
744  inline void reset( size_t i );
745  inline void clear();
746  void resize ( size_t n, bool preserve=true );
747  inline void extend ( size_t n, bool preserve=true );
748  inline void reserve( size_t elements );
749  inline void shrinkToFit();
750  inline void swap( DiagonalMatrix& m ) noexcept;
752  //**********************************************************************************************
753 
754  //**Numeric functions***************************************************************************
757  template< typename Other > inline DiagonalMatrix& scale( const Other& scalar );
759  //**********************************************************************************************
760 
761  //**Debugging functions*************************************************************************
764  inline bool isIntact() const noexcept;
766  //**********************************************************************************************
767 
768  //**Expression template evaluation functions****************************************************
771  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
772  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
773 
774  inline bool isAligned () const noexcept;
775  inline bool canSMPAssign() const noexcept;
776 
777  BLAZE_ALWAYS_INLINE SIMDType load ( size_t i, size_t j ) const noexcept;
778  BLAZE_ALWAYS_INLINE SIMDType loada( size_t i, size_t j ) const noexcept;
779  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t i, size_t j ) const noexcept;
781  //**********************************************************************************************
782 
783  private:
784  //**Construction functions**********************************************************************
787  inline const MT construct( size_t n , TrueType );
788  inline const MT construct( const ElementType& value, FalseType );
789 
790  template< typename MT2, bool SO2, typename T >
791  inline const MT construct( const Matrix<MT2,SO2>& m, T );
793  //**********************************************************************************************
794 
795  //**Member variables****************************************************************************
798  MT matrix_;
799 
800  //**********************************************************************************************
801 
802  //**Friend declarations*************************************************************************
803  template< bool RF, typename MT2, bool SO2, bool DF2 >
804  friend bool isDefault( const DiagonalMatrix<MT2,SO2,DF2>& m );
805 
806  template< typename MT2, bool SO2, bool DF2 >
807  friend MT2& derestrict( DiagonalMatrix<MT2,SO2,DF2>& m );
808  //**********************************************************************************************
809 
810  //**Compile time checks*************************************************************************
823  BLAZE_STATIC_ASSERT( ( Size<MT,0UL>::value == Size<MT,1UL>::value ) );
824  //**********************************************************************************************
825 };
827 //*************************************************************************************************
828 
829 
830 
831 
832 //=================================================================================================
833 //
834 // CONSTRUCTORS
835 //
836 //=================================================================================================
837 
838 //*************************************************************************************************
842 template< typename MT // Type of the adapted dense matrix
843  , bool SO > // Storage order of the adapted dense matrix
844 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix()
845  : matrix_() // The adapted dense matrix
846 {
847  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
848  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
849 }
851 //*************************************************************************************************
852 
853 
854 //*************************************************************************************************
872 template< typename MT // Type of the adapted dense matrix
873  , bool SO > // Storage order of the adapted dense matrix
874 template< typename A1 > // Type of the constructor argument
875 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( const A1& a1 )
876  : matrix_( construct( a1, typename IsResizable<MT>::Type() ) ) // The adapted dense matrix
877 {
878  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
879  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
880 }
882 //*************************************************************************************************
883 
884 
885 //*************************************************************************************************
892 template< typename MT // Type of the adapted dense matrix
893  , bool SO > // Storage order of the adapted dense matrix
894 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( size_t n, const ElementType& init )
895  : matrix_( n, n, ElementType() ) // The adapted dense matrix
896 {
898 
899  for( size_t i=0UL; i<n; ++i )
900  matrix_(i,i) = init;
901 
902  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
903  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
904 }
906 //*************************************************************************************************
907 
908 
909 //*************************************************************************************************
933 template< typename MT // Type of the adapted dense matrix
934  , bool SO > // Storage order of the adapted dense matrix
935 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( initializer_list< initializer_list<ElementType> > list )
936  : matrix_( list ) // The adapted dense matrix
937 {
938  if( !isDiagonal( matrix_ ) ) {
939  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
940  }
941 
942  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
943 }
945 //*************************************************************************************************
946 
947 
948 //*************************************************************************************************
974 template< typename MT // Type of the adapted dense matrix
975  , bool SO > // Storage order of the adapted dense matrix
976 template< typename Other > // Data type of the initialization array
977 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( size_t n, const Other* array )
978  : matrix_( n, n, array ) // The adapted dense matrix
979 {
980  if( !isDiagonal( matrix_ ) ) {
981  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
982  }
983 
984  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
985 }
987 //*************************************************************************************************
988 
989 
990 //*************************************************************************************************
1013 template< typename MT // Type of the adapted dense matrix
1014  , bool SO > // Storage order of the adapted dense matrix
1015 template< typename Other // Data type of the initialization array
1016  , size_t N > // Number of rows and columns of the initialization array
1017 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( const Other (&array)[N][N] )
1018  : matrix_( array ) // The adapted dense matrix
1019 {
1020  if( !isDiagonal( matrix_ ) ) {
1021  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
1022  }
1023 
1024  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1025 }
1027 //*************************************************************************************************
1028 
1029 
1030 //*************************************************************************************************
1062 template< typename MT // Type of the adapted dense matrix
1063  , bool SO > // Storage order of the adapted dense matrix
1064 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( ElementType* ptr, size_t n )
1065  : matrix_( ptr, n, n ) // The adapted dense matrix
1066 {
1067  if( !isDiagonal( matrix_ ) ) {
1068  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
1069  }
1070 
1071  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1072 }
1074 //*************************************************************************************************
1075 
1076 
1077 //*************************************************************************************************
1111 template< typename MT // Type of the adapted dense matrix
1112  , bool SO > // Storage order of the adapted dense matrix
1113 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( ElementType* ptr, size_t n, size_t nn )
1114  : matrix_( ptr, n, n, nn ) // The adapted dense matrix
1115 {
1116  if( !isDiagonal( matrix_ ) ) {
1117  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
1118  }
1119 
1120  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1121 }
1123 //*************************************************************************************************
1124 
1125 
1126 //*************************************************************************************************
1132 template< typename MT // Type of the adapted dense matrix
1133  , bool SO > // Storage order of the adapted dense matrix
1134 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( const DiagonalMatrix& m )
1135  : matrix_( m.matrix_ ) // The adapted dense matrix
1136 {
1137  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1138  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1139 }
1141 //*************************************************************************************************
1142 
1143 
1144 //*************************************************************************************************
1150 template< typename MT // Type of the adapted dense matrix
1151  , bool SO > // Storage order of the adapted dense matrix
1152 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( DiagonalMatrix&& m ) noexcept
1153  : matrix_( std::move( m.matrix_ ) ) // The adapted dense matrix
1154 {
1155  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1156  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1157 }
1159 //*************************************************************************************************
1160 
1161 
1162 
1163 
1164 //=================================================================================================
1165 //
1166 // DATA ACCESS FUNCTIONS
1167 //
1168 //=================================================================================================
1169 
1170 //*************************************************************************************************
1186 template< typename MT // Type of the adapted dense matrix
1187  , bool SO > // Storage order of the adapted dense matrix
1189  DiagonalMatrix<MT,SO,true>::operator()( size_t i, size_t j )
1190 {
1191  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1192  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1193 
1194  return Reference( matrix_, i, j );
1195 }
1197 //*************************************************************************************************
1198 
1199 
1200 //*************************************************************************************************
1216 template< typename MT // Type of the adapted dense matrix
1217  , bool SO > // Storage order of the adapted dense matrix
1219  DiagonalMatrix<MT,SO,true>::operator()( size_t i, size_t j ) const
1220 {
1221  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1222  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1223 
1224  return matrix_(i,j);
1225 }
1227 //*************************************************************************************************
1228 
1229 
1230 //*************************************************************************************************
1247 template< typename MT // Type of the adapted dense matrix
1248  , bool SO > // Storage order of the adapted dense matrix
1250  DiagonalMatrix<MT,SO,true>::at( size_t i, size_t j )
1251 {
1252  if( i >= rows() ) {
1253  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1254  }
1255  if( j >= columns() ) {
1256  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1257  }
1258  return (*this)(i,j);
1259 }
1261 //*************************************************************************************************
1262 
1263 
1264 //*************************************************************************************************
1281 template< typename MT // Type of the adapted dense matrix
1282  , bool SO > // Storage order of the adapted dense matrix
1284  DiagonalMatrix<MT,SO,true>::at( size_t i, size_t j ) const
1285 {
1286  if( i >= rows() ) {
1287  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1288  }
1289  if( j >= columns() ) {
1290  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1291  }
1292  return (*this)(i,j);
1293 }
1295 //*************************************************************************************************
1296 
1297 
1298 //*************************************************************************************************
1311 template< typename MT // Type of the adapted dense matrix
1312  , bool SO > // Storage order of the adapted dense matrix
1313 inline typename DiagonalMatrix<MT,SO,true>::ConstPointer
1314  DiagonalMatrix<MT,SO,true>::data() const noexcept
1315 {
1316  return matrix_.data();
1317 }
1319 //*************************************************************************************************
1320 
1321 
1322 //*************************************************************************************************
1331 template< typename MT // Type of the adapted dense matrix
1332  , bool SO > // Storage order of the adapted dense matrix
1333 inline typename DiagonalMatrix<MT,SO,true>::ConstPointer
1334  DiagonalMatrix<MT,SO,true>::data( size_t i ) const noexcept
1335 {
1336  return matrix_.data(i);
1337 }
1339 //*************************************************************************************************
1340 
1341 
1342 //*************************************************************************************************
1354 template< typename MT // Type of the adapted dense matrix
1355  , bool SO > // Storage order of the adapted dense matrix
1358 {
1359  if( SO )
1360  return Iterator( matrix_, 0UL, i );
1361  else
1362  return Iterator( matrix_, i, 0UL );
1363 }
1365 //*************************************************************************************************
1366 
1367 
1368 //*************************************************************************************************
1380 template< typename MT // Type of the adapted dense matrix
1381  , bool SO > // Storage order of the adapted dense matrix
1383  DiagonalMatrix<MT,SO,true>::begin( size_t i ) const
1384 {
1385  return matrix_.begin(i);
1386 }
1388 //*************************************************************************************************
1389 
1390 
1391 //*************************************************************************************************
1403 template< typename MT // Type of the adapted dense matrix
1404  , bool SO > // Storage order of the adapted dense matrix
1406  DiagonalMatrix<MT,SO,true>::cbegin( size_t i ) const
1407 {
1408  return matrix_.cbegin(i);
1409 }
1411 //*************************************************************************************************
1412 
1413 
1414 //*************************************************************************************************
1426 template< typename MT // Type of the adapted dense matrix
1427  , bool SO > // Storage order of the adapted dense matrix
1430 {
1431  if( SO )
1432  return Iterator( matrix_, rows(), i );
1433  else
1434  return Iterator( matrix_, i, columns() );
1435 }
1437 //*************************************************************************************************
1438 
1439 
1440 //*************************************************************************************************
1452 template< typename MT // Type of the adapted dense matrix
1453  , bool SO > // Storage order of the adapted dense matrix
1455  DiagonalMatrix<MT,SO,true>::end( size_t i ) const
1456 {
1457  return matrix_.end(i);
1458 }
1460 //*************************************************************************************************
1461 
1462 
1463 //*************************************************************************************************
1475 template< typename MT // Type of the adapted dense matrix
1476  , bool SO > // Storage order of the adapted dense matrix
1478  DiagonalMatrix<MT,SO,true>::cend( size_t i ) const
1479 {
1480  return matrix_.cend(i);
1481 }
1483 //*************************************************************************************************
1484 
1485 
1486 
1487 
1488 //=================================================================================================
1489 //
1490 // ASSIGNMENT OPERATORS
1491 //
1492 //=================================================================================================
1493 
1494 //*************************************************************************************************
1501 template< typename MT // Type of the adapted dense matrix
1502  , bool SO > // Storage order of the adapted dense matrix
1503 inline DiagonalMatrix<MT,SO,true>&
1504  DiagonalMatrix<MT,SO,true>::operator=( const ElementType& rhs )
1505 {
1506  for( size_t i=0UL; i<rows(); ++i )
1507  matrix_(i,i) = rhs;
1508 
1509  return *this;
1510 }
1512 //*************************************************************************************************
1513 
1514 
1515 //*************************************************************************************************
1540 template< typename MT // Type of the adapted dense matrix
1541  , bool SO > // Storage order of the adapted dense matrix
1542 inline DiagonalMatrix<MT,SO,true>&
1543  DiagonalMatrix<MT,SO,true>::operator=( initializer_list< initializer_list<ElementType> > list )
1544 {
1545  const InitializerMatrix<ElementType> tmp( list, list.size() );
1546 
1547  if( !isDiagonal( tmp ) ) {
1548  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1549  }
1550 
1551  matrix_ = list;
1552 
1553  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1554  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1555 
1556  return *this;
1557 }
1559 //*************************************************************************************************
1560 
1561 
1562 //*************************************************************************************************
1586 template< typename MT // Type of the adapted dense matrix
1587  , bool SO > // Storage order of the adapted dense matrix
1588 template< typename Other // Data type of the initialization array
1589  , size_t N > // Number of rows and columns of the initialization array
1590 inline DiagonalMatrix<MT,SO,true>&
1591  DiagonalMatrix<MT,SO,true>::operator=( const Other (&array)[N][N] )
1592 {
1593  MT tmp( array );
1594 
1595  if( !isDiagonal( tmp ) ) {
1596  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1597  }
1598 
1599  matrix_ = std::move( tmp );
1600 
1601  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1602  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1603 
1604  return *this;
1605 }
1607 //*************************************************************************************************
1608 
1609 
1610 //*************************************************************************************************
1620 template< typename MT // Type of the adapted dense matrix
1621  , bool SO > // Storage order of the adapted dense matrix
1622 inline DiagonalMatrix<MT,SO,true>&
1623  DiagonalMatrix<MT,SO,true>::operator=( const DiagonalMatrix& rhs )
1624 {
1625  matrix_ = rhs.matrix_;
1626 
1627  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1628  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1629 
1630  return *this;
1631 }
1633 //*************************************************************************************************
1634 
1635 
1636 //*************************************************************************************************
1643 template< typename MT // Type of the adapted dense matrix
1644  , bool SO > // Storage order of the adapted dense matrix
1645 inline DiagonalMatrix<MT,SO,true>&
1646  DiagonalMatrix<MT,SO,true>::operator=( DiagonalMatrix&& rhs ) noexcept
1647 {
1648  matrix_ = std::move( rhs.matrix_ );
1649 
1650  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1651  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1652 
1653  return *this;
1654 }
1656 //*************************************************************************************************
1657 
1658 
1659 //*************************************************************************************************
1672 template< typename MT // Type of the adapted dense matrix
1673  , bool SO > // Storage order of the adapted dense matrix
1674 template< typename MT2 // Type of the right-hand side matrix
1675  , bool SO2 > // Storage order of the right-hand side matrix
1676 inline DisableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >
1677  DiagonalMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1678 {
1679  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
1680  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1681  }
1682 
1683  matrix_ = decldiag( ~rhs );
1684 
1685  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1686  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1687 
1688  return *this;
1689 }
1691 //*************************************************************************************************
1692 
1693 
1694 //*************************************************************************************************
1707 template< typename MT // Type of the adapted dense matrix
1708  , bool SO > // Storage order of the adapted dense matrix
1709 template< typename MT2 // Type of the right-hand side matrix
1710  , bool SO2 > // Storage order of the right-hand side matrix
1711 inline EnableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >
1712  DiagonalMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1713 {
1714  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1715  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1716  }
1717 
1718  if( IsDiagonal<MT2>::value ) {
1719  matrix_ = ~rhs;
1720  }
1721  else {
1722  MT tmp( ~rhs );
1723 
1724  if( !isDiagonal( tmp ) ) {
1725  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1726  }
1727 
1728  matrix_ = std::move( tmp );
1729  }
1730 
1731  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1732  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1733 
1734  return *this;
1735 }
1737 //*************************************************************************************************
1738 
1739 
1740 //*************************************************************************************************
1753 template< typename MT // Type of the adapted dense matrix
1754  , bool SO > // Storage order of the adapted dense matrix
1755 template< typename MT2 // Type of the right-hand side matrix
1756  , bool SO2 > // Storage order of the right-hand side matrix
1757 inline DisableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >
1758  DiagonalMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1759 {
1760  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
1761  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1762  }
1763 
1764  matrix_ += decldiag( ~rhs );
1765 
1766  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1767  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1768 
1769  return *this;
1770 }
1772 //*************************************************************************************************
1773 
1774 
1775 //*************************************************************************************************
1788 template< typename MT // Type of the adapted dense matrix
1789  , bool SO > // Storage order of the adapted dense matrix
1790 template< typename MT2 // Type of the right-hand side matrix
1791  , bool SO2 > // Storage order of the right-hand side matrix
1792 inline EnableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >
1793  DiagonalMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1794 {
1795  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1796  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1797  }
1798 
1799  if( IsDiagonal<MT2>::value ) {
1800  matrix_ += ~rhs;
1801  }
1802  else {
1803  const ResultType_<MT2> tmp( ~rhs );
1804 
1805  if( !isDiagonal( tmp ) ) {
1806  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1807  }
1808 
1809  matrix_ += decldiag( tmp );
1810  }
1811 
1812  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1813  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1814 
1815  return *this;
1816 }
1818 //*************************************************************************************************
1819 
1820 
1821 //*************************************************************************************************
1834 template< typename MT // Type of the adapted dense matrix
1835  , bool SO > // Storage order of the adapted dense matrix
1836 template< typename MT2 // Type of the right-hand side matrix
1837  , bool SO2 > // Storage order of the right-hand side matrix
1838 inline DisableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >
1839  DiagonalMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1840 {
1841  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
1842  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1843  }
1844 
1845  matrix_ -= decldiag( ~rhs );
1846 
1847  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1848  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1849 
1850  return *this;
1851 }
1853 //*************************************************************************************************
1854 
1855 
1856 //*************************************************************************************************
1869 template< typename MT // Type of the adapted dense matrix
1870  , bool SO > // Storage order of the adapted dense matrix
1871 template< typename MT2 // Type of the right-hand side matrix
1872  , bool SO2 > // Storage order of the right-hand side matrix
1873 inline EnableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >
1874  DiagonalMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1875 {
1876  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1877  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1878  }
1879 
1880  if( IsDiagonal<MT2>::value ) {
1881  matrix_ -= ~rhs;
1882  }
1883  else {
1884  const ResultType_<MT2> tmp( ~rhs );
1885 
1886  if( !isDiagonal( tmp ) ) {
1887  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1888  }
1889 
1890  matrix_ -= decldiag( tmp );
1891  }
1892 
1893  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1894  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1895 
1896  return *this;
1897 }
1899 //*************************************************************************************************
1900 
1901 
1902 //*************************************************************************************************
1913 template< typename MT // Type of the adapted dense matrix
1914  , bool SO > // Storage order of the adapted dense matrix
1915 template< typename MT2 // Type of the right-hand side matrix
1916  , bool SO2 > // Storage order of the right-hand side matrix
1917 inline DiagonalMatrix<MT,SO,true>&
1918  DiagonalMatrix<MT,SO,true>::operator%=( const Matrix<MT2,SO2>& rhs )
1919 {
1920  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1921  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1922  }
1923 
1924  matrix_ %= ~rhs;
1925 
1926  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1927  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1928 
1929  return *this;
1930 }
1932 //*************************************************************************************************
1933 
1934 
1935 //*************************************************************************************************
1943 template< typename MT // Type of the adapted dense matrix
1944  , bool SO > // Storage order of the adapted dense matrix
1945 template< typename ST > // Data type of the right-hand side scalar
1946 inline EnableIf_< IsNumeric<ST>, DiagonalMatrix<MT,SO,true> >&
1948 {
1949  diagonal( matrix_ ) *= scalar;
1950 
1951  return *this;
1952 }
1953 //*************************************************************************************************
1954 
1955 
1956 //*************************************************************************************************
1964 template< typename MT // Type of the adapted dense matrix
1965  , bool SO > // Storage order of the adapted dense matrix
1966 template< typename ST > // Data type of the right-hand side scalar
1967 inline EnableIf_< IsNumeric<ST>, DiagonalMatrix<MT,SO,true> >&
1969 {
1970  diagonal( matrix_ ) /= scalar;
1971 
1972  return *this;
1973 }
1975 //*************************************************************************************************
1976 
1977 
1978 
1979 
1980 //=================================================================================================
1981 //
1982 // UTILITY FUNCTIONS
1983 //
1984 //=================================================================================================
1985 
1986 //*************************************************************************************************
1992 template< typename MT // Type of the adapted dense matrix
1993  , bool SO > // Storage order of the adapted dense matrix
1994 inline size_t DiagonalMatrix<MT,SO,true>::rows() const noexcept
1995 {
1996  return matrix_.rows();
1997 }
1999 //*************************************************************************************************
2000 
2001 
2002 //*************************************************************************************************
2008 template< typename MT // Type of the adapted dense matrix
2009  , bool SO > // Storage order of the adapted dense matrix
2010 inline size_t DiagonalMatrix<MT,SO,true>::columns() const noexcept
2011 {
2012  return matrix_.columns();
2013 }
2015 //*************************************************************************************************
2016 
2017 
2018 //*************************************************************************************************
2029 template< typename MT // Type of the adapted dense matrix
2030  , bool SO > // Storage order of the adapted dense matrix
2031 inline size_t DiagonalMatrix<MT,SO,true>::spacing() const noexcept
2032 {
2033  return matrix_.spacing();
2034 }
2036 //*************************************************************************************************
2037 
2038 
2039 //*************************************************************************************************
2045 template< typename MT // Type of the adapted dense matrix
2046  , bool SO > // Storage order of the adapted dense matrix
2047 inline size_t DiagonalMatrix<MT,SO,true>::capacity() const noexcept
2048 {
2049  return matrix_.capacity();
2050 }
2052 //*************************************************************************************************
2053 
2054 
2055 //*************************************************************************************************
2067 template< typename MT // Type of the adapted dense matrix
2068  , bool SO > // Storage order of the adapted dense matrix
2069 inline size_t DiagonalMatrix<MT,SO,true>::capacity( size_t i ) const noexcept
2070 {
2071  return matrix_.capacity(i);
2072 }
2074 //*************************************************************************************************
2075 
2076 
2077 //*************************************************************************************************
2083 template< typename MT // Type of the adapted dense matrix
2084  , bool SO > // Storage order of the adapted dense matrix
2085 inline size_t DiagonalMatrix<MT,SO,true>::nonZeros() const
2086 {
2087  return matrix_.nonZeros();
2088 }
2090 //*************************************************************************************************
2091 
2092 
2093 //*************************************************************************************************
2105 template< typename MT // Type of the adapted dense matrix
2106  , bool SO > // Storage order of the adapted dense matrix
2107 inline size_t DiagonalMatrix<MT,SO,true>::nonZeros( size_t i ) const
2108 {
2109  return matrix_.nonZeros(i);
2110 }
2112 //*************************************************************************************************
2113 
2114 
2115 //*************************************************************************************************
2121 template< typename MT // Type of the adapted dense matrix
2122  , bool SO > // Storage order of the adapted dense matrix
2124 {
2125  matrix_.reset();
2126 }
2128 //*************************************************************************************************
2129 
2130 
2131 //*************************************************************************************************
2144 template< typename MT // Type of the adapted dense matrix
2145  , bool SO > // Storage order of the adapted dense matrix
2146 inline void DiagonalMatrix<MT,SO,true>::reset( size_t i )
2147 {
2148  matrix_.reset( i );
2149 }
2151 //*************************************************************************************************
2152 
2153 
2154 //*************************************************************************************************
2166 template< typename MT // Type of the adapted dense matrix
2167  , bool SO > // Storage order of the adapted dense matrix
2169 {
2170  using blaze::clear;
2171 
2172  clear( matrix_ );
2173 }
2175 //*************************************************************************************************
2176 
2177 
2178 //*************************************************************************************************
2214 template< typename MT // Type of the adapted dense matrix
2215  , bool SO > // Storage order of the adapted dense matrix
2216 void DiagonalMatrix<MT,SO,true>::resize( size_t n, bool preserve )
2217 {
2219 
2220  UNUSED_PARAMETER( preserve );
2221 
2222  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
2223 
2224  const size_t oldsize( matrix_.rows() );
2225 
2226  matrix_.resize( n, n, true );
2227 
2228  if( n > oldsize ) {
2229  const size_t increment( n - oldsize );
2230  submatrix( matrix_, 0UL, oldsize, n, increment ).reset();
2231  submatrix( matrix_, oldsize, 0UL, increment, increment ).reset();
2232  }
2233 }
2235 //*************************************************************************************************
2236 
2237 
2238 //*************************************************************************************************
2251 template< typename MT // Type of the adapted dense matrix
2252  , bool SO > // Storage order of the adapted dense matrix
2253 inline void DiagonalMatrix<MT,SO,true>::extend( size_t n, bool preserve )
2254 {
2256 
2257  UNUSED_PARAMETER( preserve );
2258 
2259  resize( rows() + n, true );
2260 }
2261 //*************************************************************************************************
2262 
2263 
2264 //*************************************************************************************************
2274 template< typename MT // Type of the adapted dense matrix
2275  , bool SO > // Storage order of the adapted dense matrix
2276 inline void DiagonalMatrix<MT,SO,true>::reserve( size_t elements )
2277 {
2278  matrix_.reserve( elements );
2279 }
2281 //*************************************************************************************************
2282 
2283 
2284 //*************************************************************************************************
2294 template< typename MT // Type of the adapted dense matrix
2295  , bool SO > // Storage order of the adapted dense matrix
2297 {
2298  matrix_.shrinkToFit();
2299 }
2301 //*************************************************************************************************
2302 
2303 
2304 //*************************************************************************************************
2311 template< typename MT // Type of the adapted dense matrix
2312  , bool SO > // Storage order of the adapted dense matrix
2313 inline void DiagonalMatrix<MT,SO,true>::swap( DiagonalMatrix& m ) noexcept
2314 {
2315  using std::swap;
2316 
2317  swap( matrix_, m.matrix_ );
2318 }
2320 //*************************************************************************************************
2321 
2322 
2323 
2324 
2325 //=================================================================================================
2326 //
2327 // NUMERIC FUNCTIONS
2328 //
2329 //=================================================================================================
2330 
2331 //*************************************************************************************************
2349 template< typename MT // Type of the adapted dense matrix
2350  , bool SO > // Storage order of the adapted dense matrix
2351 template< typename Other > // Data type of the scalar value
2352 inline DiagonalMatrix<MT,SO,true>& DiagonalMatrix<MT,SO,true>::scale( const Other& scalar )
2353 {
2354  matrix_.scale( scalar );
2355  return *this;
2356 }
2358 //*************************************************************************************************
2359 
2360 
2361 
2362 
2363 //=================================================================================================
2364 //
2365 // DEBUGGING FUNCTIONS
2366 //
2367 //=================================================================================================
2368 
2369 //*************************************************************************************************
2379 template< typename MT // Type of the adapted dense matrix
2380  , bool SO > // Storage order of the adapted dense matrix
2381 inline bool DiagonalMatrix<MT,SO,true>::isIntact() const noexcept
2382 {
2383  using blaze::isIntact;
2384 
2385  return ( isIntact( matrix_ ) && isDiagonal( matrix_ ) );
2386 }
2388 //*************************************************************************************************
2389 
2390 
2391 
2392 
2393 //=================================================================================================
2394 //
2395 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2396 //
2397 //=================================================================================================
2398 
2399 //*************************************************************************************************
2410 template< typename MT // Type of the adapted dense matrix
2411  , bool SO > // Storage order of the adapted dense matrix
2412 template< typename Other > // Data type of the foreign expression
2413 inline bool DiagonalMatrix<MT,SO,true>::canAlias( const Other* alias ) const noexcept
2414 {
2415  return matrix_.canAlias( alias );
2416 }
2418 //*************************************************************************************************
2419 
2420 
2421 //*************************************************************************************************
2432 template< typename MT // Type of the adapted dense matrix
2433  , bool SO > // Storage order of the adapted dense matrix
2434 template< typename Other > // Data type of the foreign expression
2435 inline bool DiagonalMatrix<MT,SO,true>::isAliased( const Other* alias ) const noexcept
2436 {
2437  return matrix_.isAliased( alias );
2438 }
2440 //*************************************************************************************************
2441 
2442 
2443 //*************************************************************************************************
2453 template< typename MT // Type of the adapted dense matrix
2454  , bool SO > // Storage order of the adapted dense matrix
2455 inline bool DiagonalMatrix<MT,SO,true>::isAligned() const noexcept
2456 {
2457  return matrix_.isAligned();
2458 }
2460 //*************************************************************************************************
2461 
2462 
2463 //*************************************************************************************************
2474 template< typename MT // Type of the adapted dense matrix
2475  , bool SO > // Storage order of the adapted dense matrix
2476 inline bool DiagonalMatrix<MT,SO,true>::canSMPAssign() const noexcept
2477 {
2478  return matrix_.canSMPAssign();
2479 }
2481 //*************************************************************************************************
2482 
2483 
2484 //*************************************************************************************************
2500 template< typename MT // Type of the adapted dense matrix
2501  , bool SO > // Storage order of the adapted dense matrix
2502 BLAZE_ALWAYS_INLINE typename DiagonalMatrix<MT,SO,true>::SIMDType
2503  DiagonalMatrix<MT,SO,true>::load( size_t i, size_t j ) const noexcept
2504 {
2505  return matrix_.load( i, j );
2506 }
2508 //*************************************************************************************************
2509 
2510 
2511 //*************************************************************************************************
2527 template< typename MT // Type of the adapted dense matrix
2528  , bool SO > // Storage order of the adapted dense matrix
2529 BLAZE_ALWAYS_INLINE typename DiagonalMatrix<MT,SO,true>::SIMDType
2530  DiagonalMatrix<MT,SO,true>::loada( size_t i, size_t j ) const noexcept
2531 {
2532  return matrix_.loada( i, j );
2533 }
2535 //*************************************************************************************************
2536 
2537 
2538 //*************************************************************************************************
2554 template< typename MT // Type of the adapted dense matrix
2555  , bool SO > // Storage order of the adapted dense matrix
2556 BLAZE_ALWAYS_INLINE typename DiagonalMatrix<MT,SO,true>::SIMDType
2557  DiagonalMatrix<MT,SO,true>::loadu( size_t i, size_t j ) const noexcept
2558 {
2559  return matrix_.loadu( i, j );
2560 }
2562 //*************************************************************************************************
2563 
2564 
2565 
2566 
2567 //=================================================================================================
2568 //
2569 // CONSTRUCTION FUNCTIONS
2570 //
2571 //=================================================================================================
2572 
2573 //*************************************************************************************************
2580 template< typename MT // Type of the adapted dense matrix
2581  , bool SO > // Storage order of the adapted dense matrix
2582 inline const MT DiagonalMatrix<MT,SO,true>::construct( size_t n, TrueType )
2583 {
2585 
2586  return MT( n, n, ElementType() );
2587 }
2589 //*************************************************************************************************
2590 
2591 
2592 //*************************************************************************************************
2599 template< typename MT // Type of the adapted dense matrix
2600  , bool SO > // Storage order of the adapted dense matrix
2601 inline const MT DiagonalMatrix<MT,SO,true>::construct( const ElementType& init, FalseType )
2602 {
2605 
2606  MT tmp;
2607 
2608  for( size_t i=0UL; i<tmp.rows(); ++i )
2609  tmp(i,i) = init;
2610 
2611  return tmp;
2612 }
2614 //*************************************************************************************************
2615 
2616 
2617 //*************************************************************************************************
2628 template< typename MT // Type of the adapted dense matrix
2629  , bool SO > // Storage order of the adapted dense matrix
2630 template< typename MT2 // Type of the foreign matrix
2631  , bool SO2 // Storage order of the foreign matrix
2632  , typename T > // Type of the third argument
2633 inline const MT DiagonalMatrix<MT,SO,true>::construct( const Matrix<MT2,SO2>& m, T )
2634 {
2635  const MT tmp( ~m );
2636 
2637  if( !IsDiagonal<MT2>::value && !isDiagonal( tmp ) ) {
2638  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
2639  }
2640 
2641  return tmp;
2642 }
2644 //*************************************************************************************************
2645 
2646 } // namespace blaze
2647 
2648 #endif
Constraint on the data type.
Header file for the implementation of the Submatrix view.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
Header file for the UnderlyingNumeric type trait.
BoolConstant< false > 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_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:131
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3077
decltype(auto) decldiag(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as diagonal.
Definition: DMatDeclDiagExpr.h:996
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:522
Header file for basic type definitions.
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:63
Header file for the IsDiagonal type trait.
Header file for the implementation of the Band view.
#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:61
constexpr bool operator<(const NegativeAccuracy< A > &lhs, const T &rhs)
Less-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:329
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3076
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:364
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3074
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:701
BLAZE_ALWAYS_INLINE void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:775
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5829
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3078
Header file for the And class template.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3083
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
bool isDiagonal(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is diagonal.
Definition: DenseMatrix.h:1725
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:560
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:733
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3084
Header file for the extended initializer_list functionality.
Constraint on the data type.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loadu.h:77
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:474
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:408
Constraint on the data type.
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:252
#define BLAZE_CONSTRAINT_MUST_BE_SQUARE_MATRIX_TYPE(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:60
Header file for the IsSquare type trait.
Constraint on the data type.
Header file for the implementation of a matrix representation of an initializer list.
Header file for the DisableIf class template.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3082
Header file for the DiagonalProxy class.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5908
Header file for the If class template.
Compile time assertion.
Header file for the IsFloatingPoint type trait.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5891
Header file for the UnderlyingBuiltin type trait.
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3079
Header file for the Or class template.
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the DenseMatrix base class.
constexpr bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:367
constexpr 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:443
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
Header file for the isZero shim.
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:506
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:80
Constraints on the storage order of matrix types.
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:134
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:81
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:714
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:430
decltype(auto) diagonal(Matrix< MT, SO > &matrix, RDAs... args)
Creating a view on the diagonal of the given matrix.
Definition: Band.h:374
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8893
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:360
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:608
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:79
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:131
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_RESIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is resizable, i.e. has a &#39;resize&#39; member fu...
Definition: Resizable.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:272
Constraint on the data type.
Constraint on the data type.
constexpr 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:405
Header file for the IsInvertible type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:224
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:490
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
Header file for the implementation of the base template of the DiagonalMatrix.
BLAZE_ALWAYS_INLINE MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:169
EnableIf_< IsNumeric< ST >, MT &> operator/=(DenseMatrix< MT, SO > &mat, ST scalar)
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:655
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a &#39;res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
Header file for the IsBuiltin type trait.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3081
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:254
Header file for the IsComplex type trait.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
EnableIf_< IsNumeric< ST >, MT &> operator*=(DenseMatrix< MT, SO > &mat, ST scalar)
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:593
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:908
Header file for the IsResizable type trait.
System settings for the inline keywords.
Header file for the Size type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for the TrueType type/value trait base class.