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 NewType > // Data type of the other matrix
137  struct Rebind {
139  typedef SymmetricMatrix< typename MT::template Rebind<NewType>::Other > 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  typedef SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other > 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  typedef If_< IsConst<MatrixType>
164  , ConstReference_<MatrixType>
165  , Reference_<MatrixType> > Reference;
166 
167  typedef std::random_access_iterator_tag IteratorCategory;
168  typedef RemoveReference_<Reference> ValueType;
169  typedef ValueType* PointerType;
170  typedef Reference ReferenceType;
171  typedef ptrdiff_t DifferenceType;
172 
173  // STL iterator requirements
174  typedef IteratorCategory iterator_category;
175  typedef ValueType value_type;
176  typedef PointerType pointer;
177  typedef ReferenceType reference;
178  typedef DifferenceType difference_type;
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  typedef MatrixIterator<MT> Iterator;
459  typedef MatrixIterator<const MT> ConstIterator;
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  template< typename Deleter >
480  explicit inline SymmetricMatrix( ElementType* ptr, size_t n, Deleter d );
481 
482  template< typename Deleter >
483  explicit inline SymmetricMatrix( ElementType* ptr, size_t n, size_t nn, Deleter d );
484 
485  inline SymmetricMatrix( const SymmetricMatrix& m );
486  inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
487 
488  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,SO>& m );
489  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,!SO>& m );
491  //**********************************************************************************************
492 
493  //**Destructor**********************************************************************************
494  // No explicitly declared destructor.
495  //**********************************************************************************************
496 
497  //**Data access functions***********************************************************************
500  inline Reference operator()( size_t i, size_t j );
501  inline ConstReference operator()( size_t i, size_t j ) const;
502  inline Reference at( size_t i, size_t j );
503  inline ConstReference at( size_t i, size_t j ) const;
504  inline ConstPointer data () const noexcept;
505  inline ConstPointer data ( size_t i ) const noexcept;
506  inline Iterator begin ( size_t i );
507  inline ConstIterator begin ( size_t i ) const;
508  inline ConstIterator cbegin( size_t i ) const;
509  inline Iterator end ( size_t i );
510  inline ConstIterator end ( size_t i ) const;
511  inline ConstIterator cend ( size_t i ) const;
513  //**********************************************************************************************
514 
515  //**Assignment operators************************************************************************
518  inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
519  inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
520 
521  template< typename MT2 >
522  inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
523 
524  template< typename MT2 >
525  inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator=( const Matrix<MT2,SO>& rhs );
526 
527  template< typename MT2 >
528  inline SymmetricMatrix& operator=( const Matrix<MT2,!SO>& rhs );
529 
530  template< typename MT2 >
531  inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator+=( const Matrix<MT2,SO>& rhs );
532 
533  template< typename MT2 >
534  inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator+=( const Matrix<MT2,SO>& rhs );
535 
536  template< typename MT2 >
537  inline SymmetricMatrix& operator+=( const Matrix<MT2,!SO>& rhs );
538 
539  template< typename MT2 >
540  inline DisableIf_< IsComputation<MT2>, SymmetricMatrix& > operator-=( const Matrix<MT2,SO>& rhs );
541 
542  template< typename MT2 >
543  inline EnableIf_< IsComputation<MT2>, SymmetricMatrix& > operator-=( const Matrix<MT2,SO>& rhs );
544 
545  template< typename MT2 >
546  inline SymmetricMatrix& operator-=( const Matrix<MT2,!SO>& rhs );
547 
548  template< typename MT2, bool SO2 >
549  inline SymmetricMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
550 
551  template< typename Other >
552  inline EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator*=( Other rhs );
553 
554  template< typename Other >
555  inline EnableIf_< IsNumeric<Other>, SymmetricMatrix >& operator/=( Other 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 swap( SymmetricMatrix& m ) noexcept;
577  //**********************************************************************************************
578 
579  //**Numeric functions***************************************************************************
582  inline SymmetricMatrix& transpose();
583  inline SymmetricMatrix& ctranspose();
584 
585  template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
587  //**********************************************************************************************
588 
589  //**Debugging functions*************************************************************************
592  inline bool isIntact() const noexcept;
594  //**********************************************************************************************
595 
596  //**Expression template evaluation functions****************************************************
599  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
600  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
601 
602  inline bool isAligned () const noexcept;
603  inline bool canSMPAssign() const noexcept;
605  //**********************************************************************************************
606 
607  private:
608  //**Expression template evaluation functions****************************************************
611  template< typename MT2 > inline void assign ( DenseMatrix <MT2,SO>& rhs );
612  template< typename MT2 > inline void assign ( const DenseMatrix <MT2,SO>& rhs );
613  template< typename MT2 > inline void assign ( const SparseMatrix<MT2,SO>& rhs );
614  template< typename MT2 > inline void addAssign( const DenseMatrix <MT2,SO>& rhs );
615  template< typename MT2 > inline void addAssign( const SparseMatrix<MT2,SO>& rhs );
616  template< typename MT2 > inline void subAssign( const DenseMatrix <MT2,SO>& rhs );
617  template< typename MT2 > inline void subAssign( const SparseMatrix<MT2,SO>& rhs );
619  //**********************************************************************************************
620 
621  //**Member variables****************************************************************************
624  MT matrix_;
625 
626  //**********************************************************************************************
627 
628  //**Friend declarations*************************************************************************
629  template< bool RF, typename MT2, bool SO2, bool DF2, bool NF2 >
630  friend bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
631  //**********************************************************************************************
632 
633  //**Compile time checks*************************************************************************
647  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
648  //**********************************************************************************************
649 };
651 //*************************************************************************************************
652 
653 
654 
655 
656 //=================================================================================================
657 //
658 // CONSTRUCTORS
659 //
660 //=================================================================================================
661 
662 //*************************************************************************************************
666 template< typename MT // Type of the adapted dense matrix
667  , bool SO > // Storage order of the adapted dense matrix
668 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
669  : matrix_() // The adapted dense matrix
670 {
671  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
672 }
674 //*************************************************************************************************
675 
676 
677 //*************************************************************************************************
683 template< typename MT // Type of the adapted dense matrix
684  , bool SO > // Storage order of the adapted dense matrix
685 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( size_t n )
686  : matrix_( n, n ) // The adapted dense matrix
687 {
689 
690  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
691 }
693 //*************************************************************************************************
694 
695 
696 //*************************************************************************************************
717 template< typename MT // Type of the adapted dense matrix
718  , bool SO > // Storage order of the adapted dense matrix
719 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n )
720  : matrix_( ptr, n, n ) // The adapted dense matrix
721 {
722  if( !isSymmetric( matrix_ ) ) {
723  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
724  }
725 
726  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
727 }
729 //*************************************************************************************************
730 
731 
732 //*************************************************************************************************
755 template< typename MT // Type of the adapted dense matrix
756  , bool SO > // Storage order of the adapted dense matrix
757 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n, size_t nn )
758  : matrix_( ptr, n, n, nn ) // The adapted dense matrix
759 {
760  if( !isSymmetric( matrix_ ) ) {
761  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
762  }
763 
764  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
765 }
767 //*************************************************************************************************
768 
769 
770 //*************************************************************************************************
791 template< typename MT // Type of the adapted dense matrix
792  , bool SO > // Storage order of the adapted dense matrix
793 template< typename Deleter > // Type of the custom deleter
794 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n, Deleter d )
795  : matrix_( ptr, n, n, d ) // The adapted dense matrix
796 {
797  if( !isSymmetric( matrix_ ) ) {
798  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
799  }
800 
801  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
802 }
804 //*************************************************************************************************
805 
806 
807 //*************************************************************************************************
829 template< typename MT // Type of the adapted dense matrix
830  , bool SO > // Storage order of the adapted dense matrix
831 template< typename Deleter > // Type of the custom deleter
832 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n, size_t nn, Deleter d )
833  : matrix_( ptr, n, n, nn, d ) // The adapted dense matrix
834 {
835  if( !isSymmetric( matrix_ ) ) {
836  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
837  }
838 
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( const SymmetricMatrix& m )
854  : matrix_( 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 //*************************************************************************************************
869 template< typename MT // Type of the adapted dense matrix
870  , bool SO > // Storage order of the adapted dense matrix
871 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
872  : matrix_( std::move( m.matrix_ ) ) // The adapted dense matrix
873 {
874  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
875  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
876 }
878 //*************************************************************************************************
879 
880 
881 //*************************************************************************************************
891 template< typename MT // Type of the adapted dense matrix
892  , bool SO > // Storage order of the adapted dense matrix
893 template< typename MT2 > // Type of the foreign matrix
894 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,SO>& m )
895  : matrix_() // The adapted dense matrix
896 {
897  using blaze::resize;
898 
899  typedef RemoveAdaptor_<ResultType_<MT2> > RT;
900  typedef If_< IsComputation<MT2>, RT, const MT2& > Tmp;
901 
902  if( IsSymmetric<MT2>::value ) {
903  resize( matrix_, (~m).rows(), (~m).columns() );
904  assign( ~m );
905  }
906  else {
907  Tmp tmp( ~m );
908 
909  if( !isSymmetric( tmp ) ) {
910  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
911  }
912 
913  resize( matrix_, tmp.rows(), tmp.rows() );
914  assign( tmp );
915  }
916 
917  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
918  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
919 }
921 //*************************************************************************************************
922 
923 
924 //*************************************************************************************************
934 template< typename MT // Type of the adapted dense matrix
935  , bool SO > // Storage order of the adapted dense matrix
936 template< typename MT2 > // Type of the foreign matrix
937 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
938  : matrix_() // The adapted dense matrix
939 {
940  using blaze::resize;
941 
942  typedef RemoveAdaptor_< ResultType_<MT2> > RT;
943  typedef If_< IsComputation<MT2>, RT, const MT2& > Tmp;
944 
945  if( IsSymmetric<MT2>::value ) {
946  resize( matrix_, (~m).rows(), (~m).columns() );
947  assign( trans( ~m ) );
948  }
949  else {
950  Tmp tmp( ~m );
951 
952  if( !isSymmetric( tmp ) ) {
953  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
954  }
955 
956  resize( matrix_, tmp.rows(), tmp.rows() );
957  assign( trans( tmp ) );
958  }
959 
960  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
961  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
962 }
964 //*************************************************************************************************
965 
966 
967 
968 
969 //=================================================================================================
970 //
971 // DATA ACCESS FUNCTIONS
972 //
973 //=================================================================================================
974 
975 //*************************************************************************************************
990 template< typename MT // Type of the adapted dense matrix
991  , bool SO > // Storage order of the adapted dense matrix
993  SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j )
994 {
995  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
996  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
997 
998  if( ( !SO && i > j ) || ( SO && i < j ) )
999  return matrix_(i,j);
1000  else
1001  return matrix_(j,i);
1002 }
1004 //*************************************************************************************************
1005 
1006 
1007 //*************************************************************************************************
1022 template< typename MT // Type of the adapted dense matrix
1023  , bool SO > // Storage order of the adapted dense matrix
1025  SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j ) const
1026 {
1027  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1028  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1029 
1030  if( ( !SO && i > j ) || ( SO && i < j ) )
1031  return matrix_(i,j);
1032  else
1033  return matrix_(j,i);
1034 }
1036 //*************************************************************************************************
1037 
1038 
1039 //*************************************************************************************************
1055 template< typename MT // Type of the adapted dense matrix
1056  , bool SO > // Storage order of the adapted dense matrix
1058  SymmetricMatrix<MT,SO,true,false>::at( size_t i, size_t j )
1059 {
1060  if( i >= rows() ) {
1061  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1062  }
1063  if( j >= columns() ) {
1064  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1065  }
1066  return (*this)(i,j);
1067 }
1069 //*************************************************************************************************
1070 
1071 
1072 //*************************************************************************************************
1088 template< typename MT // Type of the adapted dense matrix
1089  , bool SO > // Storage order of the adapted dense matrix
1091  SymmetricMatrix<MT,SO,true,false>::at( size_t i, size_t j ) const
1092 {
1093  if( i >= rows() ) {
1094  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1095  }
1096  if( j >= columns() ) {
1097  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1098  }
1099  return (*this)(i,j);
1100 }
1102 //*************************************************************************************************
1103 
1104 
1105 //*************************************************************************************************
1119 template< typename MT // Type of the adapted dense matrix
1120  , bool SO > // Storage order of the adapted dense matrix
1121 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1122  SymmetricMatrix<MT,SO,true,false>::data() const noexcept
1123 {
1124  return matrix_.data();
1125 }
1127 //*************************************************************************************************
1128 
1129 
1130 //*************************************************************************************************
1141 template< typename MT // Type of the adapted dense matrix
1142  , bool SO > // Storage order of the adapted dense matrix
1143 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1144  SymmetricMatrix<MT,SO,true,false>::data( size_t i ) const noexcept
1145 {
1146  return matrix_.data(i);
1147 }
1149 //*************************************************************************************************
1150 
1151 
1152 //*************************************************************************************************
1164 template< typename MT // Type of the adapted dense matrix
1165  , bool SO > // Storage order of the adapted dense matrix
1168 {
1169  if( SO )
1170  return Iterator( matrix_, 0UL, i );
1171  else
1172  return Iterator( matrix_, i, 0UL );
1173 }
1175 //*************************************************************************************************
1176 
1177 
1178 //*************************************************************************************************
1190 template< typename MT // Type of the adapted dense matrix
1191  , bool SO > // Storage order of the adapted dense matrix
1194 {
1195  if( SO )
1196  return ConstIterator( matrix_, 0UL, i );
1197  else
1198  return ConstIterator( matrix_, i, 0UL );
1199 }
1201 //*************************************************************************************************
1202 
1203 
1204 //*************************************************************************************************
1216 template< typename MT // Type of the adapted dense matrix
1217  , bool SO > // Storage order of the adapted dense matrix
1220 {
1221  if( SO )
1222  return ConstIterator( matrix_, 0UL, i );
1223  else
1224  return ConstIterator( matrix_, i, 0UL );
1225 }
1227 //*************************************************************************************************
1228 
1229 
1230 //*************************************************************************************************
1242 template< typename MT // Type of the adapted dense matrix
1243  , bool SO > // Storage order of the adapted dense matrix
1246 {
1247  if( SO )
1248  return Iterator( matrix_, rows(), i );
1249  else
1250  return Iterator( matrix_, i, columns() );
1251 }
1253 //*************************************************************************************************
1254 
1255 
1256 //*************************************************************************************************
1268 template< typename MT // Type of the adapted dense matrix
1269  , bool SO > // Storage order of the adapted dense matrix
1271  SymmetricMatrix<MT,SO,true,false>::end( size_t i ) const
1272 {
1273  if( SO )
1274  return ConstIterator( matrix_, rows(), i );
1275  else
1276  return ConstIterator( matrix_, i, columns() );
1277 }
1279 //*************************************************************************************************
1280 
1281 
1282 //*************************************************************************************************
1294 template< typename MT // Type of the adapted dense matrix
1295  , bool SO > // Storage order of the adapted dense matrix
1297  SymmetricMatrix<MT,SO,true,false>::cend( size_t i ) const
1298 {
1299  if( SO )
1300  return ConstIterator( matrix_, rows(), i );
1301  else
1302  return ConstIterator( matrix_, i, columns() );
1303 }
1305 //*************************************************************************************************
1306 
1307 
1308 
1309 
1310 //=================================================================================================
1311 //
1312 // ASSIGNMENT OPERATORS
1313 //
1314 //=================================================================================================
1315 
1316 //*************************************************************************************************
1326 template< typename MT // Type of the adapted dense matrix
1327  , bool SO > // Storage order of the adapted dense matrix
1328 inline SymmetricMatrix<MT,SO,true,false>&
1329  SymmetricMatrix<MT,SO,true,false>::operator=( const SymmetricMatrix& rhs )
1330 {
1331  using blaze::resize;
1332 
1333  if( &rhs == this ) return *this;
1334 
1335  resize( matrix_, rhs.rows(), rhs.columns() );
1336  assign( rhs );
1337 
1338  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1339  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1340 
1341  return *this;
1342 }
1344 //*************************************************************************************************
1345 
1346 
1347 //*************************************************************************************************
1354 template< typename MT // Type of the adapted dense matrix
1355  , bool SO > // Storage order of the adapted dense matrix
1356 inline SymmetricMatrix<MT,SO,true,false>&
1357  SymmetricMatrix<MT,SO,true,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1358 {
1359  matrix_ = std::move( rhs.matrix_ );
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 DisableIf_< 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  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1393  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1394  }
1395 
1396  if( (~rhs).isAliased( this ) ) {
1397  SymmetricMatrix tmp( ~rhs );
1398  swap( tmp );
1399  }
1400  else {
1401  resize( matrix_, (~rhs).rows(), (~rhs).columns() );
1402  if( IsSparseMatrix<MT2>::value )
1403  reset();
1404  assign( ~rhs );
1405  }
1406 
1407  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1408  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1409 
1410  return *this;
1411 }
1413 //*************************************************************************************************
1414 
1415 
1416 //*************************************************************************************************
1430 template< typename MT // Type of the adapted dense matrix
1431  , bool SO > // Storage order of the adapted dense matrix
1432 template< typename MT2 > // Type of the right-hand side matrix
1433 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1434  SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1435 {
1436  using blaze::resize;
1437 
1438  typedef If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> > Tmp;
1439 
1440  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1441  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1442  }
1443 
1444  Tmp tmp( ~rhs );
1445 
1446  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1447  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1448  }
1449 
1450  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1451 
1452  resize( matrix_, tmp.rows(), tmp.columns() );
1453  if( IsSparseMatrix<Tmp>::value )
1454  reset();
1455  assign( tmp );
1456 
1457  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1458  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1459 
1460  return *this;
1461 }
1463 //*************************************************************************************************
1464 
1465 
1466 //*************************************************************************************************
1480 template< typename MT // Type of the adapted dense matrix
1481  , bool SO > // Storage order of the adapted dense matrix
1482 template< typename MT2 > // Type of the right-hand side matrix
1483 inline SymmetricMatrix<MT,SO,true,false>&
1484  SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,!SO>& rhs )
1485 {
1486  return this->operator=( trans( ~rhs ) );
1487 }
1489 //*************************************************************************************************
1490 
1491 
1492 //*************************************************************************************************
1505 template< typename MT // Type of the adapted dense matrix
1506  , bool SO > // Storage order of the adapted dense matrix
1507 template< typename MT2 > // Type of the right-hand side matrix
1508 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1509  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1510 {
1511  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1512  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1513  }
1514 
1515  addAssign( ~rhs );
1516 
1517  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1518  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1519 
1520  return *this;
1521 }
1523 //*************************************************************************************************
1524 
1525 
1526 //*************************************************************************************************
1539 template< typename MT // Type of the adapted dense matrix
1540  , bool SO > // Storage order of the adapted dense matrix
1541 template< typename MT2 > // Type of the right-hand side matrix
1542 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1543  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1544 {
1545  typedef If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> > Tmp;
1546 
1547  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1548  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1549  }
1550 
1551  Tmp tmp( ~rhs );
1552 
1553  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1554  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1555  }
1556 
1557  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1558 
1559  addAssign( tmp );
1560 
1561  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1562  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1563 
1564  return *this;
1565 }
1567 //*************************************************************************************************
1568 
1569 
1570 //*************************************************************************************************
1584 template< typename MT // Type of the adapted dense matrix
1585  , bool SO > // Storage order of the adapted dense matrix
1586 template< typename MT2 > // Type of the right-hand side matrix
1587 inline SymmetricMatrix<MT,SO,true,false>&
1588  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,!SO>& rhs )
1589 {
1590  return this->operator+=( trans( ~rhs ) );
1591 }
1593 //*************************************************************************************************
1594 
1595 
1596 //*************************************************************************************************
1609 template< typename MT // Type of the adapted dense matrix
1610  , bool SO > // Storage order of the adapted dense matrix
1611 template< typename MT2 > // Type of the right-hand side matrix
1612 inline DisableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1613  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1614 {
1615  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1616  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1617  }
1618 
1619  subAssign( ~rhs );
1620 
1621  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1622  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1623 
1624  return *this;
1625 }
1627 //*************************************************************************************************
1628 
1629 
1630 //*************************************************************************************************
1643 template< typename MT // Type of the adapted dense matrix
1644  , bool SO > // Storage order of the adapted dense matrix
1645 template< typename MT2 > // Type of the right-hand side matrix
1646 inline EnableIf_< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >
1647  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1648 {
1649  typedef If_< IsSymmetric<MT2>, CompositeType_<MT2>, ResultType_<MT2> > Tmp;
1650 
1651  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1652  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1653  }
1654 
1655  Tmp tmp( ~rhs );
1656 
1657  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) ) {
1658  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1659  }
1660 
1661  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1662 
1663  subAssign( tmp );
1664 
1665  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1666  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1667 
1668  return *this;
1669 }
1671 //*************************************************************************************************
1672 
1673 
1674 //*************************************************************************************************
1688 template< typename MT // Type of the adapted dense matrix
1689  , bool SO > // Storage order of the adapted dense matrix
1690 template< typename MT2 > // Type of the right-hand side matrix
1691 inline SymmetricMatrix<MT,SO,true,false>&
1692  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,!SO>& rhs )
1693 {
1694  return this->operator-=( trans( ~rhs ) );
1695 }
1697 //*************************************************************************************************
1698 
1699 
1700 //*************************************************************************************************
1712 template< typename MT // Type of the adapted dense matrix
1713  , bool SO > // Storage order of the adapted dense matrix
1714 template< typename MT2 // Type of the right-hand side matrix
1715  , bool SO2 > // Storage order of the right-hand side matrix
1716 inline SymmetricMatrix<MT,SO,true,false>&
1717  SymmetricMatrix<MT,SO,true,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1718 {
1719  using blaze::resize;
1720 
1721  typedef MultTrait_< MT, ResultType_<MT2> > Tmp;
1722 
1724 
1725  if( matrix_.rows() != (~rhs).columns() ) {
1726  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1727  }
1728 
1729  Tmp tmp( (*this) * ~rhs );
1730 
1731  if( !isSymmetric( tmp ) ) {
1732  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1733  }
1734 
1735  resize( matrix_, tmp.rows(), tmp.columns() );
1736  assign( tmp );
1737 
1738  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1739  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1740 
1741  return *this;
1742 }
1744 //*************************************************************************************************
1745 
1746 
1747 //*************************************************************************************************
1755 template< typename MT // Type of the adapted dense matrix
1756  , bool SO > // Storage order of the adapted dense matrix
1757 template< typename Other > // Data type of the right-hand side scalar
1758 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >&
1760 {
1761  if( SO ) {
1762  for( size_t j=0UL; j<columns(); ++j )
1763  for( size_t i=0UL; i<=j; ++i )
1764  matrix_(i,j) *= rhs;
1765  }
1766  else {
1767  for( size_t i=0UL; i<rows(); ++i )
1768  for( size_t j=0UL; j<=i; ++j )
1769  matrix_(i,j) *= rhs;
1770  }
1771 
1772  return *this;
1773 }
1775 //*************************************************************************************************
1776 
1777 
1778 //*************************************************************************************************
1786 template< typename MT // Type of the adapted dense matrix
1787  , bool SO > // Storage order of the adapted dense matrix
1788 template< typename Other > // Data type of the right-hand side scalar
1789 inline EnableIf_< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >&
1791 {
1792  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1793 
1794  if( SO ) {
1795  for( size_t j=0UL; j<columns(); ++j )
1796  for( size_t i=0UL; i<=j; ++i )
1797  matrix_(i,j) /= rhs;
1798  }
1799  else {
1800  for( size_t i=0UL; i<rows(); ++i )
1801  for( size_t j=0UL; j<=i; ++j )
1802  matrix_(i,j) /= rhs;
1803  }
1804 
1805  return *this;
1806 }
1808 //*************************************************************************************************
1809 
1810 
1811 
1812 
1813 //=================================================================================================
1814 //
1815 // UTILITY FUNCTIONS
1816 //
1817 //=================================================================================================
1818 
1819 //*************************************************************************************************
1825 template< typename MT // Type of the adapted dense matrix
1826  , bool SO > // Storage order of the adapted dense matrix
1827 inline size_t SymmetricMatrix<MT,SO,true,false>::rows() const noexcept
1828 {
1829  return matrix_.rows();
1830 }
1832 //*************************************************************************************************
1833 
1834 
1835 //*************************************************************************************************
1841 template< typename MT // Type of the adapted dense matrix
1842  , bool SO > // Storage order of the adapted dense matrix
1843 inline size_t SymmetricMatrix<MT,SO,true,false>::columns() const noexcept
1844 {
1845  return matrix_.columns();
1846 }
1848 //*************************************************************************************************
1849 
1850 
1851 //*************************************************************************************************
1863 template< typename MT // Type of the adapted dense matrix
1864  , bool SO > // Storage order of the adapted dense matrix
1865 inline size_t SymmetricMatrix<MT,SO,true,false>::spacing() const noexcept
1866 {
1867  return matrix_.spacing();
1868 }
1870 //*************************************************************************************************
1871 
1872 
1873 //*************************************************************************************************
1879 template< typename MT // Type of the adapted dense matrix
1880  , bool SO > // Storage order of the adapted dense matrix
1881 inline size_t SymmetricMatrix<MT,SO,true,false>::capacity() const noexcept
1882 {
1883  return matrix_.capacity();
1884 }
1886 //*************************************************************************************************
1887 
1888 
1889 //*************************************************************************************************
1900 template< typename MT // Type of the adapted dense matrix
1901  , bool SO > // Storage order of the adapted dense matrix
1902 inline size_t SymmetricMatrix<MT,SO,true,false>::capacity( size_t i ) const noexcept
1903 {
1904  return matrix_.capacity(i);
1905 }
1907 //*************************************************************************************************
1908 
1909 
1910 //*************************************************************************************************
1916 template< typename MT // Type of the adapted dense matrix
1917  , bool SO > // Storage order of the adapted dense matrix
1918 inline size_t SymmetricMatrix<MT,SO,true,false>::nonZeros() const
1919 {
1920  size_t nonzeros( 0UL );
1921 
1922  if( SO )
1923  {
1924  for( size_t j=0UL; j<columns(); ++j ) {
1925  for( size_t i=0UL; i<j; ++i ) {
1926  if( !isDefault( matrix_(i,j) ) )
1927  nonzeros += 2UL;
1928  }
1929  if( !isDefault( matrix_(j,j) ) )
1930  ++nonzeros;
1931  }
1932  }
1933  else
1934  {
1935  for( size_t i=0UL; i<rows(); ++i ) {
1936  for( size_t j=0UL; j<i; ++j ) {
1937  if( !isDefault( matrix_(i,j) ) )
1938  nonzeros += 2UL;
1939  }
1940  if( !isDefault( matrix_(i,i) ) )
1941  ++nonzeros;
1942  }
1943  }
1944 
1945  return nonzeros;
1946 }
1948 //*************************************************************************************************
1949 
1950 
1951 //*************************************************************************************************
1963 template< typename MT // Type of the adapted dense matrix
1964  , bool SO > // Storage order of the adapted dense matrix
1965 inline size_t SymmetricMatrix<MT,SO,true,false>::nonZeros( size_t i ) const
1966 {
1967  size_t nonzeros( 0UL );
1968 
1969  if( SO )
1970  {
1971  for( size_t j=0UL; j<i; ++j ) {
1972  if( !isDefault( matrix_(j,i) ) )
1973  ++nonzeros;
1974  }
1975  for( size_t j=i; j<rows(); ++j ) {
1976  if( !isDefault( matrix_(i,j) ) )
1977  ++nonzeros;
1978  }
1979  }
1980  else
1981  {
1982  for( size_t j=0UL; j<i; ++j ) {
1983  if( !isDefault( matrix_(i,j) ) )
1984  ++nonzeros;
1985  }
1986  for( size_t j=i; j<rows(); ++j ) {
1987  if( !isDefault( matrix_(j,i) ) )
1988  ++nonzeros;
1989  }
1990  }
1991 
1992  return nonzeros;
1993 }
1995 //*************************************************************************************************
1996 
1997 
1998 //*************************************************************************************************
2004 template< typename MT // Type of the adapted dense matrix
2005  , bool SO > // Storage order of the adapted dense matrix
2007 {
2008  using blaze::clear;
2009 
2010  if( SO ) {
2011  for( size_t j=0UL; j<columns(); ++j )
2012  for( size_t i=0UL; i<=j; ++i )
2013  clear( matrix_(i,j) );
2014  }
2015  else {
2016  for( size_t i=0UL; i<rows(); ++i )
2017  for( size_t j=0UL; j<=i; ++j )
2018  clear( matrix_(i,j) );
2019  }
2020 }
2022 //*************************************************************************************************
2023 
2024 
2025 //*************************************************************************************************
2065 template< typename MT // Type of the adapted dense matrix
2066  , bool SO > // Storage order of the adapted dense matrix
2067 inline void SymmetricMatrix<MT,SO,true,false>::reset( size_t i )
2068 {
2069  using blaze::clear;
2070 
2071  for( Iterator element=begin(i); element!=end(i); ++element )
2072  clear( *element );
2073 }
2075 //*************************************************************************************************
2076 
2077 
2078 //*************************************************************************************************
2090 template< typename MT // Type of the adapted dense matrix
2091  , bool SO > // Storage order of the adapted dense matrix
2093 {
2094  using blaze::clear;
2095 
2096  clear( matrix_ );
2097 }
2099 //*************************************************************************************************
2100 
2101 
2102 //*************************************************************************************************
2118 template< typename MT // Type of the adapted dense matrix
2119  , bool SO > // Storage order of the adapted dense matrix
2120 void SymmetricMatrix<MT,SO,true,false>::resize( size_t n, bool preserve )
2121 {
2123 
2124  UNUSED_PARAMETER( preserve );
2125 
2126  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
2127 
2128  const size_t oldsize( matrix_.rows() );
2129 
2130  matrix_.resize( n, n, true );
2131 
2132  if( n > oldsize ) {
2133  const size_t increment( n - oldsize );
2134  submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2135  submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2136  }
2137 }
2139 //*************************************************************************************************
2140 
2141 
2142 //*************************************************************************************************
2155 template< typename MT // Type of the adapted dense matrix
2156  , bool SO > // Storage order of the adapted dense matrix
2157 inline void SymmetricMatrix<MT,SO,true,false>::extend( size_t n, bool preserve )
2158 {
2160 
2161  UNUSED_PARAMETER( preserve );
2162 
2163  resize( rows() + n, true );
2164 }
2166 //*************************************************************************************************
2167 
2168 
2169 //*************************************************************************************************
2179 template< typename MT // Type of the adapted dense matrix
2180  , bool SO > // Storage order of the adapted dense matrix
2181 inline void SymmetricMatrix<MT,SO,true,false>::reserve( size_t elements )
2182 {
2183  matrix_.reserve( elements );
2184 }
2186 //*************************************************************************************************
2187 
2188 
2189 //*************************************************************************************************
2196 template< typename MT // Type of the adapted dense matrix
2197  , bool SO > // Storage order of the adapted dense matrix
2198 inline void SymmetricMatrix<MT,SO,true,false>::swap( SymmetricMatrix& m ) noexcept
2199 {
2200  using std::swap;
2201 
2202  swap( matrix_, m.matrix_ );
2203 }
2205 //*************************************************************************************************
2206 
2207 
2208 
2209 
2210 //=================================================================================================
2211 //
2212 // NUMERIC FUNCTIONS
2213 //
2214 //=================================================================================================
2215 
2216 //*************************************************************************************************
2222 template< typename MT // Type of the adapted dense matrix
2223  , bool SO > // Storage order of the adapted dense matrix
2224 inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::transpose()
2225 {
2226  return *this;
2227 }
2229 //*************************************************************************************************
2230 
2231 
2232 //*************************************************************************************************
2238 template< typename MT // Type of the adapted dense matrix
2239  , bool SO > // Storage order of the adapted dense matrix
2240 inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::ctranspose()
2241 {
2242  if( SO ) {
2243  for( size_t j=0UL; j<columns(); ++j )
2244  for( size_t i=0UL; i<=j; ++i )
2245  conjugate( matrix_(i,j) );
2246  }
2247  else {
2248  for( size_t i=0UL; i<rows(); ++i )
2249  for( size_t j=0UL; j<=i; ++j )
2250  conjugate( matrix_(i,j) );
2251  }
2252 
2253  return *this;
2254 }
2256 //*************************************************************************************************
2257 
2258 
2259 //*************************************************************************************************
2266 template< typename MT // Type of the adapted dense matrix
2267  , bool SO > // Storage order of the adapted dense matrix
2268 template< typename Other > // Data type of the scalar value
2269 inline SymmetricMatrix<MT,SO,true,false>&
2270  SymmetricMatrix<MT,SO,true,false>::scale( const Other& scalar )
2271 {
2272  if( SO ) {
2273  for( size_t j=0UL; j<columns(); ++j )
2274  for( size_t i=0UL; i<=j; ++i )
2275  matrix_(i,j) *= scalar;
2276  }
2277  else {
2278  for( size_t i=0UL; i<rows(); ++i )
2279  for( size_t j=0UL; j<=i; ++j )
2280  matrix_(i,j) *= scalar;
2281  }
2282 
2283  return *this;
2284 }
2286 //*************************************************************************************************
2287 
2288 
2289 
2290 
2291 //=================================================================================================
2292 //
2293 // DEBUGGING FUNCTIONS
2294 //
2295 //=================================================================================================
2296 
2297 //*************************************************************************************************
2307 template< typename MT // Type of the adapted dense matrix
2308  , bool SO > // Storage order of the adapted dense matrix
2309 inline bool SymmetricMatrix<MT,SO,true,false>::isIntact() const noexcept
2310 {
2311  using blaze::isIntact;
2312 
2313  return isIntact( matrix_ ) &&
2314  ( IsCustom<MT>::value || ( SO ? isUpper( matrix_ ) : isLower( matrix_ ) ) );
2315 }
2317 //*************************************************************************************************
2318 
2319 
2320 
2321 
2322 //=================================================================================================
2323 //
2324 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2325 //
2326 //=================================================================================================
2327 
2328 //*************************************************************************************************
2339 template< typename MT // Type of the adapted dense matrix
2340  , bool SO > // Storage order of the adapted dense matrix
2341 template< typename Other > // Data type of the foreign expression
2342 inline bool SymmetricMatrix<MT,SO,true,false>::canAlias( const Other* alias ) const noexcept
2343 {
2344  return matrix_.canAlias( alias );
2345 }
2347 //*************************************************************************************************
2348 
2349 
2350 //*************************************************************************************************
2361 template< typename MT // Type of the adapted dense matrix
2362  , bool SO > // Storage order of the adapted dense matrix
2363 template< typename Other > // Data type of the foreign expression
2364 inline bool SymmetricMatrix<MT,SO,true,false>::isAliased( const Other* alias ) const noexcept
2365 {
2366  return matrix_.isAliased( alias );
2367 }
2369 //*************************************************************************************************
2370 
2371 
2372 //*************************************************************************************************
2382 template< typename MT // Type of the adapted dense matrix
2383  , bool SO > // Storage order of the adapted dense matrix
2384 inline bool SymmetricMatrix<MT,SO,true,false>::isAligned() const noexcept
2385 {
2386  return matrix_.isAligned();
2387 }
2389 //*************************************************************************************************
2390 
2391 
2392 //*************************************************************************************************
2403 template< typename MT // Type of the adapted dense matrix
2404  , bool SO > // Storage order of the adapted dense matrix
2405 inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign() const noexcept
2406 {
2407  return matrix_.canSMPAssign();
2408 }
2410 //*************************************************************************************************
2411 
2412 
2413 //*************************************************************************************************
2425 template< typename MT // Type of the adapted dense matrix
2426  , bool SO > // Storage order of the adapted dense matrix
2427 template< typename MT2 > // Type of the right-hand side dense matrix
2428 inline void SymmetricMatrix<MT,SO,true,false>::assign( DenseMatrix<MT2,SO>& rhs )
2429 {
2430  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2431  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2432 
2433  if( SO ) {
2434  for( size_t j=0UL; j<columns(); ++j )
2435  for( size_t i=0UL; i<=j; ++i )
2436  matrix_(i,j) = std::move( (~rhs)(i,j) );
2437  }
2438  else {
2439  for( size_t i=0UL; i<rows(); ++i )
2440  for( size_t j=0UL; j<=i; ++j )
2441  matrix_(i,j) = std::move( (~rhs)(i,j) );
2442  }
2443 }
2445 //*************************************************************************************************
2446 
2447 
2448 //*************************************************************************************************
2460 template< typename MT // Type of the adapted dense matrix
2461  , bool SO > // Storage order of the adapted dense matrix
2462 template< typename MT2 > // Type of the right-hand side dense matrix
2463 inline void SymmetricMatrix<MT,SO,true,false>::assign( const DenseMatrix<MT2,SO>& rhs )
2464 {
2465  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2466  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2467 
2468  if( SO ) {
2469  for( size_t j=0UL; j<columns(); ++j )
2470  for( size_t i=0UL; i<=j; ++i )
2471  matrix_(i,j) = (~rhs)(i,j);
2472  }
2473  else {
2474  for( size_t i=0UL; i<rows(); ++i )
2475  for( size_t j=0UL; j<=i; ++j )
2476  matrix_(i,j) = (~rhs)(i,j);
2477  }
2478 }
2480 //*************************************************************************************************
2481 
2482 
2483 //*************************************************************************************************
2495 template< typename MT // Type of the adapted dense matrix
2496  , bool SO > // Storage order of the adapted dense matrix
2497 template< typename MT2 > // Type of the right-hand side sparse matrix
2498 inline void SymmetricMatrix<MT,SO,true,false>::assign( const SparseMatrix<MT2,SO>& rhs )
2499 {
2500  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2501  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2502 
2503  typedef ConstIterator_<MT2> ConstIterator;
2504 
2505  if( SO ) {
2506  for( size_t j=0UL; j<columns(); ++j ) {
2507  const ConstIterator last( (~rhs).upperBound(j,j) );
2508  for( ConstIterator element=(~rhs).begin(j); element!=last; ++element )
2509  matrix_(element->index(),j) = element->value();
2510  }
2511  }
2512  else {
2513  for( size_t i=0UL; i<rows(); ++i ) {
2514  const ConstIterator last( (~rhs).upperBound(i,i) );
2515  for( ConstIterator element=(~rhs).begin(i); element!=last; ++element )
2516  matrix_(i,element->index()) = element->value();
2517  }
2518  }
2519 }
2521 //*************************************************************************************************
2522 
2523 
2524 //*************************************************************************************************
2536 template< typename MT // Type of the adapted dense matrix
2537  , bool SO > // Storage order of the adapted dense matrix
2538 template< typename MT2 > // Type of the right-hand side dense matrix
2539 inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const DenseMatrix<MT2,SO>& rhs )
2540 {
2541  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2542  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2543 
2544  if( SO ) {
2545  for( size_t j=0UL; j<columns(); ++j )
2546  for( size_t i=0UL; i<=j; ++i )
2547  matrix_(i,j) += (~rhs)(i,j);
2548  }
2549  else {
2550  for( size_t i=0UL; i<rows(); ++i )
2551  for( size_t j=0UL; j<=i; ++j )
2552  matrix_(i,j) += (~rhs)(i,j);
2553  }
2554 }
2556 //*************************************************************************************************
2557 
2558 
2559 //*************************************************************************************************
2571 template< typename MT // Type of the adapted dense matrix
2572  , bool SO > // Storage order of the adapted dense matrix
2573 template< typename MT2 > // Type of the right-hand side sparse matrix
2574 inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const SparseMatrix<MT2,SO>& rhs )
2575 {
2576  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2577  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2578 
2579  typedef ConstIterator_<MT2> ConstIterator;
2580 
2581  if( SO ) {
2582  for( size_t j=0UL; j<columns(); ++j ) {
2583  const ConstIterator last( (~rhs).upperBound(j,j) );
2584  for( ConstIterator element=(~rhs).begin(j); element!=last; ++element )
2585  matrix_(element->index(),j) += element->value();
2586  }
2587  }
2588  else {
2589  for( size_t i=0UL; i<rows(); ++i ) {
2590  const ConstIterator last( (~rhs).upperBound(i,i) );
2591  for( ConstIterator element=(~rhs).begin(i); element!=last; ++element )
2592  matrix_(i,element->index()) += element->value();
2593  }
2594  }
2595 }
2597 //*************************************************************************************************
2598 
2599 
2600 //*************************************************************************************************
2612 template< typename MT // Type of the adapted dense matrix
2613  , bool SO > // Storage order of the adapted dense matrix
2614 template< typename MT2 > // Type of the right-hand side dense matrix
2615 inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const DenseMatrix<MT2,SO>& rhs )
2616 {
2617  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2618  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2619 
2620  if( SO ) {
2621  for( size_t j=0UL; j<columns(); ++j )
2622  for( size_t i=0UL; i<=j; ++i )
2623  matrix_(i,j) -= (~rhs)(i,j);
2624  }
2625  else {
2626  for( size_t i=0UL; i<rows(); ++i )
2627  for( size_t j=0UL; j<=i; ++j )
2628  matrix_(i,j) -= (~rhs)(i,j);
2629  }
2630 }
2632 //*************************************************************************************************
2633 
2634 
2635 //*************************************************************************************************
2647 template< typename MT // Type of the adapted dense matrix
2648  , bool SO > // Storage order of the adapted dense matrix
2649 template< typename MT2 > // Type of the right-hand side sparse matrix
2650 inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const SparseMatrix<MT2,SO>& rhs )
2651 {
2652  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2653  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2654 
2655  typedef ConstIterator_<MT2> ConstIterator;
2656 
2657  if( SO ) {
2658  for( size_t j=0UL; j<columns(); ++j ) {
2659  const ConstIterator last( (~rhs).upperBound(j,j) );
2660  for( ConstIterator element=(~rhs).begin(j); element!=last; ++element )
2661  matrix_(element->index(),j) -= element->value();
2662  }
2663  }
2664  else {
2665  for( size_t i=0UL; i<rows(); ++i ) {
2666  const ConstIterator last( (~rhs).upperBound(i,i) );
2667  for( ConstIterator element=(~rhs).begin(i); element!=last; ++element )
2668  matrix_(i,element->index()) -= element->value();
2669  }
2670  }
2671 }
2673 //*************************************************************************************************
2674 
2675 } // namespace blaze
2676 
2677 #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
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:102
Header file for auxiliary alias declarations.
Constraint on the data type.
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1066
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1321
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the Rows type trait.
Header file for the UNUSED_PARAMETER function template.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:352
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.
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:194
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:2935
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:5556
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:596
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2928
#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:390
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.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2931
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:304
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:238
Header file for the implementation of the base template of the SymmetricMatrix.
Constraint on the data type.
Constraint on the data type.
Header file for the IsSquare type trait.
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.
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:5635
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:5618
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2939
#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.
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
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:336
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< 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:128
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2932
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:544
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:260
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:2933
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.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2937
DisableIf_< Or< IsComputation< MT >, IsTransExpr< MT >, IsDeclExpr< 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:128
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.
#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:2934
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:2938
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:267
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:697
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:320
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2929
#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 &#39;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:733
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
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2930
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:249
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2936
#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:168
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:677
const DMatDMatMultExpr< T1, T2, false, false, false, false > 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:7505
#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:570