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>
72 #include <blaze/util/Assert.h>
78 #include <blaze/util/DisableIf.h>
79 #include <blaze/util/EnableIf.h>
80 #include <blaze/util/mpl/If.h>
82 #include <blaze/util/Types.h>
85 #include <blaze/util/Unused.h>
86 
87 
88 namespace blaze {
89 
90 //=================================================================================================
91 //
92 // CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES WITH NON-NUMERIC ELEMENT TYPE
93 //
94 //=================================================================================================
95 
96 //*************************************************************************************************
104 template< typename MT // Type of the adapted dense matrix
105  , bool SO > // Storage order of the adapted dense matrix
106 class SymmetricMatrix<MT,SO,true,false>
107  : public DenseMatrix< SymmetricMatrix<MT,SO,true,false>, SO >
108 {
109  private:
110  //**Type definitions****************************************************************************
111  using OT = OppositeType_t<MT>;
112  using TT = TransposeType_t<MT>;
113  using ET = ElementType_t<MT>;
114  //**********************************************************************************************
115 
116  public:
117  //**Type definitions****************************************************************************
118  using This = SymmetricMatrix<MT,SO,true,false>;
119  using BaseType = DenseMatrix<This,SO>;
120  using ResultType = This;
121  using OppositeType = SymmetricMatrix<OT,!SO,true,false>;
122  using TransposeType = SymmetricMatrix<TT,!SO,true,false>;
123  using ElementType = ET;
124  using ReturnType = ReturnType_t<MT>;
125  using CompositeType = const This&;
126  using Reference = Reference_t<MT>;
127  using ConstReference = ConstReference_t<MT>;
128  using Pointer = Pointer_t<MT>;
129  using ConstPointer = ConstPointer_t<MT>;
130  //**********************************************************************************************
131 
132  //**Rebind struct definition********************************************************************
135  template< typename NewType > // Data type of the other matrix
136  struct Rebind {
138  using Other = SymmetricMatrix< typename MT::template Rebind<NewType>::Other >;
139  };
140  //**********************************************************************************************
141 
142  //**Resize struct definition********************************************************************
145  template< size_t NewM // Number of rows of the other matrix
146  , size_t NewN > // Number of columns of the other matrix
147  struct Resize {
149  using Other = SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other >;
150  };
151  //**********************************************************************************************
152 
153  //**MatrixIterator class definition*************************************************************
156  template< typename MatrixType > // Type of the adapted dense matrix
157  class MatrixIterator
158  {
159  public:
160  //**Type definitions*************************************************************************
162  using Reference = If_t< IsConst_v<MatrixType>
163  , ConstReference_t<MatrixType>
164  , Reference_t<MatrixType> >;
165 
166  using IteratorCategory = std::random_access_iterator_tag;
167  using ValueType = RemoveReference_t<Reference>;
168  using PointerType = ValueType*;
169  using ReferenceType = Reference;
170  using DifferenceType = ptrdiff_t;
171 
172  // STL iterator requirements
173  using iterator_category = IteratorCategory;
174  using value_type = ValueType;
175  using pointer = PointerType;
176  using reference = ReferenceType;
177  using difference_type = DifferenceType;
178  //*******************************************************************************************
179 
180  //**Constructor******************************************************************************
183  inline MatrixIterator() noexcept
184  : matrix_( nullptr ) // Reference to the adapted dense matrix
185  , row_ ( 0UL ) // The current row index of the iterator
186  , column_( 0UL ) // The current column index of the iterator
187  {}
188  //*******************************************************************************************
189 
190  //**Constructor******************************************************************************
197  inline MatrixIterator( MatrixType& matrix, size_t row, size_t column ) noexcept
198  : matrix_( &matrix ) // Reference to the adapted dense matrix
199  , row_ ( row ) // The current row index of the iterator
200  , column_( column ) // The current column index of the iterator
201  {}
202  //*******************************************************************************************
203 
204  //**Conversion constructor*******************************************************************
209  template< typename MatrixType2 >
210  inline MatrixIterator( const MatrixIterator<MatrixType2>& it ) noexcept
211  : matrix_( it.matrix_ ) // Reference to the adapted dense matrix
212  , row_ ( it.row_ ) // The current row index of the iterator
213  , column_( it.column_ ) // The current column index of the iterator
214  {}
215  //*******************************************************************************************
216 
217  //**Addition assignment operator*************************************************************
223  inline MatrixIterator& operator+=( size_t inc ) noexcept {
224  ( SO )?( row_ += inc ):( column_ += inc );
225  return *this;
226  }
227  //*******************************************************************************************
228 
229  //**Subtraction assignment operator**********************************************************
235  inline MatrixIterator& operator-=( size_t dec ) noexcept {
236  ( SO )?( row_ -= dec ):( column_ -= dec );
237  return *this;
238  }
239  //*******************************************************************************************
240 
241  //**Prefix increment operator****************************************************************
246  inline MatrixIterator& operator++() noexcept {
247  ( SO )?( ++row_ ):( ++column_ );
248  return *this;
249  }
250  //*******************************************************************************************
251 
252  //**Postfix increment operator***************************************************************
257  inline const MatrixIterator operator++( int ) noexcept {
258  const MatrixIterator tmp( *this );
259  ++(*this);
260  return tmp;
261  }
262  //*******************************************************************************************
263 
264  //**Prefix decrement operator****************************************************************
269  inline MatrixIterator& operator--() noexcept {
270  ( SO )?( --row_ ):( --column_ );
271  return *this;
272  }
273  //*******************************************************************************************
274 
275  //**Postfix decrement operator***************************************************************
280  inline const MatrixIterator operator--( int ) noexcept {
281  const MatrixIterator tmp( *this );
282  --(*this);
283  return tmp;
284  }
285  //*******************************************************************************************
286 
287  //**Element access operator******************************************************************
292  inline ReferenceType operator*() const {
293  if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
294  return (*matrix_)(row_,column_);
295  else
296  return (*matrix_)(column_,row_);
297  }
298  //*******************************************************************************************
299 
300  //**Element access operator******************************************************************
305  inline PointerType operator->() const {
306  if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
307  return &(*matrix_)(row_,column_);
308  else
309  return &(*matrix_)(column_,row_);
310  }
311  //*******************************************************************************************
312 
313  //**Equality operator************************************************************************
319  template< typename MatrixType2 >
320  inline bool operator==( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
321  return ( SO )?( row_ == rhs.row_ ):( column_ == rhs.column_ );
322  }
323  //*******************************************************************************************
324 
325  //**Inequality operator**********************************************************************
331  template< typename MatrixType2 >
332  inline bool operator!=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
333  return ( SO )?( row_ != rhs.row_ ):( column_ != rhs.column_ );
334  }
335  //*******************************************************************************************
336 
337  //**Less-than operator***********************************************************************
343  template< typename MatrixType2 >
344  inline bool operator<( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
345  return ( SO )?( row_ < rhs.row_ ):( column_ < rhs.column_ );
346  return ( column_ < rhs.column_ );
347  }
348  //*******************************************************************************************
349 
350  //**Greater-than operator********************************************************************
356  template< typename MatrixType2 >
357  inline bool operator>( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
358  return ( SO )?( row_ > rhs.row_ ):( column_ > rhs.column_ );
359  return ( column_ > rhs.column_ );
360  }
361  //*******************************************************************************************
362 
363  //**Less-or-equal-than operator**************************************************************
369  template< typename MatrixType2 >
370  inline bool operator<=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
371  return ( SO )?( row_ <= rhs.row_ ):( column_ <= rhs.column_ );
372  }
373  //*******************************************************************************************
374 
375  //**Greater-or-equal-than operator***********************************************************
381  template< typename MatrixType2 >
382  inline bool operator>=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
383  return ( SO )?( row_ >= rhs.row_ ):( column_ >= rhs.column_ );
384  }
385  //*******************************************************************************************
386 
387  //**Subtraction operator*********************************************************************
393  inline DifferenceType operator-( const MatrixIterator& rhs ) const noexcept {
394  return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
395  }
396  //*******************************************************************************************
397 
398  //**Addition operator************************************************************************
405  friend inline const MatrixIterator operator+( const MatrixIterator& it, size_t inc ) noexcept {
406  if( SO )
407  return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
408  else
409  return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
410  }
411  //*******************************************************************************************
412 
413  //**Addition operator************************************************************************
420  friend inline const MatrixIterator operator+( size_t inc, const MatrixIterator& it ) noexcept {
421  if( SO )
422  return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
423  else
424  return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
425  }
426  //*******************************************************************************************
427 
428  //**Subtraction operator*********************************************************************
435  friend inline const MatrixIterator operator-( const MatrixIterator& it, size_t dec ) noexcept {
436  if( SO )
437  return MatrixIterator( *it.matrix_, it.row_ - dec, it.column_ );
438  else
439  return MatrixIterator( *it.matrix_, it.row_, it.column_ - dec );
440  }
441  //*******************************************************************************************
442 
443  private:
444  //**Member variables*************************************************************************
445  MatrixType* matrix_;
446  size_t row_;
447  size_t column_;
448  //*******************************************************************************************
449 
450  //**Friend declarations**********************************************************************
451  template< typename MatrixType2 > friend class MatrixIterator;
452  //*******************************************************************************************
453  };
454  //**********************************************************************************************
455 
456  //**Type definitions****************************************************************************
457  using Iterator = MatrixIterator<MT>;
458  using ConstIterator = MatrixIterator<const MT>;
459  //**********************************************************************************************
460 
461  //**Compilation flags***************************************************************************
463  static constexpr bool simdEnabled = false;
464 
466  static constexpr bool smpAssignable = ( MT::smpAssignable && !IsSMPAssignable_v<ET> );
467  //**********************************************************************************************
468 
469  //**Constructors********************************************************************************
472  explicit inline SymmetricMatrix();
473  explicit inline SymmetricMatrix( size_t n );
474 
475  explicit inline SymmetricMatrix( ElementType* ptr, size_t n );
476  explicit inline SymmetricMatrix( ElementType* ptr, size_t n, size_t nn );
477 
478  inline SymmetricMatrix( const SymmetricMatrix& m );
479  inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
480 
481  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,SO>& m );
482  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,!SO>& m );
484  //**********************************************************************************************
485 
486  //**Destructor**********************************************************************************
489  ~SymmetricMatrix() = default;
491  //**********************************************************************************************
492 
493  //**Data access functions***********************************************************************
496  inline Reference operator()( size_t i, size_t j );
497  inline ConstReference operator()( size_t i, size_t j ) const;
498  inline Reference at( size_t i, size_t j );
499  inline ConstReference at( size_t i, size_t j ) const;
500  inline ConstPointer data () const noexcept;
501  inline ConstPointer data ( size_t i ) const noexcept;
502  inline Iterator begin ( size_t i );
503  inline ConstIterator begin ( size_t i ) const;
504  inline ConstIterator cbegin( size_t i ) const;
505  inline Iterator end ( size_t i );
506  inline ConstIterator end ( size_t i ) const;
507  inline ConstIterator cend ( size_t i ) const;
509  //**********************************************************************************************
510 
511  //**Assignment operators************************************************************************
514  inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
515  inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
516 
517  template< typename MT2 >
518  inline auto operator=( const Matrix<MT2,SO>& rhs )
519  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
520 
521  template< typename MT2 >
522  inline auto operator=( const Matrix<MT2,SO>& rhs )
523  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
524 
525  template< typename MT2 >
526  inline auto operator=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
527 
528  template< typename MT2 >
529  inline auto operator+=( const Matrix<MT2,SO>& rhs )
530  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
531 
532  template< typename MT2 >
533  inline auto operator+=( const Matrix<MT2,SO>& rhs )
534  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
535 
536  template< typename MT2 >
537  inline auto operator+=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
538 
539  template< typename MT2 >
540  inline auto operator-=( const Matrix<MT2,SO>& rhs )
541  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
542 
543  template< typename MT2 >
544  inline auto operator-=( const Matrix<MT2,SO>& rhs )
545  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
546 
547  template< typename MT2 >
548  inline auto operator-=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
549 
550  template< typename MT2 >
551  inline auto operator%=( const Matrix<MT2,SO>& rhs )
552  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
553 
554  template< typename MT2 >
555  inline auto operator%=( const Matrix<MT2,SO>& rhs )
556  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
557 
558  template< typename MT2 >
559  inline auto operator%=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
560 
561  template< typename ST >
562  inline auto operator*=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >;
563 
564  template< typename ST >
565  inline auto operator/=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >;
567  //**********************************************************************************************
568 
569  //**Utility functions***************************************************************************
572  inline size_t rows() const noexcept;
573  inline size_t columns() const noexcept;
574  inline size_t spacing() const noexcept;
575  inline size_t capacity() const noexcept;
576  inline size_t capacity( size_t i ) const noexcept;
577  inline size_t nonZeros() const;
578  inline size_t nonZeros( size_t i ) const;
579  inline void reset();
580  inline void reset( size_t i );
581  inline void clear();
582  void resize ( size_t n, bool preserve=true );
583  inline void extend ( size_t n, bool preserve=true );
584  inline void reserve( size_t elements );
585  inline void shrinkToFit();
586  inline void swap( SymmetricMatrix& m ) noexcept;
588  //**********************************************************************************************
589 
590  //**Numeric functions***************************************************************************
593  inline SymmetricMatrix& transpose();
594  inline SymmetricMatrix& ctranspose();
595 
596  template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
598  //**********************************************************************************************
599 
600  //**Debugging functions*************************************************************************
603  inline bool isIntact() const noexcept;
605  //**********************************************************************************************
606 
607  //**Expression template evaluation functions****************************************************
610  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
611  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
612 
613  inline bool isAligned () const noexcept;
614  inline bool canSMPAssign() const noexcept;
616  //**********************************************************************************************
617 
618  private:
619  //**Expression template evaluation functions****************************************************
622  template< typename MT2 > inline void assign ( DenseMatrix <MT2,SO>& rhs );
623  template< typename MT2 > inline void assign ( const DenseMatrix <MT2,SO>& rhs );
624  template< typename MT2 > inline void assign ( const SparseMatrix<MT2,SO>& rhs );
625  template< typename MT2 > inline void addAssign ( const DenseMatrix <MT2,SO>& rhs );
626  template< typename MT2 > inline void addAssign ( const SparseMatrix<MT2,SO>& rhs );
627  template< typename MT2 > inline void subAssign ( const DenseMatrix <MT2,SO>& rhs );
628  template< typename MT2 > inline void subAssign ( const SparseMatrix<MT2,SO>& rhs );
629  template< typename MT2 > inline void schurAssign( const DenseMatrix <MT2,SO>& rhs );
630  template< typename MT2 > inline void schurAssign( const SparseMatrix<MT2,SO>& rhs );
632  //**********************************************************************************************
633 
634  //**Member variables****************************************************************************
637  MT matrix_;
638 
639  //**********************************************************************************************
640 
641  //**Friend declarations*************************************************************************
642  template< bool RF, typename MT2, bool SO2, bool DF2, bool NF2 >
643  friend bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
644  //**********************************************************************************************
645 
646  //**Compile time checks*************************************************************************
660  BLAZE_STATIC_ASSERT( ( Size_v<MT,0UL> == Size_v<MT,1UL> ) );
661  //**********************************************************************************************
662 };
664 //*************************************************************************************************
665 
666 
667 
668 
669 //=================================================================================================
670 //
671 // CONSTRUCTORS
672 //
673 //=================================================================================================
674 
675 //*************************************************************************************************
679 template< typename MT // Type of the adapted dense matrix
680  , bool SO > // Storage order of the adapted dense matrix
681 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
682  : matrix_() // The adapted dense matrix
683 {
684  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
685 }
687 //*************************************************************************************************
688 
689 
690 //*************************************************************************************************
696 template< typename MT // Type of the adapted dense matrix
697  , bool SO > // Storage order of the adapted dense matrix
698 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( size_t n )
699  : matrix_( n, n ) // The adapted dense matrix
700 {
702 
703  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
704 }
706 //*************************************************************************************************
707 
708 
709 //*************************************************************************************************
743 template< typename MT // Type of the adapted dense matrix
744  , bool SO > // Storage order of the adapted dense matrix
745 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n )
746  : matrix_( ptr, n, n ) // The adapted dense matrix
747 {
748  if( !isSymmetric( matrix_ ) ) {
749  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
750  }
751 
752  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
753 }
755 //*************************************************************************************************
756 
757 
758 //*************************************************************************************************
794 template< typename MT // Type of the adapted dense matrix
795  , bool SO > // Storage order of the adapted dense matrix
796 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n, size_t nn )
797  : matrix_( ptr, n, n, nn ) // The adapted dense matrix
798 {
799  if( !isSymmetric( matrix_ ) ) {
800  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
801  }
802 
803  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
804 }
806 //*************************************************************************************************
807 
808 
809 //*************************************************************************************************
815 template< typename MT // Type of the adapted dense matrix
816  , bool SO > // Storage order of the adapted dense matrix
817 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const SymmetricMatrix& m )
818  : matrix_( m.matrix_ ) // The adapted dense matrix
819 {
820  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
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( SymmetricMatrix&& m ) noexcept
836  : matrix_( std::move( 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 //*************************************************************************************************
855 template< typename MT // Type of the adapted dense matrix
856  , bool SO > // Storage order of the adapted dense matrix
857 template< typename MT2 > // Type of the foreign matrix
858 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,SO>& m )
859  : matrix_() // The adapted dense matrix
860 {
861  using blaze::resize;
862 
863  using RT = RemoveAdaptor_t<ResultType_t<MT2> >;
864  using Tmp = If_t< IsComputation_v<MT2>, RT, const MT2& >;
865 
866  if( IsSymmetric_v<MT2> ) {
867  resize( matrix_, (~m).rows(), (~m).columns() );
868  assign( ~m );
869  }
870  else {
871  Tmp tmp( ~m );
872 
873  if( !isSymmetric( tmp ) ) {
874  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
875  }
876 
877  resize( matrix_, tmp.rows(), tmp.rows() );
878  assign( tmp );
879  }
880 
881  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
882  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
883 }
885 //*************************************************************************************************
886 
887 
888 //*************************************************************************************************
898 template< typename MT // Type of the adapted dense matrix
899  , bool SO > // Storage order of the adapted dense matrix
900 template< typename MT2 > // Type of the foreign matrix
901 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
902  : matrix_() // The adapted dense matrix
903 {
904  using blaze::resize;
905 
906  using RT = RemoveAdaptor_t< ResultType_t<MT2> >;
907  using Tmp = If_t< IsComputation_v<MT2>, RT, const MT2& >;
908 
909  if( IsSymmetric_v<MT2> ) {
910  resize( matrix_, (~m).rows(), (~m).columns() );
911  assign( trans( ~m ) );
912  }
913  else {
914  Tmp tmp( ~m );
915 
916  if( !isSymmetric( tmp ) ) {
917  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
918  }
919 
920  resize( matrix_, tmp.rows(), tmp.rows() );
921  assign( trans( tmp ) );
922  }
923 
924  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
925  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
926 }
928 //*************************************************************************************************
929 
930 
931 
932 
933 //=================================================================================================
934 //
935 // DATA ACCESS FUNCTIONS
936 //
937 //=================================================================================================
938 
939 //*************************************************************************************************
954 template< typename MT // Type of the adapted dense matrix
955  , bool SO > // Storage order of the adapted dense matrix
957  SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j )
958 {
959  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
960  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
961 
962  if( ( !SO && i > j ) || ( SO && i < j ) )
963  return matrix_(i,j);
964  else
965  return matrix_(j,i);
966 }
968 //*************************************************************************************************
969 
970 
971 //*************************************************************************************************
986 template< typename MT // Type of the adapted dense matrix
987  , bool SO > // Storage order of the adapted dense matrix
989  SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j ) const
990 {
991  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
992  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
993 
994  if( ( !SO && i > j ) || ( SO && i < j ) )
995  return matrix_(i,j);
996  else
997  return matrix_(j,i);
998 }
1000 //*************************************************************************************************
1001 
1002 
1003 //*************************************************************************************************
1019 template< typename MT // Type of the adapted dense matrix
1020  , bool SO > // Storage order of the adapted dense matrix
1022  SymmetricMatrix<MT,SO,true,false>::at( size_t i, size_t j )
1023 {
1024  if( i >= rows() ) {
1025  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1026  }
1027  if( j >= columns() ) {
1028  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1029  }
1030  return (*this)(i,j);
1031 }
1033 //*************************************************************************************************
1034 
1035 
1036 //*************************************************************************************************
1052 template< typename MT // Type of the adapted dense matrix
1053  , bool SO > // Storage order of the adapted dense matrix
1055  SymmetricMatrix<MT,SO,true,false>::at( size_t i, size_t j ) const
1056 {
1057  if( i >= rows() ) {
1058  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1059  }
1060  if( j >= columns() ) {
1061  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1062  }
1063  return (*this)(i,j);
1064 }
1066 //*************************************************************************************************
1067 
1068 
1069 //*************************************************************************************************
1083 template< typename MT // Type of the adapted dense matrix
1084  , bool SO > // Storage order of the adapted dense matrix
1085 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1087 {
1088  return matrix_.data();
1089 }
1091 //*************************************************************************************************
1092 
1093 
1094 //*************************************************************************************************
1105 template< typename MT // Type of the adapted dense matrix
1106  , bool SO > // Storage order of the adapted dense matrix
1107 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1108  SymmetricMatrix<MT,SO,true,false>::data( size_t i ) const noexcept
1109 {
1110  return matrix_.data(i);
1111 }
1113 //*************************************************************************************************
1114 
1115 
1116 //*************************************************************************************************
1128 template< typename MT // Type of the adapted dense matrix
1129  , bool SO > // Storage order of the adapted dense matrix
1132 {
1133  if( SO )
1134  return Iterator( matrix_, 0UL, i );
1135  else
1136  return Iterator( matrix_, i, 0UL );
1137 }
1139 //*************************************************************************************************
1140 
1141 
1142 //*************************************************************************************************
1154 template< typename MT // Type of the adapted dense matrix
1155  , bool SO > // Storage order of the adapted dense matrix
1158 {
1159  if( SO )
1160  return ConstIterator( matrix_, 0UL, i );
1161  else
1162  return ConstIterator( matrix_, i, 0UL );
1163 }
1165 //*************************************************************************************************
1166 
1167 
1168 //*************************************************************************************************
1180 template< typename MT // Type of the adapted dense matrix
1181  , bool SO > // Storage order of the adapted dense matrix
1184 {
1185  if( SO )
1186  return ConstIterator( matrix_, 0UL, i );
1187  else
1188  return ConstIterator( matrix_, i, 0UL );
1189 }
1191 //*************************************************************************************************
1192 
1193 
1194 //*************************************************************************************************
1206 template< typename MT // Type of the adapted dense matrix
1207  , bool SO > // Storage order of the adapted dense matrix
1210 {
1211  if( SO )
1212  return Iterator( matrix_, rows(), i );
1213  else
1214  return Iterator( matrix_, i, columns() );
1215 }
1217 //*************************************************************************************************
1218 
1219 
1220 //*************************************************************************************************
1232 template< typename MT // Type of the adapted dense matrix
1233  , bool SO > // Storage order of the adapted dense matrix
1235  SymmetricMatrix<MT,SO,true,false>::end( size_t i ) const
1236 {
1237  if( SO )
1238  return ConstIterator( matrix_, rows(), i );
1239  else
1240  return ConstIterator( matrix_, i, columns() );
1241 }
1243 //*************************************************************************************************
1244 
1245 
1246 //*************************************************************************************************
1258 template< typename MT // Type of the adapted dense matrix
1259  , bool SO > // Storage order of the adapted dense matrix
1261  SymmetricMatrix<MT,SO,true,false>::cend( size_t i ) const
1262 {
1263  if( SO )
1264  return ConstIterator( matrix_, rows(), i );
1265  else
1266  return ConstIterator( matrix_, i, columns() );
1267 }
1269 //*************************************************************************************************
1270 
1271 
1272 
1273 
1274 //=================================================================================================
1275 //
1276 // ASSIGNMENT OPERATORS
1277 //
1278 //=================================================================================================
1279 
1280 //*************************************************************************************************
1290 template< typename MT // Type of the adapted dense matrix
1291  , bool SO > // Storage order of the adapted dense matrix
1292 inline SymmetricMatrix<MT,SO,true,false>&
1293  SymmetricMatrix<MT,SO,true,false>::operator=( const SymmetricMatrix& rhs )
1294 {
1295  using blaze::resize;
1296 
1297  if( &rhs == this ) return *this;
1298 
1299  resize( matrix_, rhs.rows(), rhs.columns() );
1300  assign( rhs );
1301 
1302  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1303  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1304 
1305  return *this;
1306 }
1308 //*************************************************************************************************
1309 
1310 
1311 //*************************************************************************************************
1318 template< typename MT // Type of the adapted dense matrix
1319  , bool SO > // Storage order of the adapted dense matrix
1320 inline SymmetricMatrix<MT,SO,true,false>&
1321  SymmetricMatrix<MT,SO,true,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1322 {
1323  matrix_ = std::move( rhs.matrix_ );
1324 
1325  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1326  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1327 
1328  return *this;
1329 }
1331 //*************************************************************************************************
1332 
1333 
1334 //*************************************************************************************************
1348 template< typename MT // Type of the adapted dense matrix
1349  , bool SO > // Storage order of the adapted dense matrix
1350 template< typename MT2 > // Type of the right-hand side matrix
1351 inline auto SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1352  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1353 {
1354  using blaze::resize;
1355 
1356  if( !IsSymmetric_v<MT2> && !isSymmetric( ~rhs ) ) {
1357  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1358  }
1359 
1360  if( (~rhs).isAliased( this ) ) {
1361  SymmetricMatrix tmp( ~rhs );
1362  swap( tmp );
1363  }
1364  else {
1365  resize( matrix_, (~rhs).rows(), (~rhs).columns() );
1366  if( IsSparseMatrix_v<MT2> )
1367  reset();
1368  assign( ~rhs );
1369  }
1370 
1371  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1372  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1373 
1374  return *this;
1375 }
1377 //*************************************************************************************************
1378 
1379 
1380 //*************************************************************************************************
1394 template< typename MT // Type of the adapted dense matrix
1395  , bool SO > // Storage order of the adapted dense matrix
1396 template< typename MT2 > // Type of the right-hand side matrix
1397 inline auto SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1398  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1399 {
1400  using blaze::resize;
1401 
1402  using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1403 
1404  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1405  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1406  }
1407 
1408  Tmp tmp( ~rhs );
1409 
1410  if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1411  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1412  }
1413 
1414  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1415 
1416  resize( matrix_, tmp.rows(), tmp.columns() );
1417  if( IsSparseMatrix_v<Tmp> )
1418  reset();
1419  assign( tmp );
1420 
1421  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1422  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1423 
1424  return *this;
1425 }
1427 //*************************************************************************************************
1428 
1429 
1430 //*************************************************************************************************
1444 template< typename MT // Type of the adapted dense matrix
1445  , bool SO > // Storage order of the adapted dense matrix
1446 template< typename MT2 > // Type of the right-hand side matrix
1447 inline auto SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,!SO>& rhs )
1448  -> SymmetricMatrix&
1449 {
1450  return this->operator=( trans( ~rhs ) );
1451 }
1453 //*************************************************************************************************
1454 
1455 
1456 //*************************************************************************************************
1469 template< typename MT // Type of the adapted dense matrix
1470  , bool SO > // Storage order of the adapted dense matrix
1471 template< typename MT2 > // Type of the right-hand side matrix
1472 inline auto SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1473  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1474 {
1475  if( !IsSymmetric_v<MT2> && !isSymmetric( ~rhs ) ) {
1476  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1477  }
1478 
1479  addAssign( ~rhs );
1480 
1481  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1482  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1483 
1484  return *this;
1485 }
1487 //*************************************************************************************************
1488 
1489 
1490 //*************************************************************************************************
1503 template< typename MT // Type of the adapted dense matrix
1504  , bool SO > // Storage order of the adapted dense matrix
1505 template< typename MT2 > // Type of the right-hand side matrix
1506 inline auto SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1507  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1508 {
1509  using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1510 
1511  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1512  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1513  }
1514 
1515  Tmp tmp( ~rhs );
1516 
1517  if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1518  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1519  }
1520 
1521  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1522 
1523  addAssign( tmp );
1524 
1525  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1526  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1527 
1528  return *this;
1529 }
1531 //*************************************************************************************************
1532 
1533 
1534 //*************************************************************************************************
1548 template< typename MT // Type of the adapted dense matrix
1549  , bool SO > // Storage order of the adapted dense matrix
1550 template< typename MT2 > // Type of the right-hand side matrix
1551 inline auto SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,!SO>& rhs )
1552  -> SymmetricMatrix&
1553 {
1554  return this->operator+=( trans( ~rhs ) );
1555 }
1557 //*************************************************************************************************
1558 
1559 
1560 //*************************************************************************************************
1573 template< typename MT // Type of the adapted dense matrix
1574  , bool SO > // Storage order of the adapted dense matrix
1575 template< typename MT2 > // Type of the right-hand side matrix
1576 inline auto SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1577  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1578 {
1579  if( !IsSymmetric_v<MT2> && !isSymmetric( ~rhs ) ) {
1580  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1581  }
1582 
1583  subAssign( ~rhs );
1584 
1585  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1586  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1587 
1588  return *this;
1589 }
1591 //*************************************************************************************************
1592 
1593 
1594 //*************************************************************************************************
1607 template< typename MT // Type of the adapted dense matrix
1608  , bool SO > // Storage order of the adapted dense matrix
1609 template< typename MT2 > // Type of the right-hand side matrix
1610 inline auto SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1611  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1612 {
1613  using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1614 
1615  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1616  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1617  }
1618 
1619  Tmp tmp( ~rhs );
1620 
1621  if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1622  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1623  }
1624 
1625  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1626 
1627  subAssign( tmp );
1628 
1629  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1630  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1631 
1632  return *this;
1633 }
1635 //*************************************************************************************************
1636 
1637 
1638 //*************************************************************************************************
1652 template< typename MT // Type of the adapted dense matrix
1653  , bool SO > // Storage order of the adapted dense matrix
1654 template< typename MT2 > // Type of the right-hand side matrix
1655 inline auto SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,!SO>& rhs )
1656  -> SymmetricMatrix&
1657 {
1658  return this->operator-=( trans( ~rhs ) );
1659 }
1661 //*************************************************************************************************
1662 
1663 
1664 //*************************************************************************************************
1678 template< typename MT // Type of the adapted dense matrix
1679  , bool SO > // Storage order of the adapted dense matrix
1680 template< typename MT2 > // Type of the right-hand side matrix
1681 inline auto SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,SO>& rhs )
1682  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1683 {
1684  if( !IsSymmetric_v<MT2> && !isSymmetric( ~rhs ) ) {
1685  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1686  }
1687 
1688  schurAssign( ~rhs );
1689 
1690  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1691  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1692 
1693  return *this;
1694 }
1696 //*************************************************************************************************
1697 
1698 
1699 //*************************************************************************************************
1713 template< typename MT // Type of the adapted dense matrix
1714  , bool SO > // Storage order of the adapted dense matrix
1715 template< typename MT2 > // Type of the right-hand side matrix
1716 inline auto SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,SO>& rhs )
1717  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1718 {
1719  using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1720 
1721  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1722  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1723  }
1724 
1725  Tmp tmp( ~rhs );
1726 
1727  if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1728  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1729  }
1730 
1731  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1732 
1733  schurAssign( tmp );
1734 
1735  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1736  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1737 
1738  return *this;
1739 }
1741 //*************************************************************************************************
1742 
1743 
1744 //*************************************************************************************************
1758 template< typename MT // Type of the adapted dense matrix
1759  , bool SO > // Storage order of the adapted dense matrix
1760 template< typename MT2 > // Type of the right-hand side matrix
1761 inline auto SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,!SO>& rhs )
1762  -> SymmetricMatrix&
1763 {
1764  return this->operator%=( trans( ~rhs ) );
1765 }
1767 //*************************************************************************************************
1768 
1769 
1770 //*************************************************************************************************
1778 template< typename MT // Type of the adapted dense matrix
1779  , bool SO > // Storage order of the adapted dense matrix
1780 template< typename ST > // Data type of the right-hand side scalar
1782  -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1783 {
1784  if( SO ) {
1785  for( size_t j=0UL; j<columns(); ++j )
1786  for( size_t i=0UL; i<=j; ++i )
1787  matrix_(i,j) *= rhs;
1788  }
1789  else {
1790  for( size_t i=0UL; i<rows(); ++i )
1791  for( size_t j=0UL; j<=i; ++j )
1792  matrix_(i,j) *= rhs;
1793  }
1794 
1795  return *this;
1796 }
1798 //*************************************************************************************************
1799 
1800 
1801 //*************************************************************************************************
1809 template< typename MT // Type of the adapted dense matrix
1810  , bool SO > // Storage order of the adapted dense matrix
1811 template< typename ST > // Data type of the right-hand side scalar
1813  -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1814 {
1815  BLAZE_USER_ASSERT( !isZero( rhs ), "Division by zero detected" );
1816 
1817  if( SO ) {
1818  for( size_t j=0UL; j<columns(); ++j )
1819  for( size_t i=0UL; i<=j; ++i )
1820  matrix_(i,j) /= rhs;
1821  }
1822  else {
1823  for( size_t i=0UL; i<rows(); ++i )
1824  for( size_t j=0UL; j<=i; ++j )
1825  matrix_(i,j) /= rhs;
1826  }
1827 
1828  return *this;
1829 }
1831 //*************************************************************************************************
1832 
1833 
1834 
1835 
1836 //=================================================================================================
1837 //
1838 // UTILITY FUNCTIONS
1839 //
1840 //=================================================================================================
1841 
1842 //*************************************************************************************************
1848 template< typename MT // Type of the adapted dense matrix
1849  , bool SO > // Storage order of the adapted dense matrix
1850 inline size_t SymmetricMatrix<MT,SO,true,false>::rows() const noexcept
1851 {
1852  return matrix_.rows();
1853 }
1855 //*************************************************************************************************
1856 
1857 
1858 //*************************************************************************************************
1864 template< typename MT // Type of the adapted dense matrix
1865  , bool SO > // Storage order of the adapted dense matrix
1866 inline size_t SymmetricMatrix<MT,SO,true,false>::columns() const noexcept
1867 {
1868  return matrix_.columns();
1869 }
1871 //*************************************************************************************************
1872 
1873 
1874 //*************************************************************************************************
1886 template< typename MT // Type of the adapted dense matrix
1887  , bool SO > // Storage order of the adapted dense matrix
1888 inline size_t SymmetricMatrix<MT,SO,true,false>::spacing() const noexcept
1889 {
1890  return matrix_.spacing();
1891 }
1893 //*************************************************************************************************
1894 
1895 
1896 //*************************************************************************************************
1902 template< typename MT // Type of the adapted dense matrix
1903  , bool SO > // Storage order of the adapted dense matrix
1904 inline size_t SymmetricMatrix<MT,SO,true,false>::capacity() const noexcept
1905 {
1906  return matrix_.capacity();
1907 }
1909 //*************************************************************************************************
1910 
1911 
1912 //*************************************************************************************************
1923 template< typename MT // Type of the adapted dense matrix
1924  , bool SO > // Storage order of the adapted dense matrix
1925 inline size_t SymmetricMatrix<MT,SO,true,false>::capacity( size_t i ) const noexcept
1926 {
1927  return matrix_.capacity(i);
1928 }
1930 //*************************************************************************************************
1931 
1932 
1933 //*************************************************************************************************
1939 template< typename MT // Type of the adapted dense matrix
1940  , bool SO > // Storage order of the adapted dense matrix
1941 inline size_t SymmetricMatrix<MT,SO,true,false>::nonZeros() const
1942 {
1943  size_t nonzeros( 0UL );
1944 
1945  if( SO )
1946  {
1947  for( size_t j=0UL; j<columns(); ++j ) {
1948  for( size_t i=0UL; i<j; ++i ) {
1949  if( !isDefault( matrix_(i,j) ) )
1950  nonzeros += 2UL;
1951  }
1952  if( !isDefault( matrix_(j,j) ) )
1953  ++nonzeros;
1954  }
1955  }
1956  else
1957  {
1958  for( size_t i=0UL; i<rows(); ++i ) {
1959  for( size_t j=0UL; j<i; ++j ) {
1960  if( !isDefault( matrix_(i,j) ) )
1961  nonzeros += 2UL;
1962  }
1963  if( !isDefault( matrix_(i,i) ) )
1964  ++nonzeros;
1965  }
1966  }
1967 
1968  return nonzeros;
1969 }
1971 //*************************************************************************************************
1972 
1973 
1974 //*************************************************************************************************
1986 template< typename MT // Type of the adapted dense matrix
1987  , bool SO > // Storage order of the adapted dense matrix
1988 inline size_t SymmetricMatrix<MT,SO,true,false>::nonZeros( size_t i ) const
1989 {
1990  size_t nonzeros( 0UL );
1991 
1992  if( SO )
1993  {
1994  for( size_t j=0UL; j<i; ++j ) {
1995  if( !isDefault( matrix_(j,i) ) )
1996  ++nonzeros;
1997  }
1998  for( size_t j=i; j<rows(); ++j ) {
1999  if( !isDefault( matrix_(i,j) ) )
2000  ++nonzeros;
2001  }
2002  }
2003  else
2004  {
2005  for( size_t j=0UL; j<i; ++j ) {
2006  if( !isDefault( matrix_(i,j) ) )
2007  ++nonzeros;
2008  }
2009  for( size_t j=i; j<rows(); ++j ) {
2010  if( !isDefault( matrix_(j,i) ) )
2011  ++nonzeros;
2012  }
2013  }
2014 
2015  return nonzeros;
2016 }
2018 //*************************************************************************************************
2019 
2020 
2021 //*************************************************************************************************
2027 template< typename MT // Type of the adapted dense matrix
2028  , bool SO > // Storage order of the adapted dense matrix
2030 {
2031  using blaze::clear;
2032 
2033  if( SO ) {
2034  for( size_t j=0UL; j<columns(); ++j )
2035  for( size_t i=0UL; i<=j; ++i )
2036  clear( matrix_(i,j) );
2037  }
2038  else {
2039  for( size_t i=0UL; i<rows(); ++i )
2040  for( size_t j=0UL; j<=i; ++j )
2041  clear( matrix_(i,j) );
2042  }
2043 }
2045 //*************************************************************************************************
2046 
2047 
2048 //*************************************************************************************************
2088 template< typename MT // Type of the adapted dense matrix
2089  , bool SO > // Storage order of the adapted dense matrix
2090 inline void SymmetricMatrix<MT,SO,true,false>::reset( size_t i )
2091 {
2092  using blaze::clear;
2093 
2094  for( auto element=begin(i); element!=end(i); ++element )
2095  clear( *element );
2096 }
2098 //*************************************************************************************************
2099 
2100 
2101 //*************************************************************************************************
2113 template< typename MT // Type of the adapted dense matrix
2114  , bool SO > // Storage order of the adapted dense matrix
2116 {
2117  using blaze::clear;
2118 
2119  clear( matrix_ );
2120 }
2122 //*************************************************************************************************
2123 
2124 
2125 //*************************************************************************************************
2141 template< typename MT // Type of the adapted dense matrix
2142  , bool SO > // Storage order of the adapted dense matrix
2143 void SymmetricMatrix<MT,SO,true,false>::resize( size_t n, bool preserve )
2144 {
2146 
2147  UNUSED_PARAMETER( preserve );
2148 
2149  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
2150 
2151  const size_t oldsize( matrix_.rows() );
2152 
2153  matrix_.resize( n, n, true );
2154 
2155  if( n > oldsize ) {
2156  const size_t increment( n - oldsize );
2157  submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2158  submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2159  }
2160 }
2162 //*************************************************************************************************
2163 
2164 
2165 //*************************************************************************************************
2178 template< typename MT // Type of the adapted dense matrix
2179  , bool SO > // Storage order of the adapted dense matrix
2180 inline void SymmetricMatrix<MT,SO,true,false>::extend( size_t n, bool preserve )
2181 {
2183 
2184  UNUSED_PARAMETER( preserve );
2185 
2186  resize( rows() + n, true );
2187 }
2189 //*************************************************************************************************
2190 
2191 
2192 //*************************************************************************************************
2202 template< typename MT // Type of the adapted dense matrix
2203  , bool SO > // Storage order of the adapted dense matrix
2204 inline void SymmetricMatrix<MT,SO,true,false>::reserve( size_t elements )
2205 {
2206  matrix_.reserve( elements );
2207 }
2209 //*************************************************************************************************
2210 
2211 
2212 //*************************************************************************************************
2222 template< typename MT // Type of the adapted dense matrix
2223  , bool SO > // Storage order of the adapted dense matrix
2225 {
2226  matrix_.shrinkToFit();
2227 }
2229 //*************************************************************************************************
2230 
2231 
2232 //*************************************************************************************************
2239 template< typename MT // Type of the adapted dense matrix
2240  , bool SO > // Storage order of the adapted dense matrix
2241 inline void SymmetricMatrix<MT,SO,true,false>::swap( SymmetricMatrix& m ) noexcept
2242 {
2243  using std::swap;
2244 
2245  swap( matrix_, m.matrix_ );
2246 }
2248 //*************************************************************************************************
2249 
2250 
2251 
2252 
2253 //=================================================================================================
2254 //
2255 // NUMERIC FUNCTIONS
2256 //
2257 //=================================================================================================
2258 
2259 //*************************************************************************************************
2265 template< typename MT // Type of the adapted dense matrix
2266  , bool SO > // Storage order of the adapted dense matrix
2267 inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::transpose()
2268 {
2269  return *this;
2270 }
2272 //*************************************************************************************************
2273 
2274 
2275 //*************************************************************************************************
2281 template< typename MT // Type of the adapted dense matrix
2282  , bool SO > // Storage order of the adapted dense matrix
2283 inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::ctranspose()
2284 {
2285  if( SO ) {
2286  for( size_t j=0UL; j<columns(); ++j )
2287  for( size_t i=0UL; i<=j; ++i )
2288  conjugate( matrix_(i,j) );
2289  }
2290  else {
2291  for( size_t i=0UL; i<rows(); ++i )
2292  for( size_t j=0UL; j<=i; ++j )
2293  conjugate( matrix_(i,j) );
2294  }
2295 
2296  return *this;
2297 }
2299 //*************************************************************************************************
2300 
2301 
2302 //*************************************************************************************************
2320 template< typename MT // Type of the adapted dense matrix
2321  , bool SO > // Storage order of the adapted dense matrix
2322 template< typename Other > // Data type of the scalar value
2323 inline SymmetricMatrix<MT,SO,true,false>&
2324  SymmetricMatrix<MT,SO,true,false>::scale( const Other& scalar )
2325 {
2326  if( SO ) {
2327  for( size_t j=0UL; j<columns(); ++j )
2328  for( size_t i=0UL; i<=j; ++i )
2329  matrix_(i,j) *= scalar;
2330  }
2331  else {
2332  for( size_t i=0UL; i<rows(); ++i )
2333  for( size_t j=0UL; j<=i; ++j )
2334  matrix_(i,j) *= scalar;
2335  }
2336 
2337  return *this;
2338 }
2340 //*************************************************************************************************
2341 
2342 
2343 
2344 
2345 //=================================================================================================
2346 //
2347 // DEBUGGING FUNCTIONS
2348 //
2349 //=================================================================================================
2350 
2351 //*************************************************************************************************
2361 template< typename MT // Type of the adapted dense matrix
2362  , bool SO > // Storage order of the adapted dense matrix
2363 inline bool SymmetricMatrix<MT,SO,true,false>::isIntact() const noexcept
2364 {
2365  using blaze::isIntact;
2366 
2367  return isIntact( matrix_ ) &&
2368  ( IsCustom_v<MT> || ( SO ? isUpper( matrix_ ) : isLower( matrix_ ) ) );
2369 }
2371 //*************************************************************************************************
2372 
2373 
2374 
2375 
2376 //=================================================================================================
2377 //
2378 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2379 //
2380 //=================================================================================================
2381 
2382 //*************************************************************************************************
2393 template< typename MT // Type of the adapted dense matrix
2394  , bool SO > // Storage order of the adapted dense matrix
2395 template< typename Other > // Data type of the foreign expression
2396 inline bool SymmetricMatrix<MT,SO,true,false>::canAlias( const Other* alias ) const noexcept
2397 {
2398  return matrix_.canAlias( alias );
2399 }
2401 //*************************************************************************************************
2402 
2403 
2404 //*************************************************************************************************
2415 template< typename MT // Type of the adapted dense matrix
2416  , bool SO > // Storage order of the adapted dense matrix
2417 template< typename Other > // Data type of the foreign expression
2418 inline bool SymmetricMatrix<MT,SO,true,false>::isAliased( const Other* alias ) const noexcept
2419 {
2420  return matrix_.isAliased( alias );
2421 }
2423 //*************************************************************************************************
2424 
2425 
2426 //*************************************************************************************************
2436 template< typename MT // Type of the adapted dense matrix
2437  , bool SO > // Storage order of the adapted dense matrix
2438 inline bool SymmetricMatrix<MT,SO,true,false>::isAligned() const noexcept
2439 {
2440  return matrix_.isAligned();
2441 }
2443 //*************************************************************************************************
2444 
2445 
2446 //*************************************************************************************************
2457 template< typename MT // Type of the adapted dense matrix
2458  , bool SO > // Storage order of the adapted dense matrix
2459 inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign() const noexcept
2460 {
2461  return matrix_.canSMPAssign();
2462 }
2464 //*************************************************************************************************
2465 
2466 
2467 //*************************************************************************************************
2479 template< typename MT // Type of the adapted dense matrix
2480  , bool SO > // Storage order of the adapted dense matrix
2481 template< typename MT2 > // Type of the right-hand side dense matrix
2482 inline void SymmetricMatrix<MT,SO,true,false>::assign( DenseMatrix<MT2,SO>& rhs )
2483 {
2484  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2485  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2486 
2487  if( SO ) {
2488  for( size_t j=0UL; j<columns(); ++j )
2489  for( size_t i=0UL; i<=j; ++i )
2490  matrix_(i,j) = std::move( (~rhs)(i,j) );
2491  }
2492  else {
2493  for( size_t i=0UL; i<rows(); ++i )
2494  for( size_t j=0UL; j<=i; ++j )
2495  matrix_(i,j) = std::move( (~rhs)(i,j) );
2496  }
2497 }
2499 //*************************************************************************************************
2500 
2501 
2502 //*************************************************************************************************
2514 template< typename MT // Type of the adapted dense matrix
2515  , bool SO > // Storage order of the adapted dense matrix
2516 template< typename MT2 > // Type of the right-hand side dense matrix
2517 inline void SymmetricMatrix<MT,SO,true,false>::assign( const DenseMatrix<MT2,SO>& rhs )
2518 {
2519  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2520  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2521 
2522  if( SO ) {
2523  for( size_t j=0UL; j<columns(); ++j )
2524  for( size_t i=0UL; i<=j; ++i )
2525  matrix_(i,j) = (~rhs)(i,j);
2526  }
2527  else {
2528  for( size_t i=0UL; i<rows(); ++i )
2529  for( size_t j=0UL; j<=i; ++j )
2530  matrix_(i,j) = (~rhs)(i,j);
2531  }
2532 }
2534 //*************************************************************************************************
2535 
2536 
2537 //*************************************************************************************************
2549 template< typename MT // Type of the adapted dense matrix
2550  , bool SO > // Storage order of the adapted dense matrix
2551 template< typename MT2 > // Type of the right-hand side sparse matrix
2552 inline void SymmetricMatrix<MT,SO,true,false>::assign( const SparseMatrix<MT2,SO>& rhs )
2553 {
2554  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2555  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2556 
2557  if( SO ) {
2558  for( size_t j=0UL; j<columns(); ++j ) {
2559  const auto last( (~rhs).upperBound(j,j) );
2560  for( auto element=(~rhs).begin(j); element!=last; ++element )
2561  matrix_(element->index(),j) = element->value();
2562  }
2563  }
2564  else {
2565  for( size_t i=0UL; i<rows(); ++i ) {
2566  const auto last( (~rhs).upperBound(i,i) );
2567  for( auto element=(~rhs).begin(i); element!=last; ++element )
2568  matrix_(i,element->index()) = element->value();
2569  }
2570  }
2571 }
2573 //*************************************************************************************************
2574 
2575 
2576 //*************************************************************************************************
2588 template< typename MT // Type of the adapted dense matrix
2589  , bool SO > // Storage order of the adapted dense matrix
2590 template< typename MT2 > // Type of the right-hand side dense matrix
2591 inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const DenseMatrix<MT2,SO>& rhs )
2592 {
2593  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2594  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2595 
2596  if( SO ) {
2597  for( size_t j=0UL; j<columns(); ++j )
2598  for( size_t i=0UL; i<=j; ++i )
2599  matrix_(i,j) += (~rhs)(i,j);
2600  }
2601  else {
2602  for( size_t i=0UL; i<rows(); ++i )
2603  for( size_t j=0UL; j<=i; ++j )
2604  matrix_(i,j) += (~rhs)(i,j);
2605  }
2606 }
2608 //*************************************************************************************************
2609 
2610 
2611 //*************************************************************************************************
2623 template< typename MT // Type of the adapted dense matrix
2624  , bool SO > // Storage order of the adapted dense matrix
2625 template< typename MT2 > // Type of the right-hand side sparse matrix
2626 inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const SparseMatrix<MT2,SO>& rhs )
2627 {
2628  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2629  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2630 
2631  if( SO ) {
2632  for( size_t j=0UL; j<columns(); ++j ) {
2633  const auto last( (~rhs).upperBound(j,j) );
2634  for( auto 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 auto last( (~rhs).upperBound(i,i) );
2641  for( auto element=(~rhs).begin(i); element!=last; ++element )
2642  matrix_(i,element->index()) += element->value();
2643  }
2644  }
2645 }
2647 //*************************************************************************************************
2648 
2649 
2650 //*************************************************************************************************
2662 template< typename MT // Type of the adapted dense matrix
2663  , bool SO > // Storage order of the adapted dense matrix
2664 template< typename MT2 > // Type of the right-hand side dense matrix
2665 inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const DenseMatrix<MT2,SO>& rhs )
2666 {
2667  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2668  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2669 
2670  if( SO ) {
2671  for( size_t j=0UL; j<columns(); ++j )
2672  for( size_t i=0UL; i<=j; ++i )
2673  matrix_(i,j) -= (~rhs)(i,j);
2674  }
2675  else {
2676  for( size_t i=0UL; i<rows(); ++i )
2677  for( size_t j=0UL; j<=i; ++j )
2678  matrix_(i,j) -= (~rhs)(i,j);
2679  }
2680 }
2682 //*************************************************************************************************
2683 
2684 
2685 //*************************************************************************************************
2697 template< typename MT // Type of the adapted dense matrix
2698  , bool SO > // Storage order of the adapted dense matrix
2699 template< typename MT2 > // Type of the right-hand side sparse matrix
2700 inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const SparseMatrix<MT2,SO>& rhs )
2701 {
2702  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2703  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2704 
2705  if( SO ) {
2706  for( size_t j=0UL; j<columns(); ++j ) {
2707  const auto last( (~rhs).upperBound(j,j) );
2708  for( auto element=(~rhs).begin(j); element!=last; ++element )
2709  matrix_(element->index(),j) -= element->value();
2710  }
2711  }
2712  else {
2713  for( size_t i=0UL; i<rows(); ++i ) {
2714  const auto last( (~rhs).upperBound(i,i) );
2715  for( auto element=(~rhs).begin(i); element!=last; ++element )
2716  matrix_(i,element->index()) -= element->value();
2717  }
2718  }
2719 }
2721 //*************************************************************************************************
2722 
2723 
2724 //*************************************************************************************************
2736 template< typename MT // Type of the adapted dense matrix
2737  , bool SO > // Storage order of the adapted dense matrix
2738 template< typename MT2 > // Type of the right-hand side dense matrix
2739 inline void SymmetricMatrix<MT,SO,true,false>::schurAssign( const DenseMatrix<MT2,SO>& rhs )
2740 {
2741  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2742  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2743 
2744  if( SO ) {
2745  for( size_t j=0UL; j<columns(); ++j )
2746  for( size_t i=0UL; i<=j; ++i )
2747  matrix_(i,j) *= (~rhs)(i,j);
2748  }
2749  else {
2750  for( size_t i=0UL; i<rows(); ++i )
2751  for( size_t j=0UL; j<=i; ++j )
2752  matrix_(i,j) *= (~rhs)(i,j);
2753  }
2754 }
2756 //*************************************************************************************************
2757 
2758 
2759 //*************************************************************************************************
2771 template< typename MT // Type of the adapted dense matrix
2772  , bool SO > // Storage order of the adapted dense matrix
2773 template< typename MT2 > // Type of the right-hand side sparse matrix
2774 inline void SymmetricMatrix<MT,SO,true,false>::schurAssign( const SparseMatrix<MT2,SO>& rhs )
2775 {
2776  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2777  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2778 
2779  if( SO ) {
2780  for( size_t j=0UL; j<columns(); ++j )
2781  {
2782  size_t i( 0UL );
2783 
2784  const auto last( (~rhs).upperBound(j,j) );
2785  for( auto element=(~rhs).begin(j); element!=last; ++element ) {
2786  for( ; i<element->index(); ++i )
2787  reset( matrix_(i,j) );
2788  matrix_(i,j) *= element->value();
2789  ++i;
2790  }
2791 
2792  for( ; i<rows(); ++i ) {
2793  reset( matrix_(i,j) );
2794  }
2795  }
2796  }
2797  else {
2798  for( size_t i=0UL; i<rows(); ++i )
2799  {
2800  size_t j( 0UL );
2801 
2802  const auto last( (~rhs).upperBound(i,i) );
2803  for( auto element=(~rhs).begin(i); element!=last; ++element ) {
2804  for( ; j<element->index(); ++j )
2805  reset( matrix_(i,j) );
2806  matrix_(i,j) *= element->value();
2807  ++j;
2808  }
2809 
2810  for( ; j<columns(); ++j ) {
2811  reset( matrix_(i,j) );
2812  }
2813  }
2814  }
2815 }
2817 //*************************************************************************************************
2818 
2819 } // namespace blaze
2820 
2821 #endif
Header file for the implementation of the Submatrix view.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3078
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1004
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1271
#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
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( )...
Definition: DenseMatrix.h:354
Header file for the UNUSED_PARAMETER function template.
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
Header file for basic type definitions.
constexpr 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:750
MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:169
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
Header file for the isZero shim.
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:61
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3077
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:799
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5828
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3079
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3084
#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
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Constraint on the data type.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
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:482
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:416
Header file for the implementation of the base template of the SymmetricMatrix.
Constraint on the data type.
Constraint on the data type.
size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:252
Header file for the IsSquare type trait.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:673
Constraint on the data type.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
Header file for the DisableIf class template.
Header file for the IsCustom type trait.
Header file for the IsSymmetric type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3083
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5907
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:5890
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Header file for the IsSMPAssignable type trait.
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3080
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the DenseMatrix base class.
constexpr bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:370
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:446
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:253
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
Constraint on the data type.
Constraints on the storage order of matrix types.
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:135
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
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
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:438
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8908
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:293
Header file for all forward declarations for expression class templates.
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:360
Header file for the EnableIf class template.
Header file for utility functions for dense matrices.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
BLAZE_ALWAYS_INLINE void conjugate(T &a) noexcept(IsNumeric_v< T >)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:281
Constraint on the data type.
Constraint on the data type.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:539
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
constexpr 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:718
Header file for the RemoveReference type trait.
constexpr bool IsComputation_v
Auxiliary variable template for the IsComputation type trait.The IsComputation_v variable template pr...
Definition: IsComputation.h:90
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:765
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a &#39;res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3082
#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
auto operator*=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( )...
Definition: DenseMatrix.h:290
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
#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
bool isDefault(const CompressedMatrix< Type, SO > &m)
Returns whether the given compressed matrix is in default state.
Definition: CompressedMatrix.h:5863
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
typename DisableIf< Condition, T >::Type DisableIf_t
Auxiliary type for the DisableIf class template.The DisableIf_t alias declaration provides a convenie...
Definition: DisableIf.h:138
#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
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:951
Header file for the Size type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
constexpr ptrdiff_t Size_v
Auxiliary variable template for the Size type trait.The Size_v variable template provides a convenien...
Definition: Size.h:176
Header file for the clear shim.
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825