Sparse.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_HERMITIANMATRIX_SPARSE_H_
36 #define _BLAZE_MATH_ADAPTORS_HERMITIANMATRIX_SPARSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <iterator>
45 #include <vector>
59 #include <blaze/math/shims/Clear.h>
63 #include <blaze/math/shims/Move.h>
71 #include <blaze/util/Assert.h>
77 #include <blaze/util/DisableIf.h>
78 #include <blaze/util/EnableIf.h>
79 #include <blaze/util/Exception.h>
81 #include <blaze/util/TrueType.h>
82 #include <blaze/util/Types.h>
86 #include <blaze/util/Unused.h>
87 
88 
89 namespace blaze {
90 
91 //=================================================================================================
92 //
93 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
94 //
95 //=================================================================================================
96 
97 //*************************************************************************************************
105 template< typename MT // Type of the adapted sparse matrix
106  , bool SO > // Storage order of the adapted sparse matrix
107 class HermitianMatrix<MT,SO,false>
108  : public SparseMatrix< HermitianMatrix<MT,SO,false>, SO >
109 {
110  private:
111  //**Type definitions****************************************************************************
112  typedef typename MT::OppositeType OT;
113  typedef typename MT::TransposeType TT;
114  typedef typename MT::ElementType ET;
115  //**********************************************************************************************
116 
117  public:
118  //**Type definitions****************************************************************************
119  typedef HermitianMatrix<MT,SO,false> This;
120  typedef This ResultType;
121  typedef HermitianMatrix<OT,!SO,false> OppositeType;
122  typedef HermitianMatrix<TT,!SO,false> TransposeType;
123  typedef ET ElementType;
124  typedef typename MT::ReturnType ReturnType;
125  typedef const This& CompositeType;
126  typedef HermitianProxy<MT> Reference;
127  typedef typename MT::ConstReference ConstReference;
128  typedef typename MT::ConstIterator ConstIterator;
129  //**********************************************************************************************
130 
131  //**Rebind struct definition********************************************************************
134  template< typename ET > // Data type of the other matrix
135  struct Rebind {
137  typedef HermitianMatrix< typename MT::template Rebind<ET>::Other > Other;
138  };
139  //**********************************************************************************************
140 
141  //**Iterator class definition*******************************************************************
144  class Iterator
145  {
146  public:
147  //**Type definitions*************************************************************************
148  typedef typename MT::Iterator IteratorType;
149 
150  typedef std::forward_iterator_tag IteratorCategory;
151  typedef HermitianElement<MT> ValueType;
152  typedef ValueType PointerType;
153  typedef ValueType ReferenceType;
154  typedef ptrdiff_t DifferenceType;
155 
156  // STL iterator requirements
157  typedef IteratorCategory iterator_category;
158  typedef ValueType value_type;
159  typedef PointerType pointer;
160  typedef ReferenceType reference;
161  typedef DifferenceType difference_type;
162  //*******************************************************************************************
163 
164  //**Default constructor**********************************************************************
167  inline Iterator()
168  : pos_ ( ) // Iterator to the current sparse Hermitian matrix element
169  , matrix_( NULL ) // The sparse matrix containing the iterator
170  , index_ ( 0UL ) // The row/column index of the iterator
171  {}
172  //*******************************************************************************************
173 
174  //**Constructor******************************************************************************
181  inline Iterator( IteratorType pos, MT& matrix, size_t index )
182  : pos_ ( pos ) // Iterator to the current sparse Hermitian matrix element
183  , matrix_( &matrix ) // The sparse matrix containing the iterator
184  , index_ ( index ) // The row/column index of the iterator
185  {}
186  //*******************************************************************************************
187 
188  //**Prefix increment operator****************************************************************
193  inline Iterator& operator++() {
194  ++pos_;
195  return *this;
196  }
197  //*******************************************************************************************
198 
199  //**Postfix increment operator***************************************************************
204  inline const Iterator operator++( int ) {
205  const Iterator tmp( *this );
206  ++(*this);
207  return tmp;
208  }
209  //*******************************************************************************************
210 
211  //**Element access operator******************************************************************
216  inline ReferenceType operator*() const {
217  return ReferenceType( pos_, matrix_, index_ );
218  }
219  //*******************************************************************************************
220 
221  //**Element access operator******************************************************************
226  inline PointerType operator->() const {
227  return PointerType( pos_, matrix_, index_ );
228  }
229  //*******************************************************************************************
230 
231  //**Conversion operator**********************************************************************
236  inline operator ConstIterator() const {
237  return pos_;
238  }
239  //*******************************************************************************************
240 
241  //**Equality operator************************************************************************
247  inline bool operator==( const Iterator& rhs ) const {
248  return pos_ == rhs.pos_;
249  }
250  //*******************************************************************************************
251 
252  //**Inequality operator**********************************************************************
258  inline bool operator!=( const Iterator& rhs ) const {
259  return !( *this == rhs );
260  }
261  //*******************************************************************************************
262 
263  //**Subtraction operator*********************************************************************
269  inline DifferenceType operator-( const Iterator& rhs ) const {
270  return pos_ - rhs.pos_;
271  }
272  //*******************************************************************************************
273 
274  //**Base function****************************************************************************
279  inline IteratorType base() const {
280  return pos_;
281  }
282  //*******************************************************************************************
283 
284  private:
285  //**Member variables*************************************************************************
286  IteratorType pos_;
287  MT* matrix_;
288  size_t index_;
289  //*******************************************************************************************
290  };
291  //**********************************************************************************************
292 
293  //**Compilation flags***************************************************************************
295  enum { smpAssignable = 0 };
296  //**********************************************************************************************
297 
298  //**Constructors********************************************************************************
301  explicit inline HermitianMatrix();
302  explicit inline HermitianMatrix( size_t n );
303  explicit inline HermitianMatrix( size_t n, size_t nonzeros );
304  explicit inline HermitianMatrix( size_t n, const std::vector<size_t>& nonzeros );
305 
306  inline HermitianMatrix( const HermitianMatrix& m );
307  template< typename MT2, bool SO2 > inline HermitianMatrix( const Matrix<MT2,SO2>& m );
309  //**********************************************************************************************
310 
311  //**Destructor**********************************************************************************
312  // No explicitly declared destructor.
313  //**********************************************************************************************
314 
315  //**Data access functions***********************************************************************
318  inline Reference operator()( size_t i, size_t j );
319  inline ConstReference operator()( size_t i, size_t j ) const;
320  inline Reference at( size_t i, size_t j );
321  inline ConstReference at( size_t i, size_t j ) const;
322  inline Iterator begin ( size_t i );
323  inline ConstIterator begin ( size_t i ) const;
324  inline ConstIterator cbegin( size_t i ) const;
325  inline Iterator end ( size_t i );
326  inline ConstIterator end ( size_t i ) const;
327  inline ConstIterator cend ( size_t i ) const;
329  //**********************************************************************************************
330 
331  //**Assignment operators************************************************************************
334  inline HermitianMatrix& operator=( const HermitianMatrix& rhs );
335 
336  template< typename MT2, bool SO2 >
337  inline typename DisableIf< IsComputation<MT2>, HermitianMatrix& >::Type
338  operator=( const Matrix<MT2,SO2>& rhs );
339 
340  template< typename MT2, bool SO2 >
341  inline typename EnableIf< IsComputation<MT2>, HermitianMatrix& >::Type
342  operator=( const Matrix<MT2,SO2>& rhs );
343 
344  template< typename MT2 >
345  inline typename EnableIf< IsBuiltin<typename MT2::ElementType>, HermitianMatrix& >::Type
346  operator=( const Matrix<MT2,!SO>& rhs );
347 
348  template< typename MT2, bool SO2 >
349  inline typename DisableIf< IsComputation<MT2>, HermitianMatrix& >::Type
350  operator+=( const Matrix<MT2,SO2>& rhs );
351 
352  template< typename MT2, bool SO2 >
353  inline typename EnableIf< IsComputation<MT2>, HermitianMatrix& >::Type
354  operator+=( const Matrix<MT2,SO2>& rhs );
355 
356  template< typename MT2 >
357  inline typename EnableIf< IsBuiltin<typename MT2::ElementType>, HermitianMatrix& >::Type
358  operator+=( const Matrix<MT2,!SO>& rhs );
359 
360  template< typename MT2, bool SO2 >
361  inline typename DisableIf< IsComputation<MT2>, HermitianMatrix& >::Type
362  operator-=( const Matrix<MT2,SO2>& rhs );
363 
364  template< typename MT2, bool SO2 >
365  inline typename EnableIf< IsComputation<MT2>, HermitianMatrix& >::Type
366  operator-=( const Matrix<MT2,SO2>& rhs );
367 
368  template< typename MT2 >
369  inline typename EnableIf< IsBuiltin<typename MT2::ElementType>, HermitianMatrix& >::Type
370  operator-=( const Matrix<MT2,!SO>& rhs );
371 
372  template< typename MT2, bool SO2 >
373  inline HermitianMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
374 
375  template< typename Other >
376  inline typename EnableIf< IsNumeric<Other>, HermitianMatrix >::Type&
377  operator*=( Other rhs );
378 
379  template< typename Other >
380  inline typename EnableIf< IsNumeric<Other>, HermitianMatrix >::Type&
381  operator/=( Other rhs );
383  //**********************************************************************************************
384 
385  //**Utility functions***************************************************************************
388  inline size_t rows() const;
389  inline size_t columns() const;
390  inline size_t capacity() const;
391  inline size_t capacity( size_t i ) const;
392  inline size_t nonZeros() const;
393  inline size_t nonZeros( size_t i ) const;
394  inline void reset();
395  inline void reset( size_t i );
396  inline void clear();
397  inline Iterator set( size_t i, size_t j, const ElementType& value );
398  inline Iterator insert( size_t i, size_t j, const ElementType& value );
399  inline void erase( size_t i, size_t j );
400  inline Iterator erase( size_t i, Iterator pos );
401  inline Iterator erase( size_t i, Iterator first, Iterator last );
402  inline void resize ( size_t n, bool preserve=true );
403  inline void reserve( size_t nonzeros );
404  inline void reserve( size_t i, size_t nonzeros );
405  inline void trim();
406  inline void trim( size_t i );
407  inline HermitianMatrix& transpose();
408  inline HermitianMatrix& ctranspose();
409  template< typename Other > inline HermitianMatrix& scale( const Other& scalar );
410  template< typename Other > inline HermitianMatrix& scaleDiagonal( Other scale );
411  inline void swap( HermitianMatrix& m ) /* throw() */;
413  //**********************************************************************************************
414 
415  //**Lookup functions****************************************************************************
418  inline Iterator find ( size_t i, size_t j );
419  inline ConstIterator find ( size_t i, size_t j ) const;
420  inline Iterator lowerBound( size_t i, size_t j );
421  inline ConstIterator lowerBound( size_t i, size_t j ) const;
422  inline Iterator upperBound( size_t i, size_t j );
423  inline ConstIterator upperBound( size_t i, size_t j ) const;
425  //**********************************************************************************************
426 
427  //**Low-level utility functions*****************************************************************
430  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
431  inline void finalize( size_t i );
433  //**********************************************************************************************
434 
435  //**Debugging functions*************************************************************************
438  inline bool isIntact() const;
440  //**********************************************************************************************
441 
442  //**Expression template evaluation functions****************************************************
445  template< typename Other > inline bool canAlias ( const Other* alias ) const;
446  template< typename Other > inline bool isAliased( const Other* alias ) const;
447 
448  inline bool canSMPAssign() const;
450  //**********************************************************************************************
451 
452  private:
453  //**Construction functions**********************************************************************
456  template< typename MT2, bool SO2, typename T >
457  inline const MT2& construct( const Matrix<MT2,SO2>& m, T );
458 
459  template< typename MT2 >
460  inline typename TransExprTrait<MT2>::Type construct( const Matrix<MT2,!SO>& m, TrueType );
462  //**********************************************************************************************
463 
464  //**Member variables****************************************************************************
467  MT matrix_;
468 
469  //**********************************************************************************************
470 
471  //**Friend declarations*************************************************************************
472  template< typename MT2, bool SO2, bool DF2 >
473  friend bool isDefault( const HermitianMatrix<MT2,SO2,DF2>& m );
474  //**********************************************************************************************
475 
476  //**Compile time checks*************************************************************************
490  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
491  //**********************************************************************************************
492 };
494 //*************************************************************************************************
495 
496 
497 
498 
499 //=================================================================================================
500 //
501 // CONSTRUCTORS
502 //
503 //=================================================================================================
504 
505 //*************************************************************************************************
509 template< typename MT // Type of the adapted sparse matrix
510  , bool SO > // Storage order of the adapted sparse matrix
511 inline HermitianMatrix<MT,SO,false>::HermitianMatrix()
512  : matrix_() // The adapted sparse matrix
513 {
514  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square Hermitian matrix detected" );
515 }
517 //*************************************************************************************************
518 
519 
520 //*************************************************************************************************
528 template< typename MT // Type of the adapted sparse matrix
529  , bool SO > // Storage order of the adapted sparse matrix
530 inline HermitianMatrix<MT,SO,false>::HermitianMatrix( size_t n )
531  : matrix_( n, n ) // The adapted sparse matrix
532 {
534 
535  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square Hermitian matrix detected" );
536 }
538 //*************************************************************************************************
539 
540 
541 //*************************************************************************************************
550 template< typename MT // Type of the adapted sparse matrix
551  , bool SO > // Storage order of the adapted sparse matrix
552 inline HermitianMatrix<MT,SO,false>::HermitianMatrix( size_t n, size_t nonzeros )
553  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
554 {
556 
557  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square Hermitian matrix detected" );
558 }
560 //*************************************************************************************************
561 
562 
563 //*************************************************************************************************
574 template< typename MT // Type of the adapted sparse matrix
575  , bool SO > // Storage order of the adapted sparse matrix
576 inline HermitianMatrix<MT,SO,false>::HermitianMatrix( size_t n, const std::vector<size_t>& nonzeros )
577  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
578 {
580 
581  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square Hermitian matrix detected" );
582 }
584 //*************************************************************************************************
585 
586 
587 //*************************************************************************************************
593 template< typename MT // Type of the adapted sparse matrix
594  , bool SO > // Storage order of the adapted sparse matrix
595 inline HermitianMatrix<MT,SO,false>::HermitianMatrix( const HermitianMatrix& m )
596  : matrix_( m.matrix_ ) // The adapted sparse matrix
597 {
598  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square Hermitian matrix detected" );
599  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
600 }
602 //*************************************************************************************************
603 
604 
605 //*************************************************************************************************
615 template< typename MT // Type of the adapted sparse matrix
616  , bool SO > // Storage order of the adapted sparse matrix
617 template< typename MT2 // Type of the foreign matrix
618  , bool SO2 > // Storage order of the foreign matrix
619 inline HermitianMatrix<MT,SO,false>::HermitianMatrix( const Matrix<MT2,SO2>& m )
620  : matrix_( construct( m, typename IsBuiltin<typename MT2::ElementType>::Type() ) ) // The adapted sparse matrix
621 {
622  if( !IsHermitian<MT2>::value && !isHermitian( matrix_ ) ) {
623  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of Hermitian matrix" );
624  }
625 }
627 //*************************************************************************************************
628 
629 
630 
631 
632 //=================================================================================================
633 //
634 // DATA ACCESS FUNCTIONS
635 //
636 //=================================================================================================
637 
638 //*************************************************************************************************
654 template< typename MT // Type of the adapted sparse matrix
655  , bool SO > // Storage order of the adapted sparse matrix
657  HermitianMatrix<MT,SO,false>::operator()( size_t i, size_t j )
658 {
659  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
660  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
661 
662  return Reference( matrix_, i, j );
663 }
665 //*************************************************************************************************
666 
667 
668 //*************************************************************************************************
684 template< typename MT // Type of the adapted sparse matrix
685  , bool SO > // Storage order of the adapted sparse matrix
687  HermitianMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
688 {
689  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
690  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
691 
692  return matrix_(i,j);
693 }
695 //*************************************************************************************************
696 
697 
698 //*************************************************************************************************
715 template< typename MT // Type of the adapted sparse matrix
716  , bool SO > // Storage order of the adapted sparse matrix
718  HermitianMatrix<MT,SO,false>::at( size_t i, size_t j )
719 {
720  if( i >= rows() ) {
721  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
722  }
723  if( j >= columns() ) {
724  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
725  }
726  return (*this)(i,j);
727 }
729 //*************************************************************************************************
730 
731 
732 //*************************************************************************************************
749 template< typename MT // Type of the adapted sparse matrix
750  , bool SO > // Storage order of the adapted sparse matrix
752  HermitianMatrix<MT,SO,false>::at( size_t i, size_t j ) const
753 {
754  if( i >= rows() ) {
755  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
756  }
757  if( j >= columns() ) {
758  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
759  }
760  return (*this)(i,j);
761 }
763 //*************************************************************************************************
764 
765 
766 //*************************************************************************************************
778 template< typename MT // Type of the adapted sparse matrix
779  , bool SO > // Storage order of the adapted sparse matrix
782 {
783  return Iterator( matrix_.begin(i), matrix_, i );
784 }
786 //*************************************************************************************************
787 
788 
789 //*************************************************************************************************
801 template< typename MT // Type of the adapted sparse matrix
802  , bool SO > // Storage order of the adapted sparse matrix
804  HermitianMatrix<MT,SO,false>::begin( size_t i ) const
805 {
806  return matrix_.begin(i);
807 }
809 //*************************************************************************************************
810 
811 
812 //*************************************************************************************************
824 template< typename MT // Type of the adapted sparse matrix
825  , bool SO > // Storage order of the adapted sparse matrix
827  HermitianMatrix<MT,SO,false>::cbegin( size_t i ) const
828 {
829  return matrix_.cbegin(i);
830 }
832 //*************************************************************************************************
833 
834 
835 //*************************************************************************************************
847 template< typename MT // Type of the adapted sparse matrix
848  , bool SO > // Storage order of the adapted sparse matrix
851 {
852  return Iterator( matrix_.end(i), matrix_, i );
853 }
855 //*************************************************************************************************
856 
857 
858 //*************************************************************************************************
870 template< typename MT // Type of the adapted sparse matrix
871  , bool SO > // Storage order of the adapted sparse matrix
873  HermitianMatrix<MT,SO,false>::end( size_t i ) const
874 {
875  return matrix_.end(i);
876 }
878 //*************************************************************************************************
879 
880 
881 //*************************************************************************************************
893 template< typename MT // Type of the adapted sparse matrix
894  , bool SO > // Storage order of the adapted sparse matrix
896  HermitianMatrix<MT,SO,false>::cend( size_t i ) const
897 {
898  return matrix_.cend(i);
899 }
901 //*************************************************************************************************
902 
903 
904 
905 
906 //=================================================================================================
907 //
908 // ASSIGNMENT OPERATORS
909 //
910 //=================================================================================================
911 
912 //*************************************************************************************************
922 template< typename MT // Type of the adapted sparse matrix
923  , bool SO > // Storage order of the adapted sparse matrix
924 inline HermitianMatrix<MT,SO,false>&
925  HermitianMatrix<MT,SO,false>::operator=( const HermitianMatrix& rhs )
926 {
927  matrix_ = rhs.matrix_;
928 
929  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square Hermitian matrix detected" );
930  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
931 
932  return *this;
933 }
935 //*************************************************************************************************
936 
937 
938 //*************************************************************************************************
951 template< typename MT // Type of the adapted sparse matrix
952  , bool SO > // Storage order of the adapted sparse matrix
953 template< typename MT2 // Type of the right-hand side matrix
954  , bool SO2 > // Storage order of the right-hand side matrix
955 inline typename DisableIf< IsComputation<MT2>, HermitianMatrix<MT,SO,false>& >::Type
956  HermitianMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
957 {
958  if( !IsHermitian<MT2>::value && !isHermitian( ~rhs ) ) {
959  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to Hermitian matrix" );
960  }
961 
962  matrix_ = ~rhs;
963 
964  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square Hermitian matrix detected" );
965  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
966 
967  return *this;
968 }
970 //*************************************************************************************************
971 
972 
973 //*************************************************************************************************
986 template< typename MT // Type of the adapted sparse matrix
987  , bool SO > // Storage order of the adapted sparse matrix
988 template< typename MT2 // Type of the right-hand side matrix
989  , bool SO2 > // Storage order of the right-hand side matrix
990 inline typename EnableIf< IsComputation<MT2>, HermitianMatrix<MT,SO,false>& >::Type
991  HermitianMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
992 {
993  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
994  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to Hermitian matrix" );
995  }
996 
997  if( IsHermitian<MT2>::value ) {
998  matrix_ = ~rhs;
999  }
1000  else {
1001  MT tmp( ~rhs );
1002 
1003  if( !isHermitian( tmp ) ) {
1004  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to Hermitian matrix" );
1005  }
1006 
1007  move( matrix_, tmp );
1008  }
1009 
1010  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square Hermitian matrix detected" );
1011  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1012 
1013  return *this;
1014 }
1016 //*************************************************************************************************
1017 
1018 
1019 //*************************************************************************************************
1032 template< typename MT // Type of the adapted sparse matrix
1033  , bool SO > // Storage order of the adapted sparse matrix
1034 template< typename MT2 > // Type of the right-hand side matrix
1035 inline typename EnableIf< IsBuiltin<typename MT2::ElementType>, HermitianMatrix<MT,SO,false>& >::Type
1036  HermitianMatrix<MT,SO,false>::operator=( const Matrix<MT2,!SO>& rhs )
1037 {
1038  return this->operator=( trans( ~rhs ) );
1039 }
1041 //*************************************************************************************************
1042 
1043 
1044 //*************************************************************************************************
1057 template< typename MT // Type of the adapted sparse matrix
1058  , bool SO > // Storage order of the adapted sparse matrix
1059 template< typename MT2 // Type of the right-hand side matrix
1060  , bool SO2 > // Storage order of the right-hand side matrix
1061 inline typename DisableIf< IsComputation<MT2>, HermitianMatrix<MT,SO,false>& >::Type
1062  HermitianMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1063 {
1064  if( !IsHermitian<MT2>::value && !isHermitian( ~rhs ) ) {
1065  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to Hermitian matrix" );
1066  }
1067 
1068  matrix_ += ~rhs;
1069 
1070  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square Hermitian matrix detected" );
1071  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1072 
1073  return *this;
1074 }
1076 //*************************************************************************************************
1077 
1078 
1079 //*************************************************************************************************
1092 template< typename MT // Type of the adapted sparse matrix
1093  , bool SO > // Storage order of the adapted sparse matrix
1094 template< typename MT2 // Type of the right-hand side matrix
1095  , bool SO2 > // Storage order of the right-hand side matrix
1096 inline typename EnableIf< IsComputation<MT2>, HermitianMatrix<MT,SO,false>& >::Type
1097  HermitianMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1098 {
1099  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1100  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to Hermitian matrix" );
1101  }
1102 
1103  if( IsHermitian<MT2>::value ) {
1104  matrix_ += ~rhs;
1105  }
1106  else {
1107  typename MT2::ResultType tmp( ~rhs );
1108 
1109  if( !isHermitian( tmp ) ) {
1110  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to Hermitian matrix" );
1111  }
1112 
1113  matrix_ += tmp;
1114  }
1115 
1116  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square Hermitian matrix detected" );
1117  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1118 
1119  return *this;
1120 }
1122 //*************************************************************************************************
1123 
1124 
1125 //*************************************************************************************************
1139 template< typename MT // Type of the adapted sparse matrix
1140  , bool SO > // Storage order of the adapted sparse matrix
1141 template< typename MT2 > // Type of the right-hand side matrix
1142 inline typename EnableIf< IsBuiltin<typename MT2::ElementType>, HermitianMatrix<MT,SO,false>& >::Type
1143  HermitianMatrix<MT,SO,false>::operator+=( const Matrix<MT2,!SO>& rhs )
1144 {
1145  return this->operator+=( trans( ~rhs ) );
1146 }
1148 //*************************************************************************************************
1149 
1150 
1151 //*************************************************************************************************
1164 template< typename MT // Type of the adapted sparse matrix
1165  , bool SO > // Storage order of the adapted sparse matrix
1166 template< typename MT2 // Type of the right-hand side matrix
1167  , bool SO2 > // Storage order of the right-hand side matrix
1168 inline typename DisableIf< IsComputation<MT2>, HermitianMatrix<MT,SO,false>& >::Type
1169  HermitianMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1170 {
1171  if( !IsHermitian<MT2>::value && !isHermitian( ~rhs ) ) {
1172  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to Hermitian matrix" );
1173  }
1174 
1175  matrix_ -= ~rhs;
1176 
1177  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square Hermitian matrix detected" );
1178  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1179 
1180  return *this;
1181 }
1183 //*************************************************************************************************
1184 
1185 
1186 //*************************************************************************************************
1199 template< typename MT // Type of the adapted sparse matrix
1200  , bool SO > // Storage order of the adapted sparse matrix
1201 template< typename MT2 // Type of the right-hand side matrix
1202  , bool SO2 > // Storage order of the right-hand side matrix
1203 inline typename EnableIf< IsComputation<MT2>, HermitianMatrix<MT,SO,false>& >::Type
1204  HermitianMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1205 {
1206  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1207  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to Hermitian matrix" );
1208  }
1209 
1210  if( IsHermitian<MT2>::value ) {
1211  matrix_ -= ~rhs;
1212  }
1213  else {
1214  typename MT2::ResultType tmp( ~rhs );
1215 
1216  if( !isHermitian( tmp ) ) {
1217  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to Hermitian matrix" );
1218  }
1219 
1220  matrix_ -= tmp;
1221  }
1222 
1223  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square Hermitian matrix detected" );
1224  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1225 
1226  return *this;
1227 }
1229 //*************************************************************************************************
1230 
1231 
1232 //*************************************************************************************************
1246 template< typename MT // Type of the adapted sparse matrix
1247  , bool SO > // Storage order of the adapted sparse matrix
1248 template< typename MT2 > // Type of the right-hand side matrix
1249 inline typename EnableIf< IsBuiltin<typename MT2::ElementType>, HermitianMatrix<MT,SO,false>& >::Type
1250  HermitianMatrix<MT,SO,false>::operator-=( const Matrix<MT2,!SO>& rhs )
1251 {
1252  return this->operator-=( trans( ~rhs ) );
1253 }
1255 //*************************************************************************************************
1256 
1257 
1258 //*************************************************************************************************
1270 template< typename MT // Type of the adapted sparse matrix
1271  , bool SO > // Storage order of the adapted sparse matrix
1272 template< typename MT2 // Type of the right-hand side matrix
1273  , bool SO2 > // Storage order of the right-hand side matrix
1274 inline HermitianMatrix<MT,SO,false>&
1275  HermitianMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1276 {
1277  if( matrix_.rows() != (~rhs).columns() ) {
1278  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to Hermitian matrix" );
1279  }
1280 
1281  MT tmp( matrix_ * ~rhs );
1282 
1283  if( !isHermitian( tmp ) ) {
1284  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to Hermitian matrix" );
1285  }
1286 
1287  move( matrix_, tmp );
1288 
1289  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square Hermitian matrix detected" );
1290  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1291 
1292  return *this;
1293 }
1295 //*************************************************************************************************
1296 
1297 
1298 //*************************************************************************************************
1306 template< typename MT // Type of the adapted sparse matrix
1307  , bool SO > // Storage order of the adapted sparse matrix
1308 template< typename Other > // Data type of the right-hand side scalar
1309 inline typename EnableIf< IsNumeric<Other>, HermitianMatrix<MT,SO,false> >::Type&
1310  HermitianMatrix<MT,SO,false>::operator*=( Other rhs )
1311 {
1312  matrix_ *= rhs;
1313  return *this;
1314 }
1315 //*************************************************************************************************
1316 
1317 
1318 //*************************************************************************************************
1326 template< typename MT // Type of the adapted sparse matrix
1327  , bool SO > // Storage order of the adapted sparse matrix
1328 template< typename Other > // Data type of the right-hand side scalar
1329 inline typename EnableIf< IsNumeric<Other>, HermitianMatrix<MT,SO,false> >::Type&
1330  HermitianMatrix<MT,SO,false>::operator/=( Other rhs )
1331 {
1332  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1333 
1334  matrix_ /= rhs;
1335  return *this;
1336 }
1338 //*************************************************************************************************
1339 
1340 
1341 
1342 
1343 //=================================================================================================
1344 //
1345 // UTILITY FUNCTIONS
1346 //
1347 //=================================================================================================
1348 
1349 //*************************************************************************************************
1355 template< typename MT // Type of the adapted sparse matrix
1356  , bool SO > // Storage order of the adapted sparse matrix
1357 inline size_t HermitianMatrix<MT,SO,false>::rows() const
1358 {
1359  return matrix_.rows();
1360 }
1362 //*************************************************************************************************
1363 
1364 
1365 //*************************************************************************************************
1371 template< typename MT // Type of the adapted sparse matrix
1372  , bool SO > // Storage order of the adapted sparse matrix
1373 inline size_t HermitianMatrix<MT,SO,false>::columns() const
1374 {
1375  return matrix_.columns();
1376 }
1378 //*************************************************************************************************
1379 
1380 
1381 //*************************************************************************************************
1387 template< typename MT // Type of the adapted sparse matrix
1388  , bool SO > // Storage order of the adapted sparse matrix
1389 inline size_t HermitianMatrix<MT,SO,false>::capacity() const
1390 {
1391  return matrix_.capacity();
1392 }
1394 //*************************************************************************************************
1395 
1396 
1397 //*************************************************************************************************
1408 template< typename MT // Type of the adapted sparse matrix
1409  , bool SO > // Storage order of the adapted sparse matrix
1410 inline size_t HermitianMatrix<MT,SO,false>::capacity( size_t i ) const
1411 {
1412  return matrix_.capacity(i);
1413 }
1415 //*************************************************************************************************
1416 
1417 
1418 //*************************************************************************************************
1424 template< typename MT // Type of the adapted sparse matrix
1425  , bool SO > // Storage order of the adapted sparse matrix
1426 inline size_t HermitianMatrix<MT,SO,false>::nonZeros() const
1427 {
1428  return matrix_.nonZeros();
1429 }
1431 //*************************************************************************************************
1432 
1433 
1434 //*************************************************************************************************
1446 template< typename MT // Type of the adapted sparse matrix
1447  , bool SO > // Storage order of the adapted sparse matrix
1448 inline size_t HermitianMatrix<MT,SO,false>::nonZeros( size_t i ) const
1449 {
1450  return matrix_.nonZeros(i);
1451 }
1453 //*************************************************************************************************
1454 
1455 
1456 //*************************************************************************************************
1462 template< typename MT // Type of the adapted sparse matrix
1463  , bool SO > // Storage order of the adapted sparse matrix
1465 {
1466  matrix_.reset();
1467 }
1469 //*************************************************************************************************
1470 
1471 
1472 //*************************************************************************************************
1508 template< typename MT // Type of the adapted sparse matrix
1509  , bool SO > // Storage order of the adapted sparse matrix
1510 inline void HermitianMatrix<MT,SO,false>::reset( size_t i )
1511 {
1512  for( typename MT::Iterator it=matrix_.begin(i); it!=matrix_.end(i); ++it )
1513  {
1514  const size_t j( it->index() );
1515 
1516  if( i == j )
1517  continue;
1518 
1519  if( SO ) {
1520  const typename MT::Iterator pos( matrix_.find( i, j ) );
1521  BLAZE_INTERNAL_ASSERT( pos != matrix_.end( j ), "Missing element detected" );
1522  matrix_.erase( j, pos );
1523  }
1524  else {
1525  const typename MT::Iterator pos( matrix_.find( j, i ) );
1526  BLAZE_INTERNAL_ASSERT( pos != matrix_.end( j ), "Missing element detected" );
1527  matrix_.erase( j, pos );
1528  }
1529  }
1530 
1531  matrix_.reset( i );
1532 }
1534 //*************************************************************************************************
1535 
1536 
1537 //*************************************************************************************************
1545 template< typename MT // Type of the adapted sparse matrix
1546  , bool SO > // Storage order of the adapted sparse matrix
1548 {
1549  using blaze::clear;
1550 
1551  clear( matrix_ );
1552 }
1554 //*************************************************************************************************
1555 
1556 
1557 //*************************************************************************************************
1572 template< typename MT // Type of the adapted sparse matrix
1573  , bool SO > // Storage order of the adapted sparse matrix
1575  HermitianMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1576 {
1577  const bool isDiagonal( i == j );
1578 
1579  if( IsComplex<ElementType>::value && isDiagonal && !isReal( value ) ) {
1580  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
1581  }
1582 
1583  if( !isDiagonal )
1584  matrix_.set( j, i, conj( value ) );
1585  return Iterator( matrix_.set( i, j, value ), matrix_, ( SO ? j : i ) );
1586 }
1588 //*************************************************************************************************
1589 
1590 
1591 //*************************************************************************************************
1607 template< typename MT // Type of the adapted sparse matrix
1608  , bool SO > // Storage order of the adapted sparse matrix
1610  HermitianMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1611 {
1612  const bool isDiagonal( i == j );
1613 
1614  if( IsComplex<ElementType>::value && isDiagonal && !isReal( value ) ) {
1615  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
1616  }
1617 
1618  if( !isDiagonal )
1619  matrix_.insert( j, i, conj( value ) );
1620  return Iterator( matrix_.insert( i, j, value ), matrix_, ( SO ? j : i ) );
1621 }
1623 //*************************************************************************************************
1624 
1625 
1626 //*************************************************************************************************
1636 template< typename MT // Type of the adapted sparse matrix
1637  , bool SO > // Storage order of the adapted sparse matrix
1638 inline void HermitianMatrix<MT,SO,false>::erase( size_t i, size_t j )
1639 {
1640  matrix_.erase( i, j );
1641  if( i != j )
1642  matrix_.erase( j, i );
1643 }
1645 //*************************************************************************************************
1646 
1647 
1648 //*************************************************************************************************
1660 template< typename MT // Type of the adapted sparse matrix
1661  , bool SO > // Storage order of the adapted sparse matrix
1663  HermitianMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1664 {
1665  const typename MT::Iterator base( pos.base() );
1666 
1667  if( base == matrix_.end( i ) )
1668  return pos;
1669 
1670  const size_t j( base->index() );
1671 
1672  if( i == j ) {
1673  BLAZE_INTERNAL_ASSERT( matrix_.find( i, i ) != matrix_.end( i ), "Missing element detected" );
1674  return Iterator( matrix_.erase( i, base ), matrix_, i );
1675  }
1676 
1677  if( SO ) {
1678  BLAZE_INTERNAL_ASSERT( matrix_.find( i, j ) != matrix_.end( j ), "Missing element detected" );
1679  matrix_.erase( j, matrix_.find( i, j ) );
1680  return Iterator( matrix_.erase( i, base ), matrix_, i );
1681  }
1682  else {
1683  BLAZE_INTERNAL_ASSERT( matrix_.find( j, i ) != matrix_.end( j ), "Missing element detected" );
1684  matrix_.erase( j, matrix_.find( j, i ) );
1685  return Iterator( matrix_.erase( i, base ), matrix_, i );
1686  }
1687 }
1689 //*************************************************************************************************
1690 
1691 
1692 //*************************************************************************************************
1706 template< typename MT // Type of the adapted sparse matrix
1707  , bool SO > // Storage order of the adapted sparse matrix
1709  HermitianMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1710 {
1711  for( typename MT::Iterator it=first.base(); it!=last.base(); ++it )
1712  {
1713  const size_t j( it->index() );
1714 
1715  if( i == j )
1716  continue;
1717 
1718  if( SO ) {
1719  BLAZE_INTERNAL_ASSERT( matrix_.find( i, j ) != matrix_.end( j ), "Missing element detected" );
1720  matrix_.erase( i, j );
1721  }
1722  else {
1723  BLAZE_INTERNAL_ASSERT( matrix_.find( j, i ) != matrix_.end( j ), "Missing element detected" );
1724  matrix_.erase( j, i );
1725  }
1726  }
1727 
1728  return Iterator( matrix_.erase( i, first.base(), last.base() ), matrix_, i );
1729 }
1731 //*************************************************************************************************
1732 
1733 
1734 //*************************************************************************************************
1749 template< typename MT // Type of the adapted sparse matrix
1750  , bool SO > // Storage order of the adapted sparse matrix
1751 void HermitianMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1752 {
1754 
1755  UNUSED_PARAMETER( preserve );
1756 
1757  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square Hermitian matrix detected" );
1758 
1759  matrix_.resize( n, n, true );
1760 }
1762 //*************************************************************************************************
1763 
1764 
1765 //*************************************************************************************************
1776 template< typename MT // Type of the adapted sparse matrix
1777  , bool SO > // Storage order of the adapted sparse matrix
1778 inline void HermitianMatrix<MT,SO,false>::reserve( size_t nonzeros )
1779 {
1780  matrix_.reserve( nonzeros );
1781 }
1783 //*************************************************************************************************
1784 
1785 
1786 //*************************************************************************************************
1800 template< typename MT // Type of the adapted sparse matrix
1801  , bool SO > // Storage order of the adapted sparse matrix
1802 inline void HermitianMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1803 {
1804  matrix_.reserve( i, nonzeros );
1805 }
1807 //*************************************************************************************************
1808 
1809 
1810 //*************************************************************************************************
1821 template< typename MT // Type of the adapted sparse matrix
1822  , bool SO > // Storage order of the adapted sparse matrix
1823 inline void HermitianMatrix<MT,SO,false>::trim()
1824 {
1825  matrix_.trim();
1826 }
1828 //*************************************************************************************************
1829 
1830 
1831 //*************************************************************************************************
1843 template< typename MT // Type of the adapted sparse matrix
1844  , bool SO > // Storage order of the adapted sparse matrix
1845 inline void HermitianMatrix<MT,SO,false>::trim( size_t i )
1846 {
1847  matrix_.trim( i );
1848 }
1850 //*************************************************************************************************
1851 
1852 
1853 //*************************************************************************************************
1859 template< typename MT // Type of the adapted sparse matrix
1860  , bool SO > // Storage order of the adapted sparse matrix
1861 inline HermitianMatrix<MT,SO,false>& HermitianMatrix<MT,SO,false>::transpose()
1862 {
1863  if( IsComplex<ElementType>::value )
1864  matrix_.transpose();
1865  return *this;
1866 }
1868 //*************************************************************************************************
1869 
1870 
1871 //*************************************************************************************************
1877 template< typename MT // Type of the adapted sparse matrix
1878  , bool SO > // Storage order of the adapted sparse matrix
1879 inline HermitianMatrix<MT,SO,false>& HermitianMatrix<MT,SO,false>::ctranspose()
1880 {
1881  return *this;
1882 }
1884 //*************************************************************************************************
1885 
1886 
1887 //*************************************************************************************************
1894 template< typename MT // Type of the adapted sparse matrix
1895  , bool SO > // Storage order of the adapted sparse matrix
1896 template< typename Other > // Data type of the scalar value
1897 inline HermitianMatrix<MT,SO,false>&
1898  HermitianMatrix<MT,SO,false>::scale( const Other& scalar )
1899 {
1900  matrix_.scale( scalar );
1901  return *this;
1902 }
1904 //*************************************************************************************************
1905 
1906 
1907 //*************************************************************************************************
1914 template< typename MT // Type of the adapted sparse matrix
1915  , bool SO > // Storage order of the adapted sparse matrix
1916 template< typename Other > // Data type of the scalar value
1917 inline HermitianMatrix<MT,SO,false>&
1918  HermitianMatrix<MT,SO,false>::scaleDiagonal( Other scalar )
1919 {
1920  matrix_.scaleDiagonal( scalar );
1921  return *this;
1922 }
1924 //*************************************************************************************************
1925 
1926 
1927 //*************************************************************************************************
1935 template< typename MT // Type of the adapted sparse matrix
1936  , bool SO > // Storage order of the adapted sparse matrix
1937 inline void HermitianMatrix<MT,SO,false>::swap( HermitianMatrix& m ) /* throw() */
1938 {
1939  using std::swap;
1940 
1941  swap( matrix_, m.matrix_ );
1942 }
1944 //*************************************************************************************************
1945 
1946 
1947 
1948 
1949 //=================================================================================================
1950 //
1951 // LOOKUP FUNCTIONS
1952 //
1953 //=================================================================================================
1954 
1955 //*************************************************************************************************
1971 template< typename MT // Type of the adapted sparse matrix
1972  , bool SO > // Storage order of the adapted sparse matrix
1974  HermitianMatrix<MT,SO,false>::find( size_t i, size_t j )
1975 {
1976  return Iterator( matrix_.find( i, j ), matrix_, ( SO ? j : i ) );
1977 }
1979 //*************************************************************************************************
1980 
1981 
1982 //*************************************************************************************************
1998 template< typename MT // Type of the adapted sparse matrix
1999  , bool SO > // Storage order of the adapted sparse matrix
2001  HermitianMatrix<MT,SO,false>::find( size_t i, size_t j ) const
2002 {
2003  return matrix_.find( i, j );
2004 }
2006 //*************************************************************************************************
2007 
2008 
2009 //*************************************************************************************************
2025 template< typename MT // Type of the adapted sparse matrix
2026  , bool SO > // Storage order of the adapted sparse matrix
2028  HermitianMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
2029 {
2030  return Iterator( matrix_.lowerBound( i, j ), matrix_, ( SO ? j : i ) );
2031 }
2033 //*************************************************************************************************
2034 
2035 
2036 //*************************************************************************************************
2052 template< typename MT // Type of the adapted sparse matrix
2053  , bool SO > // Storage order of the adapted sparse matrix
2055  HermitianMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
2056 {
2057  return matrix_.lowerBound( i, j );
2058 }
2060 //*************************************************************************************************
2061 
2062 
2063 //*************************************************************************************************
2079 template< typename MT // Type of the adapted sparse matrix
2080  , bool SO > // Storage order of the adapted sparse matrix
2082  HermitianMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
2083 {
2084  return Iterator( matrix_.upperBound( i, j ), matrix_, ( SO ? j : i ) );
2085 }
2087 //*************************************************************************************************
2088 
2089 
2090 //*************************************************************************************************
2106 template< typename MT // Type of the adapted sparse matrix
2107  , bool SO > // Storage order of the adapted sparse matrix
2109  HermitianMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
2110 {
2111  return matrix_.upperBound( i, j );
2112 }
2114 //*************************************************************************************************
2115 
2116 
2117 
2118 
2119 //=================================================================================================
2120 //
2121 // LOW-LEVEL UTILITY FUNCTIONS
2122 //
2123 //=================================================================================================
2124 
2125 //*************************************************************************************************
2184 template< typename MT // Type of the adapted sparse matrix
2185  , bool SO > // Storage order of the adapted sparse matrix
2186 inline void HermitianMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
2187 {
2188  const bool isDiagonal( i == j );
2189 
2190  if( IsComplex<ElementType>::value && isDiagonal && !isReal( value ) ) {
2191  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2192  }
2193 
2194  matrix_.append( i, j, value, check );
2195  if( !isDiagonal && ( !check || !isDefault( value ) ) )
2196  matrix_.insert( j, i, conj( value ) );
2197 }
2199 //*************************************************************************************************
2200 
2201 
2202 //*************************************************************************************************
2216 template< typename MT // Type of the adapted sparse matrix
2217  , bool SO > // Storage order of the adapted sparse matrix
2218 inline void HermitianMatrix<MT,SO,false>::finalize( size_t i )
2219 {
2220  matrix_.trim( i );
2221 }
2223 //*************************************************************************************************
2224 
2225 
2226 
2227 
2228 //=================================================================================================
2229 //
2230 // DEBUGGING FUNCTIONS
2231 //
2232 //=================================================================================================
2233 
2234 //*************************************************************************************************
2244 template< typename MT // Type of the adapted sparse matrix
2245  , bool SO > // Storage order of the adapted sparse matrix
2246 inline bool HermitianMatrix<MT,SO,false>::isIntact() const
2247 {
2248  using blaze::isIntact;
2249 
2250  return ( isIntact( matrix_ ) && isHermitian( matrix_ ) );
2251 }
2253 //*************************************************************************************************
2254 
2255 
2256 
2257 
2258 //=================================================================================================
2259 //
2260 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2261 //
2262 //=================================================================================================
2263 
2264 //*************************************************************************************************
2275 template< typename MT // Type of the adapted sparse matrix
2276  , bool SO > // Storage order of the adapted sparse matrix
2277 template< typename Other > // Data type of the foreign expression
2278 inline bool HermitianMatrix<MT,SO,false>::canAlias( const Other* alias ) const
2279 {
2280  return matrix_.canAlias( alias );
2281 }
2283 //*************************************************************************************************
2284 
2285 
2286 //*************************************************************************************************
2297 template< typename MT // Type of the adapted sparse matrix
2298  , bool SO > // Storage order of the adapted sparse matrix
2299 template< typename Other > // Data type of the foreign expression
2300 inline bool HermitianMatrix<MT,SO,false>::isAliased( const Other* alias ) const
2301 {
2302  return matrix_.isAliased( alias );
2303 }
2305 //*************************************************************************************************
2306 
2307 
2308 //*************************************************************************************************
2319 template< typename MT // Type of the adapted sparse matrix
2320  , bool SO > // Storage order of the adapted sparse matrix
2321 inline bool HermitianMatrix<MT,SO,false>::canSMPAssign() const
2322 {
2323  return matrix_.canSMPAssign();
2324 }
2326 //*************************************************************************************************
2327 
2328 
2329 
2330 
2331 //=================================================================================================
2332 //
2333 // CONSTRUCTION FUNCTIONS
2334 //
2335 //=================================================================================================
2336 
2337 //*************************************************************************************************
2339 template< typename MT // Type of the adapted dense matrix
2340  , bool SO > // Storage order of the adapted dense matrix
2341 template< typename MT2 // Type of the foreign matrix
2342  , bool SO2 // Storage order of the foreign matrix
2343  , typename T > // Type of the third argument
2344 inline const MT2& HermitianMatrix<MT,SO,false>::construct( const Matrix<MT2,SO2>& m, T )
2345 {
2346  return ~m;
2347 }
2349 //*************************************************************************************************
2350 
2351 
2352 //*************************************************************************************************
2354 template< typename MT // Type of the adapted dense matrix
2355  , bool SO > // Storage order of the adapted dense matrix
2356 template< typename MT2 > // Type of the foreign matrix
2357 inline typename TransExprTrait<MT2>::Type
2358  HermitianMatrix<MT,SO,false>::construct( const Matrix<MT2,!SO>& m, TrueType )
2359 {
2360  return trans( ~m );
2361 }
2363 //*************************************************************************************************
2364 
2365 } // namespace blaze
2366 
2367 #endif
#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:116
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type set(T value)
Sets all values in the vector to the given 2-byte integral value.
Definition: Set.h:73
Constraint on the data type.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
bool isDiagonal(const DenseMatrix< MT, SO > &dm)
Checks if the give dense matrix is diagonal.
Definition: DenseMatrix.h:1511
Header file for the Rows type trait.
Header file for the UNUSED_PARAMETER function template.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7820
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix)
Checks if the given matrix is a square matrix.
Definition: Matrix.h:603
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:229
void move(CompressedMatrix< Type, SO > &dst, CompressedMatrix< Type, SO > &src)
Moving the contents of one compressed matrix to another.
Definition: CompressedMatrix.h:5016
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:292
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:250
bool isReal(const DiagonalProxy< MT > &proxy)
Returns whether the matrix element represents a real number.
Definition: DiagonalProxy.h:569
#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:81
Constraint on the data type.
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:340
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:4926
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
BLAZE_ALWAYS_INLINE void ctranspose(Matrix< MT, SO > &matrix)
In-place conjugate transpose of the given matrix.
Definition: Matrix.h:584
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2582
#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:116
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:378
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2584
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:547
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
ConjExprTrait< typename DiagonalProxy< MT >::RepresentedType >::Type conj(const DiagonalProxy< MT > &proxy)
Computing the complex conjugate of the represented element.
Definition: DiagonalProxy.h:487
Header file for utility functions for sparse matrices.
Header file for the IsSquare type trait.
Constraint on the data type.
bool isDefault(const CompressedMatrix< Type, SO > &m)
Returns whether the given compressed matrix is in default state.
Definition: CompressedMatrix.h:4953
Header file for the DisableIf class template.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Compile time assertion.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4998
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:4980
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
#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:116
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
Header file for the Columns type trait.
Constraint on the data type.
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:642
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2585
Constraints on the storage order of matrix types.
#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:118
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:187
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:532
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
Header file for all forward declarations for expression class templates.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2590
Header file for the HermitianElement class.
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:527
Header file for the conjugate shim.
Header file for the IsNumeric type trait.
Header file for the implementation of the base template of the HeritianMatrix.
#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:116
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:79
#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:118
#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:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2591
Header file for the isDefault shim.
Header file for the TransExprTrait class template.
Constraint on the data type.
Constraint on the data type.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:256
Header file for the move shim.
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a 'res...
Definition: Resizable.h:79
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:944
Header file for the IsComputation type trait class.
Header file for the IsBuiltin type trait.
bool isHermitian(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is Hermitian.
Definition: DenseMatrix.h:767
#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:118
Header file for the HermitianProxy class.
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:237
Header file for the IsComplex type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2589
#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:116
Header file for exception macros.
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
#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:143
Header file for the IsHermitian type trait.
Header file for the isReal shim.
#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
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:79
Header file for the TrueType type/value trait base class.
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:558