Blaze  3.6
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>
58 #include <blaze/math/Exception.h>
61 #include <blaze/math/shims/Clear.h>
74 #include <blaze/util/Assert.h>
80 #include <blaze/util/DisableIf.h>
81 #include <blaze/util/EnableIf.h>
82 #include <blaze/util/MaybeUnused.h>
83 #include <blaze/util/mpl/If.h>
85 #include <blaze/util/Types.h>
88 
89 
90 namespace blaze {
91 
92 //=================================================================================================
93 //
94 // CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES WITH NON-NUMERIC ELEMENT TYPE
95 //
96 //=================================================================================================
97 
98 //*************************************************************************************************
106 template< typename MT // Type of the adapted dense matrix
107  , bool SO > // Storage order of the adapted dense matrix
108 class SymmetricMatrix<MT,SO,true,false>
109  : public DenseMatrix< SymmetricMatrix<MT,SO,true,false>, SO >
110 {
111  private:
112  //**Type definitions****************************************************************************
113  using OT = OppositeType_t<MT>;
114  using TT = TransposeType_t<MT>;
115  using ET = ElementType_t<MT>;
116  //**********************************************************************************************
117 
118  public:
119  //**Type definitions****************************************************************************
120  using This = SymmetricMatrix<MT,SO,true,false>;
121  using BaseType = DenseMatrix<This,SO>;
122  using ResultType = This;
123  using OppositeType = SymmetricMatrix<OT,!SO,true,false>;
124  using TransposeType = SymmetricMatrix<TT,!SO,true,false>;
125  using ElementType = ET;
126  using ReturnType = ReturnType_t<MT>;
127  using CompositeType = const This&;
128  using Reference = Reference_t<MT>;
129  using ConstReference = ConstReference_t<MT>;
130  using Pointer = Pointer_t<MT>;
131  using ConstPointer = ConstPointer_t<MT>;
132  //**********************************************************************************************
133 
134  //**Rebind struct definition********************************************************************
137  template< typename NewType > // Data type of the other matrix
138  struct Rebind {
140  using Other = SymmetricMatrix< typename MT::template Rebind<NewType>::Other >;
141  };
142  //**********************************************************************************************
143 
144  //**Resize struct definition********************************************************************
147  template< size_t NewM // Number of rows of the other matrix
148  , size_t NewN > // Number of columns of the other matrix
149  struct Resize {
151  using Other = SymmetricMatrix< typename MT::template Resize<NewM,NewN>::Other >;
152  };
153  //**********************************************************************************************
154 
155  //**MatrixIterator class definition*************************************************************
158  template< typename MatrixType > // Type of the adapted dense matrix
159  class MatrixIterator
160  {
161  public:
162  //**Type definitions*************************************************************************
164  using Reference = If_t< IsConst_v<MatrixType>
165  , ConstReference_t<MatrixType>
166  , Reference_t<MatrixType> >;
167 
168  using IteratorCategory = std::random_access_iterator_tag;
169  using ValueType = RemoveReference_t<Reference>;
170  using PointerType = ValueType*;
171  using ReferenceType = Reference;
172  using DifferenceType = ptrdiff_t;
173 
174  // STL iterator requirements
175  using iterator_category = IteratorCategory;
176  using value_type = ValueType;
177  using pointer = PointerType;
178  using reference = ReferenceType;
179  using difference_type = DifferenceType;
180  //*******************************************************************************************
181 
182  //**Constructor******************************************************************************
185  inline MatrixIterator() noexcept
186  : matrix_( nullptr ) // Reference to the adapted dense matrix
187  , row_ ( 0UL ) // The current row index of the iterator
188  , column_( 0UL ) // The current column index of the iterator
189  {}
190  //*******************************************************************************************
191 
192  //**Constructor******************************************************************************
199  inline MatrixIterator( MatrixType& matrix, size_t row, size_t column ) noexcept
200  : matrix_( &matrix ) // Reference to the adapted dense matrix
201  , row_ ( row ) // The current row index of the iterator
202  , column_( column ) // The current column index of the iterator
203  {}
204  //*******************************************************************************************
205 
206  //**Conversion constructor*******************************************************************
211  template< typename MatrixType2 >
212  inline MatrixIterator( const MatrixIterator<MatrixType2>& it ) noexcept
213  : matrix_( it.matrix_ ) // Reference to the adapted dense matrix
214  , row_ ( it.row_ ) // The current row index of the iterator
215  , column_( it.column_ ) // The current column index of the iterator
216  {}
217  //*******************************************************************************************
218 
219  //**Addition assignment operator*************************************************************
225  inline MatrixIterator& operator+=( size_t inc ) noexcept {
226  ( SO )?( row_ += inc ):( column_ += inc );
227  return *this;
228  }
229  //*******************************************************************************************
230 
231  //**Subtraction assignment operator**********************************************************
237  inline MatrixIterator& operator-=( size_t dec ) noexcept {
238  ( SO )?( row_ -= dec ):( column_ -= dec );
239  return *this;
240  }
241  //*******************************************************************************************
242 
243  //**Prefix increment operator****************************************************************
248  inline MatrixIterator& operator++() noexcept {
249  ( SO )?( ++row_ ):( ++column_ );
250  return *this;
251  }
252  //*******************************************************************************************
253 
254  //**Postfix increment operator***************************************************************
259  inline const MatrixIterator operator++( int ) noexcept {
260  const MatrixIterator tmp( *this );
261  ++(*this);
262  return tmp;
263  }
264  //*******************************************************************************************
265 
266  //**Prefix decrement operator****************************************************************
271  inline MatrixIterator& operator--() noexcept {
272  ( SO )?( --row_ ):( --column_ );
273  return *this;
274  }
275  //*******************************************************************************************
276 
277  //**Postfix decrement operator***************************************************************
282  inline const MatrixIterator operator--( int ) noexcept {
283  const MatrixIterator tmp( *this );
284  --(*this);
285  return tmp;
286  }
287  //*******************************************************************************************
288 
289  //**Element access operator******************************************************************
294  inline ReferenceType operator*() const {
295  if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
296  return (*matrix_)(row_,column_);
297  else
298  return (*matrix_)(column_,row_);
299  }
300  //*******************************************************************************************
301 
302  //**Element access operator******************************************************************
307  inline PointerType operator->() const {
308  if( ( SO && row_ < column_ ) || ( !SO && row_ > column_ ) )
309  return &(*matrix_)(row_,column_);
310  else
311  return &(*matrix_)(column_,row_);
312  }
313  //*******************************************************************************************
314 
315  //**Equality operator************************************************************************
321  template< typename MatrixType2 >
322  inline bool operator==( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
323  return ( SO )?( row_ == rhs.row_ ):( column_ == rhs.column_ );
324  }
325  //*******************************************************************************************
326 
327  //**Inequality operator**********************************************************************
333  template< typename MatrixType2 >
334  inline bool operator!=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
335  return ( SO )?( row_ != rhs.row_ ):( column_ != rhs.column_ );
336  }
337  //*******************************************************************************************
338 
339  //**Less-than operator***********************************************************************
345  template< typename MatrixType2 >
346  inline bool operator<( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
347  return ( SO )?( row_ < rhs.row_ ):( column_ < rhs.column_ );
348  return ( column_ < rhs.column_ );
349  }
350  //*******************************************************************************************
351 
352  //**Greater-than operator********************************************************************
358  template< typename MatrixType2 >
359  inline bool operator>( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
360  return ( SO )?( row_ > rhs.row_ ):( column_ > rhs.column_ );
361  return ( column_ > rhs.column_ );
362  }
363  //*******************************************************************************************
364 
365  //**Less-or-equal-than operator**************************************************************
371  template< typename MatrixType2 >
372  inline bool operator<=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
373  return ( SO )?( row_ <= rhs.row_ ):( column_ <= rhs.column_ );
374  }
375  //*******************************************************************************************
376 
377  //**Greater-or-equal-than operator***********************************************************
383  template< typename MatrixType2 >
384  inline bool operator>=( const MatrixIterator<MatrixType2>& rhs ) const noexcept {
385  return ( SO )?( row_ >= rhs.row_ ):( column_ >= rhs.column_ );
386  }
387  //*******************************************************************************************
388 
389  //**Subtraction operator*********************************************************************
395  inline DifferenceType operator-( const MatrixIterator& rhs ) const noexcept {
396  return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
397  }
398  //*******************************************************************************************
399 
400  //**Addition operator************************************************************************
407  friend inline const MatrixIterator operator+( const MatrixIterator& it, size_t inc ) noexcept {
408  if( SO )
409  return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
410  else
411  return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
412  }
413  //*******************************************************************************************
414 
415  //**Addition operator************************************************************************
422  friend inline const MatrixIterator operator+( size_t inc, const MatrixIterator& it ) noexcept {
423  if( SO )
424  return MatrixIterator( *it.matrix_, it.row_ + inc, it.column_ );
425  else
426  return MatrixIterator( *it.matrix_, it.row_, it.column_ + inc );
427  }
428  //*******************************************************************************************
429 
430  //**Subtraction operator*********************************************************************
437  friend inline const MatrixIterator operator-( const MatrixIterator& it, size_t dec ) noexcept {
438  if( SO )
439  return MatrixIterator( *it.matrix_, it.row_ - dec, it.column_ );
440  else
441  return MatrixIterator( *it.matrix_, it.row_, it.column_ - dec );
442  }
443  //*******************************************************************************************
444 
445  private:
446  //**Member variables*************************************************************************
447  MatrixType* matrix_;
448  size_t row_;
449  size_t column_;
450  //*******************************************************************************************
451 
452  //**Friend declarations**********************************************************************
453  template< typename MatrixType2 > friend class MatrixIterator;
454  //*******************************************************************************************
455  };
456  //**********************************************************************************************
457 
458  //**Type definitions****************************************************************************
459  using Iterator = MatrixIterator<MT>;
460  using ConstIterator = MatrixIterator<const MT>;
461  //**********************************************************************************************
462 
463  //**Compilation flags***************************************************************************
465  static constexpr bool simdEnabled = false;
466 
468  static constexpr bool smpAssignable = ( MT::smpAssignable && !IsSMPAssignable_v<ET> );
469  //**********************************************************************************************
470 
471  //**Constructors********************************************************************************
474  explicit inline SymmetricMatrix();
475  explicit inline SymmetricMatrix( size_t n );
476 
477  explicit inline SymmetricMatrix( ElementType* ptr, size_t n );
478  explicit inline SymmetricMatrix( ElementType* ptr, size_t n, size_t nn );
479 
480  inline SymmetricMatrix( const SymmetricMatrix& m );
481  inline SymmetricMatrix( SymmetricMatrix&& m ) noexcept;
482 
483  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,SO>& m );
484  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,!SO>& m );
486  //**********************************************************************************************
487 
488  //**Destructor**********************************************************************************
491  ~SymmetricMatrix() = default;
493  //**********************************************************************************************
494 
495  //**Data access functions***********************************************************************
498  inline Reference operator()( size_t i, size_t j );
499  inline ConstReference operator()( size_t i, size_t j ) const;
500  inline Reference at( size_t i, size_t j );
501  inline ConstReference at( size_t i, size_t j ) const;
502  inline ConstPointer data () const noexcept;
503  inline ConstPointer data ( size_t i ) const noexcept;
504  inline Iterator begin ( size_t i );
505  inline ConstIterator begin ( size_t i ) const;
506  inline ConstIterator cbegin( size_t i ) const;
507  inline Iterator end ( size_t i );
508  inline ConstIterator end ( size_t i ) const;
509  inline ConstIterator cend ( size_t i ) const;
511  //**********************************************************************************************
512 
513  //**Assignment operators************************************************************************
516  inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
517  inline SymmetricMatrix& operator=( SymmetricMatrix&& rhs ) noexcept;
518 
519  template< typename MT2 >
520  inline auto operator=( const Matrix<MT2,SO>& rhs )
521  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
522 
523  template< typename MT2 >
524  inline auto operator=( const Matrix<MT2,SO>& rhs )
525  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
526 
527  template< typename MT2 >
528  inline auto operator=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
529 
530  template< typename MT2 >
531  inline auto operator+=( const Matrix<MT2,SO>& rhs )
532  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
533 
534  template< typename MT2 >
535  inline auto operator+=( const Matrix<MT2,SO>& rhs )
536  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
537 
538  template< typename MT2 >
539  inline auto operator+=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
540 
541  template< typename MT2 >
542  inline auto operator-=( const Matrix<MT2,SO>& rhs )
543  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
544 
545  template< typename MT2 >
546  inline auto operator-=( const Matrix<MT2,SO>& rhs )
547  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
548 
549  template< typename MT2 >
550  inline auto operator-=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
551 
552  template< typename MT2 >
553  inline auto operator%=( const Matrix<MT2,SO>& rhs )
554  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
555 
556  template< typename MT2 >
557  inline auto operator%=( const Matrix<MT2,SO>& rhs )
558  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >;
559 
560  template< typename MT2 >
561  inline auto operator%=( const Matrix<MT2,!SO>& rhs ) -> SymmetricMatrix&;
562 
563  template< typename ST >
564  inline auto operator*=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >;
565 
566  template< typename ST >
567  inline auto operator/=( ST rhs ) -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >;
569  //**********************************************************************************************
570 
571  //**Utility functions***************************************************************************
574  inline size_t rows() const noexcept;
575  inline size_t columns() const noexcept;
576  inline size_t spacing() const noexcept;
577  inline size_t capacity() const noexcept;
578  inline size_t capacity( size_t i ) const noexcept;
579  inline size_t nonZeros() const;
580  inline size_t nonZeros( size_t i ) const;
581  inline void reset();
582  inline void reset( size_t i );
583  inline void clear();
584  void resize ( size_t n, bool preserve=true );
585  inline void extend ( size_t n, bool preserve=true );
586  inline void reserve( size_t elements );
587  inline void shrinkToFit();
588  inline void swap( SymmetricMatrix& m ) noexcept;
590  //**********************************************************************************************
591 
592  //**Numeric functions***************************************************************************
595  inline SymmetricMatrix& transpose();
596  inline SymmetricMatrix& ctranspose();
597 
598  template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
600  //**********************************************************************************************
601 
602  //**Debugging functions*************************************************************************
605  inline bool isIntact() const noexcept;
607  //**********************************************************************************************
608 
609  //**Expression template evaluation functions****************************************************
612  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
613  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
614 
615  inline bool isAligned () const noexcept;
616  inline bool canSMPAssign() const noexcept;
618  //**********************************************************************************************
619 
620  private:
621  //**Expression template evaluation functions****************************************************
624  template< typename MT2 > inline void assign ( DenseMatrix <MT2,SO>& rhs );
625  template< typename MT2 > inline void assign ( const DenseMatrix <MT2,SO>& rhs );
626  template< typename MT2 > inline void assign ( const SparseMatrix<MT2,SO>& rhs );
627  template< typename MT2 > inline void addAssign ( const DenseMatrix <MT2,SO>& rhs );
628  template< typename MT2 > inline void addAssign ( const SparseMatrix<MT2,SO>& rhs );
629  template< typename MT2 > inline void subAssign ( const DenseMatrix <MT2,SO>& rhs );
630  template< typename MT2 > inline void subAssign ( const SparseMatrix<MT2,SO>& rhs );
631  template< typename MT2 > inline void schurAssign( const DenseMatrix <MT2,SO>& rhs );
632  template< typename MT2 > inline void schurAssign( const SparseMatrix<MT2,SO>& rhs );
634  //**********************************************************************************************
635 
636  //**Member variables****************************************************************************
639  MT matrix_;
640 
641  //**********************************************************************************************
642 
643  //**Friend declarations*************************************************************************
644  template< bool RF, typename MT2, bool SO2, bool DF2, bool NF2 >
645  friend bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
646  //**********************************************************************************************
647 
648  //**Compile time checks*************************************************************************
664  BLAZE_STATIC_ASSERT( ( Size_v<MT,0UL> == Size_v<MT,1UL> ) );
665  //**********************************************************************************************
666 };
668 //*************************************************************************************************
669 
670 
671 
672 
673 //=================================================================================================
674 //
675 // CONSTRUCTORS
676 //
677 //=================================================================================================
678 
679 //*************************************************************************************************
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()
686  : matrix_() // The adapted dense matrix
687 {
688  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
689 }
691 //*************************************************************************************************
692 
693 
694 //*************************************************************************************************
700 template< typename MT // Type of the adapted dense matrix
701  , bool SO > // Storage order of the adapted dense matrix
702 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( size_t n )
703  : matrix_( n, n ) // The adapted dense matrix
704 {
706 
707  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
708 }
710 //*************************************************************************************************
711 
712 
713 //*************************************************************************************************
747 template< typename MT // Type of the adapted dense matrix
748  , bool SO > // Storage order of the adapted dense matrix
749 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n )
750  : matrix_( ptr, n, n ) // The adapted dense matrix
751 {
752  if( !isSymmetric( matrix_ ) ) {
753  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
754  }
755 
756  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
757 }
759 //*************************************************************************************************
760 
761 
762 //*************************************************************************************************
798 template< typename MT // Type of the adapted dense matrix
799  , bool SO > // Storage order of the adapted dense matrix
800 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( ElementType* ptr, size_t n, size_t nn )
801  : matrix_( ptr, n, n, nn ) // The adapted dense matrix
802 {
803  if( !isSymmetric( matrix_ ) ) {
804  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
805  }
806 
807  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
808 }
810 //*************************************************************************************************
811 
812 
813 //*************************************************************************************************
819 template< typename MT // Type of the adapted dense matrix
820  , bool SO > // Storage order of the adapted dense matrix
821 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const SymmetricMatrix& m )
822  : matrix_( m.matrix_ ) // The adapted dense matrix
823 {
824  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
825  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
826 }
828 //*************************************************************************************************
829 
830 
831 //*************************************************************************************************
837 template< typename MT // Type of the adapted dense matrix
838  , bool SO > // Storage order of the adapted dense matrix
839 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( SymmetricMatrix&& m ) noexcept
840  : matrix_( std::move( m.matrix_ ) ) // The adapted dense matrix
841 {
842  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
843  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
844 }
846 //*************************************************************************************************
847 
848 
849 //*************************************************************************************************
859 template< typename MT // Type of the adapted dense matrix
860  , bool SO > // Storage order of the adapted dense matrix
861 template< typename MT2 > // Type of the foreign matrix
862 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,SO>& m )
863  : matrix_() // The adapted dense matrix
864 {
865  using blaze::resize;
866 
867  using RT = RemoveAdaptor_t<ResultType_t<MT2> >;
868  using Tmp = If_t< IsComputation_v<MT2>, RT, const MT2& >;
869 
870  if( IsSymmetric_v<MT2> ) {
871  resize( matrix_, (~m).rows(), (~m).columns() );
872  assign( ~m );
873  }
874  else {
875  Tmp tmp( ~m );
876 
877  if( !isSymmetric( tmp ) ) {
878  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
879  }
880 
881  resize( matrix_, tmp.rows(), tmp.rows() );
882  assign( tmp );
883  }
884 
885  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
886  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
887 }
889 //*************************************************************************************************
890 
891 
892 //*************************************************************************************************
902 template< typename MT // Type of the adapted dense matrix
903  , bool SO > // Storage order of the adapted dense matrix
904 template< typename MT2 > // Type of the foreign matrix
905 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
906  : matrix_() // The adapted dense matrix
907 {
908  using blaze::resize;
909 
910  using RT = RemoveAdaptor_t< ResultType_t<MT2> >;
911  using Tmp = If_t< IsComputation_v<MT2>, RT, const MT2& >;
912 
913  if( IsSymmetric_v<MT2> ) {
914  resize( matrix_, (~m).rows(), (~m).columns() );
915  assign( trans( ~m ) );
916  }
917  else {
918  Tmp tmp( ~m );
919 
920  if( !isSymmetric( tmp ) ) {
921  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
922  }
923 
924  resize( matrix_, tmp.rows(), tmp.rows() );
925  assign( trans( tmp ) );
926  }
927 
928  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
929  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
930 }
932 //*************************************************************************************************
933 
934 
935 
936 
937 //=================================================================================================
938 //
939 // DATA ACCESS FUNCTIONS
940 //
941 //=================================================================================================
942 
943 //*************************************************************************************************
958 template< typename MT // Type of the adapted dense matrix
959  , bool SO > // Storage order of the adapted dense matrix
960 inline typename SymmetricMatrix<MT,SO,true,false>::Reference
961  SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j )
962 {
963  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
964  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
965 
966  if( ( !SO && i > j ) || ( SO && i < j ) )
967  return matrix_(i,j);
968  else
969  return matrix_(j,i);
970 }
972 //*************************************************************************************************
973 
974 
975 //*************************************************************************************************
990 template< typename MT // Type of the adapted dense matrix
991  , bool SO > // Storage order of the adapted dense matrix
992 inline typename SymmetricMatrix<MT,SO,true,false>::ConstReference
993  SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j ) const
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 //*************************************************************************************************
1023 template< typename MT // Type of the adapted dense matrix
1024  , bool SO > // Storage order of the adapted dense matrix
1025 inline typename SymmetricMatrix<MT,SO,true,false>::Reference
1026  SymmetricMatrix<MT,SO,true,false>::at( size_t i, size_t j )
1027 {
1028  if( i >= rows() ) {
1029  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1030  }
1031  if( j >= columns() ) {
1032  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1033  }
1034  return (*this)(i,j);
1035 }
1037 //*************************************************************************************************
1038 
1039 
1040 //*************************************************************************************************
1056 template< typename MT // Type of the adapted dense matrix
1057  , bool SO > // Storage order of the adapted dense matrix
1058 inline typename SymmetricMatrix<MT,SO,true,false>::ConstReference
1059  SymmetricMatrix<MT,SO,true,false>::at( size_t i, size_t j ) const
1060 {
1061  if( i >= rows() ) {
1062  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1063  }
1064  if( j >= columns() ) {
1065  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1066  }
1067  return (*this)(i,j);
1068 }
1070 //*************************************************************************************************
1071 
1072 
1073 //*************************************************************************************************
1087 template< typename MT // Type of the adapted dense matrix
1088  , bool SO > // Storage order of the adapted dense matrix
1089 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1091 {
1092  return matrix_.data();
1093 }
1095 //*************************************************************************************************
1096 
1097 
1098 //*************************************************************************************************
1109 template< typename MT // Type of the adapted dense matrix
1110  , bool SO > // Storage order of the adapted dense matrix
1111 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1112  SymmetricMatrix<MT,SO,true,false>::data( size_t i ) const noexcept
1113 {
1114  return matrix_.data(i);
1115 }
1117 //*************************************************************************************************
1118 
1119 
1120 //*************************************************************************************************
1132 template< typename MT // Type of the adapted dense matrix
1133  , bool SO > // Storage order of the adapted dense matrix
1134 inline typename SymmetricMatrix<MT,SO,true,false>::Iterator
1136 {
1137  if( SO )
1138  return Iterator( matrix_, 0UL, i );
1139  else
1140  return Iterator( matrix_, i, 0UL );
1141 }
1143 //*************************************************************************************************
1144 
1145 
1146 //*************************************************************************************************
1158 template< typename MT // Type of the adapted dense matrix
1159  , bool SO > // Storage order of the adapted dense matrix
1160 inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1162 {
1163  if( SO )
1164  return ConstIterator( matrix_, 0UL, i );
1165  else
1166  return ConstIterator( matrix_, i, 0UL );
1167 }
1169 //*************************************************************************************************
1170 
1171 
1172 //*************************************************************************************************
1184 template< typename MT // Type of the adapted dense matrix
1185  , bool SO > // Storage order of the adapted dense matrix
1186 inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1188 {
1189  if( SO )
1190  return ConstIterator( matrix_, 0UL, i );
1191  else
1192  return ConstIterator( matrix_, i, 0UL );
1193 }
1195 //*************************************************************************************************
1196 
1197 
1198 //*************************************************************************************************
1210 template< typename MT // Type of the adapted dense matrix
1211  , bool SO > // Storage order of the adapted dense matrix
1212 inline typename SymmetricMatrix<MT,SO,true,false>::Iterator
1214 {
1215  if( SO )
1216  return Iterator( matrix_, rows(), i );
1217  else
1218  return Iterator( matrix_, i, columns() );
1219 }
1221 //*************************************************************************************************
1222 
1223 
1224 //*************************************************************************************************
1236 template< typename MT // Type of the adapted dense matrix
1237  , bool SO > // Storage order of the adapted dense matrix
1238 inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1239  SymmetricMatrix<MT,SO,true,false>::end( size_t i ) const
1240 {
1241  if( SO )
1242  return ConstIterator( matrix_, rows(), i );
1243  else
1244  return ConstIterator( matrix_, i, columns() );
1245 }
1247 //*************************************************************************************************
1248 
1249 
1250 //*************************************************************************************************
1262 template< typename MT // Type of the adapted dense matrix
1263  , bool SO > // Storage order of the adapted dense matrix
1264 inline typename SymmetricMatrix<MT,SO,true,false>::ConstIterator
1265  SymmetricMatrix<MT,SO,true,false>::cend( size_t i ) const
1266 {
1267  if( SO )
1268  return ConstIterator( matrix_, rows(), i );
1269  else
1270  return ConstIterator( matrix_, i, columns() );
1271 }
1273 //*************************************************************************************************
1274 
1275 
1276 
1277 
1278 //=================================================================================================
1279 //
1280 // ASSIGNMENT OPERATORS
1281 //
1282 //=================================================================================================
1283 
1284 //*************************************************************************************************
1294 template< typename MT // Type of the adapted dense matrix
1295  , bool SO > // Storage order of the adapted dense matrix
1296 inline SymmetricMatrix<MT,SO,true,false>&
1297  SymmetricMatrix<MT,SO,true,false>::operator=( const SymmetricMatrix& rhs )
1298 {
1299  using blaze::resize;
1300 
1301  if( &rhs == this ) return *this;
1302 
1303  resize( matrix_, rhs.rows(), rhs.columns() );
1304  assign( rhs );
1305 
1306  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1307  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1308 
1309  return *this;
1310 }
1312 //*************************************************************************************************
1313 
1314 
1315 //*************************************************************************************************
1322 template< typename MT // Type of the adapted dense matrix
1323  , bool SO > // Storage order of the adapted dense matrix
1324 inline SymmetricMatrix<MT,SO,true,false>&
1325  SymmetricMatrix<MT,SO,true,false>::operator=( SymmetricMatrix&& rhs ) noexcept
1326 {
1327  matrix_ = std::move( rhs.matrix_ );
1328 
1329  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1330  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1331 
1332  return *this;
1333 }
1335 //*************************************************************************************************
1336 
1337 
1338 //*************************************************************************************************
1352 template< typename MT // Type of the adapted dense matrix
1353  , bool SO > // Storage order of the adapted dense matrix
1354 template< typename MT2 > // Type of the right-hand side matrix
1355 inline auto SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1356  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1357 {
1358  using blaze::resize;
1359 
1360  if( !IsSymmetric_v<MT2> && !isSymmetric( ~rhs ) ) {
1361  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1362  }
1363 
1364  if( (~rhs).isAliased( this ) ) {
1365  SymmetricMatrix tmp( ~rhs );
1366  swap( tmp );
1367  }
1368  else {
1369  resize( matrix_, (~rhs).rows(), (~rhs).columns() );
1370  if( IsSparseMatrix_v<MT2> )
1371  reset();
1372  assign( ~rhs );
1373  }
1374 
1375  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1376  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1377 
1378  return *this;
1379 }
1381 //*************************************************************************************************
1382 
1383 
1384 //*************************************************************************************************
1398 template< typename MT // Type of the adapted dense matrix
1399  , bool SO > // Storage order of the adapted dense matrix
1400 template< typename MT2 > // Type of the right-hand side matrix
1401 inline auto SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1402  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1403 {
1404  using blaze::resize;
1405 
1406  using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1407 
1408  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1409  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1410  }
1411 
1412  Tmp tmp( ~rhs );
1413 
1414  if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1415  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1416  }
1417 
1418  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1419 
1420  resize( matrix_, tmp.rows(), tmp.columns() );
1421  if( IsSparseMatrix_v<Tmp> )
1422  reset();
1423  assign( tmp );
1424 
1425  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1426  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1427 
1428  return *this;
1429 }
1431 //*************************************************************************************************
1432 
1433 
1434 //*************************************************************************************************
1448 template< typename MT // Type of the adapted dense matrix
1449  , bool SO > // Storage order of the adapted dense matrix
1450 template< typename MT2 > // Type of the right-hand side matrix
1451 inline auto SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,!SO>& rhs )
1452  -> SymmetricMatrix&
1453 {
1454  return this->operator=( trans( ~rhs ) );
1455 }
1457 //*************************************************************************************************
1458 
1459 
1460 //*************************************************************************************************
1473 template< typename MT // Type of the adapted dense matrix
1474  , bool SO > // Storage order of the adapted dense matrix
1475 template< typename MT2 > // Type of the right-hand side matrix
1476 inline auto SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1477  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1478 {
1479  if( !IsSymmetric_v<MT2> && !isSymmetric( ~rhs ) ) {
1480  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1481  }
1482 
1483  addAssign( ~rhs );
1484 
1485  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1486  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1487 
1488  return *this;
1489 }
1491 //*************************************************************************************************
1492 
1493 
1494 //*************************************************************************************************
1507 template< typename MT // Type of the adapted dense matrix
1508  , bool SO > // Storage order of the adapted dense matrix
1509 template< typename MT2 > // Type of the right-hand side matrix
1510 inline auto SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1511  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1512 {
1513  using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1514 
1515  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1516  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1517  }
1518 
1519  Tmp tmp( ~rhs );
1520 
1521  if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1522  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1523  }
1524 
1525  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1526 
1527  addAssign( tmp );
1528 
1529  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1530  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1531 
1532  return *this;
1533 }
1535 //*************************************************************************************************
1536 
1537 
1538 //*************************************************************************************************
1552 template< typename MT // Type of the adapted dense matrix
1553  , bool SO > // Storage order of the adapted dense matrix
1554 template< typename MT2 > // Type of the right-hand side matrix
1555 inline auto SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,!SO>& rhs )
1556  -> SymmetricMatrix&
1557 {
1558  return this->operator+=( trans( ~rhs ) );
1559 }
1561 //*************************************************************************************************
1562 
1563 
1564 //*************************************************************************************************
1577 template< typename MT // Type of the adapted dense matrix
1578  , bool SO > // Storage order of the adapted dense matrix
1579 template< typename MT2 > // Type of the right-hand side matrix
1580 inline auto SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1581  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1582 {
1583  if( !IsSymmetric_v<MT2> && !isSymmetric( ~rhs ) ) {
1584  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1585  }
1586 
1587  subAssign( ~rhs );
1588 
1589  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1590  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1591 
1592  return *this;
1593 }
1595 //*************************************************************************************************
1596 
1597 
1598 //*************************************************************************************************
1611 template< typename MT // Type of the adapted dense matrix
1612  , bool SO > // Storage order of the adapted dense matrix
1613 template< typename MT2 > // Type of the right-hand side matrix
1614 inline auto SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1615  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1616 {
1617  using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1618 
1619  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1620  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1621  }
1622 
1623  Tmp tmp( ~rhs );
1624 
1625  if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1626  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1627  }
1628 
1629  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1630 
1631  subAssign( tmp );
1632 
1633  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1634  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1635 
1636  return *this;
1637 }
1639 //*************************************************************************************************
1640 
1641 
1642 //*************************************************************************************************
1656 template< typename MT // Type of the adapted dense matrix
1657  , bool SO > // Storage order of the adapted dense matrix
1658 template< typename MT2 > // Type of the right-hand side matrix
1659 inline auto SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,!SO>& rhs )
1660  -> SymmetricMatrix&
1661 {
1662  return this->operator-=( trans( ~rhs ) );
1663 }
1665 //*************************************************************************************************
1666 
1667 
1668 //*************************************************************************************************
1682 template< typename MT // Type of the adapted dense matrix
1683  , bool SO > // Storage order of the adapted dense matrix
1684 template< typename MT2 > // Type of the right-hand side matrix
1685 inline auto SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,SO>& rhs )
1686  -> DisableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1687 {
1688  if( !IsSymmetric_v<MT2> && !isSymmetric( ~rhs ) ) {
1689  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1690  }
1691 
1692  schurAssign( ~rhs );
1693 
1694  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1695  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1696 
1697  return *this;
1698 }
1700 //*************************************************************************************************
1701 
1702 
1703 //*************************************************************************************************
1717 template< typename MT // Type of the adapted dense matrix
1718  , bool SO > // Storage order of the adapted dense matrix
1719 template< typename MT2 > // Type of the right-hand side matrix
1720 inline auto SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,SO>& rhs )
1721  -> EnableIf_t< IsComputation_v<MT2>, SymmetricMatrix& >
1722 {
1723  using Tmp = If_t< IsSymmetric_v<MT2>, CompositeType_t<MT2>, ResultType_t<MT2> >;
1724 
1725  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1726  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1727  }
1728 
1729  Tmp tmp( ~rhs );
1730 
1731  if( !IsSymmetric_v<Tmp> && !isSymmetric( tmp ) ) {
1732  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1733  }
1734 
1735  BLAZE_INTERNAL_ASSERT( !tmp.canAlias( this ), "Aliasing detected" );
1736 
1737  schurAssign( tmp );
1738 
1739  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1740  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1741 
1742  return *this;
1743 }
1745 //*************************************************************************************************
1746 
1747 
1748 //*************************************************************************************************
1762 template< typename MT // Type of the adapted dense matrix
1763  , bool SO > // Storage order of the adapted dense matrix
1764 template< typename MT2 > // Type of the right-hand side matrix
1765 inline auto SymmetricMatrix<MT,SO,true,false>::operator%=( const Matrix<MT2,!SO>& rhs )
1766  -> SymmetricMatrix&
1767 {
1768  return this->operator%=( trans( ~rhs ) );
1769 }
1771 //*************************************************************************************************
1772 
1773 
1774 //*************************************************************************************************
1782 template< typename MT // Type of the adapted dense matrix
1783  , bool SO > // Storage order of the adapted dense matrix
1784 template< typename ST > // Data type of the right-hand side scalar
1786  -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1787 {
1788  if( SO ) {
1789  for( size_t j=0UL; j<columns(); ++j )
1790  for( size_t i=0UL; i<=j; ++i )
1791  matrix_(i,j) *= rhs;
1792  }
1793  else {
1794  for( size_t i=0UL; i<rows(); ++i )
1795  for( size_t j=0UL; j<=i; ++j )
1796  matrix_(i,j) *= rhs;
1797  }
1798 
1799  return *this;
1800 }
1802 //*************************************************************************************************
1803 
1804 
1805 //*************************************************************************************************
1813 template< typename MT // Type of the adapted dense matrix
1814  , bool SO > // Storage order of the adapted dense matrix
1815 template< typename ST > // Data type of the right-hand side scalar
1817  -> EnableIf_t< IsNumeric_v<ST>, SymmetricMatrix& >
1818 {
1819  BLAZE_USER_ASSERT( !isZero( rhs ), "Division by zero detected" );
1820 
1821  if( SO ) {
1822  for( size_t j=0UL; j<columns(); ++j )
1823  for( size_t i=0UL; i<=j; ++i )
1824  matrix_(i,j) /= rhs;
1825  }
1826  else {
1827  for( size_t i=0UL; i<rows(); ++i )
1828  for( size_t j=0UL; j<=i; ++j )
1829  matrix_(i,j) /= rhs;
1830  }
1831 
1832  return *this;
1833 }
1835 //*************************************************************************************************
1836 
1837 
1838 
1839 
1840 //=================================================================================================
1841 //
1842 // UTILITY FUNCTIONS
1843 //
1844 //=================================================================================================
1845 
1846 //*************************************************************************************************
1852 template< typename MT // Type of the adapted dense matrix
1853  , bool SO > // Storage order of the adapted dense matrix
1854 inline size_t SymmetricMatrix<MT,SO,true,false>::rows() const noexcept
1855 {
1856  return matrix_.rows();
1857 }
1859 //*************************************************************************************************
1860 
1861 
1862 //*************************************************************************************************
1868 template< typename MT // Type of the adapted dense matrix
1869  , bool SO > // Storage order of the adapted dense matrix
1870 inline size_t SymmetricMatrix<MT,SO,true,false>::columns() const noexcept
1871 {
1872  return matrix_.columns();
1873 }
1875 //*************************************************************************************************
1876 
1877 
1878 //*************************************************************************************************
1890 template< typename MT // Type of the adapted dense matrix
1891  , bool SO > // Storage order of the adapted dense matrix
1892 inline size_t SymmetricMatrix<MT,SO,true,false>::spacing() const noexcept
1893 {
1894  return matrix_.spacing();
1895 }
1897 //*************************************************************************************************
1898 
1899 
1900 //*************************************************************************************************
1906 template< typename MT // Type of the adapted dense matrix
1907  , bool SO > // Storage order of the adapted dense matrix
1908 inline size_t SymmetricMatrix<MT,SO,true,false>::capacity() const noexcept
1909 {
1910  return matrix_.capacity();
1911 }
1913 //*************************************************************************************************
1914 
1915 
1916 //*************************************************************************************************
1927 template< typename MT // Type of the adapted dense matrix
1928  , bool SO > // Storage order of the adapted dense matrix
1929 inline size_t SymmetricMatrix<MT,SO,true,false>::capacity( size_t i ) const noexcept
1930 {
1931  return matrix_.capacity(i);
1932 }
1934 //*************************************************************************************************
1935 
1936 
1937 //*************************************************************************************************
1943 template< typename MT // Type of the adapted dense matrix
1944  , bool SO > // Storage order of the adapted dense matrix
1945 inline size_t SymmetricMatrix<MT,SO,true,false>::nonZeros() const
1946 {
1947  size_t nonzeros( 0UL );
1948 
1949  if( SO )
1950  {
1951  for( size_t j=0UL; j<columns(); ++j ) {
1952  for( size_t i=0UL; i<j; ++i ) {
1953  if( !isDefault( matrix_(i,j) ) )
1954  nonzeros += 2UL;
1955  }
1956  if( !isDefault( matrix_(j,j) ) )
1957  ++nonzeros;
1958  }
1959  }
1960  else
1961  {
1962  for( size_t i=0UL; i<rows(); ++i ) {
1963  for( size_t j=0UL; j<i; ++j ) {
1964  if( !isDefault( matrix_(i,j) ) )
1965  nonzeros += 2UL;
1966  }
1967  if( !isDefault( matrix_(i,i) ) )
1968  ++nonzeros;
1969  }
1970  }
1971 
1972  return nonzeros;
1973 }
1975 //*************************************************************************************************
1976 
1977 
1978 //*************************************************************************************************
1990 template< typename MT // Type of the adapted dense matrix
1991  , bool SO > // Storage order of the adapted dense matrix
1992 inline size_t SymmetricMatrix<MT,SO,true,false>::nonZeros( size_t i ) const
1993 {
1994  size_t nonzeros( 0UL );
1995 
1996  if( SO )
1997  {
1998  for( size_t j=0UL; j<i; ++j ) {
1999  if( !isDefault( matrix_(j,i) ) )
2000  ++nonzeros;
2001  }
2002  for( size_t j=i; j<rows(); ++j ) {
2003  if( !isDefault( matrix_(i,j) ) )
2004  ++nonzeros;
2005  }
2006  }
2007  else
2008  {
2009  for( size_t j=0UL; j<i; ++j ) {
2010  if( !isDefault( matrix_(i,j) ) )
2011  ++nonzeros;
2012  }
2013  for( size_t j=i; j<rows(); ++j ) {
2014  if( !isDefault( matrix_(j,i) ) )
2015  ++nonzeros;
2016  }
2017  }
2018 
2019  return nonzeros;
2020 }
2022 //*************************************************************************************************
2023 
2024 
2025 //*************************************************************************************************
2031 template< typename MT // Type of the adapted dense matrix
2032  , bool SO > // Storage order of the adapted dense matrix
2034 {
2035  using blaze::clear;
2036 
2037  if( SO ) {
2038  for( size_t j=0UL; j<columns(); ++j )
2039  for( size_t i=0UL; i<=j; ++i )
2040  clear( matrix_(i,j) );
2041  }
2042  else {
2043  for( size_t i=0UL; i<rows(); ++i )
2044  for( size_t j=0UL; j<=i; ++j )
2045  clear( matrix_(i,j) );
2046  }
2047 }
2049 //*************************************************************************************************
2050 
2051 
2052 //*************************************************************************************************
2092 template< typename MT // Type of the adapted dense matrix
2093  , bool SO > // Storage order of the adapted dense matrix
2094 inline void SymmetricMatrix<MT,SO,true,false>::reset( size_t i )
2095 {
2096  using blaze::clear;
2097 
2098  for( auto element=begin(i); element!=end(i); ++element )
2099  clear( *element );
2100 }
2102 //*************************************************************************************************
2103 
2104 
2105 //*************************************************************************************************
2117 template< typename MT // Type of the adapted dense matrix
2118  , bool SO > // Storage order of the adapted dense matrix
2120 {
2121  using blaze::clear;
2122 
2123  clear( matrix_ );
2124 }
2126 //*************************************************************************************************
2127 
2128 
2129 //*************************************************************************************************
2145 template< typename MT // Type of the adapted dense matrix
2146  , bool SO > // Storage order of the adapted dense matrix
2147 void SymmetricMatrix<MT,SO,true,false>::resize( size_t n, bool preserve )
2148 {
2150 
2151  MAYBE_UNUSED( preserve );
2152 
2153  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
2154 
2155  const size_t oldsize( matrix_.rows() );
2156 
2157  matrix_.resize( n, n, true );
2158 
2159  if( n > oldsize ) {
2160  const size_t increment( n - oldsize );
2161  submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2162  submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2163  }
2164 }
2166 //*************************************************************************************************
2167 
2168 
2169 //*************************************************************************************************
2182 template< typename MT // Type of the adapted dense matrix
2183  , bool SO > // Storage order of the adapted dense matrix
2184 inline void SymmetricMatrix<MT,SO,true,false>::extend( size_t n, bool preserve )
2185 {
2187 
2188  MAYBE_UNUSED( preserve );
2189 
2190  resize( rows() + n, true );
2191 }
2193 //*************************************************************************************************
2194 
2195 
2196 //*************************************************************************************************
2206 template< typename MT // Type of the adapted dense matrix
2207  , bool SO > // Storage order of the adapted dense matrix
2208 inline void SymmetricMatrix<MT,SO,true,false>::reserve( size_t elements )
2209 {
2210  matrix_.reserve( elements );
2211 }
2213 //*************************************************************************************************
2214 
2215 
2216 //*************************************************************************************************
2226 template< typename MT // Type of the adapted dense matrix
2227  , bool SO > // Storage order of the adapted dense matrix
2229 {
2230  matrix_.shrinkToFit();
2231 }
2233 //*************************************************************************************************
2234 
2235 
2236 //*************************************************************************************************
2243 template< typename MT // Type of the adapted dense matrix
2244  , bool SO > // Storage order of the adapted dense matrix
2245 inline void SymmetricMatrix<MT,SO,true,false>::swap( SymmetricMatrix& m ) noexcept
2246 {
2247  using std::swap;
2248 
2249  swap( matrix_, m.matrix_ );
2250 }
2252 //*************************************************************************************************
2253 
2254 
2255 
2256 
2257 //=================================================================================================
2258 //
2259 // NUMERIC FUNCTIONS
2260 //
2261 //=================================================================================================
2262 
2263 //*************************************************************************************************
2269 template< typename MT // Type of the adapted dense matrix
2270  , bool SO > // Storage order of the adapted dense matrix
2271 inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::transpose()
2272 {
2273  return *this;
2274 }
2276 //*************************************************************************************************
2277 
2278 
2279 //*************************************************************************************************
2285 template< typename MT // Type of the adapted dense matrix
2286  , bool SO > // Storage order of the adapted dense matrix
2287 inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::ctranspose()
2288 {
2289  if( SO ) {
2290  for( size_t j=0UL; j<columns(); ++j )
2291  for( size_t i=0UL; i<=j; ++i )
2292  conjugate( matrix_(i,j) );
2293  }
2294  else {
2295  for( size_t i=0UL; i<rows(); ++i )
2296  for( size_t j=0UL; j<=i; ++j )
2297  conjugate( matrix_(i,j) );
2298  }
2299 
2300  return *this;
2301 }
2303 //*************************************************************************************************
2304 
2305 
2306 //*************************************************************************************************
2324 template< typename MT // Type of the adapted dense matrix
2325  , bool SO > // Storage order of the adapted dense matrix
2326 template< typename Other > // Data type of the scalar value
2327 inline SymmetricMatrix<MT,SO,true,false>&
2328  SymmetricMatrix<MT,SO,true,false>::scale( const Other& scalar )
2329 {
2330  if( SO ) {
2331  for( size_t j=0UL; j<columns(); ++j )
2332  for( size_t i=0UL; i<=j; ++i )
2333  matrix_(i,j) *= scalar;
2334  }
2335  else {
2336  for( size_t i=0UL; i<rows(); ++i )
2337  for( size_t j=0UL; j<=i; ++j )
2338  matrix_(i,j) *= scalar;
2339  }
2340 
2341  return *this;
2342 }
2344 //*************************************************************************************************
2345 
2346 
2347 
2348 
2349 //=================================================================================================
2350 //
2351 // DEBUGGING FUNCTIONS
2352 //
2353 //=================================================================================================
2354 
2355 //*************************************************************************************************
2365 template< typename MT // Type of the adapted dense matrix
2366  , bool SO > // Storage order of the adapted dense matrix
2367 inline bool SymmetricMatrix<MT,SO,true,false>::isIntact() const noexcept
2368 {
2369  using blaze::isIntact;
2370 
2371  return isIntact( matrix_ ) &&
2372  ( IsCustom_v<MT> || ( SO ? isUpper( matrix_ ) : isLower( matrix_ ) ) );
2373 }
2375 //*************************************************************************************************
2376 
2377 
2378 
2379 
2380 //=================================================================================================
2381 //
2382 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2383 //
2384 //=================================================================================================
2385 
2386 //*************************************************************************************************
2397 template< typename MT // Type of the adapted dense matrix
2398  , bool SO > // Storage order of the adapted dense matrix
2399 template< typename Other > // Data type of the foreign expression
2400 inline bool SymmetricMatrix<MT,SO,true,false>::canAlias( const Other* alias ) const noexcept
2401 {
2402  return matrix_.canAlias( alias );
2403 }
2405 //*************************************************************************************************
2406 
2407 
2408 //*************************************************************************************************
2419 template< typename MT // Type of the adapted dense matrix
2420  , bool SO > // Storage order of the adapted dense matrix
2421 template< typename Other > // Data type of the foreign expression
2422 inline bool SymmetricMatrix<MT,SO,true,false>::isAliased( const Other* alias ) const noexcept
2423 {
2424  return matrix_.isAliased( alias );
2425 }
2427 //*************************************************************************************************
2428 
2429 
2430 //*************************************************************************************************
2440 template< typename MT // Type of the adapted dense matrix
2441  , bool SO > // Storage order of the adapted dense matrix
2442 inline bool SymmetricMatrix<MT,SO,true,false>::isAligned() const noexcept
2443 {
2444  return matrix_.isAligned();
2445 }
2447 //*************************************************************************************************
2448 
2449 
2450 //*************************************************************************************************
2461 template< typename MT // Type of the adapted dense matrix
2462  , bool SO > // Storage order of the adapted dense matrix
2463 inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign() const noexcept
2464 {
2465  return matrix_.canSMPAssign();
2466 }
2468 //*************************************************************************************************
2469 
2470 
2471 //*************************************************************************************************
2483 template< typename MT // Type of the adapted dense matrix
2484  , bool SO > // Storage order of the adapted dense matrix
2485 template< typename MT2 > // Type of the right-hand side dense matrix
2486 inline void SymmetricMatrix<MT,SO,true,false>::assign( DenseMatrix<MT2,SO>& rhs )
2487 {
2488  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2489  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2490 
2491  if( SO ) {
2492  for( size_t j=0UL; j<columns(); ++j )
2493  for( size_t i=0UL; i<=j; ++i )
2494  matrix_(i,j) = std::move( (~rhs)(i,j) );
2495  }
2496  else {
2497  for( size_t i=0UL; i<rows(); ++i )
2498  for( size_t j=0UL; j<=i; ++j )
2499  matrix_(i,j) = std::move( (~rhs)(i,j) );
2500  }
2501 }
2503 //*************************************************************************************************
2504 
2505 
2506 //*************************************************************************************************
2518 template< typename MT // Type of the adapted dense matrix
2519  , bool SO > // Storage order of the adapted dense matrix
2520 template< typename MT2 > // Type of the right-hand side dense matrix
2521 inline void SymmetricMatrix<MT,SO,true,false>::assign( const DenseMatrix<MT2,SO>& rhs )
2522 {
2523  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2524  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2525 
2526  if( SO ) {
2527  for( size_t j=0UL; j<columns(); ++j )
2528  for( size_t i=0UL; i<=j; ++i )
2529  matrix_(i,j) = (~rhs)(i,j);
2530  }
2531  else {
2532  for( size_t i=0UL; i<rows(); ++i )
2533  for( size_t j=0UL; j<=i; ++j )
2534  matrix_(i,j) = (~rhs)(i,j);
2535  }
2536 }
2538 //*************************************************************************************************
2539 
2540 
2541 //*************************************************************************************************
2553 template< typename MT // Type of the adapted dense matrix
2554  , bool SO > // Storage order of the adapted dense matrix
2555 template< typename MT2 > // Type of the right-hand side sparse matrix
2556 inline void SymmetricMatrix<MT,SO,true,false>::assign( const SparseMatrix<MT2,SO>& rhs )
2557 {
2558  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2559  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2560 
2561  if( SO ) {
2562  for( size_t j=0UL; j<columns(); ++j ) {
2563  const auto last( (~rhs).upperBound(j,j) );
2564  for( auto element=(~rhs).begin(j); element!=last; ++element )
2565  matrix_(element->index(),j) = element->value();
2566  }
2567  }
2568  else {
2569  for( size_t i=0UL; i<rows(); ++i ) {
2570  const auto last( (~rhs).upperBound(i,i) );
2571  for( auto element=(~rhs).begin(i); element!=last; ++element )
2572  matrix_(i,element->index()) = element->value();
2573  }
2574  }
2575 }
2577 //*************************************************************************************************
2578 
2579 
2580 //*************************************************************************************************
2592 template< typename MT // Type of the adapted dense matrix
2593  , bool SO > // Storage order of the adapted dense matrix
2594 template< typename MT2 > // Type of the right-hand side dense matrix
2595 inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const DenseMatrix<MT2,SO>& rhs )
2596 {
2597  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2598  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2599 
2600  if( SO ) {
2601  for( size_t j=0UL; j<columns(); ++j )
2602  for( size_t i=0UL; i<=j; ++i )
2603  matrix_(i,j) += (~rhs)(i,j);
2604  }
2605  else {
2606  for( size_t i=0UL; i<rows(); ++i )
2607  for( size_t j=0UL; j<=i; ++j )
2608  matrix_(i,j) += (~rhs)(i,j);
2609  }
2610 }
2612 //*************************************************************************************************
2613 
2614 
2615 //*************************************************************************************************
2627 template< typename MT // Type of the adapted dense matrix
2628  , bool SO > // Storage order of the adapted dense matrix
2629 template< typename MT2 > // Type of the right-hand side sparse matrix
2630 inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const SparseMatrix<MT2,SO>& rhs )
2631 {
2632  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2633  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2634 
2635  if( SO ) {
2636  for( size_t j=0UL; j<columns(); ++j ) {
2637  const auto last( (~rhs).upperBound(j,j) );
2638  for( auto element=(~rhs).begin(j); element!=last; ++element )
2639  matrix_(element->index(),j) += element->value();
2640  }
2641  }
2642  else {
2643  for( size_t i=0UL; i<rows(); ++i ) {
2644  const auto last( (~rhs).upperBound(i,i) );
2645  for( auto element=(~rhs).begin(i); element!=last; ++element )
2646  matrix_(i,element->index()) += element->value();
2647  }
2648  }
2649 }
2651 //*************************************************************************************************
2652 
2653 
2654 //*************************************************************************************************
2666 template< typename MT // Type of the adapted dense matrix
2667  , bool SO > // Storage order of the adapted dense matrix
2668 template< typename MT2 > // Type of the right-hand side dense matrix
2669 inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const DenseMatrix<MT2,SO>& rhs )
2670 {
2671  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2672  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2673 
2674  if( SO ) {
2675  for( size_t j=0UL; j<columns(); ++j )
2676  for( size_t i=0UL; i<=j; ++i )
2677  matrix_(i,j) -= (~rhs)(i,j);
2678  }
2679  else {
2680  for( size_t i=0UL; i<rows(); ++i )
2681  for( size_t j=0UL; j<=i; ++j )
2682  matrix_(i,j) -= (~rhs)(i,j);
2683  }
2684 }
2686 //*************************************************************************************************
2687 
2688 
2689 //*************************************************************************************************
2701 template< typename MT // Type of the adapted dense matrix
2702  , bool SO > // Storage order of the adapted dense matrix
2703 template< typename MT2 > // Type of the right-hand side sparse matrix
2704 inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const SparseMatrix<MT2,SO>& rhs )
2705 {
2706  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2707  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2708 
2709  if( SO ) {
2710  for( size_t j=0UL; j<columns(); ++j ) {
2711  const auto last( (~rhs).upperBound(j,j) );
2712  for( auto element=(~rhs).begin(j); element!=last; ++element )
2713  matrix_(element->index(),j) -= element->value();
2714  }
2715  }
2716  else {
2717  for( size_t i=0UL; i<rows(); ++i ) {
2718  const auto last( (~rhs).upperBound(i,i) );
2719  for( auto element=(~rhs).begin(i); element!=last; ++element )
2720  matrix_(i,element->index()) -= element->value();
2721  }
2722  }
2723 }
2725 //*************************************************************************************************
2726 
2727 
2728 //*************************************************************************************************
2740 template< typename MT // Type of the adapted dense matrix
2741  , bool SO > // Storage order of the adapted dense matrix
2742 template< typename MT2 > // Type of the right-hand side dense matrix
2743 inline void SymmetricMatrix<MT,SO,true,false>::schurAssign( const DenseMatrix<MT2,SO>& rhs )
2744 {
2745  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2746  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2747 
2748  if( SO ) {
2749  for( size_t j=0UL; j<columns(); ++j )
2750  for( size_t i=0UL; i<=j; ++i )
2751  matrix_(i,j) *= (~rhs)(i,j);
2752  }
2753  else {
2754  for( size_t i=0UL; i<rows(); ++i )
2755  for( size_t j=0UL; j<=i; ++j )
2756  matrix_(i,j) *= (~rhs)(i,j);
2757  }
2758 }
2760 //*************************************************************************************************
2761 
2762 
2763 //*************************************************************************************************
2775 template< typename MT // Type of the adapted dense matrix
2776  , bool SO > // Storage order of the adapted dense matrix
2777 template< typename MT2 > // Type of the right-hand side sparse matrix
2778 inline void SymmetricMatrix<MT,SO,true,false>::schurAssign( const SparseMatrix<MT2,SO>& rhs )
2779 {
2780  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2781  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2782 
2783  if( SO ) {
2784  for( size_t j=0UL; j<columns(); ++j )
2785  {
2786  size_t i( 0UL );
2787 
2788  const auto last( (~rhs).upperBound(j,j) );
2789  for( auto element=(~rhs).begin(j); element!=last; ++element ) {
2790  for( ; i<element->index(); ++i )
2791  reset( matrix_(i,j) );
2792  matrix_(i,j) *= element->value();
2793  ++i;
2794  }
2795 
2796  for( ; i<rows(); ++i ) {
2797  reset( matrix_(i,j) );
2798  }
2799  }
2800  }
2801  else {
2802  for( size_t i=0UL; i<rows(); ++i )
2803  {
2804  size_t j( 0UL );
2805 
2806  const auto last( (~rhs).upperBound(i,i) );
2807  for( auto element=(~rhs).begin(i); element!=last; ++element ) {
2808  for( ; j<element->index(); ++j )
2809  reset( matrix_(i,j) );
2810  matrix_(i,j) *= element->value();
2811  ++j;
2812  }
2813 
2814  for( ; j<columns(); ++j ) {
2815  reset( matrix_(i,j) );
2816  }
2817  }
2818  }
2819 }
2821 //*************************************************************************************************
2822 
2823 } // namespace blaze
2824 
2825 #endif
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T)
Constraint on the data type.In case the given data type T is a transformation expression (i....
Definition: Transformation.h:81
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,...
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
Constraint on the data type.
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
auto operator-=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Subtraction assignment operator for the subtraction of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:432
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
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:1793
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:2060
Constraint on the data type.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
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:170
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:178
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_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.In case the given data type T is a computational expression (i....
Definition: Computation.h:81
#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
constexpr bool operator<(const NegativeAccuracy< A > &lhs, const T &rhs)
Less-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:332
Constraint on the data type.
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
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:799
void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:851
Header file for the MAYBE_UNUSED function template.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type,...
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
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:253
Header file for the IsSquare type trait.
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:677
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.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for the If class template.
Compile time assertion.
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:9091
#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.
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
auto operator+=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsNumeric_v< ST >, MT & >
Addition assignment operator for the addition of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:370
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.
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
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:139
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
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 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:615
constexpr bool IsComputation_v
Auxiliary variable template for the IsComputation type trait.The IsComputation_v variable template pr...
Definition: IsComputation.h:90
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
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:558
#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,...
Definition: Symmetric.h:79
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
Header file for all forward declarations for expression class templates.
#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,...
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:282
Constraint on the data type.
Constraint on the data type.
constexpr bool operator<=(const NegativeAccuracy< A > &, const T &rhs)
Less-or-equal-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:408
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:1328
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VIEW_TYPE(T)
Constraint on the data type.In case the given data type T is a view type (i.e. a subvector,...
Definition: View.h:81
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.
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 'res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
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:494
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
#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,...
Definition: Hermitian.h:79
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
Constraint on the data type.
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,...
Definition: Assert.h:101
Header file for the clear shim.
void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:825