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  typedef OppositeType_<MT> OT;
113  typedef TransposeType_<MT> TT;
114  typedef ElementType_<MT> ET;
115  //**********************************************************************************************
116 
117  public:
118  //**Type definitions****************************************************************************
119  typedef SymmetricMatrix<MT,SO,true,false> This;
120  typedef DenseMatrix<This,SO> BaseType;
121  typedef This ResultType;
122  typedef SymmetricMatrix<OT,!SO,true,false> OppositeType;
123  typedef SymmetricMatrix<TT,!SO,true,false> TransposeType;
124  typedef ET ElementType;
125  typedef ReturnType_<MT> ReturnType;
126  typedef const This& CompositeType;
127  typedef Reference_<MT> Reference;
128  typedef ConstReference_<MT> ConstReference;
129  typedef Pointer_<MT> Pointer;
130  typedef ConstPointer_<MT> ConstPointer;
131  //**********************************************************************************************
132 
133  //**Rebind struct definition********************************************************************
136  template< typename ET > // Data type of the other matrix
137  struct Rebind {
139  typedef SymmetricMatrix< typename MT::template Rebind<ET>::Other > Other;
140  };
141  //**********************************************************************************************
142 
143  //**MatrixIterator class definition*************************************************************
146  template< typename MatrixType > // Type of the adapted dense matrix
147  class MatrixIterator
148  {
149  public:
150  //**Type definitions*************************************************************************
152  typedef If_< IsConst<MatrixType>
153  , ConstReference_<MatrixType>
154  , Reference_<MatrixType> > Reference;
155 
156  typedef std::random_access_iterator_tag IteratorCategory;
157  typedef RemoveReference_<Reference> ValueType;
158  typedef ValueType* PointerType;
159  typedef Reference ReferenceType;
160  typedef ptrdiff_t DifferenceType;
161 
162  // STL iterator requirements
163  typedef IteratorCategory iterator_category;
164  typedef ValueType value_type;
165  typedef PointerType pointer;
166  typedef ReferenceType reference;
167  typedef DifferenceType difference_type;
168  //*******************************************************************************************
169 
170  //**Constructor******************************************************************************
173  inline MatrixIterator() noexcept
174  : matrix_( nullptr ) // Reference to the adapted dense matrix
175  , row_ ( 0UL ) // The current row index of the iterator
176  , column_( 0UL ) // The current column index of the iterator
177  {}
178  //*******************************************************************************************
179 
180  //**Constructor******************************************************************************
187  inline MatrixIterator( MatrixType& matrix, size_t row, size_t column ) noexcept
188  : matrix_( &matrix ) // Reference to the adapted dense matrix
189  , row_ ( row ) // The current row index of the iterator
190  , column_( column ) // The current column index of the iterator
191  {}
192  //*******************************************************************************************
193 
194  //**Conversion constructor*******************************************************************
199  template< typename MatrixType2 >
200  inline MatrixIterator( const MatrixIterator<MatrixType2>& it ) noexcept
201  : matrix_( it.matrix_ ) // Reference to the adapted dense matrix
202  , row_ ( it.row_ ) // The current row index of the iterator
203  , column_( it.column_ ) // The current column index of the iterator
204  {}
205  //*******************************************************************************************
206 
207  //**Addition assignment operator*************************************************************
213  inline MatrixIterator& operator+=( size_t inc ) noexcept {
214  ( SO )?( row_ += inc ):( column_ += inc );
215  return *this;
216  }
217  //*******************************************************************************************
218 
219  //**Subtraction assignment operator**********************************************************
225  inline MatrixIterator& operator-=( size_t dec ) noexcept {
226  ( SO )?( row_ -= dec ):( column_ -= dec );
227  return *this;
228  }
229  //*******************************************************************************************
230 
231  //**Prefix increment operator****************************************************************
236  inline MatrixIterator& operator++() noexcept {
237  ( SO )?( ++row_ ):( ++column_ );
238  return *this;
239  }
240  //*******************************************************************************************
241 
242  //**Postfix increment operator***************************************************************
247  inline const MatrixIterator operator++( int ) noexcept {
248  const MatrixIterator tmp( *this );
249  ++(*this);
250  return tmp;
251  }
252  //*******************************************************************************************
253 
254  //**Prefix decrement operator****************************************************************
259  inline MatrixIterator& operator--() noexcept {
260  ( SO )?( --row_ ):( --column_ );
261  return *this;
262  }
263  //*******************************************************************************************
264 
265  //**Postfix decrement operator***************************************************************
270  inline const MatrixIterator operator--( int ) noexcept {
271  const MatrixIterator tmp( *this );
272  --(*this);
273  return tmp;
274  }
275  //*******************************************************************************************
276 
277  //**Element access operator******************************************************************
282  inline ReferenceType operator*() const {
283  if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
284  return (*matrix_)(row_,column_);
285  else
286  return (*matrix_)(column_,row_);
287  }
288  //*******************************************************************************************
289 
290  //**Element access operator******************************************************************
295  inline PointerType operator->() const {
296  if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
297  return &(*matrix_)(row_,column_);
298  else
299  return &(*matrix_)(column_,row_);
300  }
301  //*******************************************************************************************
302 
303  //**Equality operator************************************************************************
309  template< typename MatrixType2 >
310  inline bool operator==( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
311  return ( SO )?( row_ == rhs.row_ ):( column_ == rhs.column_ );
312  }
313  //*******************************************************************************************
314 
315  //**Inequality operator**********************************************************************
321  template< typename MatrixType2 >
322  inline bool operator!=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
323  return ( SO )?( row_ != rhs.row_ ):( column_ != rhs.column_ );
324  }
325  //*******************************************************************************************
326 
327  //**Less-than operator***********************************************************************
333  template< typename MatrixType2 >
334  inline bool operator<( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
335  return ( SO )?( row_ < rhs.row_ ):( column_ < rhs.column_ );
336  return ( column_ < rhs.column_ );
337  }
338  //*******************************************************************************************
339 
340  //**Greater-than operator********************************************************************
346  template< typename MatrixType2 >
347  inline bool operator>( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
348  return ( SO )?( row_ > rhs.row_ ):( column_ > rhs.column_ );
349  return ( column_ > rhs.column_ );
350  }
351  //*******************************************************************************************
352 
353  //**Less-or-equal-than operator**************************************************************
359  template< typename MatrixType2 >
360  inline bool operator<=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
361  return ( SO )?( row_ <= rhs.row_ ):( column_ <= rhs.column_ );
362  }
363  //*******************************************************************************************
364 
365  //**Greater-or-equal-than operator***********************************************************
371  template< typename MatrixType2 >
372  inline bool operator>=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
373  return ( SO )?( row_ >= rhs.row_ ):( column_ >= rhs.column_ );
374  }
375  //*******************************************************************************************
376 
377  //**Subtraction operator*********************************************************************
383  inline DifferenceType operator-( const MatrixIterator& rhs ) const noexcept {
384  return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
385  }
386  //*******************************************************************************************
387 
388  //**Addition operator************************************************************************
395  friend inline const MatrixIterator operator+( const MatrixIterator& it, size_t inc ) noexcept {
396  if( SO )
397  return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
398  else
399  return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
400  }
401  //*******************************************************************************************
402 
403  //**Addition operator************************************************************************
410  friend inline const MatrixIterator operator+( size_t inc, const MatrixIterator& it ) noexcept {
411  if( SO )
412  return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
413  else
414  return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
415  }
416  //*******************************************************************************************
417 
418  //**Subtraction operator*********************************************************************
425  friend inline const MatrixIterator operator-( const MatrixIterator& it, size_t dec ) noexcept {
426  if( SO )
427  return MatrixIterator( *it.matrix_, it.row_ - dec, it.column_ );
428  else
429  return MatrixIterator( *it.matrix_, it.row_, it.column_ - dec );
430  }
431  //*******************************************************************************************
432 
433  private:
434  //**Member variables*************************************************************************
435  MatrixType* matrix_;
436  size_t row_;
437  size_t column_;
438  //*******************************************************************************************
439 
440  //**Friend declarations**********************************************************************
441  template< typename MatrixType2 > friend class MatrixIterator;
442  //*******************************************************************************************
443  };
444  //**********************************************************************************************
445 
446  //**Type definitions****************************************************************************
447  typedef MatrixIterator<MT> Iterator;
448  typedef MatrixIterator<const MT> ConstIterator;
449  //**********************************************************************************************
450 
451  //**Compilation flags***************************************************************************
453  enum : bool { simdEnabled = false };
454 
456  enum : bool { smpAssignable = MT::smpAssignable && !IsSMPAssignable<ET>::value };
457  //**********************************************************************************************
458 
459  //**Constructors********************************************************************************
462  explicit inline SymmetricMatrix();
463  explicit inline SymmetricMatrix( size_t n );
464 
465  explicit inline SymmetricMatrix( ElementType* ptr, size_t n );
466  explicit inline SymmetricMatrix( ElementType* ptr, size_t n, size_t nn );
467 
468  template< typename Deleter >
469  explicit inline SymmetricMatrix( ElementType* ptr, size_t n, Deleter d );
470 
471  template< typename Deleter >
472  explicit inline SymmetricMatrix( ElementType* ptr, size_t n, size_t nn, Deleter d );
473 
474  inline SymmetricMatrix( const SymmetricMatrix& m );
475  inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
476 
477  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,SO>& m );
478  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,!SO>& m );
480  //**********************************************************************************************
481 
482  //**Destructor**********************************************************************************
483  // No explicitly declared destructor.
484  //**********************************************************************************************
485 
486  //**Data access functions***********************************************************************
489  inline Reference operator()( size_t i, size_t j );
490  inline ConstReference operator()( size_t i, size_t j ) const;
491  inline Reference at( size_t i, size_t j );
492  inline ConstReference at( size_t i, size_t j ) const;
493  inline ConstPointer data () const noexcept;
494  inline ConstPointer data ( size_t i ) const noexcept;
495  inline Iterator begin ( size_t i );
496  inline ConstIterator begin ( size_t i ) const;
497  inline ConstIterator cbegin( size_t i ) const;
498  inline Iterator end ( size_t i );
499  inline ConstIterator end ( size_t i ) const;
500  inline ConstIterator cend ( size_t i ) const;
502  //**********************************************************************************************
503 
504  //**Assignment operators************************************************************************
507  inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
508  inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
509 
510  template< typename MT2 >
511  inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
512 
513  template< typename MT2 >
514  inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
515 
516  template< typename MT2 >
517  inline SymmetricMatrix& operator=( const Matrix<MT2,!SO>& rhs );
518 
519  template< typename MT2 >
520  inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator+=( const Matrix<MT2,SO>& rhs );
521 
522  template< typename MT2 >
523  inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator+=( const Matrix<MT2,SO>& rhs );
524 
525  template< typename MT2 >
526  inline SymmetricMatrix& operator+=( const Matrix<MT2,!SO>& rhs );
527 
528  template< typename MT2 >
529  inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator-=( const Matrix<MT2,SO>& rhs );
530 
531  template< typename MT2 >
532  inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator-=( const Matrix<MT2,SO>& rhs );
533 
534  template< typename MT2 >
535  inline SymmetricMatrix& operator-=( const Matrix<MT2,!SO>& rhs );
536 
537  template< typename MT2, bool SO2 >
538  inline SymmetricMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
539 
540  template< typename Other >
541  inline EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator*=( Other rhs );
542 
543  template< typename Other >
544  inline EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator/=( Other rhs );
546  //**********************************************************************************************
547 
548  //**Utility functions***************************************************************************
551  inline size_t rows() const noexcept;
552  inline size_t columns() const noexcept;
553  inline size_t spacing() const noexcept;
554  inline size_t capacity() const noexcept;
555  inline size_t capacity( size_t i ) const noexcept;
556  inline size_t nonZeros() const;
557  inline size_t nonZeros( size_t i ) const;
558  inline void reset();
559  inline void reset( size_t i );
560  inline void clear();
561  void resize ( size_t n, bool preserve=true );
562  inline void extend ( size_t n, bool preserve=true );
563  inline void reserve( size_t elements );
564  inline SymmetricMatrix& transpose();
565  inline SymmetricMatrix& ctranspose();
566  template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
567  inline void swap( SymmetricMatrix& m ) noexcept;
569  //**********************************************************************************************
570 
571  //**Debugging functions*************************************************************************
574  inline bool isIntact() const noexcept;
576  //**********************************************************************************************
577 
578  //**Expression template evaluation functions****************************************************
581  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
582  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
583 
584  inline bool isAligned () const noexcept;
585  inline bool canSMPAssign() const noexcept;
587  //**********************************************************************************************
588 
589  private:
590  //**Expression template evaluation functions****************************************************
593  template< typename MT2 > inline void assign ( DenseMatrix <MT2,SO>& rhs );
594  template< typename MT2 > inline void assign ( const DenseMatrix <MT2,SO>& rhs );
595  template< typename MT2 > inline void assign ( const SparseMatrix<MT2,SO>& rhs );
596  template< typename MT2 > inline void addAssign( const DenseMatrix <MT2,SO>& rhs );
597  template< typename MT2 > inline void addAssign( const SparseMatrix<MT2,SO>& rhs );
598  template< typename MT2 > inline void subAssign( const DenseMatrix <MT2,SO>& rhs );
599  template< typename MT2 > inline void subAssign( const SparseMatrix<MT2,SO>& rhs );
601  //**********************************************************************************************
602 
603  //**Member variables****************************************************************************
606  MT matrix_;
607 
608  //**********************************************************************************************
609 
610  //**Friend declarations*************************************************************************
611  template< typename MT2, bool SO2, bool DF2, bool NF2 >
612  friend bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
613  //**********************************************************************************************
614 
615  //**Compile time checks*************************************************************************
629  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
630  //**********************************************************************************************
631 };
633 //*************************************************************************************************
634 
635 
636 
637 
638 //=================================================================================================
639 //
640 // CONSTRUCTORS
641 //
642 //=================================================================================================
643 
644 //*************************************************************************************************
648 template< typename MT // Type of the adapted dense matrix
649  , bool SO > // Storage order of the adapted dense matrix
650 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
651  : matrix_() // The adapted dense matrix
652 {
653  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
654 }
656 //*************************************************************************************************
657 
658 
659 //*************************************************************************************************
665 template< typename MT // Type of the adapted dense matrix
666  , bool SO > // Storage order of the adapted dense matrix
667 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( size_t n )
668  : matrix_( n, n ) // The adapted dense matrix
669 {
671 
672  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
673 }
675 //*************************************************************************************************
676 
677 
678 //*************************************************************************************************
699 template< typename MT // Type of the adapted dense matrix
700  , bool SO > // Storage order of the adapted dense matrix
701 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n )
702  : matrix_( ptr, n, n ) // The adapted dense matrix
703 {
704  if( !isSymmetric( matrix_ ) ) {
705  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
706  }
707 
708  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
709 }
711 //*************************************************************************************************
712 
713 
714 //*************************************************************************************************
737 template< typename MT // Type of the adapted dense matrix
738  , bool SO > // Storage order of the adapted dense matrix
739 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n, size_t nn )
740  : matrix_( ptr, n, n, nn ) // The adapted dense matrix
741 {
742  if( !isSymmetric( matrix_ ) ) {
743  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
744  }
745 
746  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
747 }
749 //*************************************************************************************************
750 
751 
752 //*************************************************************************************************
773 template< typename MT // Type of the adapted dense matrix
774  , bool SO > // Storage order of the adapted dense matrix
775 template< typename Deleter > // Type of the custom deleter
776 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n, Deleter d )
777  : matrix_( ptr, n, n, d ) // The adapted dense matrix
778 {
779  if( !isSymmetric( matrix_ ) ) {
780  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
781  }
782 
783  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
784 }
786 //*************************************************************************************************
787 
788 
789 //*************************************************************************************************
811 template< typename MT // Type of the adapted dense matrix
812  , bool SO > // Storage order of the adapted dense matrix
813 template< typename Deleter > // Type of the custom deleter
814 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n, size_t nn, Deleter d )
815  : matrix_( ptr, n, n, nn, d ) // The adapted dense matrix
816 {
817  if( !isSymmetric( matrix_ ) ) {
818  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
819  }
820 
821  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
822 }
824 //*************************************************************************************************
825 
826 
827 //*************************************************************************************************
833 template< typename MT // Type of the adapted dense matrix
834  , bool SO > // Storage order of the adapted dense matrix
835 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const SymmetricMatrix& m )
836  : matrix_( m.matrix_ ) // The adapted dense matrix
837 {
838  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
839  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
840 }
842 //*************************************************************************************************
843 
844 
845 //*************************************************************************************************
851 template< typename MT // Type of the adapted dense matrix
852  , bool SO > // Storage order of the adapted dense matrix
853 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
854  : matrix_( std::move( m.matrix_ ) ) // The adapted dense matrix
855 {
856  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
857  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
858 }
860 //*************************************************************************************************
861 
862 
863 //*************************************************************************************************
873 template< typename MT // Type of the adapted dense matrix
874  , bool SO > // Storage order of the adapted dense matrix
875 template< typename MT2 > // Type of the foreign matrix
876 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,SO>& m )
877  : matrix_() // The adapted dense matrix
878 {
879  using blaze::resize;
880 
881  typedef RemoveAdaptor_<ResultType_<MT2> > RT;
882  typedef If_< IsComputation<MT2>, RT, const MT2& > Tmp;
883 
884  if( IsSymmetric<MT2>::value ) {
885  resize( matrix_, (~m).rows(), (~m).columns() );
886  assign( ~m );
887  }
888  else {
889  Tmp tmp( ~m );
890 
891  if( !isSymmetric( tmp ) ) {
892  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
893  }
894 
895  resize( matrix_, tmp.rows(), tmp.rows() );
896  assign( tmp );
897  }
898 
899  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
900  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
901 }
903 //*************************************************************************************************
904 
905 
906 //*************************************************************************************************
916 template< typename MT // Type of the adapted dense matrix
917  , bool SO > // Storage order of the adapted dense matrix
918 template< typename MT2 > // Type of the foreign matrix
919 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
920  : matrix_() // The adapted dense matrix
921 {
922  using blaze::resize;
923 
924  typedef RemoveAdaptor_< ResultType_<MT2> > RT;
925  typedef If_< IsComputation<MT2>, RT, const MT2& > Tmp;
926 
927  if( IsSymmetric<MT2>::value ) {
928  resize( matrix_, (~m).rows(), (~m).columns() );
929  assign( trans( ~m ) );
930  }
931  else {
932  Tmp tmp( ~m );
933 
934  if( !isSymmetric( tmp ) ) {
935  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
936  }
937 
938  resize( matrix_, tmp.rows(), tmp.rows() );
939  assign( trans( tmp ) );
940  }
941 
942  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
943  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
944 }
946 //*************************************************************************************************
947 
948 
949 
950 
951 //=================================================================================================
952 //
953 // DATA ACCESS FUNCTIONS
954 //
955 //=================================================================================================
956 
957 //*************************************************************************************************
972 template< typename MT // Type of the adapted dense matrix
973  , bool SO > // Storage order of the adapted dense matrix
975  SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j )
976 {
977  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
978  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
979 
980  if( ( !SO && i > j ) || ( SO && i < j ) )
981  return matrix_(i,j);
982  else
983  return matrix_(j,i);
984 }
986 //*************************************************************************************************
987 
988 
989 //*************************************************************************************************
1004 template< typename MT // Type of the adapted dense matrix
1005  , bool SO > // Storage order of the adapted dense matrix
1007  SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j ) const
1008 {
1009  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1010  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1011 
1012  if( ( !SO && i > j ) || ( SO && i < j ) )
1013  return matrix_(i,j);
1014  else
1015  return matrix_(j,i);
1016 }
1018 //*************************************************************************************************
1019 
1020 
1021 //*************************************************************************************************
1037 template< typename MT // Type of the adapted dense matrix
1038  , bool SO > // Storage order of the adapted dense matrix
1040  SymmetricMatrix<MT,SO,true,false>::at( size_t i, size_t j )
1041 {
1042  if( i >= rows() ) {
1043  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1044  }
1045  if( j >= columns() ) {
1046  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1047  }
1048  return (*this)(i,j);
1049 }
1051 //*************************************************************************************************
1052 
1053 
1054 //*************************************************************************************************
1070 template< typename MT // Type of the adapted dense matrix
1071  , bool SO > // Storage order of the adapted dense matrix
1073  SymmetricMatrix<MT,SO,true,false>::at( size_t i, size_t j ) const
1074 {
1075  if( i >= rows() ) {
1076  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1077  }
1078  if( j >= columns() ) {
1079  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1080  }
1081  return (*this)(i,j);
1082 }
1084 //*************************************************************************************************
1085 
1086 
1087 //*************************************************************************************************
1101 template< typename MT // Type of the adapted dense matrix
1102  , bool SO > // Storage order of the adapted dense matrix
1103 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1104  SymmetricMatrix<MT,SO,true,false>::data() const noexcept
1105 {
1106  return matrix_.data();
1107 }
1109 //*************************************************************************************************
1110 
1111 
1112 //*************************************************************************************************
1123 template< typename MT // Type of the adapted dense matrix
1124  , bool SO > // Storage order of the adapted dense matrix
1125 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1126  SymmetricMatrix<MT,SO,true,false>::data( size_t i ) const noexcept
1127 {
1128  return matrix_.data(i);
1129 }
1131 //*************************************************************************************************
1132 
1133 
1134 //*************************************************************************************************
1146 template< typename MT // Type of the adapted dense matrix
1147  , bool SO > // Storage order of the adapted dense matrix
1150 {
1151  if( SO )
1152  return Iterator( matrix_, 0UL, i );
1153  else
1154  return Iterator( matrix_, i, 0UL );
1155 }
1157 //*************************************************************************************************
1158 
1159 
1160 //*************************************************************************************************
1172 template< typename MT // Type of the adapted dense matrix
1173  , bool SO > // Storage order of the adapted dense matrix
1176 {
1177  if( SO )
1178  return ConstIterator( matrix_, 0UL, i );
1179  else
1180  return ConstIterator( matrix_, i, 0UL );
1181 }
1183 //*************************************************************************************************
1184 
1185 
1186 //*************************************************************************************************
1198 template< typename MT // Type of the adapted dense matrix
1199  , bool SO > // Storage order of the adapted dense matrix
1202 {
1203  if( SO )
1204  return ConstIterator( matrix_, 0UL, i );
1205  else
1206  return ConstIterator( matrix_, i, 0UL );
1207 }
1209 //*************************************************************************************************
1210 
1211 
1212 //*************************************************************************************************
1224 template< typename MT // Type of the adapted dense matrix
1225  , bool SO > // Storage order of the adapted dense matrix
1228 {
1229  if( SO )
1230  return Iterator( matrix_, rows(), i );
1231  else
1232  return Iterator( matrix_, i, columns() );
1233 }
1235 //*************************************************************************************************
1236 
1237 
1238 //*************************************************************************************************
1250 template< typename MT // Type of the adapted dense matrix
1251  , bool SO > // Storage order of the adapted dense matrix
1253  SymmetricMatrix<MT,SO,true,false>::end( size_t i ) const
1254 {
1255  if( SO )
1256  return ConstIterator( matrix_, rows(), i );
1257  else
1258  return ConstIterator( matrix_, i, columns() );
1259 }
1261 //*************************************************************************************************
1262 
1263 
1264 //*************************************************************************************************
1276 template< typename MT // Type of the adapted dense matrix
1277  , bool SO > // Storage order of the adapted dense matrix
1279  SymmetricMatrix<MT,SO,true,false>::cend( size_t i ) const
1280 {
1281  if( SO )
1282  return ConstIterator( matrix_, rows(), i );
1283  else
1284  return ConstIterator( matrix_, i, columns() );
1285 }
1287 //*************************************************************************************************
1288 
1289 
1290 
1291 
1292 //=================================================================================================
1293 //
1294 // ASSIGNMENT OPERATORS
1295 //
1296 //=================================================================================================
1297 
1298 //*************************************************************************************************
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=( const SymmetricMatrix& rhs )
1312 {
1313  using blaze::resize;
1314 
1315  if( &rhs == this ) return *this;
1316 
1317  resize( matrix_, rhs.rows(), rhs.columns() );
1318  assign( rhs );
1319 
1320  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1321  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1322 
1323  return *this;
1324 }
1326 //*************************************************************************************************
1327 
1328 
1329 //*************************************************************************************************
1336 template< typename MT // Type of the adapted dense matrix
1337  , bool SO > // Storage order of the adapted dense matrix
1338 inline SymmetricMatrix<MT,SO,true,false>&
1339  SymmetricMatrix<MT,SO,true,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1340 {
1341  matrix_ = std::move( rhs.matrix_ );
1342 
1343  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1344  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1345 
1346  return *this;
1347 }
1349 //*************************************************************************************************
1350 
1351 
1352 //*************************************************************************************************
1366 template< typename MT // Type of the adapted dense matrix
1367  , bool SO > // Storage order of the adapted dense matrix
1368 template< typename MT2 > // Type of the right-hand side matrix
1369 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1370  SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1371 {
1372  using blaze::resize;
1373 
1374  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1375  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1376  }
1377 
1378  if( (~rhs).isAliased( this ) ) {
1379  SymmetricMatrix tmp( ~rhs );
1380  swap( tmp );
1381  }
1382  else {
1383  resize( matrix_, (~rhs).rows(), (~rhs).columns() );
1384  if( IsSparseMatrix<MT2>::value )
1385  reset();
1386  assign( ~rhs );
1387  }
1388 
1389  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1390  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1391 
1392  return *this;
1393 }
1395 //*************************************************************************************************
1396 
1397 
1398 //*************************************************************************************************
1412 template< typename MT // Type of the adapted dense matrix
1413  , bool SO > // Storage order of the adapted dense matrix
1414 template< typename MT2 > // Type of the right-hand side matrix
1415 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1416  SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1417 {
1418  using blaze::resize;
1419 
1420  typedef If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> > Tmp;
1421 
1422  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1423  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1424  }
1425 
1426  Tmp tmp( ~rhs );
1427 
1428  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1429  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1430  }
1431 
1432  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1433 
1434  resize( matrix_, tmp.rows(), tmp.columns() );
1435  if( IsSparseMatrix<Tmp>::value )
1436  reset();
1437  assign( tmp );
1438 
1439  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1440  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1441 
1442  return *this;
1443 }
1445 //*************************************************************************************************
1446 
1447 
1448 //*************************************************************************************************
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 SymmetricMatrix<MT,SO,true,false>&
1466  SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,!SO>& rhs )
1467 {
1468  return this->operator=( trans( ~rhs ) );
1469 }
1471 //*************************************************************************************************
1472 
1473 
1474 //*************************************************************************************************
1487 template< typename MT // Type of the adapted dense matrix
1488  , bool SO > // Storage order of the adapted dense matrix
1489 template< typename MT2 > // Type of the right-hand side matrix
1490 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1491  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1492 {
1493  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1494  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1495  }
1496 
1497  addAssign( ~rhs );
1498 
1499  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1500  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1501 
1502  return *this;
1503 }
1505 //*************************************************************************************************
1506 
1507 
1508 //*************************************************************************************************
1521 template< typename MT // Type of the adapted dense matrix
1522  , bool SO > // Storage order of the adapted dense matrix
1523 template< typename MT2 > // Type of the right-hand side matrix
1524 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1525  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1526 {
1527  typedef If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> > Tmp;
1528 
1529  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1530  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1531  }
1532 
1533  Tmp tmp( ~rhs );
1534 
1535  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1536  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1537  }
1538 
1539  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1540 
1541  addAssign( tmp );
1542 
1543  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1544  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1545 
1546  return *this;
1547 }
1549 //*************************************************************************************************
1550 
1551 
1552 //*************************************************************************************************
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 SymmetricMatrix<MT,SO,true,false>&
1570  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,!SO>& rhs )
1571 {
1572  return this->operator+=( trans( ~rhs ) );
1573 }
1575 //*************************************************************************************************
1576 
1577 
1578 //*************************************************************************************************
1591 template< typename MT // Type of the adapted dense matrix
1592  , bool SO > // Storage order of the adapted dense matrix
1593 template< typename MT2 > // Type of the right-hand side matrix
1594 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1595  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1596 {
1597  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1598  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1599  }
1600 
1601  subAssign( ~rhs );
1602 
1603  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1604  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1605 
1606  return *this;
1607 }
1609 //*************************************************************************************************
1610 
1611 
1612 //*************************************************************************************************
1625 template< typename MT // Type of the adapted dense matrix
1626  , bool SO > // Storage order of the adapted dense matrix
1627 template< typename MT2 > // Type of the right-hand side matrix
1628 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1629  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1630 {
1631  typedef If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> > Tmp;
1632 
1633  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1634  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1635  }
1636 
1637  Tmp tmp( ~rhs );
1638 
1639  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1640  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1641  }
1642 
1643  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1644 
1645  subAssign( tmp );
1646 
1647  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1648  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1649 
1650  return *this;
1651 }
1653 //*************************************************************************************************
1654 
1655 
1656 //*************************************************************************************************
1670 template< typename MT // Type of the adapted dense matrix
1671  , bool SO > // Storage order of the adapted dense matrix
1672 template< typename MT2 > // Type of the right-hand side matrix
1673 inline SymmetricMatrix<MT,SO,true,false>&
1674  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,!SO>& rhs )
1675 {
1676  return this->operator-=( trans( ~rhs ) );
1677 }
1679 //*************************************************************************************************
1680 
1681 
1682 //*************************************************************************************************
1694 template< typename MT // Type of the adapted dense matrix
1695  , bool SO > // Storage order of the adapted dense matrix
1696 template< typename MT2 // Type of the right-hand side matrix
1697  , bool SO2 > // Storage order of the right-hand side matrix
1698 inline SymmetricMatrix<MT,SO,true,false>&
1699  SymmetricMatrix<MT,SO,true,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1700 {
1701  using blaze::resize;
1702 
1703  typedef MultTrait_< MT, ResultType_<MT2> > Tmp;
1704 
1706 
1707  if( matrix_.rows() != (~rhs).columns() ) {
1708  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1709  }
1710 
1711  Tmp tmp( (*this) * ~rhs );
1712 
1713  if( !isSymmetric( tmp ) ) {
1714  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1715  }
1716 
1717  resize( matrix_, tmp.rows(), tmp.columns() );
1718  assign( tmp );
1719 
1720  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1721  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1722 
1723  return *this;
1724 }
1726 //*************************************************************************************************
1727 
1728 
1729 //*************************************************************************************************
1737 template< typename MT // Type of the adapted dense matrix
1738  , bool SO > // Storage order of the adapted dense matrix
1739 template< typename Other > // Data type of the right-hand side scalar
1740 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >&
1742 {
1743  if( SO ) {
1744  for( size_t j=0UL; j<columns(); ++j )
1745  for( size_t i=0UL; i<=j; ++i )
1746  matrix_(i,j) *= rhs;
1747  }
1748  else {
1749  for( size_t i=0UL; i<rows(); ++i )
1750  for( size_t j=0UL; j<=i; ++j )
1751  matrix_(i,j) *= rhs;
1752  }
1753 
1754  return *this;
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 Other > // Data type of the right-hand side scalar
1771 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >&
1773 {
1774  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1775 
1776  if( SO ) {
1777  for( size_t j=0UL; j<columns(); ++j )
1778  for( size_t i=0UL; i<=j; ++i )
1779  matrix_(i,j) /= rhs;
1780  }
1781  else {
1782  for( size_t i=0UL; i<rows(); ++i )
1783  for( size_t j=0UL; j<=i; ++j )
1784  matrix_(i,j) /= rhs;
1785  }
1786 
1787  return *this;
1788 }
1790 //*************************************************************************************************
1791 
1792 
1793 
1794 
1795 //=================================================================================================
1796 //
1797 // UTILITY FUNCTIONS
1798 //
1799 //=================================================================================================
1800 
1801 //*************************************************************************************************
1807 template< typename MT // Type of the adapted dense matrix
1808  , bool SO > // Storage order of the adapted dense matrix
1809 inline size_t SymmetricMatrix<MT,SO,true,false>::rows() const noexcept
1810 {
1811  return matrix_.rows();
1812 }
1814 //*************************************************************************************************
1815 
1816 
1817 //*************************************************************************************************
1823 template< typename MT // Type of the adapted dense matrix
1824  , bool SO > // Storage order of the adapted dense matrix
1825 inline size_t SymmetricMatrix<MT,SO,true,false>::columns() const noexcept
1826 {
1827  return matrix_.columns();
1828 }
1830 //*************************************************************************************************
1831 
1832 
1833 //*************************************************************************************************
1845 template< typename MT // Type of the adapted dense matrix
1846  , bool SO > // Storage order of the adapted dense matrix
1847 inline size_t SymmetricMatrix<MT,SO,true,false>::spacing() const noexcept
1848 {
1849  return matrix_.spacing();
1850 }
1852 //*************************************************************************************************
1853 
1854 
1855 //*************************************************************************************************
1861 template< typename MT // Type of the adapted dense matrix
1862  , bool SO > // Storage order of the adapted dense matrix
1863 inline size_t SymmetricMatrix<MT,SO,true,false>::capacity() const noexcept
1864 {
1865  return matrix_.capacity();
1866 }
1868 //*************************************************************************************************
1869 
1870 
1871 //*************************************************************************************************
1882 template< typename MT // Type of the adapted dense matrix
1883  , bool SO > // Storage order of the adapted dense matrix
1884 inline size_t SymmetricMatrix<MT,SO,true,false>::capacity( size_t i ) const noexcept
1885 {
1886  return matrix_.capacity(i);
1887 }
1889 //*************************************************************************************************
1890 
1891 
1892 //*************************************************************************************************
1898 template< typename MT // Type of the adapted dense matrix
1899  , bool SO > // Storage order of the adapted dense matrix
1900 inline size_t SymmetricMatrix<MT,SO,true,false>::nonZeros() const
1901 {
1902  size_t nonzeros( 0UL );
1903 
1904  if( SO )
1905  {
1906  for( size_t j=0UL; j<columns(); ++j ) {
1907  for( size_t i=0UL; i<j; ++i ) {
1908  if( !isDefault( matrix_(i,j) ) )
1909  nonzeros += 2UL;
1910  }
1911  if( !isDefault( matrix_(j,j) ) )
1912  ++nonzeros;
1913  }
1914  }
1915  else
1916  {
1917  for( size_t i=0UL; i<rows(); ++i ) {
1918  for( size_t j=0UL; j<i; ++j ) {
1919  if( !isDefault( matrix_(i,j) ) )
1920  nonzeros += 2UL;
1921  }
1922  if( !isDefault( matrix_(i,i) ) )
1923  ++nonzeros;
1924  }
1925  }
1926 
1927  return nonzeros;
1928 }
1930 //*************************************************************************************************
1931 
1932 
1933 //*************************************************************************************************
1945 template< typename MT // Type of the adapted dense matrix
1946  , bool SO > // Storage order of the adapted dense matrix
1947 inline size_t SymmetricMatrix<MT,SO,true,false>::nonZeros( size_t i ) const
1948 {
1949  size_t nonzeros( 0UL );
1950 
1951  if( SO )
1952  {
1953  for( size_t j=0UL; j<i; ++j ) {
1954  if( !isDefault( matrix_(j,i) ) )
1955  ++nonzeros;
1956  }
1957  for( size_t j=i; j<rows(); ++j ) {
1958  if( !isDefault( matrix_(i,j) ) )
1959  ++nonzeros;
1960  }
1961  }
1962  else
1963  {
1964  for( size_t j=0UL; j<i; ++j ) {
1965  if( !isDefault( matrix_(i,j) ) )
1966  ++nonzeros;
1967  }
1968  for( size_t j=i; j<rows(); ++j ) {
1969  if( !isDefault( matrix_(j,i) ) )
1970  ++nonzeros;
1971  }
1972  }
1973 
1974  return nonzeros;
1975 }
1977 //*************************************************************************************************
1978 
1979 
1980 //*************************************************************************************************
1986 template< typename MT // Type of the adapted dense matrix
1987  , bool SO > // Storage order of the adapted dense matrix
1989 {
1990  using blaze::clear;
1991 
1992  if( SO ) {
1993  for( size_t j=0UL; j<columns(); ++j )
1994  for( size_t i=0UL; i<=j; ++i )
1995  clear( matrix_(i,j) );
1996  }
1997  else {
1998  for( size_t i=0UL; i<rows(); ++i )
1999  for( size_t j=0UL; j<=i; ++j )
2000  clear( matrix_(i,j) );
2001  }
2002 }
2004 //*************************************************************************************************
2005 
2006 
2007 //*************************************************************************************************
2047 template< typename MT // Type of the adapted dense matrix
2048  , bool SO > // Storage order of the adapted dense matrix
2049 inline void SymmetricMatrix<MT,SO,true,false>::reset( size_t i )
2050 {
2051  using blaze::clear;
2052 
2053  for( Iterator element=begin(i); element!=end(i); ++element )
2054  clear( *element );
2055 }
2057 //*************************************************************************************************
2058 
2059 
2060 //*************************************************************************************************
2072 template< typename MT // Type of the adapted dense matrix
2073  , bool SO > // Storage order of the adapted dense matrix
2075 {
2076  using blaze::clear;
2077 
2078  clear( matrix_ );
2079 }
2081 //*************************************************************************************************
2082 
2083 
2084 //*************************************************************************************************
2100 template< typename MT // Type of the adapted dense matrix
2101  , bool SO > // Storage order of the adapted dense matrix
2102 void SymmetricMatrix<MT,SO,true,false>::resize( size_t n, bool preserve )
2103 {
2105 
2106  UNUSED_PARAMETER( preserve );
2107 
2108  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
2109 
2110  const size_t oldsize( matrix_.rows() );
2111 
2112  matrix_.resize( n, n, true );
2113 
2114  if( n > oldsize ) {
2115  const size_t increment( n - oldsize );
2116  submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2117  submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2118  }
2119 }
2121 //*************************************************************************************************
2122 
2123 
2124 //*************************************************************************************************
2137 template< typename MT // Type of the adapted dense matrix
2138  , bool SO > // Storage order of the adapted dense matrix
2139 inline void SymmetricMatrix<MT,SO,true,false>::extend( size_t n, bool preserve )
2140 {
2142 
2143  UNUSED_PARAMETER( preserve );
2144 
2145  resize( rows() + n, true );
2146 }
2148 //*************************************************************************************************
2149 
2150 
2151 //*************************************************************************************************
2161 template< typename MT // Type of the adapted dense matrix
2162  , bool SO > // Storage order of the adapted dense matrix
2163 inline void SymmetricMatrix<MT,SO,true,false>::reserve( size_t elements )
2164 {
2165  matrix_.reserve( elements );
2166 }
2168 //*************************************************************************************************
2169 
2170 
2171 //*************************************************************************************************
2177 template< typename MT // Type of the adapted dense matrix
2178  , bool SO > // Storage order of the adapted dense matrix
2179 inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::transpose()
2180 {
2181  return *this;
2182 }
2184 //*************************************************************************************************
2185 
2186 
2187 //*************************************************************************************************
2193 template< typename MT // Type of the adapted dense matrix
2194  , bool SO > // Storage order of the adapted dense matrix
2195 inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::ctranspose()
2196 {
2197  if( SO ) {
2198  for( size_t j=0UL; j<columns(); ++j )
2199  for( size_t i=0UL; i<=j; ++i )
2200  conjugate( matrix_(i,j) );
2201  }
2202  else {
2203  for( size_t i=0UL; i<rows(); ++i )
2204  for( size_t j=0UL; j<=i; ++j )
2205  conjugate( matrix_(i,j) );
2206  }
2207 
2208  return *this;
2209 }
2211 //*************************************************************************************************
2212 
2213 
2214 //*************************************************************************************************
2221 template< typename MT // Type of the adapted dense matrix
2222  , bool SO > // Storage order of the adapted dense matrix
2223 template< typename Other > // Data type of the scalar value
2224 inline SymmetricMatrix<MT,SO,true,false>&
2225  SymmetricMatrix<MT,SO,true,false>::scale( const Other& scalar )
2226 {
2227  if( SO ) {
2228  for( size_t j=0UL; j<columns(); ++j )
2229  for( size_t i=0UL; i<=j; ++i )
2230  matrix_(i,j) *= scalar;
2231  }
2232  else {
2233  for( size_t i=0UL; i<rows(); ++i )
2234  for( size_t j=0UL; j<=i; ++j )
2235  matrix_(i,j) *= scalar;
2236  }
2237 
2238  return *this;
2239 }
2241 //*************************************************************************************************
2242 
2243 
2244 //*************************************************************************************************
2251 template< typename MT // Type of the adapted dense matrix
2252  , bool SO > // Storage order of the adapted dense matrix
2253 inline void SymmetricMatrix<MT,SO,true,false>::swap( SymmetricMatrix& m ) noexcept
2254 {
2255  using std::swap;
2256 
2257  swap( matrix_, m.matrix_ );
2258 }
2260 //*************************************************************************************************
2261 
2262 
2263 
2264 
2265 //=================================================================================================
2266 //
2267 // DEBUGGING FUNCTIONS
2268 //
2269 //=================================================================================================
2270 
2271 //*************************************************************************************************
2281 template< typename MT // Type of the adapted dense matrix
2282  , bool SO > // Storage order of the adapted dense matrix
2283 inline bool SymmetricMatrix<MT,SO,true,false>::isIntact() const noexcept
2284 {
2285  using blaze::isIntact;
2286 
2287  return isIntact( matrix_ ) &&
2288  ( IsCustom<MT>::value || ( SO ? isUpper( matrix_ ) : isLower( matrix_ ) ) );
2289 }
2291 //*************************************************************************************************
2292 
2293 
2294 
2295 
2296 //=================================================================================================
2297 //
2298 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2299 //
2300 //=================================================================================================
2301 
2302 //*************************************************************************************************
2313 template< typename MT // Type of the adapted dense matrix
2314  , bool SO > // Storage order of the adapted dense matrix
2315 template< typename Other > // Data type of the foreign expression
2316 inline bool SymmetricMatrix<MT,SO,true,false>::canAlias( const Other* alias ) const noexcept
2317 {
2318  return matrix_.canAlias( alias );
2319 }
2321 //*************************************************************************************************
2322 
2323 
2324 //*************************************************************************************************
2335 template< typename MT // Type of the adapted dense matrix
2336  , bool SO > // Storage order of the adapted dense matrix
2337 template< typename Other > // Data type of the foreign expression
2338 inline bool SymmetricMatrix<MT,SO,true,false>::isAliased( const Other* alias ) const noexcept
2339 {
2340  return matrix_.isAliased( alias );
2341 }
2343 //*************************************************************************************************
2344 
2345 
2346 //*************************************************************************************************
2356 template< typename MT // Type of the adapted dense matrix
2357  , bool SO > // Storage order of the adapted dense matrix
2358 inline bool SymmetricMatrix<MT,SO,true,false>::isAligned() const noexcept
2359 {
2360  return matrix_.isAligned();
2361 }
2363 //*************************************************************************************************
2364 
2365 
2366 //*************************************************************************************************
2377 template< typename MT // Type of the adapted dense matrix
2378  , bool SO > // Storage order of the adapted dense matrix
2379 inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign() const noexcept
2380 {
2381  return matrix_.canSMPAssign();
2382 }
2384 //*************************************************************************************************
2385 
2386 
2387 //*************************************************************************************************
2399 template< typename MT // Type of the adapted dense matrix
2400  , bool SO > // Storage order of the adapted dense matrix
2401 template< typename MT2 > // Type of the right-hand side dense matrix
2402 inline void SymmetricMatrix<MT,SO,true,false>::assign( DenseMatrix<MT2,SO>& rhs )
2403 {
2404  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2405  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2406 
2407  if( SO ) {
2408  for( size_t j=0UL; j<columns(); ++j )
2409  for( size_t i=0UL; i<=j; ++i )
2410  matrix_(i,j) = std::move( (~rhs)(i,j) );
2411  }
2412  else {
2413  for( size_t i=0UL; i<rows(); ++i )
2414  for( size_t j=0UL; j<=i; ++j )
2415  matrix_(i,j) = std::move( (~rhs)(i,j) );
2416  }
2417 }
2419 //*************************************************************************************************
2420 
2421 
2422 //*************************************************************************************************
2434 template< typename MT // Type of the adapted dense matrix
2435  , bool SO > // Storage order of the adapted dense matrix
2436 template< typename MT2 > // Type of the right-hand side dense matrix
2437 inline void SymmetricMatrix<MT,SO,true,false>::assign( const DenseMatrix<MT2,SO>& rhs )
2438 {
2439  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2440  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2441 
2442  if( SO ) {
2443  for( size_t j=0UL; j<columns(); ++j )
2444  for( size_t i=0UL; i<=j; ++i )
2445  matrix_(i,j) = (~rhs)(i,j);
2446  }
2447  else {
2448  for( size_t i=0UL; i<rows(); ++i )
2449  for( size_t j=0UL; j<=i; ++j )
2450  matrix_(i,j) = (~rhs)(i,j);
2451  }
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 sparse matrix
2472 inline void SymmetricMatrix<MT,SO,true,false>::assign( const SparseMatrix<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  typedef ConstIterator_<MT2> ConstIterator;
2478 
2479  if( SO ) {
2480  for( size_t j=0UL; j<columns(); ++j ) {
2481  const ConstIterator last( (~rhs).upperBound(j,j) );
2482  for( ConstIterator element=(~rhs).begin(j); element!=last; ++element )
2483  matrix_(element->index(),j) = element->value();
2484  }
2485  }
2486  else {
2487  for( size_t i=0UL; i<rows(); ++i ) {
2488  const ConstIterator last( (~rhs).upperBound(i,i) );
2489  for( ConstIterator element=(~rhs).begin(i); element!=last; ++element )
2490  matrix_(i,element->index()) = element->value();
2491  }
2492  }
2493 }
2495 //*************************************************************************************************
2496 
2497 
2498 //*************************************************************************************************
2510 template< typename MT // Type of the adapted dense matrix
2511  , bool SO > // Storage order of the adapted dense matrix
2512 template< typename MT2 > // Type of the right-hand side dense matrix
2513 inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const DenseMatrix<MT2,SO>& rhs )
2514 {
2515  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2516  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2517 
2518  if( SO ) {
2519  for( size_t j=0UL; j<columns(); ++j )
2520  for( size_t i=0UL; i<=j; ++i )
2521  matrix_(i,j) += (~rhs)(i,j);
2522  }
2523  else {
2524  for( size_t i=0UL; i<rows(); ++i )
2525  for( size_t j=0UL; j<=i; ++j )
2526  matrix_(i,j) += (~rhs)(i,j);
2527  }
2528 }
2530 //*************************************************************************************************
2531 
2532 
2533 //*************************************************************************************************
2545 template< typename MT // Type of the adapted dense matrix
2546  , bool SO > // Storage order of the adapted dense matrix
2547 template< typename MT2 > // Type of the right-hand side sparse matrix
2548 inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const SparseMatrix<MT2,SO>& rhs )
2549 {
2550  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2551  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2552 
2553  typedef ConstIterator_<MT2> ConstIterator;
2554 
2555  if( SO ) {
2556  for( size_t j=0UL; j<columns(); ++j ) {
2557  const ConstIterator last( (~rhs).upperBound(j,j) );
2558  for( ConstIterator element=(~rhs).begin(j); element!=last; ++element )
2559  matrix_(element->index(),j) += element->value();
2560  }
2561  }
2562  else {
2563  for( size_t i=0UL; i<rows(); ++i ) {
2564  const ConstIterator last( (~rhs).upperBound(i,i) );
2565  for( ConstIterator element=(~rhs).begin(i); element!=last; ++element )
2566  matrix_(i,element->index()) += element->value();
2567  }
2568  }
2569 }
2571 //*************************************************************************************************
2572 
2573 
2574 //*************************************************************************************************
2586 template< typename MT // Type of the adapted dense matrix
2587  , bool SO > // Storage order of the adapted dense matrix
2588 template< typename MT2 > // Type of the right-hand side dense matrix
2589 inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const DenseMatrix<MT2,SO>& rhs )
2590 {
2591  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2592  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2593 
2594  if( SO ) {
2595  for( size_t j=0UL; j<columns(); ++j )
2596  for( size_t i=0UL; i<=j; ++i )
2597  matrix_(i,j) -= (~rhs)(i,j);
2598  }
2599  else {
2600  for( size_t i=0UL; i<rows(); ++i )
2601  for( size_t j=0UL; j<=i; ++j )
2602  matrix_(i,j) -= (~rhs)(i,j);
2603  }
2604 }
2606 //*************************************************************************************************
2607 
2608 
2609 //*************************************************************************************************
2621 template< typename MT // Type of the adapted dense matrix
2622  , bool SO > // Storage order of the adapted dense matrix
2623 template< typename MT2 > // Type of the right-hand side sparse matrix
2624 inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const SparseMatrix<MT2,SO>& rhs )
2625 {
2626  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2627  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2628 
2629  typedef ConstIterator_<MT2> ConstIterator;
2630 
2631  if( SO ) {
2632  for( size_t j=0UL; j<columns(); ++j ) {
2633  const ConstIterator last( (~rhs).upperBound(j,j) );
2634  for( ConstIterator element=(~rhs).begin(j); element!=last; ++element )
2635  matrix_(element->index(),j) -= element->value();
2636  }
2637  }
2638  else {
2639  for( size_t i=0UL; i<rows(); ++i ) {
2640  const ConstIterator last( (~rhs).upperBound(i,i) );
2641  for( ConstIterator element=(~rhs).begin(i); element!=last; ++element )
2642  matrix_(i,element->index()) -= element->value();
2643  }
2644  }
2645 }
2647 //*************************************************************************************************
2648 
2649 } // namespace blaze
2650 
2651 #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.
#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.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7800
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:346
Header file for basic type definitions.
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:1339
Constraint on the data type.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:689
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:188
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:699
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2643
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5077
bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:366
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:590
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2636
bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:442
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:384
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
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Constraint on the data type.
STL namespace.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2639
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, ColumnExprTrait_< MT > > column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:126
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:298
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1036
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:232
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Header file for the implementation of the base template of the SymmetricMatrix.
Constraint on the data type.
Constraint on the data type.
constexpr bool spacing
Adding an additional spacing line between two log messages.This setting gives the opportunity to add ...
Definition: Logging.h:70
Header file for the IsSquare type trait.
Constraint on the data type.
bool isDefault(const CompressedMatrix< Type, SO > &m)
Returns whether the given compressed matrix is in default state.
Definition: CompressedMatrix.h:5104
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.
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:5148
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:5131
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Header file for the IsSMPAssignable type trait.
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the DenseMatrix base class.
Header file for the Columns type trait.
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:330
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2640
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1267
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:538
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:254
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2641
Header file for the RemoveAdaptor type trait.
Header file for all forward declarations for expression class templates.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
Header file for the EnableIf class template.
Header file for utility functions for dense matrices.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT > >, RowExprTrait_< MT > > row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:126
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2642
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:258
Constraint on the data type.
Constraint on the data type.
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric< T >::value)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
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:223
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:314
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2637
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a 'res...
Definition: Resizable.h:61
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:950
Header file for the IsComputation type trait class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2638
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
SubmatrixExprTrait_< MT, unaligned > submatrix(Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:167
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:609
#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:564