SparseNumeric.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_SPARSENUMERIC_H_
36 #define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_SPARSENUMERIC_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <vector>
59 #include <blaze/math/shims/Clear.h>
62 #include <blaze/math/shims/Move.h>
69 #include <blaze/util/Assert.h>
75 #include <blaze/util/DisableIf.h>
76 #include <blaze/util/EnableIf.h>
77 #include <blaze/util/Exception.h>
81 #include <blaze/util/Types.h>
82 #include <blaze/util/Unused.h>
83 
84 
85 namespace blaze {
86 
87 //=================================================================================================
88 //
89 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES WITH NUMERIC ELEMENT TYPE
90 //
91 //=================================================================================================
92 
93 //*************************************************************************************************
101 template< typename MT // Type of the adapted sparse matrix
102  , bool SO > // Storage order of the adapted sparse matrix
103 class SymmetricMatrix<MT,SO,false,true>
104  : public SparseMatrix< SymmetricMatrix<MT,SO,false,true>, SO >
105 {
106  private:
107  //**Type definitions****************************************************************************
108  typedef typename MT::OppositeType OT;
109  typedef typename MT::TransposeType TT;
110  typedef typename MT::ElementType ET;
111  //**********************************************************************************************
112 
113  public:
114  //**Type definitions****************************************************************************
115  typedef SymmetricMatrix<MT,SO,false,true> This;
116  typedef This ResultType;
117  typedef SymmetricMatrix<OT,!SO,false,true> OppositeType;
118  typedef SymmetricMatrix<TT,!SO,false,true> TransposeType;
119  typedef ET ElementType;
120  typedef typename MT::ReturnType ReturnType;
121  typedef const This& CompositeType;
122  typedef NumericProxy<MT> Reference;
123  typedef typename MT::ConstReference ConstReference;
124  typedef typename MT::ConstIterator ConstIterator;
125  //**********************************************************************************************
126 
127  //**Rebind struct definition********************************************************************
130  template< typename ET > // Data type of the other matrix
131  struct Rebind {
133  typedef SymmetricMatrix< typename MT::template Rebind<ET>::Other > Other;
134  };
135  //**********************************************************************************************
136 
137  //**Iterator class definition*******************************************************************
140  class Iterator
141  {
142  public:
143  //**Type definitions*************************************************************************
144  typedef typename MT::Iterator IteratorType;
145 
146  typedef std::forward_iterator_tag IteratorCategory;
147  typedef SymmetricElement<MT> ValueType;
148  typedef ValueType PointerType;
149  typedef ValueType ReferenceType;
150  typedef ptrdiff_t DifferenceType;
151 
152  // STL iterator requirements
153  typedef IteratorCategory iterator_category;
154  typedef ValueType value_type;
155  typedef PointerType pointer;
156  typedef ReferenceType reference;
157  typedef DifferenceType difference_type;
158  //*******************************************************************************************
159 
160  //**Default constructor**********************************************************************
163  inline Iterator()
164  : pos_ ( ) // Iterator to the current sparse symmetric matrix element
165  , matrix_( NULL ) // The sparse matrix containing the iterator
166  , index_ ( 0UL ) // The row/column index of the iterator
167  {}
168  //*******************************************************************************************
169 
170  //**Constructor******************************************************************************
177  inline Iterator( IteratorType pos, MT& matrix, size_t index )
178  : pos_ ( pos ) // Iterator to the current sparse symmetric matrix element
179  , matrix_( &matrix ) // The sparse matrix containing the iterator
180  , index_ ( index ) // The row/column index of the iterator
181  {}
182  //*******************************************************************************************
183 
184  //**Prefix increment operator****************************************************************
189  inline Iterator& operator++() {
190  ++pos_;
191  return *this;
192  }
193  //*******************************************************************************************
194 
195  //**Postfix increment operator***************************************************************
200  inline const Iterator operator++( int ) {
201  const Iterator tmp( *this );
202  ++(*this);
203  return tmp;
204  }
205  //*******************************************************************************************
206 
207  //**Element access operator******************************************************************
212  inline ReferenceType operator*() const {
213  return ReferenceType( pos_, matrix_, index_ );
214  }
215  //*******************************************************************************************
216 
217  //**Element access operator******************************************************************
222  inline PointerType operator->() const {
223  return PointerType( pos_, matrix_, index_ );
224  }
225  //*******************************************************************************************
226 
227  //**Conversion operator**********************************************************************
232  inline operator ConstIterator() const {
233  return pos_;
234  }
235  //*******************************************************************************************
236 
237  //**Equality operator************************************************************************
243  inline bool operator==( const Iterator& rhs ) const {
244  return pos_ == rhs.pos_;
245  }
246  //*******************************************************************************************
247 
248  //**Inequality operator**********************************************************************
254  inline bool operator!=( const Iterator& rhs ) const {
255  return !( *this == rhs );
256  }
257  //*******************************************************************************************
258 
259  //**Subtraction operator*********************************************************************
265  inline DifferenceType operator-( const Iterator& rhs ) const {
266  return pos_ - rhs.pos_;
267  }
268  //*******************************************************************************************
269 
270  //**Base function****************************************************************************
275  inline IteratorType base() const {
276  return pos_;
277  }
278  //*******************************************************************************************
279 
280  private:
281  //**Member variables*************************************************************************
282  IteratorType pos_;
283  MT* matrix_;
284  size_t index_;
285  //*******************************************************************************************
286  };
287  //**********************************************************************************************
288 
289  //**Compilation flags***************************************************************************
291  enum { smpAssignable = 0 };
292  //**********************************************************************************************
293 
294  //**Constructors********************************************************************************
297  explicit inline SymmetricMatrix();
298  explicit inline SymmetricMatrix( size_t n );
299  explicit inline SymmetricMatrix( size_t n, size_t nonzeros );
300  explicit inline SymmetricMatrix( size_t n, const std::vector<size_t>& nonzeros );
301 
302  inline SymmetricMatrix( const SymmetricMatrix& m );
303  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,SO>& m );
304  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,!SO>& m );
306  //**********************************************************************************************
307 
308  //**Destructor**********************************************************************************
309  // No explicitly declared destructor.
310  //**********************************************************************************************
311 
312  //**Data access functions***********************************************************************
315  inline Reference operator()( size_t i, size_t j );
316  inline ConstReference operator()( size_t i, size_t j ) const;
317  inline Reference at( size_t i, size_t j );
318  inline ConstReference at( size_t i, size_t j ) const;
319  inline Iterator begin ( size_t i );
320  inline ConstIterator begin ( size_t i ) const;
321  inline ConstIterator cbegin( size_t i ) const;
322  inline Iterator end ( size_t i );
323  inline ConstIterator end ( size_t i ) const;
324  inline ConstIterator cend ( size_t i ) const;
326  //**********************************************************************************************
327 
328  //**Assignment operators************************************************************************
331  inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
332 
333  template< typename MT2 >
334  inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
335  operator=( const Matrix<MT2,SO>& rhs );
336 
337  template< typename MT2 >
338  inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
339  operator=( const Matrix<MT2,SO>& rhs );
340 
341  template< typename MT2 >
342  inline SymmetricMatrix& operator=( const Matrix<MT2,!SO>& rhs );
343 
344  template< typename MT2 >
345  inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
346  operator+=( const Matrix<MT2,SO>& rhs );
347 
348  template< typename MT2 >
349  inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
350  operator+=( const Matrix<MT2,SO>& rhs );
351 
352  template< typename MT2 >
353  inline SymmetricMatrix& operator+=( const Matrix<MT2,!SO>& rhs );
354 
355  template< typename MT2 >
356  inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
357  operator-=( const Matrix<MT2,SO>& rhs );
358 
359  template< typename MT2 >
360  inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
361  operator-=( const Matrix<MT2,SO>& rhs );
362 
363  template< typename MT2 >
364  inline SymmetricMatrix& operator-=( const Matrix<MT2,!SO>& rhs );
365 
366  template< typename MT2, bool SO2 >
367  inline SymmetricMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
368 
369  template< typename Other >
370  inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix >::Type&
371  operator*=( Other rhs );
372 
373  template< typename Other >
374  inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix >::Type&
375  operator/=( Other rhs );
377  //**********************************************************************************************
378 
379  //**Utility functions***************************************************************************
382  inline size_t rows() const;
383  inline size_t columns() const;
384  inline size_t capacity() const;
385  inline size_t capacity( size_t i ) const;
386  inline size_t nonZeros() const;
387  inline size_t nonZeros( size_t i ) const;
388  inline void reset();
389  inline void reset( size_t i );
390  inline void clear();
391  inline Iterator set( size_t i, size_t j, const ElementType& value );
392  inline Iterator insert( size_t i, size_t j, const ElementType& value );
393  inline void erase( size_t i, size_t j );
394  inline Iterator erase( size_t i, Iterator pos );
395  inline Iterator erase( size_t i, Iterator first, Iterator last );
396  inline void resize ( size_t n, bool preserve=true );
397  inline void reserve( size_t nonzeros );
398  inline void reserve( size_t i, size_t nonzeros );
399  inline void trim();
400  inline void trim( size_t i );
401  inline SymmetricMatrix& transpose();
402  inline SymmetricMatrix& ctranspose();
403  template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
404  template< typename Other > inline SymmetricMatrix& scaleDiagonal( Other scale );
405  inline void swap( SymmetricMatrix& m ) /* throw() */;
407  //**********************************************************************************************
408 
409  //**Lookup functions****************************************************************************
412  inline Iterator find ( size_t i, size_t j );
413  inline ConstIterator find ( size_t i, size_t j ) const;
414  inline Iterator lowerBound( size_t i, size_t j );
415  inline ConstIterator lowerBound( size_t i, size_t j ) const;
416  inline Iterator upperBound( size_t i, size_t j );
417  inline ConstIterator upperBound( size_t i, size_t j ) const;
419  //**********************************************************************************************
420 
421  //**Low-level utility functions*****************************************************************
424  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
425  inline void finalize( size_t i );
427  //**********************************************************************************************
428 
429  //**Debugging functions*************************************************************************
432  inline bool isIntact() const;
434  //**********************************************************************************************
435 
436  //**Expression template evaluation functions****************************************************
439  template< typename Other > inline bool canAlias ( const Other* alias ) const;
440  template< typename Other > inline bool isAliased( const Other* alias ) const;
441 
442  inline bool canSMPAssign() const;
444  //**********************************************************************************************
445 
446  private:
447  //**Member variables****************************************************************************
450  MT matrix_;
451 
452  //**********************************************************************************************
453 
454  //**Friend declarations*************************************************************************
455  template< typename MT2, bool SO2, bool DF2, bool NF2 >
456  friend bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
457  //**********************************************************************************************
458 
459  //**Compile time checks*************************************************************************
473  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
474  //**********************************************************************************************
475 };
477 //*************************************************************************************************
478 
479 
480 
481 
482 //=================================================================================================
483 //
484 // CONSTRUCTORS
485 //
486 //=================================================================================================
487 
488 //*************************************************************************************************
492 template< typename MT // Type of the adapted sparse matrix
493  , bool SO > // Storage order of the adapted sparse matrix
494 inline SymmetricMatrix<MT,SO,false,true>::SymmetricMatrix()
495  : matrix_() // The adapted sparse matrix
496 {
497  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
498 }
500 //*************************************************************************************************
501 
502 
503 //*************************************************************************************************
511 template< typename MT // Type of the adapted sparse matrix
512  , bool SO > // Storage order of the adapted sparse matrix
513 inline SymmetricMatrix<MT,SO,false,true>::SymmetricMatrix( size_t n )
514  : matrix_( n, n ) // The adapted sparse matrix
515 {
517 
518  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
519 }
521 //*************************************************************************************************
522 
523 
524 //*************************************************************************************************
533 template< typename MT // Type of the adapted sparse matrix
534  , bool SO > // Storage order of the adapted sparse matrix
535 inline SymmetricMatrix<MT,SO,false,true>::SymmetricMatrix( size_t n, size_t nonzeros )
536  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
537 {
539 
540  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
541 }
543 //*************************************************************************************************
544 
545 
546 //*************************************************************************************************
557 template< typename MT // Type of the adapted sparse matrix
558  , bool SO > // Storage order of the adapted sparse matrix
559 inline SymmetricMatrix<MT,SO,false,true>::SymmetricMatrix( size_t n, const std::vector<size_t>& nonzeros )
560  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
561 {
563 
564  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
565 }
567 //*************************************************************************************************
568 
569 
570 //*************************************************************************************************
576 template< typename MT // Type of the adapted sparse matrix
577  , bool SO > // Storage order of the adapted sparse matrix
578 inline SymmetricMatrix<MT,SO,false,true>::SymmetricMatrix( const SymmetricMatrix& m )
579  : matrix_( m.matrix_ ) // The adapted sparse matrix
580 {
581  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
582  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
583 }
585 //*************************************************************************************************
586 
587 
588 //*************************************************************************************************
598 template< typename MT // Type of the adapted sparse matrix
599  , bool SO > // Storage order of the adapted sparse matrix
600 template< typename MT2 > // Type of the foreign matrix
601 inline SymmetricMatrix<MT,SO,false,true>::SymmetricMatrix( const Matrix<MT2,SO>& m )
602  : matrix_( ~m ) // The adapted sparse matrix
603 {
604  if( !IsSymmetric<MT2>::value && !isSymmetric( matrix_ ) ) {
605  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
606  }
607 
608  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
609  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
610 }
612 //*************************************************************************************************
613 
614 
615 //*************************************************************************************************
625 template< typename MT // Type of the adapted sparse matrix
626  , bool SO > // Storage order of the adapted sparse matrix
627 template< typename MT2 > // Type of the foreign matrix
628 inline SymmetricMatrix<MT,SO,false,true>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
629  : matrix_( trans( ~m ) ) // The adapted sparse matrix
630 {
631  if( !IsSymmetric<MT2>::value && !isSymmetric( matrix_ ) ) {
632  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of symmetric matrix" );
633  }
634 
635  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
636  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
637 }
639 //*************************************************************************************************
640 
641 
642 
643 
644 //=================================================================================================
645 //
646 // DATA ACCESS FUNCTIONS
647 //
648 //=================================================================================================
649 
650 //*************************************************************************************************
665 template< typename MT // Type of the adapted sparse matrix
666  , bool SO > // Storage order of the adapted sparse matrix
668  SymmetricMatrix<MT,SO,false,true>::operator()( size_t i, size_t j )
669 {
670  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
671  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
672 
673  return Reference( matrix_, i, j );
674 }
676 //*************************************************************************************************
677 
678 
679 //*************************************************************************************************
694 template< typename MT // Type of the adapted sparse matrix
695  , bool SO > // Storage order of the adapted sparse matrix
697  SymmetricMatrix<MT,SO,false,true>::operator()( size_t i, size_t j ) const
698 {
699  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
700  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
701 
702  return matrix_(i,j);
703 }
705 //*************************************************************************************************
706 
707 
708 //*************************************************************************************************
724 template< typename MT // Type of the adapted dense matrix
725  , bool SO > // Storage order of the adapted dense matrix
727  SymmetricMatrix<MT,SO,false,true>::at( size_t i, size_t j )
728 {
729  if( i >= rows() ) {
730  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
731  }
732  if( j >= columns() ) {
733  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
734  }
735  return (*this)(i,j);
736 }
738 //*************************************************************************************************
739 
740 
741 //*************************************************************************************************
757 template< typename MT // Type of the adapted dense matrix
758  , bool SO > // Storage order of the adapted dense matrix
760  SymmetricMatrix<MT,SO,false,true>::at( size_t i, size_t j ) const
761 {
762  if( i >= rows() ) {
763  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
764  }
765  if( j >= columns() ) {
766  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
767  }
768  return (*this)(i,j);
769 }
771 //*************************************************************************************************
772 
773 
774 //*************************************************************************************************
786 template< typename MT // Type of the adapted sparse matrix
787  , bool SO > // Storage order of the adapted sparse matrix
790 {
791  return Iterator( matrix_.begin(i), matrix_, i );
792 }
794 //*************************************************************************************************
795 
796 
797 //*************************************************************************************************
809 template< typename MT // Type of the adapted sparse matrix
810  , bool SO > // Storage order of the adapted sparse matrix
813 {
814  return matrix_.begin(i);
815 }
817 //*************************************************************************************************
818 
819 
820 //*************************************************************************************************
832 template< typename MT // Type of the adapted sparse matrix
833  , bool SO > // Storage order of the adapted sparse matrix
836 {
837  return matrix_.cbegin(i);
838 }
840 //*************************************************************************************************
841 
842 
843 //*************************************************************************************************
855 template< typename MT // Type of the adapted sparse matrix
856  , bool SO > // Storage order of the adapted sparse matrix
859 {
860  return Iterator( matrix_.end(i), matrix_, i );
861 }
863 //*************************************************************************************************
864 
865 
866 //*************************************************************************************************
878 template< typename MT // Type of the adapted sparse matrix
879  , bool SO > // Storage order of the adapted sparse matrix
882 {
883  return matrix_.end(i);
884 }
886 //*************************************************************************************************
887 
888 
889 //*************************************************************************************************
901 template< typename MT // Type of the adapted sparse matrix
902  , bool SO > // Storage order of the adapted sparse matrix
905 {
906  return matrix_.cend(i);
907 }
909 //*************************************************************************************************
910 
911 
912 
913 
914 //=================================================================================================
915 //
916 // ASSIGNMENT OPERATORS
917 //
918 //=================================================================================================
919 
920 //*************************************************************************************************
930 template< typename MT // Type of the adapted sparse matrix
931  , bool SO > // Storage order of the adapted sparse matrix
932 inline SymmetricMatrix<MT,SO,false,true>&
933  SymmetricMatrix<MT,SO,false,true>::operator=( const SymmetricMatrix& rhs )
934 {
935  matrix_ = rhs.matrix_;
936 
937  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
938  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
939 
940  return *this;
941 }
943 //*************************************************************************************************
944 
945 
946 //*************************************************************************************************
959 template< typename MT // Type of the adapted sparse matrix
960  , bool SO > // Storage order of the adapted sparse matrix
961 template< typename MT2 > // Type of the right-hand side matrix
962 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,true>& >::Type
963  SymmetricMatrix<MT,SO,false,true>::operator=( const Matrix<MT2,SO>& rhs )
964 {
965  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
966  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
967  }
968 
969  matrix_ = ~rhs;
970 
971  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
972  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
973 
974  return *this;
975 }
977 //*************************************************************************************************
978 
979 
980 //*************************************************************************************************
993 template< typename MT // Type of the adapted sparse matrix
994  , bool SO > // Storage order of the adapted sparse matrix
995 template< typename MT2 > // Type of the right-hand side matrix
996 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,true>& >::Type
997  SymmetricMatrix<MT,SO,false,true>::operator=( const Matrix<MT2,SO>& rhs )
998 {
999  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1000  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1001  }
1002 
1003  if( IsSymmetric<MT2>::value ) {
1004  matrix_ = ~rhs;
1005  }
1006  else {
1007  MT tmp( ~rhs );
1008 
1009  if( !isSymmetric( tmp ) ) {
1010  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1011  }
1012 
1013  move( matrix_, tmp );
1014  }
1015 
1016  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1017  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1018 
1019  return *this;
1020 }
1022 //*************************************************************************************************
1023 
1024 
1025 //*************************************************************************************************
1038 template< typename MT // Type of the adapted sparse matrix
1039  , bool SO > // Storage order of the adapted sparse matrix
1040 template< typename MT2 > // Type of the right-hand side matrix
1041 inline SymmetricMatrix<MT,SO,false,true>&
1042  SymmetricMatrix<MT,SO,false,true>::operator=( const Matrix<MT2,!SO>& rhs )
1043 {
1044  return this->operator=( trans( ~rhs ) );
1045 }
1047 //*************************************************************************************************
1048 
1049 
1050 //*************************************************************************************************
1063 template< typename MT // Type of the adapted sparse matrix
1064  , bool SO > // Storage order of the adapted sparse matrix
1065 template< typename MT2 > // Type of the right-hand side matrix
1066 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,true>& >::Type
1067  SymmetricMatrix<MT,SO,false,true>::operator+=( const Matrix<MT2,SO>& rhs )
1068 {
1069  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1070  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1071  }
1072 
1073  matrix_ += ~rhs;
1074 
1075  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1076  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1077 
1078  return *this;
1079 }
1081 //*************************************************************************************************
1082 
1083 
1084 //*************************************************************************************************
1097 template< typename MT // Type of the adapted sparse matrix
1098  , bool SO > // Storage order of the adapted sparse matrix
1099 template< typename MT2 > // Type of the right-hand side matrix
1100 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,true>& >::Type
1101  SymmetricMatrix<MT,SO,false,true>::operator+=( const Matrix<MT2,SO>& rhs )
1102 {
1103  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1104  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1105  }
1106 
1107  if( IsSymmetric<MT2>::value ) {
1108  matrix_ += ~rhs;
1109  }
1110  else {
1111  typename MT2::ResultType tmp( ~rhs );
1112 
1113  if( !isSymmetric( tmp ) ) {
1114  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1115  }
1116 
1117  matrix_ += tmp;
1118  }
1119 
1120  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1121  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1122 
1123  return *this;
1124 }
1126 //*************************************************************************************************
1127 
1128 
1129 //*************************************************************************************************
1143 template< typename MT // Type of the adapted sparse matrix
1144  , bool SO > // Storage order of the adapted sparse matrix
1145 template< typename MT2 > // Type of the right-hand side matrix
1146 inline SymmetricMatrix<MT,SO,false,true>&
1147  SymmetricMatrix<MT,SO,false,true>::operator+=( const Matrix<MT2,!SO>& rhs )
1148 {
1149  return this->operator+=( trans( ~rhs ) );
1150 }
1152 //*************************************************************************************************
1153 
1154 
1155 //*************************************************************************************************
1168 template< typename MT // Type of the adapted sparse matrix
1169  , bool SO > // Storage order of the adapted sparse matrix
1170 template< typename MT2 > // Type of the right-hand side matrix
1171 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,true>& >::Type
1172  SymmetricMatrix<MT,SO,false,true>::operator-=( const Matrix<MT2,SO>& rhs )
1173 {
1174  if( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) {
1175  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1176  }
1177 
1178  matrix_ -= ~rhs;
1179 
1180  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1181  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1182 
1183  return *this;
1184 }
1186 //*************************************************************************************************
1187 
1188 
1189 //*************************************************************************************************
1202 template< typename MT // Type of the adapted sparse matrix
1203  , bool SO > // Storage order of the adapted sparse matrix
1204 template< typename MT2 > // Type of the right-hand side matrix
1205 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,false,true>& >::Type
1206  SymmetricMatrix<MT,SO,false,true>::operator-=( const Matrix<MT2,SO>& rhs )
1207 {
1208  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1209  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1210  }
1211 
1212  if( IsSymmetric<MT2>::value ) {
1213  matrix_ -= ~rhs;
1214  }
1215  else {
1216  typename MT2::ResultType tmp( ~rhs );
1217 
1218  if( !isSymmetric( tmp ) ) {
1219  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1220  }
1221 
1222  matrix_ -= tmp;
1223  }
1224 
1225  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1226  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1227 
1228  return *this;
1229 }
1231 //*************************************************************************************************
1232 
1233 
1234 //*************************************************************************************************
1248 template< typename MT // Type of the adapted sparse matrix
1249  , bool SO > // Storage order of the adapted sparse matrix
1250 template< typename MT2 > // Type of the right-hand side matrix
1251 inline SymmetricMatrix<MT,SO,false,true>&
1252  SymmetricMatrix<MT,SO,false,true>::operator-=( const Matrix<MT2,!SO>& rhs )
1253 {
1254  return this->operator-=( trans( ~rhs ) );
1255 }
1257 //*************************************************************************************************
1258 
1259 
1260 //*************************************************************************************************
1272 template< typename MT // Type of the adapted sparse matrix
1273  , bool SO > // Storage order of the adapted sparse matrix
1274 template< typename MT2 // Type of the right-hand side matrix
1275  , bool SO2 > // Storage order of the right-hand side matrix
1276 inline SymmetricMatrix<MT,SO,false,true>&
1277  SymmetricMatrix<MT,SO,false,true>::operator*=( const Matrix<MT2,SO2>& rhs )
1278 {
1279  if( matrix_.rows() != (~rhs).columns() ) {
1280  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1281  }
1282 
1283  MT tmp( matrix_ * ~rhs );
1284 
1285  if( !isSymmetric( tmp ) ) {
1286  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to symmetric matrix" );
1287  }
1288 
1289  move( matrix_, tmp );
1290 
1291  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1292  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1293 
1294  return *this;
1295 }
1297 //*************************************************************************************************
1298 
1299 
1300 //*************************************************************************************************
1308 template< typename MT // Type of the adapted sparse matrix
1309  , bool SO > // Storage order of the adapted sparse matrix
1310 template< typename Other > // Data type of the right-hand side scalar
1311 inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix<MT,SO,false,true> >::Type&
1312  SymmetricMatrix<MT,SO,false,true>::operator*=( Other rhs )
1313 {
1314  matrix_ *= rhs;
1315  return *this;
1316 }
1317 //*************************************************************************************************
1318 
1319 
1320 //*************************************************************************************************
1328 template< typename MT // Type of the adapted sparse matrix
1329  , bool SO > // Storage order of the adapted sparse matrix
1330 template< typename Other > // Data type of the right-hand side scalar
1331 inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix<MT,SO,false,true> >::Type&
1332  SymmetricMatrix<MT,SO,false,true>::operator/=( Other rhs )
1333 {
1334  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1335 
1336  matrix_ /= rhs;
1337  return *this;
1338 }
1340 //*************************************************************************************************
1341 
1342 
1343 
1344 
1345 //=================================================================================================
1346 //
1347 // UTILITY FUNCTIONS
1348 //
1349 //=================================================================================================
1350 
1351 //*************************************************************************************************
1357 template< typename MT // Type of the adapted sparse matrix
1358  , bool SO > // Storage order of the adapted sparse matrix
1359 inline size_t SymmetricMatrix<MT,SO,false,true>::rows() const
1360 {
1361  return matrix_.rows();
1362 }
1364 //*************************************************************************************************
1365 
1366 
1367 //*************************************************************************************************
1373 template< typename MT // Type of the adapted sparse matrix
1374  , bool SO > // Storage order of the adapted sparse matrix
1375 inline size_t SymmetricMatrix<MT,SO,false,true>::columns() const
1376 {
1377  return matrix_.columns();
1378 }
1380 //*************************************************************************************************
1381 
1382 
1383 //*************************************************************************************************
1389 template< typename MT // Type of the adapted sparse matrix
1390  , bool SO > // Storage order of the adapted sparse matrix
1391 inline size_t SymmetricMatrix<MT,SO,false,true>::capacity() const
1392 {
1393  return matrix_.capacity();
1394 }
1396 //*************************************************************************************************
1397 
1398 
1399 //*************************************************************************************************
1410 template< typename MT // Type of the adapted sparse matrix
1411  , bool SO > // Storage order of the adapted sparse matrix
1412 inline size_t SymmetricMatrix<MT,SO,false,true>::capacity( size_t i ) const
1413 {
1414  return matrix_.capacity(i);
1415 }
1417 //*************************************************************************************************
1418 
1419 
1420 //*************************************************************************************************
1426 template< typename MT // Type of the adapted sparse matrix
1427  , bool SO > // Storage order of the adapted sparse matrix
1428 inline size_t SymmetricMatrix<MT,SO,false,true>::nonZeros() const
1429 {
1430  return matrix_.nonZeros();
1431 }
1433 //*************************************************************************************************
1434 
1435 
1436 //*************************************************************************************************
1448 template< typename MT // Type of the adapted sparse matrix
1449  , bool SO > // Storage order of the adapted sparse matrix
1450 inline size_t SymmetricMatrix<MT,SO,false,true>::nonZeros( size_t i ) const
1451 {
1452  return matrix_.nonZeros(i);
1453 }
1455 //*************************************************************************************************
1456 
1457 
1458 //*************************************************************************************************
1464 template< typename MT // Type of the adapted sparse matrix
1465  , bool SO > // Storage order of the adapted sparse matrix
1467 {
1468  matrix_.reset();
1469 }
1471 //*************************************************************************************************
1472 
1473 
1474 //*************************************************************************************************
1510 template< typename MT // Type of the adapted sparse matrix
1511  , bool SO > // Storage order of the adapted sparse matrix
1512 inline void SymmetricMatrix<MT,SO,false,true>::reset( size_t i )
1513 {
1514  for( typename MT::Iterator it=matrix_.begin(i); it!=matrix_.end(i); ++it )
1515  {
1516  const size_t j( it->index() );
1517 
1518  if( i == j )
1519  continue;
1520 
1521  if( SO ) {
1522  const typename MT::Iterator pos( matrix_.find( i, j ) );
1523  BLAZE_INTERNAL_ASSERT( pos != matrix_.end( j ), "Missing element detected" );
1524  matrix_.erase( j, pos );
1525  }
1526  else {
1527  const typename MT::Iterator pos( matrix_.find( j, i ) );
1528  BLAZE_INTERNAL_ASSERT( pos != matrix_.end( j ), "Missing element detected" );
1529  matrix_.erase( j, pos );
1530  }
1531  }
1532 
1533  matrix_.reset( i );
1534 }
1536 //*************************************************************************************************
1537 
1538 
1539 //*************************************************************************************************
1547 template< typename MT // Type of the adapted sparse matrix
1548  , bool SO > // Storage order of the adapted sparse matrix
1550 {
1551  using blaze::clear;
1552 
1553  clear( matrix_ );
1554 }
1556 //*************************************************************************************************
1557 
1558 
1559 //*************************************************************************************************
1573 template< typename MT // Type of the adapted sparse matrix
1574  , bool SO > // Storage order of the adapted sparse matrix
1576  SymmetricMatrix<MT,SO,false,true>::set( size_t i, size_t j, const ElementType& value )
1577 {
1578  if( i != j )
1579  matrix_.set( j, i, value );
1580  return Iterator( matrix_.set( i, j, value ), matrix_, ( SO ? j : i ) );
1581 }
1583 //*************************************************************************************************
1584 
1585 
1586 //*************************************************************************************************
1601 template< typename MT // Type of the adapted sparse matrix
1602  , bool SO > // Storage order of the adapted sparse matrix
1604  SymmetricMatrix<MT,SO,false,true>::insert( size_t i, size_t j, const ElementType& value )
1605 {
1606  if( i != j )
1607  matrix_.insert( j, i, value );
1608  return Iterator( matrix_.insert( i, j, value ), matrix_, ( SO ? j : i ) );
1609 }
1611 //*************************************************************************************************
1612 
1613 
1614 //*************************************************************************************************
1624 template< typename MT // Type of the adapted sparse matrix
1625  , bool SO > // Storage order of the adapted sparse matrix
1626 inline void SymmetricMatrix<MT,SO,false,true>::erase( size_t i, size_t j )
1627 {
1628  matrix_.erase( i, j );
1629  if( i != j )
1630  matrix_.erase( j, i );
1631 }
1633 //*************************************************************************************************
1634 
1635 
1636 //*************************************************************************************************
1648 template< typename MT // Type of the adapted sparse matrix
1649  , bool SO > // Storage order of the adapted sparse matrix
1651  SymmetricMatrix<MT,SO,false,true>::erase( size_t i, Iterator pos )
1652 {
1653  const typename MT::Iterator base( pos.base() );
1654 
1655  if( base == matrix_.end( i ) )
1656  return pos;
1657 
1658  const size_t j( base->index() );
1659 
1660  if( i == j ) {
1661  BLAZE_INTERNAL_ASSERT( matrix_.find( i, i ) != matrix_.end( i ), "Missing element detected" );
1662  return Iterator( matrix_.erase( i, base ), matrix_, i );
1663  }
1664 
1665  if( SO ) {
1666  BLAZE_INTERNAL_ASSERT( matrix_.find( i, j ) != matrix_.end( j ), "Missing element detected" );
1667  matrix_.erase( j, matrix_.find( i, j ) );
1668  return Iterator( matrix_.erase( i, base ), matrix_, i );
1669  }
1670  else {
1671  BLAZE_INTERNAL_ASSERT( matrix_.find( j, i ) != matrix_.end( j ), "Missing element detected" );
1672  matrix_.erase( j, matrix_.find( j, i ) );
1673  return Iterator( matrix_.erase( i, base ), matrix_, i );
1674  }
1675 }
1677 //*************************************************************************************************
1678 
1679 
1680 //*************************************************************************************************
1694 template< typename MT // Type of the adapted sparse matrix
1695  , bool SO > // Storage order of the adapted sparse matrix
1697  SymmetricMatrix<MT,SO,false,true>::erase( size_t i, Iterator first, Iterator last )
1698 {
1699  for( typename MT::Iterator it=first.base(); it!=last.base(); ++it )
1700  {
1701  const size_t j( it->index() );
1702 
1703  if( i == j )
1704  continue;
1705 
1706  if( SO ) {
1707  BLAZE_INTERNAL_ASSERT( matrix_.find( i, j ) != matrix_.end( j ), "Missing element detected" );
1708  matrix_.erase( i, j );
1709  }
1710  else {
1711  BLAZE_INTERNAL_ASSERT( matrix_.find( j, i ) != matrix_.end( j ), "Missing element detected" );
1712  matrix_.erase( j, i );
1713  }
1714  }
1715 
1716  return Iterator( matrix_.erase( i, first.base(), last.base() ), matrix_, i );
1717 }
1719 //*************************************************************************************************
1720 
1721 
1722 //*************************************************************************************************
1737 template< typename MT // Type of the adapted sparse matrix
1738  , bool SO > // Storage order of the adapted sparse matrix
1739 void SymmetricMatrix<MT,SO,false,true>::resize( size_t n, bool preserve )
1740 {
1742 
1743  UNUSED_PARAMETER( preserve );
1744 
1745  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1746 
1747  matrix_.resize( n, n, true );
1748 }
1750 //*************************************************************************************************
1751 
1752 
1753 //*************************************************************************************************
1764 template< typename MT // Type of the adapted sparse matrix
1765  , bool SO > // Storage order of the adapted sparse matrix
1766 inline void SymmetricMatrix<MT,SO,false,true>::reserve( size_t nonzeros )
1767 {
1768  matrix_.reserve( nonzeros );
1769 }
1771 //*************************************************************************************************
1772 
1773 
1774 //*************************************************************************************************
1788 template< typename MT // Type of the adapted sparse matrix
1789  , bool SO > // Storage order of the adapted sparse matrix
1790 inline void SymmetricMatrix<MT,SO,false,true>::reserve( size_t i, size_t nonzeros )
1791 {
1792  matrix_.reserve( i, nonzeros );
1793 }
1795 //*************************************************************************************************
1796 
1797 
1798 //*************************************************************************************************
1809 template< typename MT // Type of the adapted sparse matrix
1810  , bool SO > // Storage order of the adapted sparse matrix
1811 inline void SymmetricMatrix<MT,SO,false,true>::trim()
1812 {
1813  matrix_.trim();
1814 }
1816 //*************************************************************************************************
1817 
1818 
1819 //*************************************************************************************************
1831 template< typename MT // Type of the adapted sparse matrix
1832  , bool SO > // Storage order of the adapted sparse matrix
1833 inline void SymmetricMatrix<MT,SO,false,true>::trim( size_t i )
1834 {
1835  matrix_.trim( i );
1836 }
1838 //*************************************************************************************************
1839 
1840 
1841 //*************************************************************************************************
1847 template< typename MT // Type of the adapted sparse matrix
1848  , bool SO > // Storage order of the adapted sparse matrix
1849 inline SymmetricMatrix<MT,SO,false,true>& SymmetricMatrix<MT,SO,false,true>::transpose()
1850 {
1851  return *this;
1852 }
1854 //*************************************************************************************************
1855 
1856 
1857 //*************************************************************************************************
1863 template< typename MT // Type of the adapted sparse matrix
1864  , bool SO > // Storage order of the adapted sparse matrix
1865 inline SymmetricMatrix<MT,SO,false,true>& SymmetricMatrix<MT,SO,false,true>::ctranspose()
1866 {
1867  if( !IsBuiltin<ElementType>::value )
1868  conjugate( matrix_ );
1869 
1870  return *this;
1871 }
1873 //*************************************************************************************************
1874 
1875 
1876 //*************************************************************************************************
1883 template< typename MT // Type of the adapted sparse matrix
1884  , bool SO > // Storage order of the adapted sparse matrix
1885 template< typename Other > // Data type of the scalar value
1886 inline SymmetricMatrix<MT,SO,false,true>&
1887  SymmetricMatrix<MT,SO,false,true>::scale( const Other& scalar )
1888 {
1889  matrix_.scale( scalar );
1890  return *this;
1891 }
1893 //*************************************************************************************************
1894 
1895 
1896 //*************************************************************************************************
1903 template< typename MT // Type of the adapted sparse matrix
1904  , bool SO > // Storage order of the adapted sparse matrix
1905 template< typename Other > // Data type of the scalar value
1906 inline SymmetricMatrix<MT,SO,false,true>&
1907  SymmetricMatrix<MT,SO,false,true>::scaleDiagonal( Other scalar )
1908 {
1909  matrix_.scaleDiagonal( scalar );
1910  return *this;
1911 }
1913 //*************************************************************************************************
1914 
1915 
1916 //*************************************************************************************************
1924 template< typename MT // Type of the adapted sparse matrix
1925  , bool SO > // Storage order of the adapted sparse matrix
1926 inline void SymmetricMatrix<MT,SO,false,true>::swap( SymmetricMatrix& m ) /* throw() */
1927 {
1928  using std::swap;
1929 
1930  swap( matrix_, m.matrix_ );
1931 }
1933 //*************************************************************************************************
1934 
1935 
1936 
1937 
1938 //=================================================================================================
1939 //
1940 // LOOKUP FUNCTIONS
1941 //
1942 //=================================================================================================
1943 
1944 //*************************************************************************************************
1960 template< typename MT // Type of the adapted sparse matrix
1961  , bool SO > // Storage order of the adapted sparse matrix
1963  SymmetricMatrix<MT,SO,false,true>::find( size_t i, size_t j )
1964 {
1965  return Iterator( matrix_.find( i, j ), matrix_, ( SO ? j : i ) );
1966 }
1968 //*************************************************************************************************
1969 
1970 
1971 //*************************************************************************************************
1987 template< typename MT // Type of the adapted sparse matrix
1988  , bool SO > // Storage order of the adapted sparse matrix
1990  SymmetricMatrix<MT,SO,false,true>::find( size_t i, size_t j ) const
1991 {
1992  return matrix_.find( i, j );
1993 }
1995 //*************************************************************************************************
1996 
1997 
1998 //*************************************************************************************************
2014 template< typename MT // Type of the adapted sparse matrix
2015  , bool SO > // Storage order of the adapted sparse matrix
2017  SymmetricMatrix<MT,SO,false,true>::lowerBound( size_t i, size_t j )
2018 {
2019  return Iterator( matrix_.lowerBound( i, j ), matrix_, ( SO ? j : i ) );
2020 }
2022 //*************************************************************************************************
2023 
2024 
2025 //*************************************************************************************************
2041 template< typename MT // Type of the adapted sparse matrix
2042  , bool SO > // Storage order of the adapted sparse matrix
2044  SymmetricMatrix<MT,SO,false,true>::lowerBound( size_t i, size_t j ) const
2045 {
2046  return matrix_.lowerBound( i, j );
2047 }
2049 //*************************************************************************************************
2050 
2051 
2052 //*************************************************************************************************
2068 template< typename MT // Type of the adapted sparse matrix
2069  , bool SO > // Storage order of the adapted sparse matrix
2071  SymmetricMatrix<MT,SO,false,true>::upperBound( size_t i, size_t j )
2072 {
2073  return Iterator( matrix_.upperBound( i, j ), matrix_, ( SO ? j : i ) );
2074 }
2076 //*************************************************************************************************
2077 
2078 
2079 //*************************************************************************************************
2095 template< typename MT // Type of the adapted sparse matrix
2096  , bool SO > // Storage order of the adapted sparse matrix
2098  SymmetricMatrix<MT,SO,false,true>::upperBound( size_t i, size_t j ) const
2099 {
2100  return matrix_.upperBound( i, j );
2101 }
2103 //*************************************************************************************************
2104 
2105 
2106 
2107 
2108 //=================================================================================================
2109 //
2110 // LOW-LEVEL UTILITY FUNCTIONS
2111 //
2112 //=================================================================================================
2113 
2114 //*************************************************************************************************
2169 template< typename MT // Type of the adapted sparse matrix
2170  , bool SO > // Storage order of the adapted sparse matrix
2171 inline void SymmetricMatrix<MT,SO,false,true>::append( size_t i, size_t j, const ElementType& value, bool check )
2172 {
2173  matrix_.append( i, j, value, check );
2174  if( i != j && ( !check || !isDefault( value ) ) )
2175  matrix_.insert( j, i, value );
2176 }
2178 //*************************************************************************************************
2179 
2180 
2181 //*************************************************************************************************
2195 template< typename MT // Type of the adapted sparse matrix
2196  , bool SO > // Storage order of the adapted sparse matrix
2197 inline void SymmetricMatrix<MT,SO,false,true>::finalize( size_t i )
2198 {
2199  matrix_.trim( i );
2200 }
2202 //*************************************************************************************************
2203 
2204 
2205 
2206 
2207 //=================================================================================================
2208 //
2209 // DEBUGGING FUNCTIONS
2210 //
2211 //=================================================================================================
2212 
2213 //*************************************************************************************************
2223 template< typename MT // Type of the adapted sparse matrix
2224  , bool SO > // Storage order of the adapted sparse matrix
2226 {
2227  using blaze::isIntact;
2228 
2229  return ( isIntact( matrix_ ) && isSymmetric( matrix_ ) );
2230 }
2232 //*************************************************************************************************
2233 
2234 
2235 
2236 
2237 //=================================================================================================
2238 //
2239 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2240 //
2241 //=================================================================================================
2242 
2243 //*************************************************************************************************
2254 template< typename MT // Type of the adapted sparse matrix
2255  , bool SO > // Storage order of the adapted sparse matrix
2256 template< typename Other > // Data type of the foreign expression
2257 inline bool SymmetricMatrix<MT,SO,false,true>::canAlias( const Other* alias ) const
2258 {
2259  return matrix_.canAlias( alias );
2260 }
2262 //*************************************************************************************************
2263 
2264 
2265 //*************************************************************************************************
2276 template< typename MT // Type of the adapted sparse matrix
2277  , bool SO > // Storage order of the adapted sparse matrix
2278 template< typename Other > // Data type of the foreign expression
2279 inline bool SymmetricMatrix<MT,SO,false,true>::isAliased( const Other* alias ) const
2280 {
2281  return matrix_.isAliased( alias );
2282 }
2284 //*************************************************************************************************
2285 
2286 
2287 //*************************************************************************************************
2298 template< typename MT // Type of the adapted sparse matrix
2299  , bool SO > // Storage order of the adapted sparse matrix
2300 inline bool SymmetricMatrix<MT,SO,false,true>::canSMPAssign() const
2301 {
2302  return matrix_.canSMPAssign();
2303 }
2305 //*************************************************************************************************
2306 
2307 } // namespace blaze
2308 
2309 #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
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
#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.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:697
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.
Header file for the NumericProxy class.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2584
Header file for the implementation of the base template of the SymmetricMatrix.
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.
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 IsSymmetric type trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Header file for the SymmetricElement class.
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.
BLAZE_ALWAYS_INLINE void conjugate(T &a)
In-place conjugation of the given value/object.
Definition: Conjugate.h:120
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 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.
#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 SymmetricValue class.
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.
#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
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
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.
#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
#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
BLAZE_ALWAYS_INLINE void transpose(Matrix< MT, SO > &matrix)
In-place transpose of the given matrix.
Definition: Matrix.h:558