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 ST >
552  inline EnableIf_< IsNumeric<ST>, SymmetricMatrix >& operator*=( ST rhs );
553 
554  template< typename ST >
555  inline EnableIf_< IsNumeric<ST>, SymmetricMatrix >& operator/=( ST rhs );
557  //**********************************************************************************************
558 
559  //**Utility functions***************************************************************************
562  inline size_t rows() const noexcept;
563  inline size_t columns() const noexcept;
564  inline size_t spacing() const noexcept;
565  inline size_t capacity() const noexcept;
566  inline size_t capacity( size_t i ) const noexcept;
567  inline size_t nonZeros() const;
568  inline size_t nonZeros( size_t i ) const;
569  inline void reset();
570  inline void reset( size_t i );
571  inline void clear();
572  void resize ( size_t n, bool preserve=true );
573  inline void extend ( size_t n, bool preserve=true );
574  inline void reserve( size_t elements );
575  inline void shrinkToFit();
576  inline void swap( SymmetricMatrix& m ) noexcept;
578  //**********************************************************************************************
579 
580  //**Numeric functions***************************************************************************
583  inline SymmetricMatrix& transpose();
584  inline SymmetricMatrix& ctranspose();
585 
586  template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
588  //**********************************************************************************************
589 
590  //**Debugging functions*************************************************************************
593  inline bool isIntact() const noexcept;
595  //**********************************************************************************************
596 
597  //**Expression template evaluation functions****************************************************
600  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
601  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
602 
603  inline bool isAligned () const noexcept;
604  inline bool canSMPAssign() const noexcept;
606  //**********************************************************************************************
607 
608  private:
609  //**Expression template evaluation functions****************************************************
612  template< typename MT2 > inline void assign ( DenseMatrix <MT2,SO>& rhs );
613  template< typename MT2 > inline void assign ( const DenseMatrix <MT2,SO>& rhs );
614  template< typename MT2 > inline void assign ( const SparseMatrix<MT2,SO>& rhs );
615  template< typename MT2 > inline void addAssign ( const DenseMatrix <MT2,SO>& rhs );
616  template< typename MT2 > inline void addAssign ( const SparseMatrix<MT2,SO>& rhs );
617  template< typename MT2 > inline void subAssign ( const DenseMatrix <MT2,SO>& rhs );
618  template< typename MT2 > inline void subAssign ( const SparseMatrix<MT2,SO>& rhs );
619  template< typename MT2 > inline void schurAssign( const DenseMatrix <MT2,SO>& rhs );
620  template< typename MT2 > inline void schurAssign( const SparseMatrix<MT2,SO>& rhs );
622  //**********************************************************************************************
623 
624  //**Member variables****************************************************************************
627  MT matrix_;
628 
629  //**********************************************************************************************
630 
631  //**Friend declarations*************************************************************************
632  template< bool RF, typename MT2, bool SO2, bool DF2, bool NF2 >
633  friend bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
634  //**********************************************************************************************
635 
636  //**Compile time checks*************************************************************************
650  BLAZE_STATIC_ASSERT( ( Size<MT,0UL>::value == Size<MT,1UL>::value ) );
651  //**********************************************************************************************
652 };
654 //*************************************************************************************************
655 
656 
657 
658 
659 //=================================================================================================
660 //
661 // CONSTRUCTORS
662 //
663 //=================================================================================================
664 
665 //*************************************************************************************************
669 template< typename MT // Type of the adapted dense matrix
670  , bool SO > // Storage order of the adapted dense matrix
671 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
672  : matrix_() // The adapted dense matrix
673 {
674  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
675 }
677 //*************************************************************************************************
678 
679 
680 //*************************************************************************************************
686 template< typename MT // Type of the adapted dense matrix
687  , bool SO > // Storage order of the adapted dense matrix
688 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( size_t n )
689  : matrix_( n, n ) // The adapted dense matrix
690 {
692 
693  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
694 }
696 //*************************************************************************************************
697 
698 
699 //*************************************************************************************************
733 template< typename MT // Type of the adapted dense matrix
734  , bool SO > // Storage order of the adapted dense matrix
735 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n )
736  : matrix_( ptr, n, n ) // The adapted dense matrix
737 {
738  if( !isSymmetric( matrix_ ) ) {
739  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
740  }
741 
742  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
743 }
745 //*************************************************************************************************
746 
747 
748 //*************************************************************************************************
784 template< typename MT // Type of the adapted dense matrix
785  , bool SO > // Storage order of the adapted dense matrix
786 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n, size_t nn )
787  : matrix_( ptr, n, n, nn ) // The adapted dense matrix
788 {
789  if( !isSymmetric( matrix_ ) ) {
790  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
791  }
792 
793  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
794 }
796 //*************************************************************************************************
797 
798 
799 //*************************************************************************************************
805 template< typename MT // Type of the adapted dense matrix
806  , bool SO > // Storage order of the adapted dense matrix
807 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const SymmetricMatrix& m )
808  : matrix_( m.matrix_ ) // The adapted dense matrix
809 {
810  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
811  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
812 }
814 //*************************************************************************************************
815 
816 
817 //*************************************************************************************************
823 template< typename MT // Type of the adapted dense matrix
824  , bool SO > // Storage order of the adapted dense matrix
825 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
826  : matrix_( std::move( m.matrix_ ) ) // The adapted dense matrix
827 {
828  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
829  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
830 }
832 //*************************************************************************************************
833 
834 
835 //*************************************************************************************************
845 template< typename MT // Type of the adapted dense matrix
846  , bool SO > // Storage order of the adapted dense matrix
847 template< typename MT2 > // Type of the foreign matrix
848 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,SO>& m )
849  : matrix_() // The adapted dense matrix
850 {
851  using blaze::resize;
852 
853  using RT = RemoveAdaptor_<ResultType_<MT2> >;
854  using Tmp = If_< IsComputation<MT2>, RT, const MT2& >;
855 
856  if( IsSymmetric<MT2>::value ) {
857  resize( matrix_, (~m).rows(), (~m).columns() );
858  assign( ~m );
859  }
860  else {
861  Tmp tmp( ~m );
862 
863  if( !isSymmetric( tmp ) ) {
864  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
865  }
866 
867  resize( matrix_, tmp.rows(), tmp.rows() );
868  assign( tmp );
869  }
870 
871  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
872  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
873 }
875 //*************************************************************************************************
876 
877 
878 //*************************************************************************************************
888 template< typename MT // Type of the adapted dense matrix
889  , bool SO > // Storage order of the adapted dense matrix
890 template< typename MT2 > // Type of the foreign matrix
891 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
892  : matrix_() // The adapted dense matrix
893 {
894  using blaze::resize;
895 
896  using RT = RemoveAdaptor_< ResultType_<MT2> >;
897  using Tmp = If_< IsComputation<MT2>, RT, const MT2& >;
898 
899  if( IsSymmetric<MT2>::value ) {
900  resize( matrix_, (~m).rows(), (~m).columns() );
901  assign( trans( ~m ) );
902  }
903  else {
904  Tmp tmp( ~m );
905 
906  if( !isSymmetric( tmp ) ) {
907  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
908  }
909 
910  resize( matrix_, tmp.rows(), tmp.rows() );
911  assign( trans( tmp ) );
912  }
913 
914  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
915  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
916 }
918 //*************************************************************************************************
919 
920 
921 
922 
923 //=================================================================================================
924 //
925 // DATA ACCESS FUNCTIONS
926 //
927 //=================================================================================================
928 
929 //*************************************************************************************************
944 template< typename MT // Type of the adapted dense matrix
945  , bool SO > // Storage order of the adapted dense matrix
947  SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j )
948 {
949  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
950  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
951 
952  if( ( !SO && i > j ) || ( SO && i < j ) )
953  return matrix_(i,j);
954  else
955  return matrix_(j,i);
956 }
958 //*************************************************************************************************
959 
960 
961 //*************************************************************************************************
976 template< typename MT // Type of the adapted dense matrix
977  , bool SO > // Storage order of the adapted dense matrix
979  SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j ) const
980 {
981  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
982  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
983 
984  if( ( !SO && i > j ) || ( SO && i < j ) )
985  return matrix_(i,j);
986  else
987  return matrix_(j,i);
988 }
990 //*************************************************************************************************
991 
992 
993 //*************************************************************************************************
1009 template< typename MT // Type of the adapted dense matrix
1010  , bool SO > // Storage order of the adapted dense matrix
1012  SymmetricMatrix<MT,SO,true,false>::at( size_t i, size_t j )
1013 {
1014  if( i >= rows() ) {
1015  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1016  }
1017  if( j >= columns() ) {
1018  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1019  }
1020  return (*this)(i,j);
1021 }
1023 //*************************************************************************************************
1024 
1025 
1026 //*************************************************************************************************
1042 template< typename MT // Type of the adapted dense matrix
1043  , bool SO > // Storage order of the adapted dense matrix
1045  SymmetricMatrix<MT,SO,true,false>::at( size_t i, size_t j ) const
1046 {
1047  if( i >= rows() ) {
1048  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1049  }
1050  if( j >= columns() ) {
1051  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1052  }
1053  return (*this)(i,j);
1054 }
1056 //*************************************************************************************************
1057 
1058 
1059 //*************************************************************************************************
1073 template< typename MT // Type of the adapted dense matrix
1074  , bool SO > // Storage order of the adapted dense matrix
1075 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1077 {
1078  return matrix_.data();
1079 }
1081 //*************************************************************************************************
1082 
1083 
1084 //*************************************************************************************************
1095 template< typename MT // Type of the adapted dense matrix
1096  , bool SO > // Storage order of the adapted dense matrix
1097 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1098  SymmetricMatrix<MT,SO,true,false>::data( size_t i ) const noexcept
1099 {
1100  return matrix_.data(i);
1101 }
1103 //*************************************************************************************************
1104 
1105 
1106 //*************************************************************************************************
1118 template< typename MT // Type of the adapted dense matrix
1119  , bool SO > // Storage order of the adapted dense matrix
1122 {
1123  if( SO )
1124  return Iterator( matrix_, 0UL, i );
1125  else
1126  return Iterator( matrix_, i, 0UL );
1127 }
1129 //*************************************************************************************************
1130 
1131 
1132 //*************************************************************************************************
1144 template< typename MT // Type of the adapted dense matrix
1145  , bool SO > // Storage order of the adapted dense matrix
1148 {
1149  if( SO )
1150  return ConstIterator( matrix_, 0UL, i );
1151  else
1152  return ConstIterator( matrix_, i, 0UL );
1153 }
1155 //*************************************************************************************************
1156 
1157 
1158 //*************************************************************************************************
1170 template< typename MT // Type of the adapted dense matrix
1171  , bool SO > // Storage order of the adapted dense matrix
1174 {
1175  if( SO )
1176  return ConstIterator( matrix_, 0UL, i );
1177  else
1178  return ConstIterator( matrix_, i, 0UL );
1179 }
1181 //*************************************************************************************************
1182 
1183 
1184 //*************************************************************************************************
1196 template< typename MT // Type of the adapted dense matrix
1197  , bool SO > // Storage order of the adapted dense matrix
1200 {
1201  if( SO )
1202  return Iterator( matrix_, rows(), i );
1203  else
1204  return Iterator( matrix_, i, columns() );
1205 }
1207 //*************************************************************************************************
1208 
1209 
1210 //*************************************************************************************************
1222 template< typename MT // Type of the adapted dense matrix
1223  , bool SO > // Storage order of the adapted dense matrix
1225  SymmetricMatrix<MT,SO,true,false>::end( size_t i ) const
1226 {
1227  if( SO )
1228  return ConstIterator( matrix_, rows(), i );
1229  else
1230  return ConstIterator( matrix_, i, columns() );
1231 }
1233 //*************************************************************************************************
1234 
1235 
1236 //*************************************************************************************************
1248 template< typename MT // Type of the adapted dense matrix
1249  , bool SO > // Storage order of the adapted dense matrix
1251  SymmetricMatrix<MT,SO,true,false>::cend( size_t i ) const
1252 {
1253  if( SO )
1254  return ConstIterator( matrix_, rows(), i );
1255  else
1256  return ConstIterator( matrix_, i, columns() );
1257 }
1259 //*************************************************************************************************
1260 
1261 
1262 
1263 
1264 //=================================================================================================
1265 //
1266 // ASSIGNMENT OPERATORS
1267 //
1268 //=================================================================================================
1269 
1270 //*************************************************************************************************
1280 template< typename MT // Type of the adapted dense matrix
1281  , bool SO > // Storage order of the adapted dense matrix
1282 inline SymmetricMatrix<MT,SO,true,false>&
1283  SymmetricMatrix<MT,SO,true,false>::operator=( const SymmetricMatrix& rhs )
1284 {
1285  using blaze::resize;
1286 
1287  if( &rhs == this ) return *this;
1288 
1289  resize( matrix_, rhs.rows(), rhs.columns() );
1290  assign( rhs );
1291 
1292  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1293  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1294 
1295  return *this;
1296 }
1298 //*************************************************************************************************
1299 
1300 
1301 //*************************************************************************************************
1308 template< typename MT // Type of the adapted dense matrix
1309  , bool SO > // Storage order of the adapted dense matrix
1310 inline SymmetricMatrix<MT,SO,true,false>&
1311  SymmetricMatrix<MT,SO,true,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1312 {
1313  matrix_ = std::move( rhs.matrix_ );
1314 
1315  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1316  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1317 
1318  return *this;
1319 }
1321 //*************************************************************************************************
1322 
1323 
1324 //*************************************************************************************************
1338 template< typename MT // Type of the adapted dense matrix
1339  , bool SO > // Storage order of the adapted dense matrix
1340 template< typename MT2 > // Type of the right-hand side matrix
1341 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1342  SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1343 {
1344  using blaze::resize;
1345 
1346  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1347  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1348  }
1349 
1350  if( (~rhs).isAliased( this ) ) {
1351  SymmetricMatrix tmp( ~rhs );
1352  swap( tmp );
1353  }
1354  else {
1355  resize( matrix_, (~rhs).rows(), (~rhs).columns() );
1356  if( IsSparseMatrix<MT2>::value )
1357  reset();
1358  assign( ~rhs );
1359  }
1360 
1361  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1362  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1363 
1364  return *this;
1365 }
1367 //*************************************************************************************************
1368 
1369 
1370 //*************************************************************************************************
1384 template< typename MT // Type of the adapted dense matrix
1385  , bool SO > // Storage order of the adapted dense matrix
1386 template< typename MT2 > // Type of the right-hand side matrix
1387 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1388  SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1389 {
1390  using blaze::resize;
1391 
1392  using Tmp = If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> >;
1393 
1394  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1395  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1396  }
1397 
1398  Tmp tmp( ~rhs );
1399 
1400  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1401  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1402  }
1403 
1404  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1405 
1406  resize( matrix_, tmp.rows(), tmp.columns() );
1407  if( IsSparseMatrix<Tmp>::value )
1408  reset();
1409  assign( tmp );
1410 
1411  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1412  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1413 
1414  return *this;
1415 }
1417 //*************************************************************************************************
1418 
1419 
1420 //*************************************************************************************************
1434 template< typename MT // Type of the adapted dense matrix
1435  , bool SO > // Storage order of the adapted dense matrix
1436 template< typename MT2 > // Type of the right-hand side matrix
1437 inline SymmetricMatrix<MT,SO,true,false>&
1438  SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,!SO>& rhs )
1439 {
1440  return this->operator=( trans( ~rhs ) );
1441 }
1443 //*************************************************************************************************
1444 
1445 
1446 //*************************************************************************************************
1459 template< typename MT // Type of the adapted dense matrix
1460  , bool SO > // Storage order of the adapted dense matrix
1461 template< typename MT2 > // Type of the right-hand side matrix
1462 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1463  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1464 {
1465  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1466  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1467  }
1468 
1469  addAssign( ~rhs );
1470 
1471  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1472  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1473 
1474  return *this;
1475 }
1477 //*************************************************************************************************
1478 
1479 
1480 //*************************************************************************************************
1493 template< typename MT // Type of the adapted dense matrix
1494  , bool SO > // Storage order of the adapted dense matrix
1495 template< typename MT2 > // Type of the right-hand side matrix
1496 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1497  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1498 {
1499  using Tmp = If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> >;
1500 
1501  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1502  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1503  }
1504 
1505  Tmp tmp( ~rhs );
1506 
1507  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1508  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1509  }
1510 
1511  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1512 
1513  addAssign( tmp );
1514 
1515  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1516  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1517 
1518  return *this;
1519 }
1521 //*************************************************************************************************
1522 
1523 
1524 //*************************************************************************************************
1538 template< typename MT // Type of the adapted dense matrix
1539  , bool SO > // Storage order of the adapted dense matrix
1540 template< typename MT2 > // Type of the right-hand side matrix
1541 inline SymmetricMatrix<MT,SO,true,false>&
1542  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,!SO>& rhs )
1543 {
1544  return this->operator+=( trans( ~rhs ) );
1545 }
1547 //*************************************************************************************************
1548 
1549 
1550 //*************************************************************************************************
1563 template< typename MT // Type of the adapted dense matrix
1564  , bool SO > // Storage order of the adapted dense matrix
1565 template< typename MT2 > // Type of the right-hand side matrix
1566 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1567  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1568 {
1569  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1570  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1571  }
1572 
1573  subAssign( ~rhs );
1574 
1575  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1576  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1577 
1578  return *this;
1579 }
1581 //*************************************************************************************************
1582 
1583 
1584 //*************************************************************************************************
1597 template< typename MT // Type of the adapted dense matrix
1598  , bool SO > // Storage order of the adapted dense matrix
1599 template< typename MT2 > // Type of the right-hand side matrix
1600 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1601  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1602 {
1603  using Tmp = If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> >;
1604 
1605  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1606  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1607  }
1608 
1609  Tmp tmp( ~rhs );
1610 
1611  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1612  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1613  }
1614 
1615  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1616 
1617  subAssign( tmp );
1618 
1619  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1620  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1621 
1622  return *this;
1623 }
1625 //*************************************************************************************************
1626 
1627 
1628 //*************************************************************************************************
1642 template< typename MT // Type of the adapted dense matrix
1643  , bool SO > // Storage order of the adapted dense matrix
1644 template< typename MT2 > // Type of the right-hand side matrix
1645 inline SymmetricMatrix<MT,SO,true,false>&
1646  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,!SO>& rhs )
1647 {
1648  return this->operator-=( trans( ~rhs ) );
1649 }
1651 //*************************************************************************************************
1652 
1653 
1654 //*************************************************************************************************
1668 template< typename MT // Type of the adapted dense matrix
1669  , bool SO > // Storage order of the adapted dense matrix
1670 template< typename MT2 > // Type of the right-hand side matrix
1671 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1672  SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,SO>& rhs )
1673 {
1674  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1675  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1676  }
1677 
1678  schurAssign( ~rhs );
1679 
1680  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1681  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1682 
1683  return *this;
1684 }
1686 //*************************************************************************************************
1687 
1688 
1689 //*************************************************************************************************
1703 template< typename MT // Type of the adapted dense matrix
1704  , bool SO > // Storage order of the adapted dense matrix
1705 template< typename MT2 > // Type of the right-hand side matrix
1706 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1707  SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,SO>& rhs )
1708 {
1709  using Tmp = If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> >;
1710 
1711  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1712  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1713  }
1714 
1715  Tmp tmp( ~rhs );
1716 
1717  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1718  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1719  }
1720 
1721  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1722 
1723  schurAssign( tmp );
1724 
1725  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1726  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1727 
1728  return *this;
1729 }
1731 //*************************************************************************************************
1732 
1733 
1734 //*************************************************************************************************
1748 template< typename MT // Type of the adapted dense matrix
1749  , bool SO > // Storage order of the adapted dense matrix
1750 template< typename MT2 > // Type of the right-hand side matrix
1751 inline SymmetricMatrix<MT,SO,true,false>&
1752  SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,!SO>& rhs )
1753 {
1754  return this->operator%=( trans( ~rhs ) );
1755 }
1757 //*************************************************************************************************
1758 
1759 
1760 //*************************************************************************************************
1768 template< typename MT // Type of the adapted dense matrix
1769  , bool SO > // Storage order of the adapted dense matrix
1770 template< typename ST > // Data type of the right-hand side scalar
1771 inline EnableIf_< IsNumeric<ST>, SymmetricMatrix<MT,SO,true,false> >&
1773 {
1774  if( SO ) {
1775  for( size_t j=0UL; j<columns(); ++j )
1776  for( size_t i=0UL; i<=j; ++i )
1777  matrix_(i,j) *= rhs;
1778  }
1779  else {
1780  for( size_t i=0UL; i<rows(); ++i )
1781  for( size_t j=0UL; j<=i; ++j )
1782  matrix_(i,j) *= rhs;
1783  }
1784 
1785  return *this;
1786 }
1788 //*************************************************************************************************
1789 
1790 
1791 //*************************************************************************************************
1799 template< typename MT // Type of the adapted dense matrix
1800  , bool SO > // Storage order of the adapted dense matrix
1801 template< typename ST > // Data type of the right-hand side scalar
1802 inline EnableIf_< IsNumeric<ST>, SymmetricMatrix<MT,SO,true,false> >&
1804 {
1805  BLAZE_USER_ASSERT( !isZero( rhs ), "Division by zero detected" );
1806 
1807  if( SO ) {
1808  for( size_t j=0UL; j<columns(); ++j )
1809  for( size_t i=0UL; i<=j; ++i )
1810  matrix_(i,j) /= rhs;
1811  }
1812  else {
1813  for( size_t i=0UL; i<rows(); ++i )
1814  for( size_t j=0UL; j<=i; ++j )
1815  matrix_(i,j) /= rhs;
1816  }
1817 
1818  return *this;
1819 }
1821 //*************************************************************************************************
1822 
1823 
1824 
1825 
1826 //=================================================================================================
1827 //
1828 // UTILITY FUNCTIONS
1829 //
1830 //=================================================================================================
1831 
1832 //*************************************************************************************************
1838 template< typename MT // Type of the adapted dense matrix
1839  , bool SO > // Storage order of the adapted dense matrix
1840 inline size_t SymmetricMatrix<MT,SO,true,false>::rows() const noexcept
1841 {
1842  return matrix_.rows();
1843 }
1845 //*************************************************************************************************
1846 
1847 
1848 //*************************************************************************************************
1854 template< typename MT // Type of the adapted dense matrix
1855  , bool SO > // Storage order of the adapted dense matrix
1856 inline size_t SymmetricMatrix<MT,SO,true,false>::columns() const noexcept
1857 {
1858  return matrix_.columns();
1859 }
1861 //*************************************************************************************************
1862 
1863 
1864 //*************************************************************************************************
1876 template< typename MT // Type of the adapted dense matrix
1877  , bool SO > // Storage order of the adapted dense matrix
1878 inline size_t SymmetricMatrix<MT,SO,true,false>::spacing() const noexcept
1879 {
1880  return matrix_.spacing();
1881 }
1883 //*************************************************************************************************
1884 
1885 
1886 //*************************************************************************************************
1892 template< typename MT // Type of the adapted dense matrix
1893  , bool SO > // Storage order of the adapted dense matrix
1894 inline size_t SymmetricMatrix<MT,SO,true,false>::capacity() const noexcept
1895 {
1896  return matrix_.capacity();
1897 }
1899 //*************************************************************************************************
1900 
1901 
1902 //*************************************************************************************************
1913 template< typename MT // Type of the adapted dense matrix
1914  , bool SO > // Storage order of the adapted dense matrix
1915 inline size_t SymmetricMatrix<MT,SO,true,false>::capacity( size_t i ) const noexcept
1916 {
1917  return matrix_.capacity(i);
1918 }
1920 //*************************************************************************************************
1921 
1922 
1923 //*************************************************************************************************
1929 template< typename MT // Type of the adapted dense matrix
1930  , bool SO > // Storage order of the adapted dense matrix
1931 inline size_t SymmetricMatrix<MT,SO,true,false>::nonZeros() const
1932 {
1933  size_t nonzeros( 0UL );
1934 
1935  if( SO )
1936  {
1937  for( size_t j=0UL; j<columns(); ++j ) {
1938  for( size_t i=0UL; i<j; ++i ) {
1939  if( !isDefault( matrix_(i,j) ) )
1940  nonzeros += 2UL;
1941  }
1942  if( !isDefault( matrix_(j,j) ) )
1943  ++nonzeros;
1944  }
1945  }
1946  else
1947  {
1948  for( size_t i=0UL; i<rows(); ++i ) {
1949  for( size_t j=0UL; j<i; ++j ) {
1950  if( !isDefault( matrix_(i,j) ) )
1951  nonzeros += 2UL;
1952  }
1953  if( !isDefault( matrix_(i,i) ) )
1954  ++nonzeros;
1955  }
1956  }
1957 
1958  return nonzeros;
1959 }
1961 //*************************************************************************************************
1962 
1963 
1964 //*************************************************************************************************
1976 template< typename MT // Type of the adapted dense matrix
1977  , bool SO > // Storage order of the adapted dense matrix
1978 inline size_t SymmetricMatrix<MT,SO,true,false>::nonZeros( size_t i ) const
1979 {
1980  size_t nonzeros( 0UL );
1981 
1982  if( SO )
1983  {
1984  for( size_t j=0UL; j<i; ++j ) {
1985  if( !isDefault( matrix_(j,i) ) )
1986  ++nonzeros;
1987  }
1988  for( size_t j=i; j<rows(); ++j ) {
1989  if( !isDefault( matrix_(i,j) ) )
1990  ++nonzeros;
1991  }
1992  }
1993  else
1994  {
1995  for( size_t j=0UL; j<i; ++j ) {
1996  if( !isDefault( matrix_(i,j) ) )
1997  ++nonzeros;
1998  }
1999  for( size_t j=i; j<rows(); ++j ) {
2000  if( !isDefault( matrix_(j,i) ) )
2001  ++nonzeros;
2002  }
2003  }
2004 
2005  return nonzeros;
2006 }
2008 //*************************************************************************************************
2009 
2010 
2011 //*************************************************************************************************
2017 template< typename MT // Type of the adapted dense matrix
2018  , bool SO > // Storage order of the adapted dense matrix
2020 {
2021  using blaze::clear;
2022 
2023  if( SO ) {
2024  for( size_t j=0UL; j<columns(); ++j )
2025  for( size_t i=0UL; i<=j; ++i )
2026  clear( matrix_(i,j) );
2027  }
2028  else {
2029  for( size_t i=0UL; i<rows(); ++i )
2030  for( size_t j=0UL; j<=i; ++j )
2031  clear( matrix_(i,j) );
2032  }
2033 }
2035 //*************************************************************************************************
2036 
2037 
2038 //*************************************************************************************************
2078 template< typename MT // Type of the adapted dense matrix
2079  , bool SO > // Storage order of the adapted dense matrix
2080 inline void SymmetricMatrix<MT,SO,true,false>::reset( size_t i )
2081 {
2082  using blaze::clear;
2083 
2084  for( Iterator element=begin(i); element!=end(i); ++element )
2085  clear( *element );
2086 }
2088 //*************************************************************************************************
2089 
2090 
2091 //*************************************************************************************************
2103 template< typename MT // Type of the adapted dense matrix
2104  , bool SO > // Storage order of the adapted dense matrix
2106 {
2107  using blaze::clear;
2108 
2109  clear( matrix_ );
2110 }
2112 //*************************************************************************************************
2113 
2114 
2115 //*************************************************************************************************
2131 template< typename MT // Type of the adapted dense matrix
2132  , bool SO > // Storage order of the adapted dense matrix
2133 void SymmetricMatrix<MT,SO,true,false>::resize( size_t n, bool preserve )
2134 {
2136 
2137  UNUSED_PARAMETER( preserve );
2138 
2139  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
2140 
2141  const size_t oldsize( matrix_.rows() );
2142 
2143  matrix_.resize( n, n, true );
2144 
2145  if( n > oldsize ) {
2146  const size_t increment( n - oldsize );
2147  submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2148  submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2149  }
2150 }
2152 //*************************************************************************************************
2153 
2154 
2155 //*************************************************************************************************
2168 template< typename MT // Type of the adapted dense matrix
2169  , bool SO > // Storage order of the adapted dense matrix
2170 inline void SymmetricMatrix<MT,SO,true,false>::extend( size_t n, bool preserve )
2171 {
2173 
2174  UNUSED_PARAMETER( preserve );
2175 
2176  resize( rows() + n, true );
2177 }
2179 //*************************************************************************************************
2180 
2181 
2182 //*************************************************************************************************
2192 template< typename MT // Type of the adapted dense matrix
2193  , bool SO > // Storage order of the adapted dense matrix
2194 inline void SymmetricMatrix<MT,SO,true,false>::reserve( size_t elements )
2195 {
2196  matrix_.reserve( elements );
2197 }
2199 //*************************************************************************************************
2200 
2201 
2202 //*************************************************************************************************
2212 template< typename MT // Type of the adapted dense matrix
2213  , bool SO > // Storage order of the adapted dense matrix
2215 {
2216  matrix_.shrinkToFit();
2217 }
2219 //*************************************************************************************************
2220 
2221 
2222 //*************************************************************************************************
2229 template< typename MT // Type of the adapted dense matrix
2230  , bool SO > // Storage order of the adapted dense matrix
2231 inline void SymmetricMatrix<MT,SO,true,false>::swap( SymmetricMatrix& m ) noexcept
2232 {
2233  using std::swap;
2234 
2235  swap( matrix_, m.matrix_ );
2236 }
2238 //*************************************************************************************************
2239 
2240 
2241 
2242 
2243 //=================================================================================================
2244 //
2245 // NUMERIC FUNCTIONS
2246 //
2247 //=================================================================================================
2248 
2249 //*************************************************************************************************
2255 template< typename MT // Type of the adapted dense matrix
2256  , bool SO > // Storage order of the adapted dense matrix
2257 inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::transpose()
2258 {
2259  return *this;
2260 }
2262 //*************************************************************************************************
2263 
2264 
2265 //*************************************************************************************************
2271 template< typename MT // Type of the adapted dense matrix
2272  , bool SO > // Storage order of the adapted dense matrix
2273 inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::ctranspose()
2274 {
2275  if( SO ) {
2276  for( size_t j=0UL; j<columns(); ++j )
2277  for( size_t i=0UL; i<=j; ++i )
2278  conjugate( matrix_(i,j) );
2279  }
2280  else {
2281  for( size_t i=0UL; i<rows(); ++i )
2282  for( size_t j=0UL; j<=i; ++j )
2283  conjugate( matrix_(i,j) );
2284  }
2285 
2286  return *this;
2287 }
2289 //*************************************************************************************************
2290 
2291 
2292 //*************************************************************************************************
2310 template< typename MT // Type of the adapted dense matrix
2311  , bool SO > // Storage order of the adapted dense matrix
2312 template< typename Other > // Data type of the scalar value
2313 inline SymmetricMatrix<MT,SO,true,false>&
2314  SymmetricMatrix<MT,SO,true,false>::scale( const Other& scalar )
2315 {
2316  if( SO ) {
2317  for( size_t j=0UL; j<columns(); ++j )
2318  for( size_t i=0UL; i<=j; ++i )
2319  matrix_(i,j) *= scalar;
2320  }
2321  else {
2322  for( size_t i=0UL; i<rows(); ++i )
2323  for( size_t j=0UL; j<=i; ++j )
2324  matrix_(i,j) *= scalar;
2325  }
2326 
2327  return *this;
2328 }
2330 //*************************************************************************************************
2331 
2332 
2333 
2334 
2335 //=================================================================================================
2336 //
2337 // DEBUGGING FUNCTIONS
2338 //
2339 //=================================================================================================
2340 
2341 //*************************************************************************************************
2351 template< typename MT // Type of the adapted dense matrix
2352  , bool SO > // Storage order of the adapted dense matrix
2353 inline bool SymmetricMatrix<MT,SO,true,false>::isIntact() const noexcept
2354 {
2355  using blaze::isIntact;
2356 
2357  return isIntact( matrix_ ) &&
2358  ( IsCustom<MT>::value || ( SO ? isUpper( matrix_ ) : isLower( matrix_ ) ) );
2359 }
2361 //*************************************************************************************************
2362 
2363 
2364 
2365 
2366 //=================================================================================================
2367 //
2368 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2369 //
2370 //=================================================================================================
2371 
2372 //*************************************************************************************************
2383 template< typename MT // Type of the adapted dense matrix
2384  , bool SO > // Storage order of the adapted dense matrix
2385 template< typename Other > // Data type of the foreign expression
2386 inline bool SymmetricMatrix<MT,SO,true,false>::canAlias( const Other* alias ) const noexcept
2387 {
2388  return matrix_.canAlias( alias );
2389 }
2391 //*************************************************************************************************
2392 
2393 
2394 //*************************************************************************************************
2405 template< typename MT // Type of the adapted dense matrix
2406  , bool SO > // Storage order of the adapted dense matrix
2407 template< typename Other > // Data type of the foreign expression
2408 inline bool SymmetricMatrix<MT,SO,true,false>::isAliased( const Other* alias ) const noexcept
2409 {
2410  return matrix_.isAliased( alias );
2411 }
2413 //*************************************************************************************************
2414 
2415 
2416 //*************************************************************************************************
2426 template< typename MT // Type of the adapted dense matrix
2427  , bool SO > // Storage order of the adapted dense matrix
2428 inline bool SymmetricMatrix<MT,SO,true,false>::isAligned() const noexcept
2429 {
2430  return matrix_.isAligned();
2431 }
2433 //*************************************************************************************************
2434 
2435 
2436 //*************************************************************************************************
2447 template< typename MT // Type of the adapted dense matrix
2448  , bool SO > // Storage order of the adapted dense matrix
2449 inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign() const noexcept
2450 {
2451  return matrix_.canSMPAssign();
2452 }
2454 //*************************************************************************************************
2455 
2456 
2457 //*************************************************************************************************
2469 template< typename MT // Type of the adapted dense matrix
2470  , bool SO > // Storage order of the adapted dense matrix
2471 template< typename MT2 > // Type of the right-hand side dense matrix
2472 inline void SymmetricMatrix<MT,SO,true,false>::assign( DenseMatrix<MT2,SO>& rhs )
2473 {
2474  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2475  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2476 
2477  if( SO ) {
2478  for( size_t j=0UL; j<columns(); ++j )
2479  for( size_t i=0UL; i<=j; ++i )
2480  matrix_(i,j) = std::move( (~rhs)(i,j) );
2481  }
2482  else {
2483  for( size_t i=0UL; i<rows(); ++i )
2484  for( size_t j=0UL; j<=i; ++j )
2485  matrix_(i,j) = std::move( (~rhs)(i,j) );
2486  }
2487 }
2489 //*************************************************************************************************
2490 
2491 
2492 //*************************************************************************************************
2504 template< typename MT // Type of the adapted dense matrix
2505  , bool SO > // Storage order of the adapted dense matrix
2506 template< typename MT2 > // Type of the right-hand side dense matrix
2507 inline void SymmetricMatrix<MT,SO,true,false>::assign( const DenseMatrix<MT2,SO>& rhs )
2508 {
2509  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2510  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2511 
2512  if( SO ) {
2513  for( size_t j=0UL; j<columns(); ++j )
2514  for( size_t i=0UL; i<=j; ++i )
2515  matrix_(i,j) = (~rhs)(i,j);
2516  }
2517  else {
2518  for( size_t i=0UL; i<rows(); ++i )
2519  for( size_t j=0UL; j<=i; ++j )
2520  matrix_(i,j) = (~rhs)(i,j);
2521  }
2522 }
2524 //*************************************************************************************************
2525 
2526 
2527 //*************************************************************************************************
2539 template< typename MT // Type of the adapted dense matrix
2540  , bool SO > // Storage order of the adapted dense matrix
2541 template< typename MT2 > // Type of the right-hand side sparse matrix
2542 inline void SymmetricMatrix<MT,SO,true,false>::assign( const SparseMatrix<MT2,SO>& rhs )
2543 {
2544  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2545  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2546 
2547  using RhsIterator = ConstIterator_<MT2>;
2548 
2549  if( SO ) {
2550  for( size_t j=0UL; j<columns(); ++j ) {
2551  const RhsIterator last( (~rhs).upperBound(j,j) );
2552  for( RhsIterator element=(~rhs).begin(j); element!=last; ++element )
2553  matrix_(element->index(),j) = element->value();
2554  }
2555  }
2556  else {
2557  for( size_t i=0UL; i<rows(); ++i ) {
2558  const RhsIterator last( (~rhs).upperBound(i,i) );
2559  for( RhsIterator element=(~rhs).begin(i); element!=last; ++element )
2560  matrix_(i,element->index()) = element->value();
2561  }
2562  }
2563 }
2565 //*************************************************************************************************
2566 
2567 
2568 //*************************************************************************************************
2580 template< typename MT // Type of the adapted dense matrix
2581  , bool SO > // Storage order of the adapted dense matrix
2582 template< typename MT2 > // Type of the right-hand side dense matrix
2583 inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const DenseMatrix<MT2,SO>& rhs )
2584 {
2585  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2586  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2587 
2588  if( SO ) {
2589  for( size_t j=0UL; j<columns(); ++j )
2590  for( size_t i=0UL; i<=j; ++i )
2591  matrix_(i,j) += (~rhs)(i,j);
2592  }
2593  else {
2594  for( size_t i=0UL; i<rows(); ++i )
2595  for( size_t j=0UL; j<=i; ++j )
2596  matrix_(i,j) += (~rhs)(i,j);
2597  }
2598 }
2600 //*************************************************************************************************
2601 
2602 
2603 //*************************************************************************************************
2615 template< typename MT // Type of the adapted dense matrix
2616  , bool SO > // Storage order of the adapted dense matrix
2617 template< typename MT2 > // Type of the right-hand side sparse matrix
2618 inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const SparseMatrix<MT2,SO>& rhs )
2619 {
2620  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2621  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2622 
2623  using RhsIterator = ConstIterator_<MT2>;
2624 
2625  if( SO ) {
2626  for( size_t j=0UL; j<columns(); ++j ) {
2627  const RhsIterator last( (~rhs).upperBound(j,j) );
2628  for( RhsIterator element=(~rhs).begin(j); element!=last; ++element )
2629  matrix_(element->index(),j) += element->value();
2630  }
2631  }
2632  else {
2633  for( size_t i=0UL; i<rows(); ++i ) {
2634  const RhsIterator last( (~rhs).upperBound(i,i) );
2635  for( RhsIterator element=(~rhs).begin(i); element!=last; ++element )
2636  matrix_(i,element->index()) += element->value();
2637  }
2638  }
2639 }
2641 //*************************************************************************************************
2642 
2643 
2644 //*************************************************************************************************
2656 template< typename MT // Type of the adapted dense matrix
2657  , bool SO > // Storage order of the adapted dense matrix
2658 template< typename MT2 > // Type of the right-hand side dense matrix
2659 inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const DenseMatrix<MT2,SO>& rhs )
2660 {
2661  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2662  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2663 
2664  if( SO ) {
2665  for( size_t j=0UL; j<columns(); ++j )
2666  for( size_t i=0UL; i<=j; ++i )
2667  matrix_(i,j) -= (~rhs)(i,j);
2668  }
2669  else {
2670  for( size_t i=0UL; i<rows(); ++i )
2671  for( size_t j=0UL; j<=i; ++j )
2672  matrix_(i,j) -= (~rhs)(i,j);
2673  }
2674 }
2676 //*************************************************************************************************
2677 
2678 
2679 //*************************************************************************************************
2691 template< typename MT // Type of the adapted dense matrix
2692  , bool SO > // Storage order of the adapted dense matrix
2693 template< typename MT2 > // Type of the right-hand side sparse matrix
2694 inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const SparseMatrix<MT2,SO>& rhs )
2695 {
2696  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2697  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2698 
2699  using RhsIterator = ConstIterator_<MT2>;
2700 
2701  if( SO ) {
2702  for( size_t j=0UL; j<columns(); ++j ) {
2703  const RhsIterator last( (~rhs).upperBound(j,j) );
2704  for( RhsIterator element=(~rhs).begin(j); element!=last; ++element )
2705  matrix_(element->index(),j) -= element->value();
2706  }
2707  }
2708  else {
2709  for( size_t i=0UL; i<rows(); ++i ) {
2710  const RhsIterator last( (~rhs).upperBound(i,i) );
2711  for( RhsIterator element=(~rhs).begin(i); element!=last; ++element )
2712  matrix_(i,element->index()) -= element->value();
2713  }
2714  }
2715 }
2717 //*************************************************************************************************
2718 
2719 
2720 //*************************************************************************************************
2732 template< typename MT // Type of the adapted dense matrix
2733  , bool SO > // Storage order of the adapted dense matrix
2734 template< typename MT2 > // Type of the right-hand side dense matrix
2735 inline void SymmetricMatrix<MT,SO,true,false>::schurAssign( const DenseMatrix<MT2,SO>& rhs )
2736 {
2737  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2738  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2739 
2740  if( SO ) {
2741  for( size_t j=0UL; j<columns(); ++j )
2742  for( size_t i=0UL; i<=j; ++i )
2743  matrix_(i,j) *= (~rhs)(i,j);
2744  }
2745  else {
2746  for( size_t i=0UL; i<rows(); ++i )
2747  for( size_t j=0UL; j<=i; ++j )
2748  matrix_(i,j) *= (~rhs)(i,j);
2749  }
2750 }
2752 //*************************************************************************************************
2753 
2754 
2755 //*************************************************************************************************
2767 template< typename MT // Type of the adapted dense matrix
2768  , bool SO > // Storage order of the adapted dense matrix
2769 template< typename MT2 > // Type of the right-hand side sparse matrix
2770 inline void SymmetricMatrix<MT,SO,true,false>::schurAssign( const SparseMatrix<MT2,SO>& rhs )
2771 {
2772  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2773  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2774 
2775  using RhsIterator = ConstIterator_<MT2>;
2776 
2777  if( SO ) {
2778  for( size_t j=0UL; j<columns(); ++j )
2779  {
2780  size_t i( 0UL );
2781 
2782  const RhsIterator last( (~rhs).upperBound(j,j) );
2783  for( RhsIterator element=(~rhs).begin(j); element!=last; ++element ) {
2784  for( ; i<element->index(); ++i )
2785  reset( matrix_(i,j) );
2786  matrix_(i,j) *= element->value();
2787  ++i;
2788  }
2789 
2790  for( ; i<rows(); ++i ) {
2791  reset( matrix_(i,j) );
2792  }
2793  }
2794  }
2795  else {
2796  for( size_t i=0UL; i<rows(); ++i )
2797  {
2798  size_t j( 0UL );
2799 
2800  const RhsIterator last( (~rhs).upperBound(i,i) );
2801  for( RhsIterator element=(~rhs).begin(i); element!=last; ++element ) {
2802  for( ; j<element->index(); ++j )
2803  reset( matrix_(i,j) );
2804  matrix_(i,j) *= element->value();
2805  ++j;
2806  }
2807 
2808  for( ; j<columns(); ++j ) {
2809  reset( matrix_(i,j) );
2810  }
2811  }
2812  }
2813 }
2815 //*************************************************************************************************
2816 
2817 } // namespace blaze
2818 
2819 #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.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:131
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3077
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1214
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1469
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:522
Header file for basic type definitions.
Header file for the 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
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3076
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:364
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3074
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:701
BLAZE_ALWAYS_INLINE void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:775
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:224
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5829
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3078
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:827
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3083
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:560
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:733
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3084
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:474
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:408
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:252
Header file for the IsSquare type trait.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:670
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:3082
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5908
Header file for the If class template.
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5891
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Header file for the IsSMPAssignable type trait.
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3079
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the DenseMatrix base class.
constexpr bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:367
constexpr bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:443
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3085
Header file for the isZero shim.
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:506
Constraints on the storage order of matrix types.
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:134
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:81
#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:714
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:430
decltype(auto) 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.
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:360
Header file for the EnableIf class template.
Header file for utility functions for dense matrices.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:608
Header file for the 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.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:131
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:272
Constraint on the data type.
Constraint on the data type.
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:841
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:490
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
BLAZE_ALWAYS_INLINE MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:169
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:789
EnableIf_< IsNumeric< ST >, MT &> operator/=(DenseMatrix< MT, SO > &mat, ST scalar)
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:655
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a &#39;res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3081
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:254
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:628
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
EnableIf_< IsNumeric< ST >, MT &> operator*=(DenseMatrix< MT, SO > &mat, ST scalar)
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:593
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:908
Header file for the Size type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:801