DenseNonNumeric.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONNUMERIC_H_
36 #define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONNUMERIC_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <utility>
46 #include <blaze/math/Aliases.h>
56 #include <blaze/math/Exception.h>
59 #include <blaze/math/shims/Clear.h>
73 #include <blaze/util/Assert.h>
79 #include <blaze/util/DisableIf.h>
80 #include <blaze/util/EnableIf.h>
81 #include <blaze/util/mpl/If.h>
83 #include <blaze/util/Types.h>
86 #include <blaze/util/Unused.h>
87 
88 
89 namespace blaze {
90 
91 //=================================================================================================
92 //
93 // CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES WITH NON-NUMERIC ELEMENT TYPE
94 //
95 //=================================================================================================
96 
97 //*************************************************************************************************
105 template< typename MT // Type of the adapted dense matrix
106  , bool SO > // Storage order of the adapted dense matrix
107 class SymmetricMatrix<MT,SO,true,false>
108  : public DenseMatrix< SymmetricMatrix<MT,SO,true,false>, SO >
109 {
110  private:
111  //**Type definitions****************************************************************************
112  using OT = OppositeType_<MT>;
113  using TT = TransposeType_<MT>;
114  using ET = ElementType_<MT>;
115  //**********************************************************************************************
116 
117  public:
118  //**Type definitions****************************************************************************
119  using This = SymmetricMatrix<MT,SO,true,false>;
120  using BaseType = DenseMatrix<This,SO>;
121  using ResultType = This;
122  using OppositeType = SymmetricMatrix<OT,!SO,true,false>;
123  using TransposeType = SymmetricMatrix<TT,!SO,true,false>;
124  using ElementType = ET;
125  using ReturnType = ReturnType_<MT>;
126  using CompositeType = const This&;
127  using Reference = Reference_<MT>;
128  using ConstReference = ConstReference_<MT>;
129  using Pointer = Pointer_<MT>;
130  using ConstPointer = ConstPointer_<MT>;
131  //**********************************************************************************************
132 
133  //**Rebind struct definition********************************************************************
136  template< typename NewType > // Data type of the other matrix
137  struct Rebind {
139  using Other = SymmetricMatrix< typename MT::template Rebind<NewType>::Other >;
140  };
141  //**********************************************************************************************
142 
143  //**Resize struct definition********************************************************************
146  template< size_t NewM // Number of rows of the other matrix
147  , size_t NewN > // Number of columns of the other matrix
148  struct Resize {
150  using Other = SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other >;
151  };
152  //**********************************************************************************************
153 
154  //**MatrixIterator class definition*************************************************************
157  template< typename MatrixType > // Type of the adapted dense matrix
158  class MatrixIterator
159  {
160  public:
161  //**Type definitions*************************************************************************
163  using Reference = If_< IsConst<MatrixType>
164  , ConstReference_<MatrixType>
165  , Reference_<MatrixType> >;
166 
167  using IteratorCategory = std::random_access_iterator_tag;
168  using ValueType = RemoveReference_<Reference>;
169  using PointerType = ValueType*;
170  using ReferenceType = Reference;
171  using DifferenceType = ptrdiff_t;
172 
173  // STL iterator requirements
174  using iterator_category = IteratorCategory;
175  using value_type = ValueType;
176  using pointer = PointerType;
177  using reference = ReferenceType;
178  using difference_type = DifferenceType;
179  //*******************************************************************************************
180 
181  //**Constructor******************************************************************************
184  inline MatrixIterator() noexcept
185  : matrix_( nullptr ) // Reference to the adapted dense matrix
186  , row_ ( 0UL ) // The current row index of the iterator
187  , column_( 0UL ) // The current column index of the iterator
188  {}
189  //*******************************************************************************************
190 
191  //**Constructor******************************************************************************
198  inline MatrixIterator( MatrixType& matrix, size_t row, size_t column ) noexcept
199  : matrix_( &matrix ) // Reference to the adapted dense matrix
200  , row_ ( row ) // The current row index of the iterator
201  , column_( column ) // The current column index of the iterator
202  {}
203  //*******************************************************************************************
204 
205  //**Conversion constructor*******************************************************************
210  template< typename MatrixType2 >
211  inline MatrixIterator( const MatrixIterator<MatrixType2>& it ) noexcept
212  : matrix_( it.matrix_ ) // Reference to the adapted dense matrix
213  , row_ ( it.row_ ) // The current row index of the iterator
214  , column_( it.column_ ) // The current column index of the iterator
215  {}
216  //*******************************************************************************************
217 
218  //**Addition assignment operator*************************************************************
224  inline MatrixIterator& operator+=( size_t inc ) noexcept {
225  ( SO )?( row_ += inc ):( column_ += inc );
226  return *this;
227  }
228  //*******************************************************************************************
229 
230  //**Subtraction assignment operator**********************************************************
236  inline MatrixIterator& operator-=( size_t dec ) noexcept {
237  ( SO )?( row_ -= dec ):( column_ -= dec );
238  return *this;
239  }
240  //*******************************************************************************************
241 
242  //**Prefix increment operator****************************************************************
247  inline MatrixIterator& operator++() noexcept {
248  ( SO )?( ++row_ ):( ++column_ );
249  return *this;
250  }
251  //*******************************************************************************************
252 
253  //**Postfix increment operator***************************************************************
258  inline const MatrixIterator operator++( int ) noexcept {
259  const MatrixIterator tmp( *this );
260  ++(*this);
261  return tmp;
262  }
263  //*******************************************************************************************
264 
265  //**Prefix decrement operator****************************************************************
270  inline MatrixIterator& operator--() noexcept {
271  ( SO )?( --row_ ):( --column_ );
272  return *this;
273  }
274  //*******************************************************************************************
275 
276  //**Postfix decrement operator***************************************************************
281  inline const MatrixIterator operator--( int ) noexcept {
282  const MatrixIterator tmp( *this );
283  --(*this);
284  return tmp;
285  }
286  //*******************************************************************************************
287 
288  //**Element access operator******************************************************************
293  inline ReferenceType operator*() const {
294  if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
295  return (*matrix_)(row_,column_);
296  else
297  return (*matrix_)(column_,row_);
298  }
299  //*******************************************************************************************
300 
301  //**Element access operator******************************************************************
306  inline PointerType operator->() const {
307  if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
308  return &(*matrix_)(row_,column_);
309  else
310  return &(*matrix_)(column_,row_);
311  }
312  //*******************************************************************************************
313 
314  //**Equality operator************************************************************************
320  template< typename MatrixType2 >
321  inline bool operator==( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
322  return ( SO )?( row_ == rhs.row_ ):( column_ == rhs.column_ );
323  }
324  //*******************************************************************************************
325 
326  //**Inequality operator**********************************************************************
332  template< typename MatrixType2 >
333  inline bool operator!=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
334  return ( SO )?( row_ != rhs.row_ ):( column_ != rhs.column_ );
335  }
336  //*******************************************************************************************
337 
338  //**Less-than operator***********************************************************************
344  template< typename MatrixType2 >
345  inline bool operator<( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
346  return ( SO )?( row_ < rhs.row_ ):( column_ < rhs.column_ );
347  return ( column_ < rhs.column_ );
348  }
349  //*******************************************************************************************
350 
351  //**Greater-than operator********************************************************************
357  template< typename MatrixType2 >
358  inline bool operator>( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
359  return ( SO )?( row_ > rhs.row_ ):( column_ > rhs.column_ );
360  return ( column_ > rhs.column_ );
361  }
362  //*******************************************************************************************
363 
364  //**Less-or-equal-than operator**************************************************************
370  template< typename MatrixType2 >
371  inline bool operator<=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
372  return ( SO )?( row_ <= rhs.row_ ):( column_ <= rhs.column_ );
373  }
374  //*******************************************************************************************
375 
376  //**Greater-or-equal-than operator***********************************************************
382  template< typename MatrixType2 >
383  inline bool operator>=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
384  return ( SO )?( row_ >= rhs.row_ ):( column_ >= rhs.column_ );
385  }
386  //*******************************************************************************************
387 
388  //**Subtraction operator*********************************************************************
394  inline DifferenceType operator-( const MatrixIterator& rhs ) const noexcept {
395  return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
396  }
397  //*******************************************************************************************
398 
399  //**Addition operator************************************************************************
406  friend inline const MatrixIterator operator+( const MatrixIterator& it, size_t inc ) noexcept {
407  if( SO )
408  return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
409  else
410  return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
411  }
412  //*******************************************************************************************
413 
414  //**Addition operator************************************************************************
421  friend inline const MatrixIterator operator+( size_t inc, const MatrixIterator& it ) noexcept {
422  if( SO )
423  return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
424  else
425  return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
426  }
427  //*******************************************************************************************
428 
429  //**Subtraction operator*********************************************************************
436  friend inline const MatrixIterator operator-( const MatrixIterator& it, size_t dec ) noexcept {
437  if( SO )
438  return MatrixIterator( *it.matrix_, it.row_ - dec, it.column_ );
439  else
440  return MatrixIterator( *it.matrix_, it.row_, it.column_ - dec );
441  }
442  //*******************************************************************************************
443 
444  private:
445  //**Member variables*************************************************************************
446  MatrixType* matrix_;
447  size_t row_;
448  size_t column_;
449  //*******************************************************************************************
450 
451  //**Friend declarations**********************************************************************
452  template< typename MatrixType2 > friend class MatrixIterator;
453  //*******************************************************************************************
454  };
455  //**********************************************************************************************
456 
457  //**Type definitions****************************************************************************
458  using Iterator = MatrixIterator<MT>;
459  using ConstIterator = MatrixIterator<const MT>;
460  //**********************************************************************************************
461 
462  //**Compilation flags***************************************************************************
464  enum : bool { simdEnabled = false };
465 
467  enum : bool { smpAssignable = MT::smpAssignable && !IsSMPAssignable<ET>::value };
468  //**********************************************************************************************
469 
470  //**Constructors********************************************************************************
473  explicit inline SymmetricMatrix();
474  explicit inline SymmetricMatrix( size_t n );
475 
476  explicit inline SymmetricMatrix( ElementType* ptr, size_t n );
477  explicit inline SymmetricMatrix( ElementType* ptr, size_t n, size_t nn );
478 
479  inline SymmetricMatrix( const SymmetricMatrix& m );
480  inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
481 
482  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,SO>& m );
483  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,!SO>& m );
485  //**********************************************************************************************
486 
487  //**Destructor**********************************************************************************
488  // No explicitly declared destructor.
489  //**********************************************************************************************
490 
491  //**Data access functions***********************************************************************
494  inline Reference operator()( size_t i, size_t j );
495  inline ConstReference operator()( size_t i, size_t j ) const;
496  inline Reference at( size_t i, size_t j );
497  inline ConstReference at( size_t i, size_t j ) const;
498  inline ConstPointer data () const noexcept;
499  inline ConstPointer data ( size_t i ) const noexcept;
500  inline Iterator begin ( size_t i );
501  inline ConstIterator begin ( size_t i ) const;
502  inline ConstIterator cbegin( size_t i ) const;
503  inline Iterator end ( size_t i );
504  inline ConstIterator end ( size_t i ) const;
505  inline ConstIterator cend ( size_t i ) const;
507  //**********************************************************************************************
508 
509  //**Assignment operators************************************************************************
512  inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
513  inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
514 
515  template< typename MT2 >
516  inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
517 
518  template< typename MT2 >
519  inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
520 
521  template< typename MT2 >
522  inline SymmetricMatrix& operator=( const Matrix<MT2,!SO>& rhs );
523 
524  template< typename MT2 >
525  inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator+=( const Matrix<MT2,SO>& rhs );
526 
527  template< typename MT2 >
528  inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator+=( const Matrix<MT2,SO>& rhs );
529 
530  template< typename MT2 >
531  inline SymmetricMatrix& operator+=( const Matrix<MT2,!SO>& rhs );
532 
533  template< typename MT2 >
534  inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator-=( const Matrix<MT2,SO>& rhs );
535 
536  template< typename MT2 >
537  inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator-=( const Matrix<MT2,SO>& rhs );
538 
539  template< typename MT2 >
540  inline SymmetricMatrix& operator-=( const Matrix<MT2,!SO>& rhs );
541 
542  template< typename MT2 >
543  inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator%=( const Matrix<MT2,SO>& rhs );
544 
545  template< typename MT2 >
546  inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator%=( const Matrix<MT2,SO>& rhs );
547 
548  template< typename MT2 >
549  inline SymmetricMatrix& operator%=( const Matrix<MT2,!SO>& rhs );
550 
551  template< typename MT2, bool SO2 >
552  inline SymmetricMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
553 
554  template< typename Other >
555  inline EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator*=( Other rhs );
556 
557  template< typename Other >
558  inline EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator/=( Other rhs );
560  //**********************************************************************************************
561 
562  //**Utility functions***************************************************************************
565  inline size_t rows() const noexcept;
566  inline size_t columns() const noexcept;
567  inline size_t spacing() const noexcept;
568  inline size_t capacity() const noexcept;
569  inline size_t capacity( size_t i ) const noexcept;
570  inline size_t nonZeros() const;
571  inline size_t nonZeros( size_t i ) const;
572  inline void reset();
573  inline void reset( size_t i );
574  inline void clear();
575  void resize ( size_t n, bool preserve=true );
576  inline void extend ( size_t n, bool preserve=true );
577  inline void reserve( size_t elements );
578  inline void shrinkToFit();
579  inline void swap( SymmetricMatrix& m ) noexcept;
581  //**********************************************************************************************
582 
583  //**Numeric functions***************************************************************************
586  inline SymmetricMatrix& transpose();
587  inline SymmetricMatrix& ctranspose();
588 
589  template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
591  //**********************************************************************************************
592 
593  //**Debugging functions*************************************************************************
596  inline bool isIntact() const noexcept;
598  //**********************************************************************************************
599 
600  //**Expression template evaluation functions****************************************************
603  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
604  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
605 
606  inline bool isAligned () const noexcept;
607  inline bool canSMPAssign() const noexcept;
609  //**********************************************************************************************
610 
611  private:
612  //**Expression template evaluation functions****************************************************
615  template< typename MT2 > inline void assign ( DenseMatrix <MT2,SO>& rhs );
616  template< typename MT2 > inline void assign ( const DenseMatrix <MT2,SO>& rhs );
617  template< typename MT2 > inline void assign ( const SparseMatrix<MT2,SO>& rhs );
618  template< typename MT2 > inline void addAssign ( const DenseMatrix <MT2,SO>& rhs );
619  template< typename MT2 > inline void addAssign ( const SparseMatrix<MT2,SO>& rhs );
620  template< typename MT2 > inline void subAssign ( const DenseMatrix <MT2,SO>& rhs );
621  template< typename MT2 > inline void subAssign ( const SparseMatrix<MT2,SO>& rhs );
622  template< typename MT2 > inline void schurAssign( const DenseMatrix <MT2,SO>& rhs );
623  template< typename MT2 > inline void schurAssign( const SparseMatrix<MT2,SO>& rhs );
625  //**********************************************************************************************
626 
627  //**Member variables****************************************************************************
630  MT matrix_;
631 
632  //**********************************************************************************************
633 
634  //**Friend declarations*************************************************************************
635  template< bool RF, typename MT2, bool SO2, bool DF2, bool NF2 >
636  friend bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
637  //**********************************************************************************************
638 
639  //**Compile time checks*************************************************************************
653  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
654  //**********************************************************************************************
655 };
657 //*************************************************************************************************
658 
659 
660 
661 
662 //=================================================================================================
663 //
664 // CONSTRUCTORS
665 //
666 //=================================================================================================
667 
668 //*************************************************************************************************
672 template< typename MT // Type of the adapted dense matrix
673  , bool SO > // Storage order of the adapted dense matrix
674 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
675  : matrix_() // The adapted dense matrix
676 {
677  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
678 }
680 //*************************************************************************************************
681 
682 
683 //*************************************************************************************************
689 template< typename MT // Type of the adapted dense matrix
690  , bool SO > // Storage order of the adapted dense matrix
691 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( size_t n )
692  : matrix_( n, n ) // The adapted dense matrix
693 {
695 
696  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
697 }
699 //*************************************************************************************************
700 
701 
702 //*************************************************************************************************
736 template< typename MT // Type of the adapted dense matrix
737  , bool SO > // Storage order of the adapted dense matrix
738 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n )
739  : matrix_( ptr, n, n ) // The adapted dense matrix
740 {
741  if( !isSymmetric( matrix_ ) ) {
742  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
743  }
744 
745  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
746 }
748 //*************************************************************************************************
749 
750 
751 //*************************************************************************************************
787 template< typename MT // Type of the adapted dense matrix
788  , bool SO > // Storage order of the adapted dense matrix
789 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n, size_t nn )
790  : matrix_( ptr, n, n, nn ) // The adapted dense matrix
791 {
792  if( !isSymmetric( matrix_ ) ) {
793  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
794  }
795 
796  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
797 }
799 //*************************************************************************************************
800 
801 
802 //*************************************************************************************************
808 template< typename MT // Type of the adapted dense matrix
809  , bool SO > // Storage order of the adapted dense matrix
810 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const SymmetricMatrix& m )
811  : matrix_( m.matrix_ ) // The adapted dense matrix
812 {
813  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
814  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
815 }
817 //*************************************************************************************************
818 
819 
820 //*************************************************************************************************
826 template< typename MT // Type of the adapted dense matrix
827  , bool SO > // Storage order of the adapted dense matrix
828 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
829  : matrix_( std::move( m.matrix_ ) ) // The adapted dense matrix
830 {
831  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
832  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
833 }
835 //*************************************************************************************************
836 
837 
838 //*************************************************************************************************
848 template< typename MT // Type of the adapted dense matrix
849  , bool SO > // Storage order of the adapted dense matrix
850 template< typename MT2 > // Type of the foreign matrix
851 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,SO>& m )
852  : matrix_() // The adapted dense matrix
853 {
854  using blaze::resize;
855 
856  using RT = RemoveAdaptor_<ResultType_<MT2> >;
857  using Tmp = If_< IsComputation<MT2>, RT, const MT2& >;
858 
859  if( IsSymmetric<MT2>::value ) {
860  resize( matrix_, (~m).rows(), (~m).columns() );
861  assign( ~m );
862  }
863  else {
864  Tmp tmp( ~m );
865 
866  if( !isSymmetric( tmp ) ) {
867  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
868  }
869 
870  resize( matrix_, tmp.rows(), tmp.rows() );
871  assign( tmp );
872  }
873 
874  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
875  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
876 }
878 //*************************************************************************************************
879 
880 
881 //*************************************************************************************************
891 template< typename MT // Type of the adapted dense matrix
892  , bool SO > // Storage order of the adapted dense matrix
893 template< typename MT2 > // Type of the foreign matrix
894 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
895  : matrix_() // The adapted dense matrix
896 {
897  using blaze::resize;
898 
899  using RT = RemoveAdaptor_< ResultType_<MT2> >;
900  using Tmp = If_< IsComputation<MT2>, RT, const MT2& >;
901 
902  if( IsSymmetric<MT2>::value ) {
903  resize( matrix_, (~m).rows(), (~m).columns() );
904  assign( trans( ~m ) );
905  }
906  else {
907  Tmp tmp( ~m );
908 
909  if( !isSymmetric( tmp ) ) {
910  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
911  }
912 
913  resize( matrix_, tmp.rows(), tmp.rows() );
914  assign( trans( tmp ) );
915  }
916 
917  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
918  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
919 }
921 //*************************************************************************************************
922 
923 
924 
925 
926 //=================================================================================================
927 //
928 // DATA ACCESS FUNCTIONS
929 //
930 //=================================================================================================
931 
932 //*************************************************************************************************
947 template< typename MT // Type of the adapted dense matrix
948  , bool SO > // Storage order of the adapted dense matrix
950  SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j )
951 {
952  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
953  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
954 
955  if( ( !SO && i > j ) || ( SO && i < j ) )
956  return matrix_(i,j);
957  else
958  return matrix_(j,i);
959 }
961 //*************************************************************************************************
962 
963 
964 //*************************************************************************************************
979 template< typename MT // Type of the adapted dense matrix
980  , bool SO > // Storage order of the adapted dense matrix
982  SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j ) const
983 {
984  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
985  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
986 
987  if( ( !SO && i > j ) || ( SO && i < j ) )
988  return matrix_(i,j);
989  else
990  return matrix_(j,i);
991 }
993 //*************************************************************************************************
994 
995 
996 //*************************************************************************************************
1012 template< typename MT // Type of the adapted dense matrix
1013  , bool SO > // Storage order of the adapted dense matrix
1015  SymmetricMatrix<MT,SO,true,false>::at( size_t i, size_t j )
1016 {
1017  if( i >= rows() ) {
1018  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1019  }
1020  if( j >= columns() ) {
1021  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1022  }
1023  return (*this)(i,j);
1024 }
1026 //*************************************************************************************************
1027 
1028 
1029 //*************************************************************************************************
1045 template< typename MT // Type of the adapted dense matrix
1046  , bool SO > // Storage order of the adapted dense matrix
1048  SymmetricMatrix<MT,SO,true,false>::at( size_t i, size_t j ) const
1049 {
1050  if( i >= rows() ) {
1051  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1052  }
1053  if( j >= columns() ) {
1054  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1055  }
1056  return (*this)(i,j);
1057 }
1059 //*************************************************************************************************
1060 
1061 
1062 //*************************************************************************************************
1076 template< typename MT // Type of the adapted dense matrix
1077  , bool SO > // Storage order of the adapted dense matrix
1078 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1079  SymmetricMatrix<MT,SO,true,false>::data() const noexcept
1080 {
1081  return matrix_.data();
1082 }
1084 //*************************************************************************************************
1085 
1086 
1087 //*************************************************************************************************
1098 template< typename MT // Type of the adapted dense matrix
1099  , bool SO > // Storage order of the adapted dense matrix
1100 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1101  SymmetricMatrix<MT,SO,true,false>::data( size_t i ) const noexcept
1102 {
1103  return matrix_.data(i);
1104 }
1106 //*************************************************************************************************
1107 
1108 
1109 //*************************************************************************************************
1121 template< typename MT // Type of the adapted dense matrix
1122  , bool SO > // Storage order of the adapted dense matrix
1125 {
1126  if( SO )
1127  return Iterator( matrix_, 0UL, i );
1128  else
1129  return Iterator( matrix_, i, 0UL );
1130 }
1132 //*************************************************************************************************
1133 
1134 
1135 //*************************************************************************************************
1147 template< typename MT // Type of the adapted dense matrix
1148  , bool SO > // Storage order of the adapted dense matrix
1151 {
1152  if( SO )
1153  return ConstIterator( matrix_, 0UL, i );
1154  else
1155  return ConstIterator( matrix_, i, 0UL );
1156 }
1158 //*************************************************************************************************
1159 
1160 
1161 //*************************************************************************************************
1173 template< typename MT // Type of the adapted dense matrix
1174  , bool SO > // Storage order of the adapted dense matrix
1177 {
1178  if( SO )
1179  return ConstIterator( matrix_, 0UL, i );
1180  else
1181  return ConstIterator( matrix_, i, 0UL );
1182 }
1184 //*************************************************************************************************
1185 
1186 
1187 //*************************************************************************************************
1199 template< typename MT // Type of the adapted dense matrix
1200  , bool SO > // Storage order of the adapted dense matrix
1203 {
1204  if( SO )
1205  return Iterator( matrix_, rows(), i );
1206  else
1207  return Iterator( matrix_, i, columns() );
1208 }
1210 //*************************************************************************************************
1211 
1212 
1213 //*************************************************************************************************
1225 template< typename MT // Type of the adapted dense matrix
1226  , bool SO > // Storage order of the adapted dense matrix
1228  SymmetricMatrix<MT,SO,true,false>::end( size_t i ) const
1229 {
1230  if( SO )
1231  return ConstIterator( matrix_, rows(), i );
1232  else
1233  return ConstIterator( matrix_, i, columns() );
1234 }
1236 //*************************************************************************************************
1237 
1238 
1239 //*************************************************************************************************
1251 template< typename MT // Type of the adapted dense matrix
1252  , bool SO > // Storage order of the adapted dense matrix
1254  SymmetricMatrix<MT,SO,true,false>::cend( size_t i ) const
1255 {
1256  if( SO )
1257  return ConstIterator( matrix_, rows(), i );
1258  else
1259  return ConstIterator( matrix_, i, columns() );
1260 }
1262 //*************************************************************************************************
1263 
1264 
1265 
1266 
1267 //=================================================================================================
1268 //
1269 // ASSIGNMENT OPERATORS
1270 //
1271 //=================================================================================================
1272 
1273 //*************************************************************************************************
1283 template< typename MT // Type of the adapted dense matrix
1284  , bool SO > // Storage order of the adapted dense matrix
1285 inline SymmetricMatrix<MT,SO,true,false>&
1286  SymmetricMatrix<MT,SO,true,false>::operator=( const SymmetricMatrix& rhs )
1287 {
1288  using blaze::resize;
1289 
1290  if( &rhs == this ) return *this;
1291 
1292  resize( matrix_, rhs.rows(), rhs.columns() );
1293  assign( rhs );
1294 
1295  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1296  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1297 
1298  return *this;
1299 }
1301 //*************************************************************************************************
1302 
1303 
1304 //*************************************************************************************************
1311 template< typename MT // Type of the adapted dense matrix
1312  , bool SO > // Storage order of the adapted dense matrix
1313 inline SymmetricMatrix<MT,SO,true,false>&
1314  SymmetricMatrix<MT,SO,true,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1315 {
1316  matrix_ = std::move( rhs.matrix_ );
1317 
1318  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1319  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1320 
1321  return *this;
1322 }
1324 //*************************************************************************************************
1325 
1326 
1327 //*************************************************************************************************
1341 template< typename MT // Type of the adapted dense matrix
1342  , bool SO > // Storage order of the adapted dense matrix
1343 template< typename MT2 > // Type of the right-hand side matrix
1344 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1345  SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1346 {
1347  using blaze::resize;
1348 
1349  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1350  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1351  }
1352 
1353  if( (~rhs).isAliased( this ) ) {
1354  SymmetricMatrix tmp( ~rhs );
1355  swap( tmp );
1356  }
1357  else {
1358  resize( matrix_, (~rhs).rows(), (~rhs).columns() );
1359  if( IsSparseMatrix<MT2>::value )
1360  reset();
1361  assign( ~rhs );
1362  }
1363 
1364  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1365  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1366 
1367  return *this;
1368 }
1370 //*************************************************************************************************
1371 
1372 
1373 //*************************************************************************************************
1387 template< typename MT // Type of the adapted dense matrix
1388  , bool SO > // Storage order of the adapted dense matrix
1389 template< typename MT2 > // Type of the right-hand side matrix
1390 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1391  SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1392 {
1393  using blaze::resize;
1394 
1395  using Tmp = If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> >;
1396 
1397  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1398  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1399  }
1400 
1401  Tmp tmp( ~rhs );
1402 
1403  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1404  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1405  }
1406 
1407  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1408 
1409  resize( matrix_, tmp.rows(), tmp.columns() );
1410  if( IsSparseMatrix<Tmp>::value )
1411  reset();
1412  assign( tmp );
1413 
1414  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1415  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1416 
1417  return *this;
1418 }
1420 //*************************************************************************************************
1421 
1422 
1423 //*************************************************************************************************
1437 template< typename MT // Type of the adapted dense matrix
1438  , bool SO > // Storage order of the adapted dense matrix
1439 template< typename MT2 > // Type of the right-hand side matrix
1440 inline SymmetricMatrix<MT,SO,true,false>&
1441  SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,!SO>& rhs )
1442 {
1443  return this->operator=( trans( ~rhs ) );
1444 }
1446 //*************************************************************************************************
1447 
1448 
1449 //*************************************************************************************************
1462 template< typename MT // Type of the adapted dense matrix
1463  , bool SO > // Storage order of the adapted dense matrix
1464 template< typename MT2 > // Type of the right-hand side matrix
1465 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1466  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1467 {
1468  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1469  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1470  }
1471 
1472  addAssign( ~rhs );
1473 
1474  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1475  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1476 
1477  return *this;
1478 }
1480 //*************************************************************************************************
1481 
1482 
1483 //*************************************************************************************************
1496 template< typename MT // Type of the adapted dense matrix
1497  , bool SO > // Storage order of the adapted dense matrix
1498 template< typename MT2 > // Type of the right-hand side matrix
1499 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1500  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1501 {
1502  using Tmp = If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> >;
1503 
1504  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1505  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1506  }
1507 
1508  Tmp tmp( ~rhs );
1509 
1510  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1511  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1512  }
1513 
1514  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1515 
1516  addAssign( tmp );
1517 
1518  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1519  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1520 
1521  return *this;
1522 }
1524 //*************************************************************************************************
1525 
1526 
1527 //*************************************************************************************************
1541 template< typename MT // Type of the adapted dense matrix
1542  , bool SO > // Storage order of the adapted dense matrix
1543 template< typename MT2 > // Type of the right-hand side matrix
1544 inline SymmetricMatrix<MT,SO,true,false>&
1545  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,!SO>& rhs )
1546 {
1547  return this->operator+=( trans( ~rhs ) );
1548 }
1550 //*************************************************************************************************
1551 
1552 
1553 //*************************************************************************************************
1566 template< typename MT // Type of the adapted dense matrix
1567  , bool SO > // Storage order of the adapted dense matrix
1568 template< typename MT2 > // Type of the right-hand side matrix
1569 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1570  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1571 {
1572  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1573  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1574  }
1575 
1576  subAssign( ~rhs );
1577 
1578  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1579  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1580 
1581  return *this;
1582 }
1584 //*************************************************************************************************
1585 
1586 
1587 //*************************************************************************************************
1600 template< typename MT // Type of the adapted dense matrix
1601  , bool SO > // Storage order of the adapted dense matrix
1602 template< typename MT2 > // Type of the right-hand side matrix
1603 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1604  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1605 {
1606  using Tmp = If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> >;
1607 
1608  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1609  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1610  }
1611 
1612  Tmp tmp( ~rhs );
1613 
1614  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1615  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1616  }
1617 
1618  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1619 
1620  subAssign( tmp );
1621 
1622  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1623  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1624 
1625  return *this;
1626 }
1628 //*************************************************************************************************
1629 
1630 
1631 //*************************************************************************************************
1645 template< typename MT // Type of the adapted dense matrix
1646  , bool SO > // Storage order of the adapted dense matrix
1647 template< typename MT2 > // Type of the right-hand side matrix
1648 inline SymmetricMatrix<MT,SO,true,false>&
1649  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,!SO>& rhs )
1650 {
1651  return this->operator-=( trans( ~rhs ) );
1652 }
1654 //*************************************************************************************************
1655 
1656 
1657 //*************************************************************************************************
1671 template< typename MT // Type of the adapted dense matrix
1672  , bool SO > // Storage order of the adapted dense matrix
1673 template< typename MT2 > // Type of the right-hand side matrix
1674 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1675  SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,SO>& rhs )
1676 {
1677  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1678  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1679  }
1680 
1681  schurAssign( ~rhs );
1682 
1683  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1684  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1685 
1686  return *this;
1687 }
1689 //*************************************************************************************************
1690 
1691 
1692 //*************************************************************************************************
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 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1710  SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,SO>& rhs )
1711 {
1712  using Tmp = If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> >;
1713 
1714  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1715  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1716  }
1717 
1718  Tmp tmp( ~rhs );
1719 
1720  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1721  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1722  }
1723 
1724  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1725 
1726  schurAssign( tmp );
1727 
1728  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1729  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1730 
1731  return *this;
1732 }
1734 //*************************************************************************************************
1735 
1736 
1737 //*************************************************************************************************
1751 template< typename MT // Type of the adapted dense matrix
1752  , bool SO > // Storage order of the adapted dense matrix
1753 template< typename MT2 > // Type of the right-hand side matrix
1754 inline SymmetricMatrix<MT,SO,true,false>&
1755  SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,!SO>& rhs )
1756 {
1757  return this->operator%=( trans( ~rhs ) );
1758 }
1760 //*************************************************************************************************
1761 
1762 
1763 //*************************************************************************************************
1775 template< typename MT // Type of the adapted dense matrix
1776  , bool SO > // Storage order of the adapted dense matrix
1777 template< typename MT2 // Type of the right-hand side matrix
1778  , bool SO2 > // Storage order of the right-hand side matrix
1779 inline SymmetricMatrix<MT,SO,true,false>&
1780  SymmetricMatrix<MT,SO,true,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1781 {
1782  using blaze::resize;
1783 
1784  using Tmp = MultTrait_< MT, ResultType_<MT2> >;
1785 
1787 
1788  if( matrix_.rows() != (~rhs).columns() ) {
1789  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1790  }
1791 
1792  Tmp tmp( (*this) * ~rhs );
1793 
1794  if( !isSymmetric( tmp ) ) {
1795  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1796  }
1797 
1798  resize( matrix_, tmp.rows(), tmp.columns() );
1799  assign( tmp );
1800 
1801  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1802  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1803 
1804  return *this;
1805 }
1807 //*************************************************************************************************
1808 
1809 
1810 //*************************************************************************************************
1818 template< typename MT // Type of the adapted dense matrix
1819  , bool SO > // Storage order of the adapted dense matrix
1820 template< typename Other > // Data type of the right-hand side scalar
1821 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >&
1823 {
1824  if( SO ) {
1825  for( size_t j=0UL; j<columns(); ++j )
1826  for( size_t i=0UL; i<=j; ++i )
1827  matrix_(i,j) *= rhs;
1828  }
1829  else {
1830  for( size_t i=0UL; i<rows(); ++i )
1831  for( size_t j=0UL; j<=i; ++j )
1832  matrix_(i,j) *= rhs;
1833  }
1834 
1835  return *this;
1836 }
1838 //*************************************************************************************************
1839 
1840 
1841 //*************************************************************************************************
1849 template< typename MT // Type of the adapted dense matrix
1850  , bool SO > // Storage order of the adapted dense matrix
1851 template< typename Other > // Data type of the right-hand side scalar
1852 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >&
1854 {
1855  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1856 
1857  if( SO ) {
1858  for( size_t j=0UL; j<columns(); ++j )
1859  for( size_t i=0UL; i<=j; ++i )
1860  matrix_(i,j) /= rhs;
1861  }
1862  else {
1863  for( size_t i=0UL; i<rows(); ++i )
1864  for( size_t j=0UL; j<=i; ++j )
1865  matrix_(i,j) /= rhs;
1866  }
1867 
1868  return *this;
1869 }
1871 //*************************************************************************************************
1872 
1873 
1874 
1875 
1876 //=================================================================================================
1877 //
1878 // UTILITY FUNCTIONS
1879 //
1880 //=================================================================================================
1881 
1882 //*************************************************************************************************
1888 template< typename MT // Type of the adapted dense matrix
1889  , bool SO > // Storage order of the adapted dense matrix
1890 inline size_t SymmetricMatrix<MT,SO,true,false>::rows() const noexcept
1891 {
1892  return matrix_.rows();
1893 }
1895 //*************************************************************************************************
1896 
1897 
1898 //*************************************************************************************************
1904 template< typename MT // Type of the adapted dense matrix
1905  , bool SO > // Storage order of the adapted dense matrix
1906 inline size_t SymmetricMatrix<MT,SO,true,false>::columns() const noexcept
1907 {
1908  return matrix_.columns();
1909 }
1911 //*************************************************************************************************
1912 
1913 
1914 //*************************************************************************************************
1926 template< typename MT // Type of the adapted dense matrix
1927  , bool SO > // Storage order of the adapted dense matrix
1928 inline size_t SymmetricMatrix<MT,SO,true,false>::spacing() const noexcept
1929 {
1930  return matrix_.spacing();
1931 }
1933 //*************************************************************************************************
1934 
1935 
1936 //*************************************************************************************************
1942 template< typename MT // Type of the adapted dense matrix
1943  , bool SO > // Storage order of the adapted dense matrix
1944 inline size_t SymmetricMatrix<MT,SO,true,false>::capacity() const noexcept
1945 {
1946  return matrix_.capacity();
1947 }
1949 //*************************************************************************************************
1950 
1951 
1952 //*************************************************************************************************
1963 template< typename MT // Type of the adapted dense matrix
1964  , bool SO > // Storage order of the adapted dense matrix
1965 inline size_t SymmetricMatrix<MT,SO,true,false>::capacity( size_t i ) const noexcept
1966 {
1967  return matrix_.capacity(i);
1968 }
1970 //*************************************************************************************************
1971 
1972 
1973 //*************************************************************************************************
1979 template< typename MT // Type of the adapted dense matrix
1980  , bool SO > // Storage order of the adapted dense matrix
1981 inline size_t SymmetricMatrix<MT,SO,true,false>::nonZeros() const
1982 {
1983  size_t nonzeros( 0UL );
1984 
1985  if( SO )
1986  {
1987  for( size_t j=0UL; j<columns(); ++j ) {
1988  for( size_t i=0UL; i<j; ++i ) {
1989  if( !isDefault( matrix_(i,j) ) )
1990  nonzeros += 2UL;
1991  }
1992  if( !isDefault( matrix_(j,j) ) )
1993  ++nonzeros;
1994  }
1995  }
1996  else
1997  {
1998  for( size_t i=0UL; i<rows(); ++i ) {
1999  for( size_t j=0UL; j<i; ++j ) {
2000  if( !isDefault( matrix_(i,j) ) )
2001  nonzeros += 2UL;
2002  }
2003  if( !isDefault( matrix_(i,i) ) )
2004  ++nonzeros;
2005  }
2006  }
2007 
2008  return nonzeros;
2009 }
2011 //*************************************************************************************************
2012 
2013 
2014 //*************************************************************************************************
2026 template< typename MT // Type of the adapted dense matrix
2027  , bool SO > // Storage order of the adapted dense matrix
2028 inline size_t SymmetricMatrix<MT,SO,true,false>::nonZeros( size_t i ) const
2029 {
2030  size_t nonzeros( 0UL );
2031 
2032  if( SO )
2033  {
2034  for( size_t j=0UL; j<i; ++j ) {
2035  if( !isDefault( matrix_(j,i) ) )
2036  ++nonzeros;
2037  }
2038  for( size_t j=i; j<rows(); ++j ) {
2039  if( !isDefault( matrix_(i,j) ) )
2040  ++nonzeros;
2041  }
2042  }
2043  else
2044  {
2045  for( size_t j=0UL; j<i; ++j ) {
2046  if( !isDefault( matrix_(i,j) ) )
2047  ++nonzeros;
2048  }
2049  for( size_t j=i; j<rows(); ++j ) {
2050  if( !isDefault( matrix_(j,i) ) )
2051  ++nonzeros;
2052  }
2053  }
2054 
2055  return nonzeros;
2056 }
2058 //*************************************************************************************************
2059 
2060 
2061 //*************************************************************************************************
2067 template< typename MT // Type of the adapted dense matrix
2068  , bool SO > // Storage order of the adapted dense matrix
2070 {
2071  using blaze::clear;
2072 
2073  if( SO ) {
2074  for( size_t j=0UL; j<columns(); ++j )
2075  for( size_t i=0UL; i<=j; ++i )
2076  clear( matrix_(i,j) );
2077  }
2078  else {
2079  for( size_t i=0UL; i<rows(); ++i )
2080  for( size_t j=0UL; j<=i; ++j )
2081  clear( matrix_(i,j) );
2082  }
2083 }
2085 //*************************************************************************************************
2086 
2087 
2088 //*************************************************************************************************
2128 template< typename MT // Type of the adapted dense matrix
2129  , bool SO > // Storage order of the adapted dense matrix
2130 inline void SymmetricMatrix<MT,SO,true,false>::reset( size_t i )
2131 {
2132  using blaze::clear;
2133 
2134  for( Iterator element=begin(i); element!=end(i); ++element )
2135  clear( *element );
2136 }
2138 //*************************************************************************************************
2139 
2140 
2141 //*************************************************************************************************
2153 template< typename MT // Type of the adapted dense matrix
2154  , bool SO > // Storage order of the adapted dense matrix
2156 {
2157  using blaze::clear;
2158 
2159  clear( matrix_ );
2160 }
2162 //*************************************************************************************************
2163 
2164 
2165 //*************************************************************************************************
2181 template< typename MT // Type of the adapted dense matrix
2182  , bool SO > // Storage order of the adapted dense matrix
2183 void SymmetricMatrix<MT,SO,true,false>::resize( size_t n, bool preserve )
2184 {
2186 
2187  UNUSED_PARAMETER( preserve );
2188 
2189  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
2190 
2191  const size_t oldsize( matrix_.rows() );
2192 
2193  matrix_.resize( n, n, true );
2194 
2195  if( n > oldsize ) {
2196  const size_t increment( n - oldsize );
2197  submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2198  submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2199  }
2200 }
2202 //*************************************************************************************************
2203 
2204 
2205 //*************************************************************************************************
2218 template< typename MT // Type of the adapted dense matrix
2219  , bool SO > // Storage order of the adapted dense matrix
2220 inline void SymmetricMatrix<MT,SO,true,false>::extend( size_t n, bool preserve )
2221 {
2223 
2224  UNUSED_PARAMETER( preserve );
2225 
2226  resize( rows() + n, true );
2227 }
2229 //*************************************************************************************************
2230 
2231 
2232 //*************************************************************************************************
2242 template< typename MT // Type of the adapted dense matrix
2243  , bool SO > // Storage order of the adapted dense matrix
2244 inline void SymmetricMatrix<MT,SO,true,false>::reserve( size_t elements )
2245 {
2246  matrix_.reserve( elements );
2247 }
2249 //*************************************************************************************************
2250 
2251 
2252 //*************************************************************************************************
2262 template< typename MT // Type of the adapted dense matrix
2263  , bool SO > // Storage order of the adapted dense matrix
2265 {
2266  matrix_.shrinkToFit();
2267 }
2269 //*************************************************************************************************
2270 
2271 
2272 //*************************************************************************************************
2279 template< typename MT // Type of the adapted dense matrix
2280  , bool SO > // Storage order of the adapted dense matrix
2281 inline void SymmetricMatrix<MT,SO,true,false>::swap( SymmetricMatrix& m ) noexcept
2282 {
2283  using std::swap;
2284 
2285  swap( matrix_, m.matrix_ );
2286 }
2288 //*************************************************************************************************
2289 
2290 
2291 
2292 
2293 //=================================================================================================
2294 //
2295 // NUMERIC FUNCTIONS
2296 //
2297 //=================================================================================================
2298 
2299 //*************************************************************************************************
2305 template< typename MT // Type of the adapted dense matrix
2306  , bool SO > // Storage order of the adapted dense matrix
2307 inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::transpose()
2308 {
2309  return *this;
2310 }
2312 //*************************************************************************************************
2313 
2314 
2315 //*************************************************************************************************
2321 template< typename MT // Type of the adapted dense matrix
2322  , bool SO > // Storage order of the adapted dense matrix
2323 inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::ctranspose()
2324 {
2325  if( SO ) {
2326  for( size_t j=0UL; j<columns(); ++j )
2327  for( size_t i=0UL; i<=j; ++i )
2328  conjugate( matrix_(i,j) );
2329  }
2330  else {
2331  for( size_t i=0UL; i<rows(); ++i )
2332  for( size_t j=0UL; j<=i; ++j )
2333  conjugate( matrix_(i,j) );
2334  }
2335 
2336  return *this;
2337 }
2339 //*************************************************************************************************
2340 
2341 
2342 //*************************************************************************************************
2360 template< typename MT // Type of the adapted dense matrix
2361  , bool SO > // Storage order of the adapted dense matrix
2362 template< typename Other > // Data type of the scalar value
2363 inline SymmetricMatrix<MT,SO,true,false>&
2364  SymmetricMatrix<MT,SO,true,false>::scale( const Other& scalar )
2365 {
2366  if( SO ) {
2367  for( size_t j=0UL; j<columns(); ++j )
2368  for( size_t i=0UL; i<=j; ++i )
2369  matrix_(i,j) *= scalar;
2370  }
2371  else {
2372  for( size_t i=0UL; i<rows(); ++i )
2373  for( size_t j=0UL; j<=i; ++j )
2374  matrix_(i,j) *= scalar;
2375  }
2376 
2377  return *this;
2378 }
2380 //*************************************************************************************************
2381 
2382 
2383 
2384 
2385 //=================================================================================================
2386 //
2387 // DEBUGGING FUNCTIONS
2388 //
2389 //=================================================================================================
2390 
2391 //*************************************************************************************************
2401 template< typename MT // Type of the adapted dense matrix
2402  , bool SO > // Storage order of the adapted dense matrix
2403 inline bool SymmetricMatrix<MT,SO,true,false>::isIntact() const noexcept
2404 {
2405  using blaze::isIntact;
2406 
2407  return isIntact( matrix_ ) &&
2408  ( IsCustom<MT>::value || ( SO ? isUpper( matrix_ ) : isLower( matrix_ ) ) );
2409 }
2411 //*************************************************************************************************
2412 
2413 
2414 
2415 
2416 //=================================================================================================
2417 //
2418 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2419 //
2420 //=================================================================================================
2421 
2422 //*************************************************************************************************
2433 template< typename MT // Type of the adapted dense matrix
2434  , bool SO > // Storage order of the adapted dense matrix
2435 template< typename Other > // Data type of the foreign expression
2436 inline bool SymmetricMatrix<MT,SO,true,false>::canAlias( const Other* alias ) const noexcept
2437 {
2438  return matrix_.canAlias( alias );
2439 }
2441 //*************************************************************************************************
2442 
2443 
2444 //*************************************************************************************************
2455 template< typename MT // Type of the adapted dense matrix
2456  , bool SO > // Storage order of the adapted dense matrix
2457 template< typename Other > // Data type of the foreign expression
2458 inline bool SymmetricMatrix<MT,SO,true,false>::isAliased( const Other* alias ) const noexcept
2459 {
2460  return matrix_.isAliased( alias );
2461 }
2463 //*************************************************************************************************
2464 
2465 
2466 //*************************************************************************************************
2476 template< typename MT // Type of the adapted dense matrix
2477  , bool SO > // Storage order of the adapted dense matrix
2478 inline bool SymmetricMatrix<MT,SO,true,false>::isAligned() const noexcept
2479 {
2480  return matrix_.isAligned();
2481 }
2483 //*************************************************************************************************
2484 
2485 
2486 //*************************************************************************************************
2497 template< typename MT // Type of the adapted dense matrix
2498  , bool SO > // Storage order of the adapted dense matrix
2499 inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign() const noexcept
2500 {
2501  return matrix_.canSMPAssign();
2502 }
2504 //*************************************************************************************************
2505 
2506 
2507 //*************************************************************************************************
2519 template< typename MT // Type of the adapted dense matrix
2520  , bool SO > // Storage order of the adapted dense matrix
2521 template< typename MT2 > // Type of the right-hand side dense matrix
2522 inline void SymmetricMatrix<MT,SO,true,false>::assign( DenseMatrix<MT2,SO>& rhs )
2523 {
2524  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2525  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2526 
2527  if( SO ) {
2528  for( size_t j=0UL; j<columns(); ++j )
2529  for( size_t i=0UL; i<=j; ++i )
2530  matrix_(i,j) = std::move( (~rhs)(i,j) );
2531  }
2532  else {
2533  for( size_t i=0UL; i<rows(); ++i )
2534  for( size_t j=0UL; j<=i; ++j )
2535  matrix_(i,j) = std::move( (~rhs)(i,j) );
2536  }
2537 }
2539 //*************************************************************************************************
2540 
2541 
2542 //*************************************************************************************************
2554 template< typename MT // Type of the adapted dense matrix
2555  , bool SO > // Storage order of the adapted dense matrix
2556 template< typename MT2 > // Type of the right-hand side dense matrix
2557 inline void SymmetricMatrix<MT,SO,true,false>::assign( const DenseMatrix<MT2,SO>& rhs )
2558 {
2559  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2560  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2561 
2562  if( SO ) {
2563  for( size_t j=0UL; j<columns(); ++j )
2564  for( size_t i=0UL; i<=j; ++i )
2565  matrix_(i,j) = (~rhs)(i,j);
2566  }
2567  else {
2568  for( size_t i=0UL; i<rows(); ++i )
2569  for( size_t j=0UL; j<=i; ++j )
2570  matrix_(i,j) = (~rhs)(i,j);
2571  }
2572 }
2574 //*************************************************************************************************
2575 
2576 
2577 //*************************************************************************************************
2589 template< typename MT // Type of the adapted dense matrix
2590  , bool SO > // Storage order of the adapted dense matrix
2591 template< typename MT2 > // Type of the right-hand side sparse matrix
2592 inline void SymmetricMatrix<MT,SO,true,false>::assign( const SparseMatrix<MT2,SO>& rhs )
2593 {
2594  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2595  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2596 
2597  using ConstIterator = ConstIterator_<MT2>;
2598 
2599  if( SO ) {
2600  for( size_t j=0UL; j<columns(); ++j ) {
2601  const ConstIterator last( (~rhs).upperBound(j,j) );
2602  for( ConstIterator element=(~rhs).begin(j); element!=last; ++element )
2603  matrix_(element->index(),j) = element->value();
2604  }
2605  }
2606  else {
2607  for( size_t i=0UL; i<rows(); ++i ) {
2608  const ConstIterator last( (~rhs).upperBound(i,i) );
2609  for( ConstIterator element=(~rhs).begin(i); element!=last; ++element )
2610  matrix_(i,element->index()) = element->value();
2611  }
2612  }
2613 }
2615 //*************************************************************************************************
2616 
2617 
2618 //*************************************************************************************************
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 right-hand side dense matrix
2633 inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const DenseMatrix<MT2,SO>& rhs )
2634 {
2635  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2636  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2637 
2638  if( SO ) {
2639  for( size_t j=0UL; j<columns(); ++j )
2640  for( size_t i=0UL; i<=j; ++i )
2641  matrix_(i,j) += (~rhs)(i,j);
2642  }
2643  else {
2644  for( size_t i=0UL; i<rows(); ++i )
2645  for( size_t j=0UL; j<=i; ++j )
2646  matrix_(i,j) += (~rhs)(i,j);
2647  }
2648 }
2650 //*************************************************************************************************
2651 
2652 
2653 //*************************************************************************************************
2665 template< typename MT // Type of the adapted dense matrix
2666  , bool SO > // Storage order of the adapted dense matrix
2667 template< typename MT2 > // Type of the right-hand side sparse matrix
2668 inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const SparseMatrix<MT2,SO>& rhs )
2669 {
2670  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2671  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2672 
2673  using ConstIterator = ConstIterator_<MT2>;
2674 
2675  if( SO ) {
2676  for( size_t j=0UL; j<columns(); ++j ) {
2677  const ConstIterator last( (~rhs).upperBound(j,j) );
2678  for( ConstIterator element=(~rhs).begin(j); element!=last; ++element )
2679  matrix_(element->index(),j) += element->value();
2680  }
2681  }
2682  else {
2683  for( size_t i=0UL; i<rows(); ++i ) {
2684  const ConstIterator last( (~rhs).upperBound(i,i) );
2685  for( ConstIterator element=(~rhs).begin(i); element!=last; ++element )
2686  matrix_(i,element->index()) += element->value();
2687  }
2688  }
2689 }
2691 //*************************************************************************************************
2692 
2693 
2694 //*************************************************************************************************
2706 template< typename MT // Type of the adapted dense matrix
2707  , bool SO > // Storage order of the adapted dense matrix
2708 template< typename MT2 > // Type of the right-hand side dense matrix
2709 inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const DenseMatrix<MT2,SO>& rhs )
2710 {
2711  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2712  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2713 
2714  if( SO ) {
2715  for( size_t j=0UL; j<columns(); ++j )
2716  for( size_t i=0UL; i<=j; ++i )
2717  matrix_(i,j) -= (~rhs)(i,j);
2718  }
2719  else {
2720  for( size_t i=0UL; i<rows(); ++i )
2721  for( size_t j=0UL; j<=i; ++j )
2722  matrix_(i,j) -= (~rhs)(i,j);
2723  }
2724 }
2726 //*************************************************************************************************
2727 
2728 
2729 //*************************************************************************************************
2741 template< typename MT // Type of the adapted dense matrix
2742  , bool SO > // Storage order of the adapted dense matrix
2743 template< typename MT2 > // Type of the right-hand side sparse matrix
2744 inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const SparseMatrix<MT2,SO>& rhs )
2745 {
2746  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2747  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2748 
2749  using ConstIterator = ConstIterator_<MT2>;
2750 
2751  if( SO ) {
2752  for( size_t j=0UL; j<columns(); ++j ) {
2753  const ConstIterator last( (~rhs).upperBound(j,j) );
2754  for( ConstIterator element=(~rhs).begin(j); element!=last; ++element )
2755  matrix_(element->index(),j) -= element->value();
2756  }
2757  }
2758  else {
2759  for( size_t i=0UL; i<rows(); ++i ) {
2760  const ConstIterator last( (~rhs).upperBound(i,i) );
2761  for( ConstIterator element=(~rhs).begin(i); element!=last; ++element )
2762  matrix_(i,element->index()) -= element->value();
2763  }
2764  }
2765 }
2767 //*************************************************************************************************
2768 
2769 
2770 //*************************************************************************************************
2782 template< typename MT // Type of the adapted dense matrix
2783  , bool SO > // Storage order of the adapted dense matrix
2784 template< typename MT2 > // Type of the right-hand side dense matrix
2785 inline void SymmetricMatrix<MT,SO,true,false>::schurAssign( const DenseMatrix<MT2,SO>& rhs )
2786 {
2787  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2788  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2789 
2790  if( SO ) {
2791  for( size_t j=0UL; j<columns(); ++j )
2792  for( size_t i=0UL; i<=j; ++i )
2793  matrix_(i,j) *= (~rhs)(i,j);
2794  }
2795  else {
2796  for( size_t i=0UL; i<rows(); ++i )
2797  for( size_t j=0UL; j<=i; ++j )
2798  matrix_(i,j) *= (~rhs)(i,j);
2799  }
2800 }
2802 //*************************************************************************************************
2803 
2804 
2805 //*************************************************************************************************
2817 template< typename MT // Type of the adapted dense matrix
2818  , bool SO > // Storage order of the adapted dense matrix
2819 template< typename MT2 > // Type of the right-hand side sparse matrix
2820 inline void SymmetricMatrix<MT,SO,true,false>::schurAssign( const SparseMatrix<MT2,SO>& rhs )
2821 {
2822  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2823  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2824 
2825  using ConstIterator = ConstIterator_<MT2>;
2826 
2827  if( SO ) {
2828  for( size_t j=0UL; j<columns(); ++j )
2829  {
2830  size_t i( 0UL );
2831 
2832  const ConstIterator last( (~rhs).upperBound(j,j) );
2833  for( ConstIterator element=(~rhs).begin(j); element!=last; ++element ) {
2834  for( ; i<element->index(); ++i )
2835  reset( matrix_(i,j) );
2836  matrix_(i,j) *= element->value();
2837  ++i;
2838  }
2839 
2840  for( ; i<rows(); ++i ) {
2841  reset( matrix_(i,j) );
2842  }
2843  }
2844  }
2845  else {
2846  for( size_t i=0UL; i<rows(); ++i )
2847  {
2848  size_t j( 0UL );
2849 
2850  const ConstIterator last( (~rhs).upperBound(i,i) );
2851  for( ConstIterator element=(~rhs).begin(i); element!=last; ++element ) {
2852  for( ; j<element->index(); ++j )
2853  reset( matrix_(i,j) );
2854  matrix_(i,j) *= element->value();
2855  ++j;
2856  }
2857 
2858  for( ; j<columns(); ++j ) {
2859  reset( matrix_(i,j) );
2860  }
2861  }
2862  }
2863 }
2865 //*************************************************************************************************
2866 
2867 } // namespace blaze
2868 
2869 #endif
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
#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.
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3079
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1073
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1328
#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 Rows type trait.
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:356
Header file for basic type definitions.
Header file for the IsSparseMatrix type trait.
#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
#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:1411
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3078
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:198
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:560
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
BLAZE_ALWAYS_INLINE void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:609
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:5845
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3080
Submatrix< MT, AF > 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:352
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:661
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3085
#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:394
Column< MT > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:124
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
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3086
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:1393
Constraint on the data type.
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:308
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:242
Header file for the implementation of the base template of the SymmetricMatrix.
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:110
Header file for the IsSquare type trait.
Row< MT > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:124
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the IsCustom type trait.
Header file for the multiplication trait.
Header file for the IsSymmetric type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3084
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5924
Header file for the If class template.
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5907
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3077
#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
Header file for the IsSMPAssignable type trait.
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3081
#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.
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:3087
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:340
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
#define BLAZE_CONSTRAINT_MUST_NOT_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is a numeric (integral or floating point) d...
Definition: Numeric.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:548
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:264
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
Header file for the RemoveAdaptor type trait.
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
Header file for all forward declarations for expression class templates.
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:580
Header file for the conjugate shim.
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.
#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
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:270
Constraint on the data type.
Constraint on the data type.
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric< T >::value)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:700
Header file for the RemoveReference 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:324
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3082
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:790
#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.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3083
#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:252
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
#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
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:742
#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
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:635