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>
58 #include <blaze/math/Exception.h>
61 #include <blaze/math/shims/Clear.h>
70 #include <blaze/system/Inline.h>
71 #include <blaze/util/Assert.h>
77 #include <blaze/util/DisableIf.h>
78 #include <blaze/util/EnableIf.h>
79 #include <blaze/util/FalseType.h>
81 #include <blaze/util/TrueType.h>
82 #include <blaze/util/Types.h>
84 #include <blaze/util/Unused.h>
85 
86 
87 namespace blaze {
88 
89 //=================================================================================================
90 //
91 // CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES
92 //
93 //=================================================================================================
94 
95 //*************************************************************************************************
103 template< typename MT // Type of the adapted dense matrix
104  , bool SO > // Storage order of the adapted dense matrix
105 class DiagonalMatrix<MT,SO,true>
106  : public DenseMatrix< DiagonalMatrix<MT,SO,true>, SO >
107 {
108  private:
109  //**Type definitions****************************************************************************
110  typedef OppositeType_<MT> OT;
111  typedef TransposeType_<MT> TT;
112  typedef ElementType_<MT> ET;
113  //**********************************************************************************************
114 
115  public:
116  //**Type definitions****************************************************************************
117  typedef DiagonalMatrix<MT,SO,true> This;
118  typedef DenseMatrix<This,SO> BaseType;
119  typedef This ResultType;
120  typedef DiagonalMatrix<OT,!SO,true> OppositeType;
121  typedef DiagonalMatrix<TT,!SO,true> TransposeType;
122  typedef ET ElementType;
123  typedef SIMDType_<MT> SIMDType;
124  typedef ReturnType_<MT> ReturnType;
125  typedef const This& CompositeType;
126  typedef DiagonalProxy<MT> Reference;
127  typedef ConstReference_<MT> ConstReference;
128  typedef Pointer_<MT> Pointer;
129  typedef ConstPointer_<MT> ConstPointer;
130  typedef ConstIterator_<MT> ConstIterator;
131  //**********************************************************************************************
132 
133  //**Rebind struct definition********************************************************************
136  template< typename ET > // Data type of the other matrix
137  struct Rebind {
139  typedef DiagonalMatrix< typename MT::template Rebind<ET>::Other > Other;
140  };
141  //**********************************************************************************************
142 
143  //**Iterator class definition*******************************************************************
146  class Iterator
147  {
148  public:
149  //**Type definitions*************************************************************************
150  typedef std::random_access_iterator_tag IteratorCategory;
151  typedef ElementType_<MT> ValueType;
152  typedef DiagonalProxy<MT> PointerType;
153  typedef DiagonalProxy<MT> ReferenceType;
154  typedef ptrdiff_t DifferenceType;
155 
156  // STL iterator requirements
157  typedef IteratorCategory iterator_category;
158  typedef ValueType value_type;
159  typedef PointerType pointer;
160  typedef ReferenceType reference;
161  typedef DifferenceType difference_type;
162  //*******************************************************************************************
163 
164  //**Constructor******************************************************************************
167  inline Iterator() noexcept
168  : matrix_( nullptr ) // Reference to the adapted dense matrix
169  , row_ ( 0UL ) // The current row index of the iterator
170  , column_( 0UL ) // The current column index of the iterator
171  {}
172  //*******************************************************************************************
173 
174  //**Constructor******************************************************************************
181  inline Iterator( MT& matrix, size_t row, size_t column ) noexcept
182  : matrix_( &matrix ) // Reference to the adapted dense matrix
183  , row_ ( row ) // The current row-index of the iterator
184  , column_( column ) // The current column-index of the iterator
185  {}
186  //*******************************************************************************************
187 
188  //**Addition assignment operator*************************************************************
194  inline Iterator& operator+=( size_t inc ) noexcept {
195  ( SO )?( row_ += inc ):( column_ += inc );
196  return *this;
197  }
198  //*******************************************************************************************
199 
200  //**Subtraction assignment operator**********************************************************
206  inline Iterator& operator-=( size_t dec ) noexcept {
207  ( SO )?( row_ -= dec ):( column_ -= dec );
208  return *this;
209  }
210  //*******************************************************************************************
211 
212  //**Prefix increment operator****************************************************************
217  inline Iterator& operator++() noexcept {
218  ( SO )?( ++row_ ):( ++column_ );
219  return *this;
220  }
221  //*******************************************************************************************
222 
223  //**Postfix increment operator***************************************************************
228  inline const Iterator operator++( int ) noexcept {
229  const Iterator tmp( *this );
230  ++(*this);
231  return tmp;
232  }
233  //*******************************************************************************************
234 
235  //**Prefix decrement operator****************************************************************
240  inline Iterator& operator--() noexcept {
241  ( SO )?( --row_ ):( --column_ );
242  return *this;
243  }
244  //*******************************************************************************************
245 
246  //**Postfix decrement operator***************************************************************
251  inline const Iterator operator--( int ) noexcept {
252  const Iterator tmp( *this );
253  --(*this);
254  return tmp;
255  }
256  //*******************************************************************************************
257 
258  //**Element access operator******************************************************************
263  inline ReferenceType operator*() const {
264  return ReferenceType( *matrix_, row_, column_ );
265  }
266  //*******************************************************************************************
267 
268  //**Element access operator******************************************************************
273  inline PointerType operator->() const {
274  return PointerType( *matrix_, row_, column_ );
275  }
276  //*******************************************************************************************
277 
278  //**Load function****************************************************************************
288  inline SIMDType load() const {
289  return (*matrix_).load(row_,column_);
290  }
291  //*******************************************************************************************
292 
293  //**Loada function***************************************************************************
303  inline SIMDType loada() const {
304  return (*matrix_).loada(row_,column_);
305  }
306  //*******************************************************************************************
307 
308  //**Loadu function***************************************************************************
318  inline SIMDType loadu() const {
319  return (*matrix_).loadu(row_,column_);
320  }
321  //*******************************************************************************************
322 
323  //**Conversion operator**********************************************************************
328  inline operator ConstIterator() const {
329  if( SO )
330  return matrix_->begin( column_ ) + row_;
331  else
332  return matrix_->begin( row_ ) + column_;
333  }
334  //*******************************************************************************************
335 
336  //**Equality operator************************************************************************
343  friend inline bool operator==( const Iterator& lhs, const Iterator& rhs ) noexcept {
344  return ( SO )?( lhs.row_ == rhs.row_ ):( lhs.column_ == rhs.column_ );
345  }
346  //*******************************************************************************************
347 
348  //**Equality operator************************************************************************
355  friend inline bool operator==( const Iterator& lhs, const ConstIterator& rhs ) {
356  return ( ConstIterator( lhs ) == rhs );
357  }
358  //*******************************************************************************************
359 
360  //**Equality operator************************************************************************
367  friend inline bool operator==( const ConstIterator& lhs, const Iterator& rhs ) {
368  return ( lhs == ConstIterator( rhs ) );
369  }
370  //*******************************************************************************************
371 
372  //**Inequality operator**********************************************************************
379  friend inline bool operator!=( const Iterator& lhs, const Iterator& rhs ) noexcept {
380  return ( SO )?( lhs.row_ != rhs.row_ ):( lhs.column_ != rhs.column_ );
381  }
382  //*******************************************************************************************
383 
384  //**Inequality operator**********************************************************************
391  friend inline bool operator!=( const Iterator& lhs, const ConstIterator& rhs ) {
392  return ( ConstIterator( lhs ) != rhs );
393  }
394  //*******************************************************************************************
395 
396  //**Inequality operator**********************************************************************
403  friend inline bool operator!=( const ConstIterator& lhs, const Iterator& rhs ) {
404  return ( lhs != ConstIterator( rhs ) );
405  }
406  //*******************************************************************************************
407 
408  //**Less-than operator***********************************************************************
415  friend inline bool operator<( const Iterator& lhs, const Iterator& rhs ) noexcept {
416  return ( SO )?( lhs.row_ < rhs.row_ ):( lhs.column_ < rhs.column_ );
417  }
418  //*******************************************************************************************
419 
420  //**Less-than operator***********************************************************************
427  friend inline bool operator<( const Iterator& lhs, const ConstIterator& rhs ) {
428  return ( ConstIterator( lhs ) < rhs );
429  }
430  //*******************************************************************************************
431 
432  //**Less-than operator***********************************************************************
439  friend inline bool operator<( const ConstIterator& lhs, const Iterator& rhs ) {
440  return ( lhs < ConstIterator( rhs ) );
441  }
442  //*******************************************************************************************
443 
444  //**Greater-than operator********************************************************************
451  friend inline bool operator>( const Iterator& lhs, const Iterator& rhs ) noexcept {
452  return ( SO )?( lhs.row_ > rhs.row_ ):( lhs.column_ > rhs.column_ );
453  }
454  //*******************************************************************************************
455 
456  //**Greater-than operator********************************************************************
463  friend inline bool operator>( const Iterator& lhs, const ConstIterator& rhs ) {
464  return ( ConstIterator( lhs ) > rhs );
465  }
466  //*******************************************************************************************
467 
468  //**Greater-than operator********************************************************************
475  friend inline bool operator>( const ConstIterator& lhs, const Iterator& rhs ) {
476  return ( lhs > ConstIterator( rhs ) );
477  }
478  //*******************************************************************************************
479 
480  //**Less-or-equal-than operator**************************************************************
487  friend inline bool operator<=( const Iterator& lhs, const Iterator& rhs ) noexcept {
488  return ( SO )?( lhs.row_ <= rhs.row_ ):( lhs.column_ <= rhs.column_ );
489  }
490  //*******************************************************************************************
491 
492  //**Less-or-equal-than operator**************************************************************
499  friend inline bool operator<=( const Iterator& lhs, const ConstIterator& rhs ) {
500  return ( ConstIterator( lhs ) <= rhs );
501  }
502  //*******************************************************************************************
503 
504  //**Less-or-equal-than operator**************************************************************
511  friend inline bool operator<=( const ConstIterator& lhs, const Iterator& rhs ) {
512  return ( lhs <= ConstIterator( rhs ) );
513  }
514  //*******************************************************************************************
515 
516  //**Greater-or-equal-than operator***********************************************************
523  friend inline bool operator>=( const Iterator& lhs, const Iterator& rhs ) noexcept {
524  return ( SO )?( lhs.row_ >= rhs.row_ ):( lhs.column_ >= rhs.column_ );
525  }
526  //*******************************************************************************************
527 
528  //**Greater-or-equal-than operator***********************************************************
535  friend inline bool operator>=( const Iterator& lhs, const ConstIterator& rhs ) {
536  return ( ConstIterator( lhs ) >= rhs );
537  }
538  //*******************************************************************************************
539 
540  //**Greater-or-equal-than operator***********************************************************
547  friend inline bool operator>=( const ConstIterator& lhs, const Iterator& rhs ) {
548  return ( lhs >= ConstIterator( rhs ) );
549  }
550  //*******************************************************************************************
551 
552  //**Subtraction operator*********************************************************************
558  inline DifferenceType operator-( const Iterator& rhs ) const noexcept {
559  return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
560  }
561  //*******************************************************************************************
562 
563  //**Addition operator************************************************************************
570  friend inline const Iterator operator+( const Iterator& it, size_t inc ) noexcept {
571  if( SO )
572  return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
573  else
574  return Iterator( *it.matrix_, it.row_, it.column_ + inc );
575  }
576  //*******************************************************************************************
577 
578  //**Addition operator************************************************************************
585  friend inline const Iterator operator+( size_t inc, const Iterator& it ) noexcept {
586  if( SO )
587  return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
588  else
589  return Iterator( *it.matrix_, it.row_, it.column_ + inc );
590  }
591  //*******************************************************************************************
592 
593  //**Subtraction operator*********************************************************************
600  friend inline const Iterator operator-( const Iterator& it, size_t dec ) noexcept {
601  if( SO )
602  return Iterator( *it.matrix_, it.row_ - dec, it.column_ );
603  else
604  return Iterator( *it.matrix_, it.row_, it.column_ - dec );
605  }
606  //*******************************************************************************************
607 
608  private:
609  //**Member variables*************************************************************************
610  MT* matrix_;
611  size_t row_;
612  size_t column_;
613  //*******************************************************************************************
614  };
615  //**********************************************************************************************
616 
617  //**Compilation flags***************************************************************************
619  enum : bool { simdEnabled = MT::simdEnabled };
620 
622  enum : bool { smpAssignable = MT::smpAssignable };
623  //**********************************************************************************************
624 
625  //**Constructors********************************************************************************
628  explicit inline DiagonalMatrix();
629  template< typename A1 > explicit inline DiagonalMatrix( const A1& a1 );
630  explicit inline DiagonalMatrix( size_t n, const ElementType& init );
631 
632  explicit inline DiagonalMatrix( initializer_list< initializer_list<ElementType> > list );
633 
634  template< typename Other >
635  explicit inline DiagonalMatrix( size_t n, const Other* array );
636 
637  template< typename Other, size_t N >
638  explicit inline DiagonalMatrix( const Other (&array)[N][N] );
639 
640  explicit inline DiagonalMatrix( ElementType* ptr, size_t n );
641  explicit inline DiagonalMatrix( ElementType* ptr, size_t n, size_t nn );
642 
643  template< typename Deleter >
644  explicit inline DiagonalMatrix( ElementType* ptr, size_t n, Deleter d );
645 
646  template< typename Deleter >
647  explicit inline DiagonalMatrix( ElementType* ptr, size_t n, size_t nn, Deleter d );
648 
649  inline DiagonalMatrix( const DiagonalMatrix& m );
650  inline DiagonalMatrix( DiagonalMatrix&& m ) noexcept;
652  //**********************************************************************************************
653 
654  //**Destructor**********************************************************************************
655  // No explicitly declared destructor.
656  //**********************************************************************************************
657 
658  //**Data access functions***********************************************************************
661  inline Reference operator()( size_t i, size_t j );
662  inline ConstReference operator()( size_t i, size_t j ) const;
663  inline Reference at( size_t i, size_t j );
664  inline ConstReference at( size_t i, size_t j ) const;
665  inline ConstPointer data () const noexcept;
666  inline ConstPointer data ( size_t i ) const noexcept;
667  inline Iterator begin ( size_t i );
668  inline ConstIterator begin ( size_t i ) const;
669  inline ConstIterator cbegin( size_t i ) const;
670  inline Iterator end ( size_t i );
671  inline ConstIterator end ( size_t i ) const;
672  inline ConstIterator cend ( size_t i ) const;
674  //**********************************************************************************************
675 
676  //**Assignment operators************************************************************************
679  inline DiagonalMatrix& operator=( const ElementType& rhs );
680  inline DiagonalMatrix& operator=( initializer_list< initializer_list<ElementType> > list );
681 
682  template< typename Other, size_t N >
683  inline DiagonalMatrix& operator=( const Other (&array)[N][N] );
684 
685  inline DiagonalMatrix& operator=( const DiagonalMatrix& rhs );
686  inline DiagonalMatrix& operator=( DiagonalMatrix&& rhs ) noexcept;
687 
688  template< typename MT2, bool SO2 >
689  inline DisableIf_< IsComputation<MT2>, DiagonalMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
690 
691  template< typename MT2, bool SO2 >
692  inline EnableIf_< IsComputation<MT2>, DiagonalMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
693 
694  template< typename MT2, bool SO2 >
695  inline DisableIf_< IsComputation<MT2>, DiagonalMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
696 
697  template< typename MT2, bool SO2 >
698  inline EnableIf_< IsComputation<MT2>, DiagonalMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
699 
700  template< typename MT2, bool SO2 >
701  inline DisableIf_< IsComputation<MT2>, DiagonalMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
702 
703  template< typename MT2, bool SO2 >
704  inline EnableIf_< IsComputation<MT2>, DiagonalMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
705 
706  template< typename MT2, bool SO2 >
707  inline DiagonalMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
708 
709  template< typename Other >
710  inline EnableIf_< IsNumeric<Other>, DiagonalMatrix >& operator*=( Other rhs );
711 
712  template< typename Other >
713  inline EnableIf_< IsNumeric<Other>, DiagonalMatrix >& operator/=( Other rhs );
715  //**********************************************************************************************
716 
717  //**Utility functions***************************************************************************
720  inline size_t rows() const noexcept;
721  inline size_t columns() const noexcept;
722  inline size_t spacing() const noexcept;
723  inline size_t capacity() const noexcept;
724  inline size_t capacity( size_t i ) const noexcept;
725  inline size_t nonZeros() const;
726  inline size_t nonZeros( size_t i ) const;
727  inline void reset();
728  inline void reset( size_t i );
729  inline void clear();
730  void resize ( size_t n, bool preserve=true );
731  inline void extend ( size_t n, bool preserve=true );
732  inline void reserve( size_t elements );
733  template< typename Other > inline DiagonalMatrix& scale( const Other& scalar );
734  inline void swap( DiagonalMatrix& m ) noexcept;
736  //**********************************************************************************************
737 
738  //**Debugging functions*************************************************************************
741  inline bool isIntact() const noexcept;
743  //**********************************************************************************************
744 
745  //**Expression template evaluation functions****************************************************
748  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
749  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
750 
751  inline bool isAligned () const noexcept;
752  inline bool canSMPAssign() const noexcept;
753 
754  BLAZE_ALWAYS_INLINE SIMDType load ( size_t i, size_t j ) const noexcept;
755  BLAZE_ALWAYS_INLINE SIMDType loada( size_t i, size_t j ) const noexcept;
756  BLAZE_ALWAYS_INLINE SIMDType loadu( size_t i, size_t j ) const noexcept;
758  //**********************************************************************************************
759 
760  private:
761  //**Construction functions**********************************************************************
764  inline const MT construct( size_t n , TrueType );
765  inline const MT construct( const ElementType& value, FalseType );
766 
767  template< typename MT2, bool SO2, typename T >
768  inline const MT construct( const Matrix<MT2,SO2>& m, T );
770  //**********************************************************************************************
771 
772  //**Member variables****************************************************************************
775  MT matrix_;
776 
777  //**********************************************************************************************
778 
779  //**Friend declarations*************************************************************************
780  template< typename MT2, bool SO2, bool DF2 >
781  friend bool isDefault( const DiagonalMatrix<MT2,SO2,DF2>& m );
782 
783  template< typename MT2, bool SO2, bool DF2 >
784  friend MT2& derestrict( DiagonalMatrix<MT2,SO2,DF2>& m );
785  //**********************************************************************************************
786 
787  //**Compile time checks*************************************************************************
800  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
801  //**********************************************************************************************
802 };
804 //*************************************************************************************************
805 
806 
807 
808 
809 //=================================================================================================
810 //
811 // CONSTRUCTORS
812 //
813 //=================================================================================================
814 
815 //*************************************************************************************************
819 template< typename MT // Type of the adapted dense matrix
820  , bool SO > // Storage order of the adapted dense matrix
821 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix()
822  : matrix_() // The adapted dense matrix
823 {
824  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
825  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
826 }
828 //*************************************************************************************************
829 
830 
831 //*************************************************************************************************
849 template< typename MT // Type of the adapted dense matrix
850  , bool SO > // Storage order of the adapted dense matrix
851 template< typename A1 > // Type of the constructor argument
852 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( const A1& a1 )
853  : matrix_( construct( a1, typename IsResizable<MT>::Type() ) ) // The adapted dense matrix
854 {
855  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
856  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
857 }
859 //*************************************************************************************************
860 
861 
862 //*************************************************************************************************
869 template< typename MT // Type of the adapted dense matrix
870  , bool SO > // Storage order of the adapted dense matrix
871 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( size_t n, const ElementType& init )
872  : matrix_( n, n, ElementType() ) // The adapted dense matrix
873 {
875 
876  for( size_t i=0UL; i<n; ++i )
877  matrix_(i,i) = init;
878 
879  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
880  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
881 }
883 //*************************************************************************************************
884 
885 
886 //*************************************************************************************************
909 template< typename MT // Type of the adapted dense matrix
910  , bool SO > // Storage order of the adapted dense matrix
911 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( initializer_list< initializer_list<ElementType> > list )
912  : matrix_( list ) // The adapted dense matrix
913 {
914  if( !isDiagonal( matrix_ ) ) {
915  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
916  }
917 
918  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
919 }
921 //*************************************************************************************************
922 
923 
924 //*************************************************************************************************
950 template< typename MT // Type of the adapted dense matrix
951  , bool SO > // Storage order of the adapted dense matrix
952 template< typename Other > // Data type of the initialization array
953 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( size_t n, const Other* array )
954  : matrix_( n, n, array ) // The adapted dense matrix
955 {
956  if( !isDiagonal( matrix_ ) ) {
957  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
958  }
959 
960  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
961 }
963 //*************************************************************************************************
964 
965 
966 //*************************************************************************************************
989 template< typename MT // Type of the adapted dense matrix
990  , bool SO > // Storage order of the adapted dense matrix
991 template< typename Other // Data type of the initialization array
992  , size_t N > // Number of rows and columns of the initialization array
993 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( const Other (&array)[N][N] )
994  : matrix_( array ) // The adapted dense matrix
995 {
996  if( !isDiagonal( matrix_ ) ) {
997  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
998  }
999 
1000  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1001 }
1003 //*************************************************************************************************
1004 
1005 
1006 //*************************************************************************************************
1027 template< typename MT // Type of the adapted dense matrix
1028  , bool SO > // Storage order of the adapted dense matrix
1029 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( ElementType* ptr, size_t n )
1030  : matrix_( ptr, n, n ) // The adapted dense matrix
1031 {
1032  if( !isDiagonal( matrix_ ) ) {
1033  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
1034  }
1035 
1036  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1037 }
1039 //*************************************************************************************************
1040 
1041 
1042 //*************************************************************************************************
1065 template< typename MT // Type of the adapted dense matrix
1066  , bool SO > // Storage order of the adapted dense matrix
1067 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( ElementType* ptr, size_t n, size_t nn )
1068  : matrix_( ptr, n, n, nn ) // The adapted dense matrix
1069 {
1070  if( !isDiagonal( matrix_ ) ) {
1071  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
1072  }
1073 
1074  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1075 }
1077 //*************************************************************************************************
1078 
1079 
1080 //*************************************************************************************************
1101 template< typename MT // Type of the adapted dense matrix
1102  , bool SO > // Storage order of the adapted dense matrix
1103 template< typename Deleter > // Type of the custom deleter
1104 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( ElementType* ptr, size_t n, Deleter d )
1105  : matrix_( ptr, n, n, d ) // The adapted dense matrix
1106 {
1107  if( !isDiagonal( matrix_ ) ) {
1108  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
1109  }
1110 
1111  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1112 }
1114 //*************************************************************************************************
1115 
1116 
1117 //*************************************************************************************************
1139 template< typename MT // Type of the adapted dense matrix
1140  , bool SO > // Storage order of the adapted dense matrix
1141 template< typename Deleter > // Type of the custom deleter
1142 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( ElementType* ptr, size_t n, size_t nn, Deleter d )
1143  : matrix_( ptr, n, n, nn, d ) // The adapted dense matrix
1144 {
1145  if( !isDiagonal( matrix_ ) ) {
1146  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
1147  }
1148 
1149  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1150 }
1152 //*************************************************************************************************
1153 
1154 
1155 //*************************************************************************************************
1161 template< typename MT // Type of the adapted dense matrix
1162  , bool SO > // Storage order of the adapted dense matrix
1163 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( const DiagonalMatrix& m )
1164  : matrix_( m.matrix_ ) // The adapted dense matrix
1165 {
1166  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1167  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1168 }
1170 //*************************************************************************************************
1171 
1172 
1173 //*************************************************************************************************
1179 template< typename MT // Type of the adapted dense matrix
1180  , bool SO > // Storage order of the adapted dense matrix
1181 inline DiagonalMatrix<MT,SO,true>::DiagonalMatrix( DiagonalMatrix&& m ) noexcept
1182  : matrix_( std::move( m.matrix_ ) ) // The adapted dense matrix
1183 {
1184  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1185  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1186 }
1188 //*************************************************************************************************
1189 
1190 
1191 
1192 
1193 //=================================================================================================
1194 //
1195 // DATA ACCESS FUNCTIONS
1196 //
1197 //=================================================================================================
1198 
1199 //*************************************************************************************************
1215 template< typename MT // Type of the adapted dense matrix
1216  , bool SO > // Storage order of the adapted dense matrix
1218  DiagonalMatrix<MT,SO,true>::operator()( size_t i, size_t j )
1219 {
1220  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1221  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1222 
1223  return Reference( matrix_, i, j );
1224 }
1226 //*************************************************************************************************
1227 
1228 
1229 //*************************************************************************************************
1245 template< typename MT // Type of the adapted dense matrix
1246  , bool SO > // Storage order of the adapted dense matrix
1248  DiagonalMatrix<MT,SO,true>::operator()( size_t i, size_t j ) const
1249 {
1250  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1251  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1252 
1253  return matrix_(i,j);
1254 }
1256 //*************************************************************************************************
1257 
1258 
1259 //*************************************************************************************************
1276 template< typename MT // Type of the adapted dense matrix
1277  , bool SO > // Storage order of the adapted dense matrix
1279  DiagonalMatrix<MT,SO,true>::at( size_t i, size_t j )
1280 {
1281  if( i >= rows() ) {
1282  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1283  }
1284  if( j >= columns() ) {
1285  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1286  }
1287  return (*this)(i,j);
1288 }
1290 //*************************************************************************************************
1291 
1292 
1293 //*************************************************************************************************
1310 template< typename MT // Type of the adapted dense matrix
1311  , bool SO > // Storage order of the adapted dense matrix
1313  DiagonalMatrix<MT,SO,true>::at( size_t i, size_t j ) const
1314 {
1315  if( i >= rows() ) {
1316  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1317  }
1318  if( j >= columns() ) {
1319  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1320  }
1321  return (*this)(i,j);
1322 }
1324 //*************************************************************************************************
1325 
1326 
1327 //*************************************************************************************************
1340 template< typename MT // Type of the adapted dense matrix
1341  , bool SO > // Storage order of the adapted dense matrix
1342 inline typename DiagonalMatrix<MT,SO,true>::ConstPointer
1343  DiagonalMatrix<MT,SO,true>::data() const noexcept
1344 {
1345  return matrix_.data();
1346 }
1348 //*************************************************************************************************
1349 
1350 
1351 //*************************************************************************************************
1360 template< typename MT // Type of the adapted dense matrix
1361  , bool SO > // Storage order of the adapted dense matrix
1362 inline typename DiagonalMatrix<MT,SO,true>::ConstPointer
1363  DiagonalMatrix<MT,SO,true>::data( size_t i ) const noexcept
1364 {
1365  return matrix_.data(i);
1366 }
1368 //*************************************************************************************************
1369 
1370 
1371 //*************************************************************************************************
1383 template< typename MT // Type of the adapted dense matrix
1384  , bool SO > // Storage order of the adapted dense matrix
1387 {
1388  if( SO )
1389  return Iterator( matrix_, 0UL, i );
1390  else
1391  return Iterator( matrix_, i, 0UL );
1392 }
1394 //*************************************************************************************************
1395 
1396 
1397 //*************************************************************************************************
1409 template< typename MT // Type of the adapted dense matrix
1410  , bool SO > // Storage order of the adapted dense matrix
1412  DiagonalMatrix<MT,SO,true>::begin( size_t i ) const
1413 {
1414  return matrix_.begin(i);
1415 }
1417 //*************************************************************************************************
1418 
1419 
1420 //*************************************************************************************************
1432 template< typename MT // Type of the adapted dense matrix
1433  , bool SO > // Storage order of the adapted dense matrix
1435  DiagonalMatrix<MT,SO,true>::cbegin( size_t i ) const
1436 {
1437  return matrix_.cbegin(i);
1438 }
1440 //*************************************************************************************************
1441 
1442 
1443 //*************************************************************************************************
1455 template< typename MT // Type of the adapted dense matrix
1456  , bool SO > // Storage order of the adapted dense matrix
1459 {
1460  if( SO )
1461  return Iterator( matrix_, rows(), i );
1462  else
1463  return Iterator( matrix_, i, columns() );
1464 }
1466 //*************************************************************************************************
1467 
1468 
1469 //*************************************************************************************************
1481 template< typename MT // Type of the adapted dense matrix
1482  , bool SO > // Storage order of the adapted dense matrix
1484  DiagonalMatrix<MT,SO,true>::end( size_t i ) const
1485 {
1486  return matrix_.end(i);
1487 }
1489 //*************************************************************************************************
1490 
1491 
1492 //*************************************************************************************************
1504 template< typename MT // Type of the adapted dense matrix
1505  , bool SO > // Storage order of the adapted dense matrix
1507  DiagonalMatrix<MT,SO,true>::cend( size_t i ) const
1508 {
1509  return matrix_.cend(i);
1510 }
1512 //*************************************************************************************************
1513 
1514 
1515 
1516 
1517 //=================================================================================================
1518 //
1519 // ASSIGNMENT OPERATORS
1520 //
1521 //=================================================================================================
1522 
1523 //*************************************************************************************************
1530 template< typename MT // Type of the adapted dense matrix
1531  , bool SO > // Storage order of the adapted dense matrix
1532 inline DiagonalMatrix<MT,SO,true>&
1533  DiagonalMatrix<MT,SO,true>::operator=( const ElementType& rhs )
1534 {
1535  if( SO ) {
1536  for( size_t j=0UL; j<columns(); ++j )
1537  matrix_(j,j) = rhs;
1538  }
1539  else {
1540  for( size_t i=0UL; i<rows(); ++i )
1541  matrix_(i,i) = rhs;
1542  }
1543 
1544  return *this;
1545 }
1547 //*************************************************************************************************
1548 
1549 
1550 //*************************************************************************************************
1574 template< typename MT // Type of the adapted dense matrix
1575  , bool SO > // Storage order of the adapted dense matrix
1576 inline DiagonalMatrix<MT,SO,true>&
1577  DiagonalMatrix<MT,SO,true>::operator=( initializer_list< initializer_list<ElementType> > list )
1578 {
1579  MT tmp( list );
1580 
1581  if( !isDiagonal( tmp ) ) {
1582  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1583  }
1584 
1585  matrix_ = std::move( tmp );
1586 
1587  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1588  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1589 
1590  return *this;
1591 }
1593 //*************************************************************************************************
1594 
1595 
1596 //*************************************************************************************************
1620 template< typename MT // Type of the adapted dense matrix
1621  , bool SO > // Storage order of the adapted dense matrix
1622 template< typename Other // Data type of the initialization array
1623  , size_t N > // Number of rows and columns of the initialization array
1624 inline DiagonalMatrix<MT,SO,true>&
1625  DiagonalMatrix<MT,SO,true>::operator=( const Other (&array)[N][N] )
1626 {
1627  MT tmp( array );
1628 
1629  if( !isDiagonal( tmp ) ) {
1630  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1631  }
1632 
1633  matrix_ = std::move( tmp );
1634 
1635  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1636  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1637 
1638  return *this;
1639 }
1641 //*************************************************************************************************
1642 
1643 
1644 //*************************************************************************************************
1654 template< typename MT // Type of the adapted dense matrix
1655  , bool SO > // Storage order of the adapted dense matrix
1656 inline DiagonalMatrix<MT,SO,true>&
1657  DiagonalMatrix<MT,SO,true>::operator=( const DiagonalMatrix& rhs )
1658 {
1659  matrix_ = rhs.matrix_;
1660 
1661  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1662  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1663 
1664  return *this;
1665 }
1667 //*************************************************************************************************
1668 
1669 
1670 //*************************************************************************************************
1677 template< typename MT // Type of the adapted dense matrix
1678  , bool SO > // Storage order of the adapted dense matrix
1679 inline DiagonalMatrix<MT,SO,true>&
1680  DiagonalMatrix<MT,SO,true>::operator=( DiagonalMatrix&& rhs ) noexcept
1681 {
1682  matrix_ = std::move( rhs.matrix_ );
1683 
1684  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1685  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1686 
1687  return *this;
1688 }
1690 //*************************************************************************************************
1691 
1692 
1693 //*************************************************************************************************
1706 template< typename MT // Type of the adapted dense matrix
1707  , bool SO > // Storage order of the adapted dense matrix
1708 template< typename MT2 // Type of the right-hand side matrix
1709  , bool SO2 > // Storage order of the right-hand side matrix
1710 inline DisableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >
1711  DiagonalMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1712 {
1713  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
1714  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1715  }
1716 
1717  matrix_ = ~rhs;
1718 
1719  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1720  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1721 
1722  return *this;
1723 }
1725 //*************************************************************************************************
1726 
1727 
1728 //*************************************************************************************************
1741 template< typename MT // Type of the adapted dense matrix
1742  , bool SO > // Storage order of the adapted dense matrix
1743 template< typename MT2 // Type of the right-hand side matrix
1744  , bool SO2 > // Storage order of the right-hand side matrix
1745 inline EnableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >
1746  DiagonalMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1747 {
1748  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1749  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1750  }
1751 
1752  if( IsDiagonal<MT2>::value ) {
1753  matrix_ = ~rhs;
1754  }
1755  else {
1756  MT tmp( ~rhs );
1757 
1758  if( !isDiagonal( tmp ) ) {
1759  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1760  }
1761 
1762  matrix_ = std::move( tmp );
1763  }
1764 
1765  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1766  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1767 
1768  return *this;
1769 }
1771 //*************************************************************************************************
1772 
1773 
1774 //*************************************************************************************************
1787 template< typename MT // Type of the adapted dense matrix
1788  , bool SO > // Storage order of the adapted dense matrix
1789 template< typename MT2 // Type of the right-hand side matrix
1790  , bool SO2 > // Storage order of the right-hand side matrix
1791 inline DisableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >
1792  DiagonalMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1793 {
1794  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
1795  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1796  }
1797 
1798  matrix_ += ~rhs;
1799 
1800  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1801  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1802 
1803  return *this;
1804 }
1806 //*************************************************************************************************
1807 
1808 
1809 //*************************************************************************************************
1822 template< typename MT // Type of the adapted dense matrix
1823  , bool SO > // Storage order of the adapted dense matrix
1824 template< typename MT2 // Type of the right-hand side matrix
1825  , bool SO2 > // Storage order of the right-hand side matrix
1826 inline EnableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >
1827  DiagonalMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1828 {
1829  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1830  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1831  }
1832 
1833  if( IsDiagonal<MT2>::value ) {
1834  matrix_ += ~rhs;
1835  }
1836  else {
1837  const ResultType_<MT2> tmp( ~rhs );
1838 
1839  if( !isDiagonal( tmp ) ) {
1840  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1841  }
1842 
1843  matrix_ += tmp;
1844  }
1845 
1846  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1847  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1848 
1849  return *this;
1850 }
1852 //*************************************************************************************************
1853 
1854 
1855 //*************************************************************************************************
1868 template< typename MT // Type of the adapted dense matrix
1869  , bool SO > // Storage order of the adapted dense matrix
1870 template< typename MT2 // Type of the right-hand side matrix
1871  , bool SO2 > // Storage order of the right-hand side matrix
1872 inline DisableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >
1873  DiagonalMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1874 {
1875  if( !IsDiagonal<MT2>::value && !isDiagonal( ~rhs ) ) {
1876  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1877  }
1878 
1879  matrix_ -= ~rhs;
1880 
1881  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1882  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1883 
1884  return *this;
1885 }
1887 //*************************************************************************************************
1888 
1889 
1890 //*************************************************************************************************
1903 template< typename MT // Type of the adapted dense matrix
1904  , bool SO > // Storage order of the adapted dense matrix
1905 template< typename MT2 // Type of the right-hand side matrix
1906  , bool SO2 > // Storage order of the right-hand side matrix
1907 inline EnableIf_< IsComputation<MT2>, DiagonalMatrix<MT,SO,true>& >
1908  DiagonalMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1909 {
1910  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1911  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1912  }
1913 
1914  if( IsDiagonal<MT2>::value ) {
1915  matrix_ -= ~rhs;
1916  }
1917  else {
1918  const ResultType_<MT2> tmp( ~rhs );
1919 
1920  if( !isDiagonal( tmp ) ) {
1921  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1922  }
1923 
1924  matrix_ -= tmp;
1925  }
1926 
1927  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1928  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1929 
1930  return *this;
1931 }
1933 //*************************************************************************************************
1934 
1935 
1936 //*************************************************************************************************
1948 template< typename MT // Type of the adapted dense matrix
1949  , bool SO > // Storage order of the adapted dense matrix
1950 template< typename MT2 // Type of the right-hand side matrix
1951  , bool SO2 > // Storage order of the right-hand side matrix
1952 inline DiagonalMatrix<MT,SO,true>&
1953  DiagonalMatrix<MT,SO,true>::operator*=( const Matrix<MT2,SO2>& rhs )
1954 {
1955  if( matrix_.rows() != (~rhs).columns() ) {
1956  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1957  }
1958 
1959  MT tmp( matrix_ * ~rhs );
1960 
1961  if( !isDiagonal( tmp ) ) {
1962  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1963  }
1964 
1965  matrix_ = std::move( tmp );
1966 
1967  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1968  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1969 
1970  return *this;
1971 }
1973 //*************************************************************************************************
1974 
1975 
1976 //*************************************************************************************************
1984 template< typename MT // Type of the adapted dense matrix
1985  , bool SO > // Storage order of the adapted dense matrix
1986 template< typename Other > // Data type of the right-hand side scalar
1987 inline EnableIf_< IsNumeric<Other>, DiagonalMatrix<MT,SO,true> >&
1989 {
1990  matrix_ *= rhs;
1991  return *this;
1992 }
1993 //*************************************************************************************************
1994 
1995 
1996 //*************************************************************************************************
2004 template< typename MT // Type of the adapted dense matrix
2005  , bool SO > // Storage order of the adapted dense matrix
2006 template< typename Other > // Data type of the right-hand side scalar
2007 inline EnableIf_< IsNumeric<Other>, DiagonalMatrix<MT,SO,true> >&
2009 {
2010  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
2011 
2012  matrix_ /= rhs;
2013  return *this;
2014 }
2016 //*************************************************************************************************
2017 
2018 
2019 
2020 
2021 //=================================================================================================
2022 //
2023 // UTILITY FUNCTIONS
2024 //
2025 //=================================================================================================
2026 
2027 //*************************************************************************************************
2033 template< typename MT // Type of the adapted dense matrix
2034  , bool SO > // Storage order of the adapted dense matrix
2035 inline size_t DiagonalMatrix<MT,SO,true>::rows() const noexcept
2036 {
2037  return matrix_.rows();
2038 }
2040 //*************************************************************************************************
2041 
2042 
2043 //*************************************************************************************************
2049 template< typename MT // Type of the adapted dense matrix
2050  , bool SO > // Storage order of the adapted dense matrix
2051 inline size_t DiagonalMatrix<MT,SO,true>::columns() const noexcept
2052 {
2053  return matrix_.columns();
2054 }
2056 //*************************************************************************************************
2057 
2058 
2059 //*************************************************************************************************
2070 template< typename MT // Type of the adapted dense matrix
2071  , bool SO > // Storage order of the adapted dense matrix
2072 inline size_t DiagonalMatrix<MT,SO,true>::spacing() const noexcept
2073 {
2074  return matrix_.spacing();
2075 }
2077 //*************************************************************************************************
2078 
2079 
2080 //*************************************************************************************************
2086 template< typename MT // Type of the adapted dense matrix
2087  , bool SO > // Storage order of the adapted dense matrix
2088 inline size_t DiagonalMatrix<MT,SO,true>::capacity() const noexcept
2089 {
2090  return matrix_.capacity();
2091 }
2093 //*************************************************************************************************
2094 
2095 
2096 //*************************************************************************************************
2108 template< typename MT // Type of the adapted dense matrix
2109  , bool SO > // Storage order of the adapted dense matrix
2110 inline size_t DiagonalMatrix<MT,SO,true>::capacity( size_t i ) const noexcept
2111 {
2112  return matrix_.capacity(i);
2113 }
2115 //*************************************************************************************************
2116 
2117 
2118 //*************************************************************************************************
2124 template< typename MT // Type of the adapted dense matrix
2125  , bool SO > // Storage order of the adapted dense matrix
2126 inline size_t DiagonalMatrix<MT,SO,true>::nonZeros() const
2127 {
2128  return matrix_.nonZeros();
2129 }
2131 //*************************************************************************************************
2132 
2133 
2134 //*************************************************************************************************
2146 template< typename MT // Type of the adapted dense matrix
2147  , bool SO > // Storage order of the adapted dense matrix
2148 inline size_t DiagonalMatrix<MT,SO,true>::nonZeros( size_t i ) const
2149 {
2150  return matrix_.nonZeros(i);
2151 }
2153 //*************************************************************************************************
2154 
2155 
2156 //*************************************************************************************************
2162 template< typename MT // Type of the adapted dense matrix
2163  , bool SO > // Storage order of the adapted dense matrix
2165 {
2166  matrix_.reset();
2167 }
2169 //*************************************************************************************************
2170 
2171 
2172 //*************************************************************************************************
2185 template< typename MT // Type of the adapted dense matrix
2186  , bool SO > // Storage order of the adapted dense matrix
2187 inline void DiagonalMatrix<MT,SO,true>::reset( size_t i )
2188 {
2189  matrix_.reset( i );
2190 }
2192 //*************************************************************************************************
2193 
2194 
2195 //*************************************************************************************************
2207 template< typename MT // Type of the adapted dense matrix
2208  , bool SO > // Storage order of the adapted dense matrix
2210 {
2211  using blaze::clear;
2212 
2213  clear( matrix_ );
2214 }
2216 //*************************************************************************************************
2217 
2218 
2219 //*************************************************************************************************
2255 template< typename MT // Type of the adapted dense matrix
2256  , bool SO > // Storage order of the adapted dense matrix
2257 void DiagonalMatrix<MT,SO,true>::resize( size_t n, bool preserve )
2258 {
2260 
2261  UNUSED_PARAMETER( preserve );
2262 
2263  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
2264 
2265  const size_t oldsize( matrix_.rows() );
2266 
2267  matrix_.resize( n, n, true );
2268 
2269  if( n > oldsize ) {
2270  const size_t increment( n - oldsize );
2271  submatrix( matrix_, 0UL, oldsize, n, increment ).reset();
2272  submatrix( matrix_, oldsize, 0UL, increment, increment ).reset();
2273  }
2274 }
2276 //*************************************************************************************************
2277 
2278 
2279 //*************************************************************************************************
2292 template< typename MT // Type of the adapted dense matrix
2293  , bool SO > // Storage order of the adapted dense matrix
2294 inline void DiagonalMatrix<MT,SO,true>::extend( size_t n, bool preserve )
2295 {
2297 
2298  UNUSED_PARAMETER( preserve );
2299 
2300  resize( rows() + n, true );
2301 }
2302 //*************************************************************************************************
2303 
2304 
2305 //*************************************************************************************************
2315 template< typename MT // Type of the adapted dense matrix
2316  , bool SO > // Storage order of the adapted dense matrix
2317 inline void DiagonalMatrix<MT,SO,true>::reserve( size_t elements )
2318 {
2319  matrix_.reserve( elements );
2320 }
2322 //*************************************************************************************************
2323 
2324 
2325 //*************************************************************************************************
2332 template< typename MT // Type of the adapted dense matrix
2333  , bool SO > // Storage order of the adapted dense matrix
2334 template< typename Other > // Data type of the scalar value
2335 inline DiagonalMatrix<MT,SO,true>& DiagonalMatrix<MT,SO,true>::scale( const Other& scalar )
2336 {
2337  matrix_.scale( scalar );
2338  return *this;
2339 }
2341 //*************************************************************************************************
2342 
2343 
2344 //*************************************************************************************************
2351 template< typename MT // Type of the adapted dense matrix
2352  , bool SO > // Storage order of the adapted dense matrix
2353 inline void DiagonalMatrix<MT,SO,true>::swap( DiagonalMatrix& m ) noexcept
2354 {
2355  using std::swap;
2356 
2357  swap( matrix_, m.matrix_ );
2358 }
2360 //*************************************************************************************************
2361 
2362 
2363 
2364 
2365 //=================================================================================================
2366 //
2367 // DEBUGGING FUNCTIONS
2368 //
2369 //=================================================================================================
2370 
2371 //*************************************************************************************************
2381 template< typename MT // Type of the adapted dense matrix
2382  , bool SO > // Storage order of the adapted dense matrix
2383 inline bool DiagonalMatrix<MT,SO,true>::isIntact() const noexcept
2384 {
2385  using blaze::isIntact;
2386 
2387  return ( isIntact( matrix_ ) && isDiagonal( matrix_ ) );
2388 }
2390 //*************************************************************************************************
2391 
2392 
2393 
2394 
2395 //=================================================================================================
2396 //
2397 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2398 //
2399 //=================================================================================================
2400 
2401 //*************************************************************************************************
2412 template< typename MT // Type of the adapted dense matrix
2413  , bool SO > // Storage order of the adapted dense matrix
2414 template< typename Other > // Data type of the foreign expression
2415 inline bool DiagonalMatrix<MT,SO,true>::canAlias( const Other* alias ) const noexcept
2416 {
2417  return matrix_.canAlias( alias );
2418 }
2420 //*************************************************************************************************
2421 
2422 
2423 //*************************************************************************************************
2434 template< typename MT // Type of the adapted dense matrix
2435  , bool SO > // Storage order of the adapted dense matrix
2436 template< typename Other > // Data type of the foreign expression
2437 inline bool DiagonalMatrix<MT,SO,true>::isAliased( const Other* alias ) const noexcept
2438 {
2439  return matrix_.isAliased( alias );
2440 }
2442 //*************************************************************************************************
2443 
2444 
2445 //*************************************************************************************************
2455 template< typename MT // Type of the adapted dense matrix
2456  , bool SO > // Storage order of the adapted dense matrix
2457 inline bool DiagonalMatrix<MT,SO,true>::isAligned() const noexcept
2458 {
2459  return matrix_.isAligned();
2460 }
2462 //*************************************************************************************************
2463 
2464 
2465 //*************************************************************************************************
2476 template< typename MT // Type of the adapted dense matrix
2477  , bool SO > // Storage order of the adapted dense matrix
2478 inline bool DiagonalMatrix<MT,SO,true>::canSMPAssign() const noexcept
2479 {
2480  return matrix_.canSMPAssign();
2481 }
2483 //*************************************************************************************************
2484 
2485 
2486 //*************************************************************************************************
2502 template< typename MT // Type of the adapted dense matrix
2503  , bool SO > // Storage order of the adapted dense matrix
2504 BLAZE_ALWAYS_INLINE typename DiagonalMatrix<MT,SO,true>::SIMDType
2505  DiagonalMatrix<MT,SO,true>::load( size_t i, size_t j ) const noexcept
2506 {
2507  return matrix_.load( i, j );
2508 }
2510 //*************************************************************************************************
2511 
2512 
2513 //*************************************************************************************************
2529 template< typename MT // Type of the adapted dense matrix
2530  , bool SO > // Storage order of the adapted dense matrix
2531 BLAZE_ALWAYS_INLINE typename DiagonalMatrix<MT,SO,true>::SIMDType
2532  DiagonalMatrix<MT,SO,true>::loada( size_t i, size_t j ) const noexcept
2533 {
2534  return matrix_.loada( i, j );
2535 }
2537 //*************************************************************************************************
2538 
2539 
2540 //*************************************************************************************************
2556 template< typename MT // Type of the adapted dense matrix
2557  , bool SO > // Storage order of the adapted dense matrix
2558 BLAZE_ALWAYS_INLINE typename DiagonalMatrix<MT,SO,true>::SIMDType
2559  DiagonalMatrix<MT,SO,true>::loadu( size_t i, size_t j ) const noexcept
2560 {
2561  return matrix_.loadu( i, j );
2562 }
2564 //*************************************************************************************************
2565 
2566 
2567 
2568 
2569 //=================================================================================================
2570 //
2571 // CONSTRUCTION FUNCTIONS
2572 //
2573 //=================================================================================================
2574 
2575 //*************************************************************************************************
2582 template< typename MT // Type of the adapted dense matrix
2583  , bool SO > // Storage order of the adapted dense matrix
2584 inline const MT DiagonalMatrix<MT,SO,true>::construct( size_t n, TrueType )
2585 {
2587 
2588  return MT( n, n, ElementType() );
2589 }
2591 //*************************************************************************************************
2592 
2593 
2594 //*************************************************************************************************
2601 template< typename MT // Type of the adapted dense matrix
2602  , bool SO > // Storage order of the adapted dense matrix
2603 inline const MT DiagonalMatrix<MT,SO,true>::construct( const ElementType& init, FalseType )
2604 {
2607 
2608  MT tmp;
2609 
2610  for( size_t i=0UL; i<tmp.rows(); ++i )
2611  tmp(i,i) = init;
2612 
2613  return tmp;
2614 }
2616 //*************************************************************************************************
2617 
2618 
2619 //*************************************************************************************************
2630 template< typename MT // Type of the adapted dense matrix
2631  , bool SO > // Storage order of the adapted dense matrix
2632 template< typename MT2 // Type of the foreign matrix
2633  , bool SO2 // Storage order of the foreign matrix
2634  , typename T > // Type of the third argument
2635 inline const MT DiagonalMatrix<MT,SO,true>::construct( const Matrix<MT2,SO2>& m, T )
2636 {
2637  const MT tmp( ~m );
2638 
2639  if( !IsDiagonal<MT2>::value && !isDiagonal( tmp ) ) {
2640  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
2641  }
2642 
2643  return tmp;
2644 }
2646 //*************************************************************************************************
2647 
2648 } // namespace blaze
2649 
2650 #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
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.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
bool isDiagonal(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is diagonal.
Definition: DenseMatrix.h:1499
Header file for the Rows type trait.
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:7800
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:346
Header file for basic type definitions.
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
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.
#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
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
Constraint on the data type.
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:188
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:699
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2643
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5077
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:2636
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:79
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:384
#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:60
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:731
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
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Constraint on the data type.
STL namespace.
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
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2639
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:126
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:298
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:232
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
Constraint on the data type.
constexpr bool spacing
Adding an additional spacing line between two log messages.This setting gives the opportunity to add ...
Definition: Logging.h:70
Header file for the std::initializer_list aliases.
Header file for the IsSquare type trait.
Constraint on the data type.
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the DiagonalProxy class.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#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:5148
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5131
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the DenseMatrix base class.
Header file for the Columns type trait.
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:330
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
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2640
Constraints on the storage order of matrix types.
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:81
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:538
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:254
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2641
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
Header file for the EnableIf class template.
Header file for utility functions for dense matrices.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the IsNumeric type trait.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:126
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2642
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:258
Constraint on the data type.
Constraint on the data type.
#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:81
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:314
Header file for the implementation of the base template of the DiagonalMatrix.
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2637
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:61
Header file for the IsComputation type trait class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
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:2638
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
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
SubmatrixExprTrait_< MT, unaligned > 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:167
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:609
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.