All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DenseNumeric.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENUMERIC_H_
36 #define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENUMERIC_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <iterator>
45 #include <stdexcept>
58 #include <blaze/math/Functions.h>
59 #include <blaze/math/Intrinsics.h>
60 #include <blaze/math/shims/Clear.h>
71 #include <blaze/math/views/Row.h>
73 #include <blaze/util/Assert.h>
79 #include <blaze/util/DisableIf.h>
80 #include <blaze/util/EnableIf.h>
81 #include <blaze/util/mpl/If.h>
83 #include <blaze/util/Types.h>
85 #include <blaze/util/Unused.h>
86 
87 
88 namespace blaze {
89 
90 //=================================================================================================
91 //
92 // CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES WITH NUMERIC ELEMENT TYPE
93 //
94 //=================================================================================================
95 
96 //*************************************************************************************************
104 template< typename MT // Type of the adapted dense matrix
105  , bool SO > // Storage order of the adapted dense matrix
106 class SymmetricMatrix<MT,SO,true,true>
107  : public DenseMatrix< SymmetricMatrix<MT,SO,true,true>, SO >
108 {
109  private:
110  //**Type definitions****************************************************************************
111  typedef typename MT::OppositeType OT;
112  typedef typename MT::TransposeType TT;
113  typedef typename MT::ElementType ET;
114  typedef IntrinsicTrait<ET> IT;
115  //**********************************************************************************************
116 
117  public:
118  //**Type definitions****************************************************************************
119  typedef SymmetricMatrix<MT,SO,true,true> This;
120  typedef This ResultType;
121  typedef SymmetricMatrix<OT,!SO,true,true> OppositeType;
122  typedef SymmetricMatrix<TT,!SO,true,true> TransposeType;
123  typedef ET ElementType;
124  typedef typename MT::IntrinsicType IntrinsicType;
125  typedef typename MT::ReturnType ReturnType;
126  typedef const This& CompositeType;
127  typedef NumericProxy<MT> Reference;
128  typedef typename MT::ConstReference ConstReference;
129  typedef typename MT::Pointer Pointer;
130  typedef typename MT::ConstPointer ConstPointer;
131  typedef typename MT::ConstIterator ConstIterator;
132  //**********************************************************************************************
133 
134  //**Rebind struct definition********************************************************************
137  template< typename ET > // Data type of the other matrix
138  struct Rebind {
140  typedef SymmetricMatrix< typename MT::template Rebind<ET>::Other > Other;
141  };
142  //**********************************************************************************************
143 
144  //**RowIterator class definition****************************************************************
147  class RowIterator
148  {
149  public:
150  //**Type definitions*************************************************************************
151  typedef std::random_access_iterator_tag IteratorCategory;
152  typedef typename MT::ElementType ValueType;
153  typedef NumericProxy<MT> PointerType;
154  typedef NumericProxy<MT> ReferenceType;
155  typedef ptrdiff_t DifferenceType;
156 
157  // STL iterator requirements
158  typedef IteratorCategory iterator_category;
159  typedef ValueType value_type;
160  typedef PointerType pointer;
161  typedef ReferenceType reference;
162  typedef DifferenceType difference_type;
163  //*******************************************************************************************
164 
165  //**Constructor******************************************************************************
168  inline RowIterator()
169  : matrix_( NULL ) // Reference to the adapted dense matrix
170  , row_ ( 0UL ) // The current row index of the iterator
171  , column_( 0UL ) // The current column index of the iterator
172  {}
173  //*******************************************************************************************
174 
175  //**Constructor******************************************************************************
182  inline RowIterator( MT& matrix, size_t row, size_t column )
183  : matrix_( &matrix ) // Reference to the adapted dense matrix
184  , row_ ( row ) // The current row index of the iterator
185  , column_( column ) // The current column index of the iterator
186  {}
187  //*******************************************************************************************
188 
189  //**Addition assignment operator*************************************************************
195  inline RowIterator& operator+=( size_t inc ) {
196  column_ += inc;
197  return *this;
198  }
199  //*******************************************************************************************
200 
201  //**Subtraction assignment operator**********************************************************
207  inline RowIterator& operator-=( size_t dec ) {
208  column_ -= dec;
209  return *this;
210  }
211  //*******************************************************************************************
212 
213  //**Prefix increment operator****************************************************************
218  inline RowIterator& operator++() {
219  ++column_;
220  return *this;
221  }
222  //*******************************************************************************************
223 
224  //**Postfix increment operator***************************************************************
229  inline const RowIterator operator++( int ) {
230  const RowIterator tmp( *this );
231  ++(*this);
232  return tmp;
233  }
234  //*******************************************************************************************
235 
236  //**Prefix decrement operator****************************************************************
241  inline RowIterator& operator--() {
242  --column_;
243  return *this;
244  }
245  //*******************************************************************************************
246 
247  //**Postfix decrement operator***************************************************************
252  inline const RowIterator operator--( int ) {
253  const RowIterator tmp( *this );
254  --(*this);
255  return tmp;
256  }
257  //*******************************************************************************************
258 
259  //**Element access operator******************************************************************
264  inline ReferenceType operator*() const {
265  return ReferenceType( *matrix_, row_, column_ );
266  }
267  //*******************************************************************************************
268 
269  //**Element access operator******************************************************************
274  inline PointerType operator->() const {
275  return PointerType( *matrix_, row_, column_ );
276  }
277  //*******************************************************************************************
278 
279  //**Conversion operator**********************************************************************
284  inline operator ConstIterator() const {
285  return matrix_->begin(row_) + column_;
286  }
287  //*******************************************************************************************
288 
289  //**Equality operator************************************************************************
296  friend inline bool operator==( const RowIterator& lhs, const RowIterator& rhs ) {
297  return ( lhs.column_ == rhs.column_ );
298  }
299  //*******************************************************************************************
300 
301  //**Equality operator************************************************************************
308  friend inline bool operator==( const RowIterator& lhs, const ConstIterator& rhs ) {
309  return ( ConstIterator( lhs ) == rhs );
310  }
311  //*******************************************************************************************
312 
313  //**Equality operator************************************************************************
320  friend inline bool operator==( const ConstIterator& lhs, const RowIterator& rhs ) {
321  return ( lhs == ConstIterator( rhs ) );
322  }
323  //*******************************************************************************************
324 
325  //**Inequality operator**********************************************************************
332  friend inline bool operator!=( const RowIterator& lhs, const RowIterator& rhs ) {
333  return ( lhs.column_ != rhs.column_ );
334  }
335  //*******************************************************************************************
336 
337  //**Inequality operator**********************************************************************
344  friend inline bool operator!=( const RowIterator& lhs, const ConstIterator& rhs ) {
345  return ( ConstIterator( lhs ) != rhs );
346  }
347  //*******************************************************************************************
348 
349  //**Inequality operator**********************************************************************
356  friend inline bool operator!=( const ConstIterator& lhs, const RowIterator& rhs ) {
357  return ( lhs != ConstIterator( rhs ) );
358  }
359  //*******************************************************************************************
360 
361  //**Less-than operator***********************************************************************
368  friend inline bool operator<( const RowIterator& lhs, const RowIterator& rhs ) {
369  return ( lhs.column_ < rhs.column_ );
370  }
371  //*******************************************************************************************
372 
373  //**Less-than operator***********************************************************************
380  friend inline bool operator<( const RowIterator& lhs, const ConstIterator& rhs ) {
381  return ( ConstIterator( lhs ) < rhs );
382  }
383  //*******************************************************************************************
384 
385  //**Less-than operator***********************************************************************
392  friend inline bool operator<( const ConstIterator& lhs, const RowIterator& rhs ) {
393  return ( lhs < ConstIterator( rhs ) );
394  }
395  //*******************************************************************************************
396 
397  //**Greater-than operator********************************************************************
404  friend inline bool operator>( const RowIterator& lhs, const RowIterator& rhs ) {
405  return ( lhs.column_ > rhs.column_ );
406  }
407  //*******************************************************************************************
408 
409  //**Greater-than operator********************************************************************
416  friend inline bool operator>( const RowIterator& lhs, const ConstIterator& rhs ) {
417  return ( ConstIterator( lhs ) > rhs );
418  }
419  //*******************************************************************************************
420 
421  //**Greater-than operator********************************************************************
428  friend inline bool operator>( const ConstIterator& lhs, const RowIterator& rhs ) {
429  return ( lhs > ConstIterator( rhs ) );
430  }
431  //*******************************************************************************************
432 
433  //**Less-or-equal-than operator**************************************************************
440  friend inline bool operator<=( const RowIterator& lhs, const RowIterator& rhs ) {
441  return ( lhs.column_ <= rhs.column_ );
442  }
443  //*******************************************************************************************
444 
445  //**Less-or-equal-than operator**************************************************************
452  friend inline bool operator<=( const RowIterator& lhs, const ConstIterator& rhs ) {
453  return ( ConstIterator( lhs ) <= rhs );
454  }
455  //*******************************************************************************************
456 
457  //**Less-or-equal-than operator**************************************************************
464  friend inline bool operator<=( const ConstIterator& lhs, const RowIterator& rhs ) {
465  return ( lhs <= ConstIterator( rhs ) );
466  }
467  //*******************************************************************************************
468 
469  //**Greater-or-equal-than operator***********************************************************
476  friend inline bool operator>=( const RowIterator& lhs, const RowIterator& rhs ) {
477  return ( lhs.column_ >= rhs.column_ );
478  }
479  //*******************************************************************************************
480 
481  //**Greater-or-equal-than operator***********************************************************
488  friend inline bool operator>=( const RowIterator& lhs, const ConstIterator& rhs ) {
489  return ( ConstIterator( lhs ) >= rhs );
490  }
491  //*******************************************************************************************
492 
493  //**Greater-or-equal-than operator***********************************************************
500  friend inline bool operator>=( const ConstIterator& lhs, const RowIterator& rhs ) {
501  return ( lhs >= ConstIterator( rhs ) );
502  }
503  //*******************************************************************************************
504 
505  //**Subtraction operator*********************************************************************
511  inline DifferenceType operator-( const RowIterator& rhs ) const {
512  return ( column_ - rhs.column_ );
513  }
514  //*******************************************************************************************
515 
516  //**Addition operator************************************************************************
523  friend inline const RowIterator operator+( const RowIterator& it, size_t inc ) {
524  return RowIterator( *it.matrix_, it.row_, it.column_ + inc );
525  }
526  //*******************************************************************************************
527 
528  //**Addition operator************************************************************************
535  friend inline const RowIterator operator+( size_t inc, const RowIterator& it ) {
536  return RowIterator( *it.matrix_, it.row_, it.column_ + inc );
537  }
538  //*******************************************************************************************
539 
540  //**Subtraction operator*********************************************************************
547  friend inline const RowIterator operator-( const RowIterator& it, size_t dec ) {
548  return RowIterator( *it.matrix_, it.row_, it.column_ - dec );
549  }
550  //*******************************************************************************************
551 
552  private:
553  //**Member variables*************************************************************************
554  MT* matrix_;
555  size_t row_;
556  size_t column_;
557  //*******************************************************************************************
558  };
559  //**********************************************************************************************
560 
561  //**ColumnIterator class definition*************************************************************
564  class ColumnIterator
565  {
566  public:
567  //**Type definitions*************************************************************************
568  typedef std::random_access_iterator_tag IteratorCategory;
569  typedef typename MT::ElementType ValueType;
570  typedef NumericProxy<MT> PointerType;
571  typedef NumericProxy<MT> ReferenceType;
572  typedef ptrdiff_t DifferenceType;
573 
574  // STL iterator requirements
575  typedef IteratorCategory iterator_category;
576  typedef ValueType value_type;
577  typedef PointerType pointer;
578  typedef ReferenceType reference;
579  typedef DifferenceType difference_type;
580  //*******************************************************************************************
581 
582  //**Constructor******************************************************************************
585  inline ColumnIterator()
586  : matrix_( NULL ) // Reference to the adapted dense matrix
587  , row_ ( 0UL ) // The current row index of the iterator
588  , column_( 0UL ) // The current column index of the iterator
589  {}
590  //*******************************************************************************************
591 
592  //**Constructor******************************************************************************
599  inline ColumnIterator( MT& matrix, size_t row, size_t column )
600  : matrix_( &matrix ) // Reference to the adapted dense matrix
601  , row_ ( row ) // The current row index of the iterator
602  , column_( column ) // The current column index of the iterator
603  {}
604  //*******************************************************************************************
605 
606  //**Addition assignment operator*************************************************************
612  inline ColumnIterator& operator+=( size_t inc ) {
613  row_ += inc;
614  return *this;
615  }
616  //*******************************************************************************************
617 
618  //**Subtraction assignment operator**********************************************************
624  inline ColumnIterator& operator-=( size_t dec ) {
625  row_ -= dec;
626  return *this;
627  }
628  //*******************************************************************************************
629 
630  //**Prefix increment operator****************************************************************
635  inline ColumnIterator& operator++() {
636  ++row_;
637  return *this;
638  }
639  //*******************************************************************************************
640 
641  //**Postfix increment operator***************************************************************
646  inline const ColumnIterator operator++( int ) {
647  const ColumnIterator tmp( *this );
648  ++(*this);
649  return tmp;
650  }
651  //*******************************************************************************************
652 
653  //**Prefix decrement operator****************************************************************
658  inline ColumnIterator& operator--() {
659  --row_;
660  return *this;
661  }
662  //*******************************************************************************************
663 
664  //**Postfix decrement operator***************************************************************
669  inline const ColumnIterator operator--( int ) {
670  const ColumnIterator tmp( *this );
671  --(*this);
672  return tmp;
673  }
674  //*******************************************************************************************
675 
676  //**Element access operator******************************************************************
681  inline ReferenceType operator*() const {
682  return ReferenceType( *matrix_, row_, column_ );
683  }
684  //*******************************************************************************************
685 
686  //**Element access operator******************************************************************
691  inline PointerType operator->() const {
692  return PointerType( *matrix_, row_, column_ );
693  }
694  //*******************************************************************************************
695 
696  //**Conversion operator**********************************************************************
701  inline operator ConstIterator() const {
702  return matrix_->begin(column_) + row_;
703  }
704  //*******************************************************************************************
705 
706  //**Equality operator************************************************************************
713  friend inline bool operator==( const ColumnIterator& lhs, const ColumnIterator& rhs ) {
714  return ( lhs.row_ == rhs.row_ );
715  }
716  //*******************************************************************************************
717 
718  //**Equality operator************************************************************************
725  friend inline bool operator==( const ColumnIterator& lhs, const ConstIterator& rhs ) {
726  return ( ConstIterator( lhs ) == rhs );
727  }
728  //*******************************************************************************************
729 
730  //**Equality operator************************************************************************
737  friend inline bool operator==( const ConstIterator& lhs, const ColumnIterator& rhs ) {
738  return ( lhs == ConstIterator( rhs ) );
739  }
740  //*******************************************************************************************
741 
742  //**Inequality operator**********************************************************************
749  friend inline bool operator!=( const ColumnIterator& lhs, const ColumnIterator& rhs ) {
750  return ( lhs.row_ != rhs.row_ );
751  }
752  //*******************************************************************************************
753 
754  //**Inequality operator**********************************************************************
761  friend inline bool operator!=( const ColumnIterator& lhs, const ConstIterator& rhs ) {
762  return ( ConstIterator( lhs ) != rhs );
763  }
764  //*******************************************************************************************
765 
766  //**Inequality operator**********************************************************************
773  friend inline bool operator!=( const ConstIterator& lhs, const ColumnIterator& rhs ) {
774  return ( lhs != ConstIterator( rhs ) );
775  }
776  //*******************************************************************************************
777 
778  //**Less-than operator***********************************************************************
785  friend inline bool operator<( const ColumnIterator& lhs, const ColumnIterator& rhs ) {
786  return ( lhs.row_ < rhs.row_ );
787  }
788  //*******************************************************************************************
789 
790  //**Less-than operator***********************************************************************
797  friend inline bool operator<( const ColumnIterator& lhs, const ConstIterator& rhs ) {
798  return ( ConstIterator( lhs ) < rhs );
799  }
800  //*******************************************************************************************
801 
802  //**Less-than operator***********************************************************************
809  friend inline bool operator<( const ConstIterator& lhs, const ColumnIterator& rhs ) {
810  return ( lhs < ConstIterator( rhs ) );
811  }
812  //*******************************************************************************************
813 
814  //**Greater-than operator********************************************************************
821  friend inline bool operator>( const ColumnIterator& lhs, const ColumnIterator& rhs ) {
822  return ( lhs.row_ > rhs.row_ );
823  }
824  //*******************************************************************************************
825 
826  //**Greater-than operator********************************************************************
833  friend inline bool operator>( const ColumnIterator& lhs, const ConstIterator& rhs ) {
834  return ( ConstIterator( lhs ) > rhs );
835  }
836  //*******************************************************************************************
837 
838  //**Greater-than operator********************************************************************
845  friend inline bool operator>( const ConstIterator& lhs, const ColumnIterator& rhs ) {
846  return ( lhs > ConstIterator( rhs ) );
847  }
848  //*******************************************************************************************
849 
850  //**Less-or-equal-than operator**************************************************************
857  friend inline bool operator<=( const ColumnIterator& lhs, const ColumnIterator& rhs ) {
858  return ( lhs.row_ <= rhs.row_ );
859  }
860  //*******************************************************************************************
861 
862  //**Less-or-equal-than operator**************************************************************
869  friend inline bool operator<=( const ColumnIterator& lhs, const ConstIterator& rhs ) {
870  return ( ConstIterator( lhs ) <= rhs );
871  }
872  //*******************************************************************************************
873 
874  //**Less-or-equal-than operator**************************************************************
881  friend inline bool operator<=( const ConstIterator& lhs, const ColumnIterator& rhs ) {
882  return ( lhs <= ConstIterator( rhs ) );
883  }
884  //*******************************************************************************************
885 
886  //**Greater-or-equal-than operator***********************************************************
893  friend inline bool operator>=( const ColumnIterator& lhs, const ColumnIterator& rhs ) {
894  return ( lhs.row_ >= rhs.row_ );
895  }
896  //*******************************************************************************************
897 
898  //**Greater-or-equal-than operator***********************************************************
905  friend inline bool operator>=( const ColumnIterator& lhs, const ConstIterator& rhs ) {
906  return ( ConstIterator( lhs ) >= rhs );
907  }
908  //*******************************************************************************************
909 
910  //**Greater-or-equal-than operator***********************************************************
917  friend inline bool operator>=( const ConstIterator& lhs, const ColumnIterator& rhs ) {
918  return ( lhs >= ConstIterator( rhs ) );
919  }
920  //*******************************************************************************************
921 
922  //**Subtraction operator*********************************************************************
928  inline DifferenceType operator-( const ColumnIterator& rhs ) const {
929  return ( row_ - rhs.row_ );
930  }
931  //*******************************************************************************************
932 
933  //**Addition operator************************************************************************
940  friend inline const ColumnIterator operator+( const ColumnIterator& it, size_t inc ) {
941  return ColumnIterator( *it.matrix_, it.row_ + inc, it.column_ );
942  }
943  //*******************************************************************************************
944 
945  //**Addition operator************************************************************************
952  friend inline const ColumnIterator operator+( size_t inc, const ColumnIterator& it ) {
953  return ColumnIterator( *it.matrix_, it.row_ + inc, it.column_ );
954  }
955  //*******************************************************************************************
956 
957  //**Subtraction operator*********************************************************************
964  friend inline const ColumnIterator operator-( const ColumnIterator& it, size_t dec ) {
965  return ColumnIterator( *it.matrix_, it.row_ - dec, it.column_ );
966  }
967  //*******************************************************************************************
968 
969  private:
970  //**Member variables*************************************************************************
971  MT* matrix_;
972  size_t row_;
973  size_t column_;
974  //*******************************************************************************************
975  };
976  //**********************************************************************************************
977 
978  //**Type definitions****************************************************************************
980  typedef typename IfTrue< SO, ColumnIterator, RowIterator >::Type Iterator;
981  //**********************************************************************************************
982 
983  //**Compilation flags***************************************************************************
985  enum { vectorizable = MT::vectorizable };
986 
988  enum { smpAssignable = 0 };
989  //**********************************************************************************************
990 
991  //**Constructors********************************************************************************
994  explicit inline SymmetricMatrix();
995  explicit inline SymmetricMatrix( size_t n );
996 
997  inline SymmetricMatrix( const SymmetricMatrix& m );
998  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,SO>& m );
999  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,!SO>& m );
1001  //**********************************************************************************************
1002 
1003  //**Destructor**********************************************************************************
1004  // No explicitly declared destructor.
1005  //**********************************************************************************************
1006 
1007  //**Data access functions***********************************************************************
1010  inline Reference operator()( size_t i, size_t j );
1011  inline ConstReference operator()( size_t i, size_t j ) const;
1012  inline ConstPointer data () const;
1013  inline ConstPointer data ( size_t i ) const;
1014  inline Iterator begin ( size_t i );
1015  inline ConstIterator begin ( size_t i ) const;
1016  inline ConstIterator cbegin( size_t i ) const;
1017  inline Iterator end ( size_t i );
1018  inline ConstIterator end ( size_t i ) const;
1019  inline ConstIterator cend ( size_t i ) const;
1021  //**********************************************************************************************
1022 
1023  //**Assignment operators************************************************************************
1026  inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
1027 
1028  template< typename MT2 >
1029  inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
1030  operator=( const Matrix<MT2,SO>& rhs );
1031 
1032  template< typename MT2 >
1033  inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
1034  operator=( const Matrix<MT2,SO>& rhs );
1035 
1036  template< typename MT2 >
1037  inline SymmetricMatrix& operator=( const Matrix<MT2,!SO>& rhs );
1038 
1039  template< typename MT2 >
1040  inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
1041  operator+=( const Matrix<MT2,SO>& rhs );
1042 
1043  template< typename MT2 >
1044  inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
1045  operator+=( const Matrix<MT2,SO>& rhs );
1046 
1047  template< typename MT2 >
1048  inline SymmetricMatrix& operator+=( const Matrix<MT2,!SO>& rhs );
1049 
1050  template< typename MT2 >
1051  inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
1052  operator-=( const Matrix<MT2,SO>& rhs );
1053 
1054  template< typename MT2 >
1055  inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
1056  operator-=( const Matrix<MT2,SO>& rhs );
1057 
1058  template< typename MT2 >
1059  inline SymmetricMatrix& operator-=( const Matrix<MT2,!SO>& rhs );
1060 
1061  template< typename MT2, bool SO2 >
1062  inline SymmetricMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
1063 
1064  template< typename Other >
1065  inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix >::Type&
1066  operator*=( Other rhs );
1067 
1068  template< typename Other >
1069  inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix >::Type&
1070  operator/=( Other rhs );
1072  //**********************************************************************************************
1073 
1074  //**Utility functions***************************************************************************
1077  inline size_t rows() const;
1078  inline size_t columns() const;
1079  inline size_t spacing() const;
1080  inline size_t capacity() const;
1081  inline size_t capacity( size_t i ) const;
1082  inline size_t nonZeros() const;
1083  inline size_t nonZeros( size_t i ) const;
1084  inline void reset();
1085  inline void reset( size_t i );
1086  inline void clear();
1087  void resize ( size_t n, bool preserve=true );
1088  inline void extend ( size_t n, bool preserve=true );
1089  inline void reserve( size_t elements );
1090  inline SymmetricMatrix& transpose();
1091  template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
1092  inline void swap( SymmetricMatrix& m ) /* throw() */;
1094  //**********************************************************************************************
1095 
1096  //**Expression template evaluation functions****************************************************
1099  template< typename Other > inline bool canAlias ( const Other* alias ) const;
1100  template< typename Other > inline bool isAliased( const Other* alias ) const;
1101 
1102  inline bool isAligned () const;
1103  inline bool canSMPAssign() const;
1104 
1105  inline IntrinsicType load ( size_t i, size_t j ) const;
1106  inline IntrinsicType loadu ( size_t i, size_t j ) const;
1107  inline void store ( size_t i, size_t j, const IntrinsicType& value );
1108  inline void storeu( size_t i, size_t j, const IntrinsicType& value );
1109  inline void stream( size_t i, size_t j, const IntrinsicType& value );
1111  //**********************************************************************************************
1112 
1113  private:
1114  //**Member variables****************************************************************************
1117  MT matrix_;
1118 
1119  //**********************************************************************************************
1120 
1121  //**Friend declarations*************************************************************************
1122  template< typename MT2, bool SO2, bool DF2, bool NF2 >
1123  friend bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
1124  //**********************************************************************************************
1125 
1126  //**Compile time checks*************************************************************************
1139  BLAZE_STATIC_ASSERT( IsResizable<MT>::value || IsSquare<MT>::value );
1140  //**********************************************************************************************
1141 };
1143 //*************************************************************************************************
1144 
1145 
1146 
1147 
1148 //=================================================================================================
1149 //
1150 // CONSTRUCTORS
1151 //
1152 //=================================================================================================
1153 
1154 //*************************************************************************************************
1158 template< typename MT // Type of the adapted dense matrix
1159  , bool SO > // Storage order of the adapted dense matrix
1160 inline SymmetricMatrix<MT,SO,true,true>::SymmetricMatrix()
1161  : matrix_() // The adapted dense matrix
1162 {
1163  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1164 }
1166 //*************************************************************************************************
1167 
1168 
1169 //*************************************************************************************************
1175 template< typename MT // Type of the adapted dense matrix
1176  , bool SO > // Storage order of the adapted dense matrix
1177 inline SymmetricMatrix<MT,SO,true,true>::SymmetricMatrix( size_t n )
1178  : matrix_( n, n, ElementType() ) // The adapted dense matrix
1179 {
1181 
1182  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1183 }
1185 //*************************************************************************************************
1186 
1187 
1188 //*************************************************************************************************
1194 template< typename MT // Type of the adapted dense matrix
1195  , bool SO > // Storage order of the adapted dense matrix
1196 inline SymmetricMatrix<MT,SO,true,true>::SymmetricMatrix( const SymmetricMatrix& m )
1197  : matrix_( m.matrix_ ) // The adapted dense matrix
1198 {
1199  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1200 }
1202 //*************************************************************************************************
1203 
1204 
1205 //*************************************************************************************************
1215 template< typename MT // Type of the adapted dense matrix
1216  , bool SO > // Storage order of the adapted dense matrix
1217 template< typename MT2 > // Type of the foreign matrix
1218 inline SymmetricMatrix<MT,SO,true,true>::SymmetricMatrix( const Matrix<MT2,SO>& m )
1219  : matrix_( ~m ) // The adapted dense matrix
1220 {
1221  if( IsLower<MT2>::value || IsUpper<MT2>::value ||
1222  ( !IsSymmetric<MT2>::value && !isSymmetric( matrix_ ) ) )
1223  throw std::invalid_argument( "Invalid setup of symmetric matrix" );
1224 
1225  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1226 }
1228 //*************************************************************************************************
1229 
1230 
1231 //*************************************************************************************************
1241 template< typename MT // Type of the adapted dense matrix
1242  , bool SO > // Storage order of the adapted dense matrix
1243 template< typename MT2 > // Type of the foreign matrix
1244 inline SymmetricMatrix<MT,SO,true,true>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
1245  : matrix_( trans( ~m ) ) // The adapted dense matrix
1246 {
1247  if( IsLower<MT2>::value || IsUpper<MT2>::value ||
1248  ( !IsSymmetric<MT2>::value && !isSymmetric( matrix_ ) ) )
1249  throw std::invalid_argument( "Invalid setup of symmetric matrix" );
1250 
1251  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1252 }
1254 //*************************************************************************************************
1255 
1256 
1257 
1258 
1259 //=================================================================================================
1260 //
1261 // DATA ACCESS FUNCTIONS
1262 //
1263 //=================================================================================================
1264 
1265 //*************************************************************************************************
1277 template< typename MT // Type of the adapted dense matrix
1278  , bool SO > // Storage order of the adapted dense matrix
1280  SymmetricMatrix<MT,SO,true,true>::operator()( size_t i, size_t j )
1281 {
1282  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1283  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1284 
1285  return Reference( matrix_, i, j );
1286 }
1288 //*************************************************************************************************
1289 
1290 
1291 //*************************************************************************************************
1303 template< typename MT // Type of the adapted dense matrix
1304  , bool SO > // Storage order of the adapted dense matrix
1306  SymmetricMatrix<MT,SO,true,true>::operator()( size_t i, size_t j ) const
1307 {
1308  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1309  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1310 
1311  return matrix_(i,j);
1312 }
1314 //*************************************************************************************************
1315 
1316 
1317 //*************************************************************************************************
1331 template< typename MT // Type of the adapted dense matrix
1332  , bool SO > // Storage order of the adapted dense matrix
1333 inline typename SymmetricMatrix<MT,SO,true,true>::ConstPointer
1334  SymmetricMatrix<MT,SO,true,true>::data() const
1335 {
1336  return matrix_.data();
1337 }
1339 //*************************************************************************************************
1340 
1341 
1342 //*************************************************************************************************
1353 template< typename MT // Type of the adapted dense matrix
1354  , bool SO > // Storage order of the adapted dense matrix
1355 inline typename SymmetricMatrix<MT,SO,true,true>::ConstPointer
1356  SymmetricMatrix<MT,SO,true,true>::data( size_t i ) const
1357 {
1358  return matrix_.data(i);
1359 }
1361 //*************************************************************************************************
1362 
1363 
1364 //*************************************************************************************************
1376 template< typename MT // Type of the adapted dense matrix
1377  , bool SO > // Storage order of the adapted dense matrix
1380 {
1381  if( SO )
1382  return Iterator( matrix_, 0UL, i );
1383  else
1384  return Iterator( matrix_, i, 0UL );
1385 }
1387 //*************************************************************************************************
1388 
1389 
1390 //*************************************************************************************************
1402 template< typename MT // Type of the adapted dense matrix
1403  , bool SO > // Storage order of the adapted dense matrix
1405  SymmetricMatrix<MT,SO,true,true>::begin( size_t i ) const
1406 {
1407  return matrix_.begin(i);
1408 }
1410 //*************************************************************************************************
1411 
1412 
1413 //*************************************************************************************************
1425 template< typename MT // Type of the adapted dense matrix
1426  , bool SO > // Storage order of the adapted dense matrix
1429 {
1430  return matrix_.cbegin(i);
1431 }
1433 //*************************************************************************************************
1434 
1435 
1436 //*************************************************************************************************
1448 template< typename MT // Type of the adapted dense matrix
1449  , bool SO > // Storage order of the adapted dense matrix
1452 {
1453  if( SO )
1454  return Iterator( matrix_, rows(), i );
1455  else
1456  return Iterator( matrix_, i, columns() );
1457 }
1459 //*************************************************************************************************
1460 
1461 
1462 //*************************************************************************************************
1474 template< typename MT // Type of the adapted dense matrix
1475  , bool SO > // Storage order of the adapted dense matrix
1477  SymmetricMatrix<MT,SO,true,true>::end( size_t i ) const
1478 {
1479  return matrix_.end(i);
1480 }
1482 //*************************************************************************************************
1483 
1484 
1485 //*************************************************************************************************
1497 template< typename MT // Type of the adapted dense matrix
1498  , bool SO > // Storage order of the adapted dense matrix
1500  SymmetricMatrix<MT,SO,true,true>::cend( size_t i ) const
1501 {
1502  return matrix_.cend(i);
1503 }
1505 //*************************************************************************************************
1506 
1507 
1508 
1509 
1510 //=================================================================================================
1511 //
1512 // ASSIGNMENT OPERATORS
1513 //
1514 //=================================================================================================
1515 
1516 //*************************************************************************************************
1526 template< typename MT // Type of the adapted dense matrix
1527  , bool SO > // Storage order of the adapted dense matrix
1528 inline SymmetricMatrix<MT,SO,true,true>&
1529  SymmetricMatrix<MT,SO,true,true>::operator=( const SymmetricMatrix& rhs )
1530 {
1531  matrix_ = rhs.matrix_;
1532 
1533  return *this;
1534 }
1536 //*************************************************************************************************
1537 
1538 
1539 //*************************************************************************************************
1552 template< typename MT // Type of the adapted dense matrix
1553  , bool SO > // Storage order of the adapted dense matrix
1554 template< typename MT2 > // Type of the right-hand side matrix
1555 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,true>& >::Type
1556  SymmetricMatrix<MT,SO,true,true>::operator=( const Matrix<MT2,SO>& rhs )
1557 {
1558  if( IsLower<MT2>::value || IsUpper<MT2>::value ||
1559  ( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) )
1560  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1561 
1562  matrix_ = ~rhs;
1563 
1564  return *this;
1565 }
1567 //*************************************************************************************************
1568 
1569 
1570 //*************************************************************************************************
1583 template< typename MT // Type of the adapted dense matrix
1584  , bool SO > // Storage order of the adapted dense matrix
1585 template< typename MT2 > // Type of the right-hand side matrix
1586 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,true>& >::Type
1587  SymmetricMatrix<MT,SO,true,true>::operator=( const Matrix<MT2,SO>& rhs )
1588 {
1589  if( IsLower<MT2>::value || IsUpper<MT2>::value || !isSquare( ~rhs ) )
1590  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1591 
1592  if( IsSymmetric<MT2>::value ) {
1593  matrix_ = ~rhs;
1594  }
1595  else {
1596  MT tmp( ~rhs );
1597 
1598  if( !isSymmetric( tmp ) )
1599  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1600 
1601  move( matrix_, tmp );
1602  }
1603 
1604  return *this;
1605 }
1607 //*************************************************************************************************
1608 
1609 
1610 //*************************************************************************************************
1623 template< typename MT // Type of the adapted dense matrix
1624  , bool SO > // Storage order of the adapted dense matrix
1625 template< typename MT2 > // Type of the right-hand side matrix
1626 inline SymmetricMatrix<MT,SO,true,true>&
1627  SymmetricMatrix<MT,SO,true,true>::operator=( const Matrix<MT2,!SO>& rhs )
1628 {
1629  return this->operator=( trans( ~rhs ) );
1630 }
1632 //*************************************************************************************************
1633 
1634 
1635 //*************************************************************************************************
1648 template< typename MT // Type of the adapted dense matrix
1649  , bool SO > // Storage order of the adapted dense matrix
1650 template< typename MT2 > // Type of the right-hand side matrix
1651 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,true>& >::Type
1652  SymmetricMatrix<MT,SO,true,true>::operator+=( const Matrix<MT2,SO>& rhs )
1653 {
1654  if( IsLower<MT2>::value || IsUpper<MT2>::value ||
1655  ( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) )
1656  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1657 
1658  matrix_ += ~rhs;
1659 
1660  return *this;
1661 }
1663 //*************************************************************************************************
1664 
1665 
1666 //*************************************************************************************************
1679 template< typename MT // Type of the adapted dense matrix
1680  , bool SO > // Storage order of the adapted dense matrix
1681 template< typename MT2 > // Type of the right-hand side matrix
1682 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,true>& >::Type
1683  SymmetricMatrix<MT,SO,true,true>::operator+=( const Matrix<MT2,SO>& rhs )
1684 {
1685  if( IsLower<MT2>::value || IsUpper<MT2>::value || !isSquare( ~rhs ) )
1686  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1687 
1688  if( IsSymmetric<MT2>::value ) {
1689  matrix_ += ~rhs;
1690  }
1691  else {
1692  typename MT2::ResultType tmp( ~rhs );
1693 
1694  if( !isSymmetric( tmp ) )
1695  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1696 
1697  matrix_ += tmp;
1698  }
1699 
1700  return *this;
1701 }
1703 //*************************************************************************************************
1704 
1705 
1706 //*************************************************************************************************
1720 template< typename MT // Type of the adapted dense matrix
1721  , bool SO > // Storage order of the adapted dense matrix
1722 template< typename MT2 > // Type of the right-hand side matrix
1723 inline SymmetricMatrix<MT,SO,true,true>&
1724  SymmetricMatrix<MT,SO,true,true>::operator+=( const Matrix<MT2,!SO>& rhs )
1725 {
1726  return this->operator+=( trans( ~rhs ) );
1727 }
1729 //*************************************************************************************************
1730 
1731 
1732 //*************************************************************************************************
1745 template< typename MT // Type of the adapted dense matrix
1746  , bool SO > // Storage order of the adapted dense matrix
1747 template< typename MT2 > // Type of the right-hand side matrix
1748 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,true>& >::Type
1749  SymmetricMatrix<MT,SO,true,true>::operator-=( const Matrix<MT2,SO>& rhs )
1750 {
1751  if( IsLower<MT2>::value || IsUpper<MT2>::value ||
1752  ( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) )
1753  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1754 
1755  matrix_ -= ~rhs;
1756 
1757  return *this;
1758 }
1760 //*************************************************************************************************
1761 
1762 
1763 //*************************************************************************************************
1776 template< typename MT // Type of the adapted dense matrix
1777  , bool SO > // Storage order of the adapted dense matrix
1778 template< typename MT2 > // Type of the right-hand side matrix
1779 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,true>& >::Type
1780  SymmetricMatrix<MT,SO,true,true>::operator-=( const Matrix<MT2,SO>& rhs )
1781 {
1782  if( IsLower<MT2>::value || IsUpper<MT2>::value || !isSquare( ~rhs ) )
1783  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1784 
1785  if( IsSymmetric<MT2>::value ) {
1786  matrix_ -= ~rhs;
1787  }
1788  else {
1789  typename MT2::ResultType tmp( ~rhs );
1790 
1791  if( !isSymmetric( tmp ) )
1792  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1793 
1794  matrix_ -= tmp;
1795  }
1796 
1797  return *this;
1798 }
1800 //*************************************************************************************************
1801 
1802 
1803 //*************************************************************************************************
1817 template< typename MT // Type of the adapted dense matrix
1818  , bool SO > // Storage order of the adapted dense matrix
1819 template< typename MT2 > // Type of the right-hand side matrix
1820 inline SymmetricMatrix<MT,SO,true,true>&
1821  SymmetricMatrix<MT,SO,true,true>::operator-=( const Matrix<MT2,!SO>& rhs )
1822 {
1823  return this->operator-=( trans( ~rhs ) );
1824 }
1826 //*************************************************************************************************
1827 
1828 
1829 //*************************************************************************************************
1841 template< typename MT // Type of the adapted dense matrix
1842  , bool SO > // Storage order of the adapted dense matrix
1843 template< typename MT2 // Type of the right-hand side matrix
1844  , bool SO2 > // Storage order of the right-hand side matrix
1845 inline SymmetricMatrix<MT,SO,true,true>&
1846  SymmetricMatrix<MT,SO,true,true>::operator*=( const Matrix<MT2,SO2>& rhs )
1847 {
1848  if( matrix_.rows() != (~rhs).columns() )
1849  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1850 
1851  MT tmp( matrix_ * ~rhs );
1852 
1853  if( !isSymmetric( tmp ) )
1854  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1855 
1856  move( matrix_, tmp );
1857 
1858  return *this;
1859 }
1861 //*************************************************************************************************
1862 
1863 
1864 //*************************************************************************************************
1872 template< typename MT // Type of the adapted dense matrix
1873  , bool SO > // Storage order of the adapted dense matrix
1874 template< typename Other > // Data type of the right-hand side scalar
1875 inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,true> >::Type&
1876  SymmetricMatrix<MT,SO,true,true>::operator*=( Other rhs )
1877 {
1878  matrix_ *= rhs;
1879  return *this;
1880 }
1881 //*************************************************************************************************
1882 
1883 
1884 //*************************************************************************************************
1892 template< typename MT // Type of the adapted dense matrix
1893  , bool SO > // Storage order of the adapted dense matrix
1894 template< typename Other > // Data type of the right-hand side scalar
1895 inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,true> >::Type&
1896  SymmetricMatrix<MT,SO,true,true>::operator/=( Other rhs )
1897 {
1898  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1899 
1900  matrix_ /= rhs;
1901  return *this;
1902 }
1904 //*************************************************************************************************
1905 
1906 
1907 
1908 
1909 //=================================================================================================
1910 //
1911 // UTILITY FUNCTIONS
1912 //
1913 //=================================================================================================
1914 
1915 //*************************************************************************************************
1921 template< typename MT // Type of the adapted dense matrix
1922  , bool SO > // Storage order of the adapted dense matrix
1923 inline size_t SymmetricMatrix<MT,SO,true,true>::rows() const
1924 {
1925  return matrix_.rows();
1926 }
1928 //*************************************************************************************************
1929 
1930 
1931 //*************************************************************************************************
1937 template< typename MT // Type of the adapted dense matrix
1938  , bool SO > // Storage order of the adapted dense matrix
1939 inline size_t SymmetricMatrix<MT,SO,true,true>::columns() const
1940 {
1941  return matrix_.columns();
1942 }
1944 //*************************************************************************************************
1945 
1946 
1947 //*************************************************************************************************
1959 template< typename MT // Type of the adapted dense matrix
1960  , bool SO > // Storage order of the adapted dense matrix
1961 inline size_t SymmetricMatrix<MT,SO,true,true>::spacing() const
1962 {
1963  return matrix_.spacing();
1964 }
1966 //*************************************************************************************************
1967 
1968 
1969 //*************************************************************************************************
1975 template< typename MT // Type of the adapted dense matrix
1976  , bool SO > // Storage order of the adapted dense matrix
1977 inline size_t SymmetricMatrix<MT,SO,true,true>::capacity() const
1978 {
1979  return matrix_.capacity();
1980 }
1982 //*************************************************************************************************
1983 
1984 
1985 //*************************************************************************************************
1996 template< typename MT // Type of the adapted dense matrix
1997  , bool SO > // Storage order of the adapted dense matrix
1998 inline size_t SymmetricMatrix<MT,SO,true,true>::capacity( size_t i ) const
1999 {
2000  return matrix_.capacity(i);
2001 }
2003 //*************************************************************************************************
2004 
2005 
2006 //*************************************************************************************************
2012 template< typename MT // Type of the adapted dense matrix
2013  , bool SO > // Storage order of the adapted dense matrix
2014 inline size_t SymmetricMatrix<MT,SO,true,true>::nonZeros() const
2015 {
2016  return matrix_.nonZeros();
2017 }
2019 //*************************************************************************************************
2020 
2021 
2022 //*************************************************************************************************
2034 template< typename MT // Type of the adapted dense matrix
2035  , bool SO > // Storage order of the adapted dense matrix
2036 inline size_t SymmetricMatrix<MT,SO,true,true>::nonZeros( size_t i ) const
2037 {
2038  return matrix_.nonZeros(i);
2039 }
2041 //*************************************************************************************************
2042 
2043 
2044 //*************************************************************************************************
2050 template< typename MT // Type of the adapted dense matrix
2051  , bool SO > // Storage order of the adapted dense matrix
2053 {
2054  matrix_.reset();
2055 }
2057 //*************************************************************************************************
2058 
2059 
2060 //*************************************************************************************************
2096 template< typename MT // Type of the adapted dense matrix
2097  , bool SO > // Storage order of the adapted dense matrix
2098 inline void SymmetricMatrix<MT,SO,true,true>::reset( size_t i )
2099 {
2100  row ( matrix_, i ).reset();
2101  column( matrix_, i ).reset();
2102 }
2104 //*************************************************************************************************
2105 
2106 
2107 //*************************************************************************************************
2119 template< typename MT // Type of the adapted dense matrix
2120  , bool SO > // Storage order of the adapted dense matrix
2122 {
2123  using blaze::clear;
2124 
2125  clear( matrix_ );
2126 }
2128 //*************************************************************************************************
2129 
2130 
2131 //*************************************************************************************************
2166 template< typename MT // Type of the adapted dense matrix
2167  , bool SO > // Storage order of the adapted dense matrix
2168 void SymmetricMatrix<MT,SO,true,true>::resize( size_t n, bool preserve )
2169 {
2171 
2172  UNUSED_PARAMETER( preserve );
2173 
2174  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
2175 
2176  const size_t oldsize( matrix_.rows() );
2177 
2178  matrix_.resize( n, n, true );
2179 
2180  if( n > oldsize ) {
2181  const size_t increment( n - oldsize );
2182  submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2183  submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2184  }
2185 }
2187 //*************************************************************************************************
2188 
2189 
2190 //*************************************************************************************************
2203 template< typename MT // Type of the adapted dense matrix
2204  , bool SO > // Storage order of the adapted dense matrix
2205 inline void SymmetricMatrix<MT,SO,true,true>::extend( size_t n, bool preserve )
2206 {
2208 
2209  UNUSED_PARAMETER( preserve );
2210 
2211  resize( rows() + n, true );
2212 }
2213 //*************************************************************************************************
2214 
2215 
2216 //*************************************************************************************************
2226 template< typename MT // Type of the adapted dense matrix
2227  , bool SO > // Storage order of the adapted dense matrix
2228 inline void SymmetricMatrix<MT,SO,true,true>::reserve( size_t elements )
2229 {
2230  matrix_.reserve( elements );
2231 }
2233 //*************************************************************************************************
2234 
2235 
2236 //*************************************************************************************************
2242 template< typename MT // Type of the adapted dense matrix
2243  , bool SO > // Storage order of the adapted dense matrix
2244 inline SymmetricMatrix<MT,SO,true,true>& SymmetricMatrix<MT,SO,true,true>::transpose()
2245 {
2246  return *this;
2247 }
2249 //*************************************************************************************************
2250 
2251 
2252 //*************************************************************************************************
2259 template< typename MT // Type of the adapted dense matrix
2260  , bool SO > // Storage order of the adapted dense matrix
2261 template< typename Other > // Data type of the scalar value
2262 inline SymmetricMatrix<MT,SO,true,true>&
2263  SymmetricMatrix<MT,SO,true,true>::scale( const Other& scalar )
2264 {
2265  matrix_.scale( scalar );
2266  return *this;
2267 }
2269 //*************************************************************************************************
2270 
2271 
2272 //*************************************************************************************************
2280 template< typename MT // Type of the adapted dense matrix
2281  , bool SO > // Storage order of the adapted dense matrix
2282 inline void SymmetricMatrix<MT,SO,true,true>::swap( SymmetricMatrix& m ) /* throw() */
2283 {
2284  using std::swap;
2285 
2286  swap( matrix_, m.matrix_ );
2287 }
2289 //*************************************************************************************************
2290 
2291 
2292 
2293 
2294 //=================================================================================================
2295 //
2296 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2297 //
2298 //=================================================================================================
2299 
2300 //*************************************************************************************************
2311 template< typename MT // Type of the adapted dense matrix
2312  , bool SO > // Storage order of the adapted dense matrix
2313 template< typename Other > // Data type of the foreign expression
2314 inline bool SymmetricMatrix<MT,SO,true,true>::canAlias( const Other* alias ) const
2315 {
2316  return matrix_.canAlias( alias );
2317 }
2319 //*************************************************************************************************
2320 
2321 
2322 //*************************************************************************************************
2333 template< typename MT // Type of the adapted dense matrix
2334  , bool SO > // Storage order of the adapted dense matrix
2335 template< typename Other > // Data type of the foreign expression
2336 inline bool SymmetricMatrix<MT,SO,true,true>::isAliased( const Other* alias ) const
2337 {
2338  return matrix_.isAliased( alias );
2339 }
2341 //*************************************************************************************************
2342 
2343 
2344 //*************************************************************************************************
2354 template< typename MT // Type of the adapted dense matrix
2355  , bool SO > // Storage order of the adapted dense matrix
2356 inline bool SymmetricMatrix<MT,SO,true,true>::isAligned() const
2357 {
2358  return matrix_.isAligned();
2359 }
2361 //*************************************************************************************************
2362 
2363 
2364 //*************************************************************************************************
2375 template< typename MT // Type of the adapted dense matrix
2376  , bool SO > // Storage order of the adapted dense matrix
2377 inline bool SymmetricMatrix<MT,SO,true,true>::canSMPAssign() const
2378 {
2379  return matrix_.canSMPAssign();
2380 }
2382 //*************************************************************************************************
2383 
2384 
2385 //*************************************************************************************************
2401 template< typename MT // Type of the adapted dense matrix
2402  , bool SO > // Storage order of the adapted dense matrix
2403 inline typename SymmetricMatrix<MT,SO,true,true>::IntrinsicType
2404  SymmetricMatrix<MT,SO,true,true>::load( size_t i, size_t j ) const
2405 {
2406  return matrix_.load( i, j );
2407 }
2409 //*************************************************************************************************
2410 
2411 
2412 //*************************************************************************************************
2428 template< typename MT // Type of the adapted dense matrix
2429  , bool SO > // Storage order of the adapted dense matrix
2430 inline typename SymmetricMatrix<MT,SO,true,true>::IntrinsicType
2431  SymmetricMatrix<MT,SO,true,true>::loadu( size_t i, size_t j ) const
2432 {
2433  return matrix_.loadu( i, j );
2434 }
2436 //*************************************************************************************************
2437 
2438 
2439 //*************************************************************************************************
2456 template< typename MT // Type of the adapted dense matrix
2457  , bool SO > // Storage order of the adapted dense matrix
2458 inline void SymmetricMatrix<MT,SO,true,true>::store( size_t i, size_t j, const IntrinsicType& value )
2459 {
2460  matrix_.store( i, j, value );
2461 
2462  if( SO ) {
2463  const size_t kend( min( i+IT::size, rows() ) );
2464  for( size_t k=i; k<kend; ++k )
2465  matrix_(j,k) = matrix_(k,j);
2466  }
2467  else {
2468  const size_t kend( min( j+IT::size, columns() ) );
2469  for( size_t k=j; k<kend; ++k )
2470  matrix_(k,i) = matrix_(i,k);
2471  }
2472 }
2474 //*************************************************************************************************
2475 
2476 
2477 //*************************************************************************************************
2494 template< typename MT // Type of the adapted dense matrix
2495  , bool SO > // Storage order of the adapted dense matrix
2496 inline void SymmetricMatrix<MT,SO,true,true>::storeu( size_t i, size_t j, const IntrinsicType& value )
2497 {
2498  matrix_.storeu( i, j, value );
2499 
2500  if( SO ) {
2501  const size_t kend( min( i+IT::size, rows() ) );
2502  for( size_t k=i; k<kend; ++k )
2503  matrix_(j,k) = matrix_(k,j);
2504  }
2505  else {
2506  const size_t kend( min( j+IT::size, columns() ) );
2507  for( size_t k=j; k<kend; ++k )
2508  matrix_(k,i) = matrix_(i,k);
2509  }
2510 }
2512 //*************************************************************************************************
2513 
2514 
2515 //*************************************************************************************************
2532 template< typename MT // Type of the adapted dense matrix
2533  , bool SO > // Storage order of the adapted dense matrix
2534 inline void SymmetricMatrix<MT,SO,true,true>::stream( size_t i, size_t j, const IntrinsicType& value )
2535 {
2536  matrix_.stream( i, j, value );
2537 
2538  if( SO ) {
2539  const size_t kend( min( i+IT::size, rows() ) );
2540  for( size_t k=i; k<kend; ++k )
2541  matrix_(j,k) = matrix_(k,j);
2542  }
2543  else {
2544  const size_t kend( min( j+IT::size, columns() ) );
2545  for( size_t k=j; k<kend; ++k )
2546  matrix_(k,i) = matrix_(i,k);
2547  }
2548 }
2550 //*************************************************************************************************
2551 
2552 } // namespace blaze
2553 
2554 #endif
Header file for all restructuring submatrix functions.
#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
Constraint on the data type.
Header file for mathematical functions.
void swap(SymmetricMatrix< MT, SO, DF, NF > &a, SymmetricMatrix< MT, SO, DF, NF > &b)
Swapping the contents of two matrices.
Definition: SymmetricMatrix.h:195
#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 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:4838
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix)
Checks if the given matrix is a square matrix.
Definition: Matrix.h:902
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:237
void move(CompressedMatrix< Type, SO > &dst, CompressedMatrix< Type, SO > &src)
Moving the contents of one compressed matrix to another.
Definition: CompressedMatrix.h:4772
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector)
Returns the current size/dimension of the vector.
Definition: Vector.h:258
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:300
bool operator<=(const NegativeAccuracy< A > &, const T &rhs)
Less-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:404
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:258
#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:242
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:79
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type stream(T *address, const typename Stream< T, sizeof(T)>::Type &value)
Aligned, non-temporal store of a vector of integral values.
Definition: Stream.h:220
Constraint on the data type.
bool isSymmetric(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is symmetric.
Definition: DenseMatrix.h:731
Constraint on the data type.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2478
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:348
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:4709
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Load< T, sizeof(T)> >::Type::Type load(const T *address)
Loads a vector of integral values.
Definition: Load.h:224
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:103
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:366
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2472
bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:442
#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:386
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:2474
Constraint on the data type.
Header file for the DenseColumn class template.
Header file for the IsSquare type trait.
Constraint on the data type.
Header file for the DenseSubmatrix class template.
Header file for the DisableIf class template.
Header file for the IsSymmetric type trait.
Header file for the clear shim.
Header file for the If class template.
Compile time assertion.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4754
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2482
#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
const MT::ElementType min(const DenseMatrix< MT, SO > &dm)
Returns the smallest element of the dense matrix.
Definition: DenseMatrix.h:947
Header file for the DenseMatrix base class.
BLAZE_ALWAYS_INLINE void clear(const NonNumericProxy< MT > &proxy)
Clearing the represented element.
Definition: NonNumericProxy.h:854
Constraint on the data type.
const DenseIterator< Type > operator+(const DenseIterator< Type > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:556
Header file for the IsLower type trait.
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T >, Loadu< T, sizeof(T)> >::Type::Type loadu(const T *address)
Loads a vector of integral values.
Definition: Loadu.h:221
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2475
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:195
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:535
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2476
Header file for all forward declarations for expression class templates.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2480
Header file for the EnableIf class template.
Header file for utility functions for dense matrices.
Header file for all restructuring column functions.
Header file for the IsNumeric type trait.
const bool spacing
Adding an additional spacing line between two log messages.This setting gives the opportunity to add ...
Definition: Logging.h:70
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:103
#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:2477
Header file for run time assertion macros.
Header file for the DenseRow class template.
Constraint on the data type.
Constraint on the data type.
Header file for the implementation of the base template of the SymmetricMatrix.
const DenseIterator< Type > operator-(const DenseIterator< Type > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:585
#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:2481
BLAZE_ALWAYS_INLINE bool isDefault(const NonNumericProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: NonNumericProxy.h:874
Constraint on the data type.
Constraint on the data type.
BLAZE_ALWAYS_INLINE void reset(const NonNumericProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: NonNumericProxy.h:833
Header file for all intrinsic functionality.
SubmatrixExprTrait< MT, unaligned >::Type submatrix(Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:137
bool operator<(const NegativeAccuracy< A > &lhs, const T &rhs)
Less-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:328
#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:932
Header file for the IsComputation type trait class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h: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:2473
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type storeu(T *address, const typename Storeu< T, sizeof(T)>::Type &value)
Unaligned store of a vector of integral values.
Definition: Storeu.h:218
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2479
Header file for the IsUpper type trait.
#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
BLAZE_ALWAYS_INLINE EnableIf< IsIntegral< T > >::Type store(T *address, const typename Store< T, sizeof(T)>::Type &value)
Aligned store of a vector of integral values.
Definition: Store.h:225
Header file for the IsResizable type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
Header file for all restructuring row functions.