All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DenseNonNumeric.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONNUMERIC_H_
36 #define _BLAZE_MATH_ADAPTORS_SYMMETRICMATRIX_DENSENONNUMERIC_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <iterator>
45 #include <stdexcept>
57 #include <blaze/math/shims/Clear.h>
59 #include <blaze/math/shims/Move.h>
71 #include <blaze/util/Assert.h>
77 #include <blaze/util/DisableIf.h>
78 #include <blaze/util/EnableIf.h>
79 #include <blaze/util/mpl/If.h>
81 #include <blaze/util/Types.h>
84 #include <blaze/util/Unused.h>
85 
86 
87 namespace blaze {
88 
89 //=================================================================================================
90 //
91 // CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES WITH NON-NUMERIC ELEMENT TYPE
92 //
93 //=================================================================================================
94 
95 //*************************************************************************************************
103 template< typename MT // Type of the adapted dense matrix
104  , bool SO > // Storage order of the adapted dense matrix
105 class SymmetricMatrix<MT,SO,true,false>
106  : public DenseMatrix< SymmetricMatrix<MT,SO,true,false>, SO >
107 {
108  private:
109  //**Type definitions****************************************************************************
110  typedef typename MT::OppositeType OT;
111  typedef typename MT::TransposeType TT;
112  typedef typename MT::ElementType ET;
113  //**********************************************************************************************
114 
115  public:
116  //**Type definitions****************************************************************************
117  typedef SymmetricMatrix<MT,SO,true,false> This;
118  typedef This ResultType;
119  typedef SymmetricMatrix<OT,!SO,true,false> OppositeType;
120  typedef SymmetricMatrix<TT,!SO,true,false> TransposeType;
121  typedef ET ElementType;
122  typedef typename MT::ReturnType ReturnType;
123  typedef const This& CompositeType;
124  typedef typename MT::Reference Reference;
125  typedef typename MT::ConstReference ConstReference;
126  typedef typename MT::Pointer Pointer;
127  typedef typename MT::ConstPointer ConstPointer;
128  //**********************************************************************************************
129 
130  //**Rebind struct definition********************************************************************
133  template< typename ET > // Data type of the other matrix
134  struct Rebind {
136  typedef SymmetricMatrix< typename MT::template Rebind<ET>::Other > Other;
137  };
138  //**********************************************************************************************
139 
140  //**RowIterator class definition****************************************************************
143  template< typename MatrixType > // Type of the adapted dense matrix
144  class RowIterator
145  {
146  public:
147  //**Type definitions*************************************************************************
149  typedef typename IfTrue< IsConst<MatrixType>::value
150  , typename MatrixType::ConstReference
151  , typename MatrixType::Reference >::Type Reference;
152 
153  typedef std::random_access_iterator_tag IteratorCategory;
154  typedef RemoveReference<Reference> ValueType;
155  typedef ValueType* PointerType;
156  typedef Reference ReferenceType;
157  typedef ptrdiff_t DifferenceType;
158 
159  // STL iterator requirements
160  typedef IteratorCategory iterator_category;
161  typedef ValueType value_type;
162  typedef PointerType pointer;
163  typedef ReferenceType reference;
164  typedef DifferenceType difference_type;
165  //*******************************************************************************************
166 
167  //**Constructor******************************************************************************
170  inline RowIterator()
171  : matrix_( NULL ) // Reference to the adapted dense matrix
172  , row_ ( 0UL ) // The current row index of the iterator
173  , column_( 0UL ) // The current column index of the iterator
174  {}
175  //*******************************************************************************************
176 
177  //**Constructor******************************************************************************
184  inline RowIterator( MatrixType& matrix, size_t row, size_t column )
185  : matrix_( &matrix ) // Reference to the adapted dense matrix
186  , row_ ( row ) // The current row index of the iterator
187  , column_( column ) // The current column index of the iterator
188  {
190  }
191  //*******************************************************************************************
192 
193  //**Conversion constructor*******************************************************************
198  template< typename MatrixType2 >
199  inline RowIterator( const RowIterator<MatrixType2>& it )
200  : matrix_( it.matrix_ ) // Reference to the adapted dense matrix
201  , row_ ( it.row_ ) // The current row index of the iterator
202  , column_( it.column_ ) // The current column index of the iterator
203  {
205  }
206  //*******************************************************************************************
207 
208  //**Addition assignment operator*************************************************************
214  inline RowIterator& operator+=( size_t inc ) {
215  column_ += inc;
216  return *this;
217  }
218  //*******************************************************************************************
219 
220  //**Subtraction assignment operator**********************************************************
226  inline RowIterator& operator-=( size_t dec ) {
227  column_ -= dec;
228  return *this;
229  }
230  //*******************************************************************************************
231 
232  //**Prefix increment operator****************************************************************
237  inline RowIterator& operator++() {
238  ++column_;
239  return *this;
240  }
241  //*******************************************************************************************
242 
243  //**Postfix increment operator***************************************************************
248  inline const RowIterator operator++( int ) {
249  const RowIterator tmp( *this );
250  ++(*this);
251  return tmp;
252  }
253  //*******************************************************************************************
254 
255  //**Prefix decrement operator****************************************************************
260  inline RowIterator& operator--() {
261  --column_;
262  return *this;
263  }
264  //*******************************************************************************************
265 
266  //**Postfix decrement operator***************************************************************
271  inline const RowIterator operator--( int ) {
272  const RowIterator tmp( *this );
273  --(*this);
274  return tmp;
275  }
276  //*******************************************************************************************
277 
278  //**Element access operator******************************************************************
283  inline ReferenceType operator*() const {
284  if( row_ > column_ )
285  return (*matrix_)(row_,column_);
286  else
287  return (*matrix_)(column_,row_);
288  }
289  //*******************************************************************************************
290 
291  //**Element access operator******************************************************************
296  inline PointerType operator->() const {
297  if( row_ > column_ )
298  return &(*matrix_)(row_,column_);
299  else
300  return &(*matrix_)(column_,row_);
301  }
302  //*******************************************************************************************
303 
304  //**Equality operator************************************************************************
310  template< typename MatrixType2 >
311  inline bool operator==( const RowIterator<MatrixType2>& rhs ) const {
312  return ( column_ == rhs.column_ );
313  }
314  //*******************************************************************************************
315 
316  //**Inequality operator**********************************************************************
322  template< typename MatrixType2 >
323  inline bool operator!=( const RowIterator<MatrixType2>& rhs ) const {
324  return ( column_ != rhs.column_ );
325  }
326  //*******************************************************************************************
327 
328  //**Less-than operator***********************************************************************
334  template< typename MatrixType2 >
335  inline bool operator<( const RowIterator<MatrixType2>& rhs ) const {
336  return ( column_ < rhs.column_ );
337  }
338  //*******************************************************************************************
339 
340  //**Greater-than operator********************************************************************
346  template< typename MatrixType2 >
347  inline bool operator>( const RowIterator<MatrixType2>& rhs ) const {
348  return ( column_ > rhs.column_ );
349  }
350  //*******************************************************************************************
351 
352  //**Less-or-equal-than operator**************************************************************
358  template< typename MatrixType2 >
359  inline bool operator<=( const RowIterator<MatrixType2>& rhs ) const {
360  return ( column_ <= rhs.column_ );
361  }
362  //*******************************************************************************************
363 
364  //**Greater-or-equal-than operator***********************************************************
370  template< typename MatrixType2 >
371  inline bool operator>=( const RowIterator<MatrixType2>& rhs ) const {
372  return ( column_ >= rhs.column_ );
373  }
374  //*******************************************************************************************
375 
376  //**Subtraction operator*********************************************************************
382  inline DifferenceType operator-( const RowIterator& rhs ) const {
383  return ( column_ - rhs.column_ );
384  }
385  //*******************************************************************************************
386 
387  //**Addition operator************************************************************************
394  friend inline const RowIterator operator+( const RowIterator& it, size_t inc ) {
395  return RowIterator( *it.matrix_, it.row_, it.column_ + inc );
396  }
397  //*******************************************************************************************
398 
399  //**Addition operator************************************************************************
406  friend inline const RowIterator operator+( size_t inc, const RowIterator& it ) {
407  return RowIterator( *it.matrix_, it.row_, it.column_ + inc );
408  }
409  //*******************************************************************************************
410 
411  //**Subtraction operator*********************************************************************
418  friend inline const RowIterator operator-( const RowIterator& it, size_t dec ) {
419  return RowIterator( *it.matrix_, it.row_, it.column_ - dec );
420  }
421  //*******************************************************************************************
422 
423  private:
424  //**Member variables*************************************************************************
425  MatrixType* matrix_;
426  size_t row_;
427  size_t column_;
428  //*******************************************************************************************
429 
430  //**Friend declarations**********************************************************************
431  template< typename MatrixType2 > friend class RowIterator;
432  //*******************************************************************************************
433  };
434  //**********************************************************************************************
435 
436  //**ColumnIterator class definition*************************************************************
439  template< typename MatrixType > // Type of the adapted dense matrix
440  class ColumnIterator
441  {
442  public:
443  //**Type definitions*************************************************************************
445  typedef typename IfTrue< IsConst<MatrixType>::value
446  , typename MatrixType::ConstReference
447  , typename MatrixType::Reference >::Type Reference;
448 
449  typedef std::random_access_iterator_tag IteratorCategory;
450  typedef RemoveReference<Reference> ValueType;
451  typedef ValueType* PointerType;
452  typedef Reference ReferenceType;
453  typedef ptrdiff_t DifferenceType;
454 
455  // STL iterator requirements
456  typedef IteratorCategory iterator_category;
457  typedef ValueType value_type;
458  typedef PointerType pointer;
459  typedef ReferenceType reference;
460  typedef DifferenceType difference_type;
461  //*******************************************************************************************
462 
463  //**Constructor******************************************************************************
466  inline ColumnIterator()
467  : matrix_( NULL ) // Reference to the adapted dense matrix
468  , row_ ( 0UL ) // The current row index of the iterator
469  , column_( 0UL ) // The current column index of the iterator
470  {}
471  //*******************************************************************************************
472 
473  //**Constructor******************************************************************************
480  inline ColumnIterator( MatrixType& matrix, size_t row, size_t column )
481  : matrix_( &matrix ) // Reference to the adapted dense matrix
482  , row_ ( row ) // The current row index of the iterator
483  , column_( column ) // The current column index of the iterator
484  {
486  }
487  //*******************************************************************************************
488 
489  //**Conversion constructor*******************************************************************
494  template< typename MatrixType2 >
495  inline ColumnIterator( const ColumnIterator<MatrixType2>& it )
496  : matrix_( it.matrix_ ) // Reference to the adapted dense matrix
497  , row_ ( it.row_ ) // The current row index of the iterator
498  , column_( it.column_ ) // The current column index of the iterator
499  {
501  }
502  //*******************************************************************************************
503 
504  //**Addition assignment operator*************************************************************
510  inline ColumnIterator& operator+=( size_t inc ) {
511  row_ += inc;
512  return *this;
513  }
514  //*******************************************************************************************
515 
516  //**Subtraction assignment operator**********************************************************
522  inline ColumnIterator& operator-=( size_t dec ) {
523  row_ -= dec;
524  return *this;
525  }
526  //*******************************************************************************************
527 
528  //**Prefix increment operator****************************************************************
533  inline ColumnIterator& operator++() {
534  ++row_;
535  return *this;
536  }
537  //*******************************************************************************************
538 
539  //**Postfix increment operator***************************************************************
544  inline const ColumnIterator operator++( int ) {
545  const ColumnIterator tmp( *this );
546  ++(*this);
547  return tmp;
548  }
549  //*******************************************************************************************
550 
551  //**Prefix decrement operator****************************************************************
556  inline ColumnIterator& operator--() {
557  --row_;
558  return *this;
559  }
560  //*******************************************************************************************
561 
562  //**Postfix decrement operator***************************************************************
567  inline const ColumnIterator operator--( int ) {
568  const ColumnIterator tmp( *this );
569  --(*this);
570  return tmp;
571  }
572  //*******************************************************************************************
573 
574  //**Element access operator******************************************************************
579  inline ReferenceType operator*() const {
580  if( row_ < column_ )
581  return (*matrix_)( row_, column_ );
582  else
583  return (*matrix_)( column_, row_ );
584  }
585  //*******************************************************************************************
586 
587  //**Element access operator******************************************************************
592  inline PointerType operator->() const {
593  if( row_ < column_ )
594  return &(*matrix_)( row_, column_ );
595  else
596  return &(*matrix_)( column_, row_ );
597  }
598  //*******************************************************************************************
599 
600  //**Equality operator************************************************************************
606  template< typename MatrixType2 >
607  inline bool operator==( const ColumnIterator<MatrixType2>& rhs ) const {
608  return ( row_ == rhs.row_ );
609  }
610  //*******************************************************************************************
611 
612  //**Inequality operator**********************************************************************
618  template< typename MatrixType2 >
619  inline bool operator!=( const ColumnIterator<MatrixType2>& rhs ) const {
620  return ( row_ != rhs.row_ );
621  }
622  //*******************************************************************************************
623 
624  //**Less-than operator***********************************************************************
630  template< typename MatrixType2 >
631  inline bool operator<( const ColumnIterator<MatrixType2>& rhs ) const {
632  return ( row_ < rhs.row_ );
633  }
634  //*******************************************************************************************
635 
636  //**Greater-than operator********************************************************************
642  template< typename MatrixType2 >
643  inline bool operator>( const ColumnIterator<MatrixType2>& rhs ) const {
644  return ( row_ > rhs.row_ );
645  }
646  //*******************************************************************************************
647 
648  //**Less-or-equal-than operator**************************************************************
654  template< typename MatrixType2 >
655  inline bool operator<=( const ColumnIterator<MatrixType2>& rhs ) const {
656  return ( row_ <= rhs.row_ );
657  }
658  //*******************************************************************************************
659 
660  //**Greater-or-equal-than operator***********************************************************
666  template< typename MatrixType2 >
667  inline bool operator>=( const ColumnIterator<MatrixType2>& rhs ) const {
668  return ( row_ >= rhs.row_ );
669  }
670  //*******************************************************************************************
671 
672  //**Subtraction operator*********************************************************************
678  inline DifferenceType operator-( const ColumnIterator& rhs ) const {
679  return ( row_ - rhs.row_ );
680  }
681  //*******************************************************************************************
682 
683  //**Addition operator************************************************************************
690  friend inline const ColumnIterator operator+( const ColumnIterator& it, size_t inc ) {
691  return ColumnIterator( *it.matrix_, it.row_ + inc, it.column_ );
692  }
693  //*******************************************************************************************
694 
695  //**Addition operator************************************************************************
702  friend inline const ColumnIterator operator+( size_t inc, const ColumnIterator& it ) {
703  return ColumnIterator( *it.matrix_, it.row_ + inc, it.column_ );
704  }
705  //*******************************************************************************************
706 
707  //**Subtraction operator*********************************************************************
714  friend inline const ColumnIterator operator-( const ColumnIterator& it, size_t dec ) {
715  return ColumnIterator( *it.matrix_, it.row_ - dec, it.column_ );
716  }
717  //*******************************************************************************************
718 
719  private:
720  //**Member variables*************************************************************************
721  MatrixType* matrix_;
722  size_t row_;
723  size_t column_;
724  //*******************************************************************************************
725 
726  //**Friend declarations**********************************************************************
727  template< typename MatrixType2 > friend class ColumnIterator;
728  //*******************************************************************************************
729  };
730  //**********************************************************************************************
731 
732  //**Type definitions****************************************************************************
734  typedef typename IfTrue< SO, ColumnIterator<MT>, RowIterator<MT> >::Type Iterator;
735 
737  typedef typename IfTrue< SO, ColumnIterator<const MT>, RowIterator<const MT> >::Type ConstIterator;
738  //**********************************************************************************************
739 
740  //**Compilation flags***************************************************************************
742  enum { vectorizable = 0 };
743 
745  enum { smpAssignable = 0 };
746  //**********************************************************************************************
747 
748  //**Constructors********************************************************************************
751  explicit inline SymmetricMatrix();
752  explicit inline SymmetricMatrix( size_t n );
753 
754  inline SymmetricMatrix( const SymmetricMatrix& m );
755  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,SO>& m );
756  template< typename MT2 > inline SymmetricMatrix( const Matrix<MT2,!SO>& m );
758  //**********************************************************************************************
759 
760  //**Destructor**********************************************************************************
761  // No explicitly declared destructor.
762  //**********************************************************************************************
763 
764  //**Data access functions***********************************************************************
767  inline Reference operator()( size_t i, size_t j );
768  inline ConstReference operator()( size_t i, size_t j ) const;
769  inline ConstPointer data () const;
770  inline ConstPointer data ( size_t i ) const;
771  inline Iterator begin ( size_t i );
772  inline ConstIterator begin ( size_t i ) const;
773  inline ConstIterator cbegin( size_t i ) const;
774  inline Iterator end ( size_t i );
775  inline ConstIterator end ( size_t i ) const;
776  inline ConstIterator cend ( size_t i ) const;
778  //**********************************************************************************************
779 
780  //**Assignment operators************************************************************************
783  inline SymmetricMatrix& operator=( const SymmetricMatrix& rhs );
784 
785  template< typename MT2 >
786  inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
787  operator=( const Matrix<MT2,SO>& rhs );
788 
789  template< typename MT2 >
790  inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
791  operator=( const Matrix<MT2,SO>& rhs );
792 
793  template< typename MT2 >
794  inline SymmetricMatrix& operator=( const Matrix<MT2,!SO>& rhs );
795 
796  template< typename MT2 >
797  inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
798  operator+=( const Matrix<MT2,SO>& rhs );
799 
800  template< typename MT2 >
801  inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
802  operator+=( const Matrix<MT2,SO>& rhs );
803 
804  template< typename MT2 >
805  inline SymmetricMatrix& operator+=( const Matrix<MT2,!SO>& rhs );
806 
807  template< typename MT2 >
808  inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
809  operator-=( const Matrix<MT2,SO>& rhs );
810 
811  template< typename MT2 >
812  inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix& >::Type
813  operator-=( const Matrix<MT2,SO>& rhs );
814 
815  template< typename MT2 >
816  inline SymmetricMatrix& operator-=( const Matrix<MT2,!SO>& rhs );
817 
818  template< typename MT2, bool SO2 >
819  inline SymmetricMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
820 
821  template< typename Other >
822  inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix >::Type&
823  operator*=( Other rhs );
824 
825  template< typename Other >
826  inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix >::Type&
827  operator/=( Other rhs );
829  //**********************************************************************************************
830 
831  //**Utility functions***************************************************************************
834  inline size_t rows() const;
835  inline size_t columns() const;
836  inline size_t spacing() const;
837  inline size_t capacity() const;
838  inline size_t capacity( size_t i ) const;
839  inline size_t nonZeros() const;
840  inline size_t nonZeros( size_t i ) const;
841  inline void reset();
842  inline void reset( size_t i );
843  inline void clear();
844  void resize ( size_t n, bool preserve=true );
845  inline void extend ( size_t n, bool preserve=true );
846  inline void reserve( size_t elements );
847  inline SymmetricMatrix& transpose();
848  template< typename Other > inline SymmetricMatrix& scale( const Other& scalar );
849  inline void swap( SymmetricMatrix& m ) /* throw() */;
851  //**********************************************************************************************
852 
853  private:
854  //**Utility functions***************************************************************************
857  inline bool isLowerOrUpper();
859  //**********************************************************************************************
860 
861  public:
862  //**Expression template evaluation functions****************************************************
865  template< typename Other > inline bool canAlias ( const Other* alias ) const;
866  template< typename Other > inline bool isAliased( const Other* alias ) const;
867 
868  inline bool isAligned () const;
869  inline bool canSMPAssign() const;
871  //**********************************************************************************************
872 
873  private:
874  //**Expression template evaluation functions****************************************************
877  template< typename MT2 > inline void assign ( DenseMatrix <MT2,SO>& rhs );
878  template< typename MT2 > inline void assign ( const DenseMatrix <MT2,SO>& rhs );
879  template< typename MT2 > inline void assign ( const SparseMatrix<MT2,SO>& rhs );
880  template< typename MT2 > inline void addAssign( const DenseMatrix <MT2,SO>& rhs );
881  template< typename MT2 > inline void addAssign( const SparseMatrix<MT2,SO>& rhs );
882  template< typename MT2 > inline void subAssign( const DenseMatrix <MT2,SO>& rhs );
883  template< typename MT2 > inline void subAssign( const SparseMatrix<MT2,SO>& rhs );
885  //**********************************************************************************************
886 
887  //**Member variables****************************************************************************
890  MT matrix_;
891 
892  //**********************************************************************************************
893 
894  //**Friend declarations*************************************************************************
895  template< typename MT2, bool SO2, bool DF2, bool NF2 >
896  friend bool isDefault( const SymmetricMatrix<MT2,SO2,DF2,NF2>& m );
897  //**********************************************************************************************
898 
899  //**Compile time checks*************************************************************************
912  BLAZE_STATIC_ASSERT( IsResizable<MT>::value || IsSquare<MT>::value );
913  //**********************************************************************************************
914 };
916 //*************************************************************************************************
917 
918 
919 
920 
921 //=================================================================================================
922 //
923 // CONSTRUCTORS
924 //
925 //=================================================================================================
926 
927 //*************************************************************************************************
931 template< typename MT // Type of the adapted dense matrix
932  , bool SO > // Storage order of the adapted dense matrix
933 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix()
934  : matrix_() // The adapted dense matrix
935 {
936  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
937 }
939 //*************************************************************************************************
940 
941 
942 //*************************************************************************************************
948 template< typename MT // Type of the adapted dense matrix
949  , bool SO > // Storage order of the adapted dense matrix
950 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( size_t n )
951  : matrix_( n, n ) // The adapted dense matrix
952 {
954 
955  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
956 }
958 //*************************************************************************************************
959 
960 
961 //*************************************************************************************************
967 template< typename MT // Type of the adapted dense matrix
968  , bool SO > // Storage order of the adapted dense matrix
969 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const SymmetricMatrix& m )
970  : matrix_( m.matrix_ ) // The adapted dense matrix
971 {
972  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
973  BLAZE_INTERNAL_ASSERT( isLowerOrUpper() , "Broken invariant detected" );
974 }
976 //*************************************************************************************************
977 
978 
979 //*************************************************************************************************
989 template< typename MT // Type of the adapted dense matrix
990  , bool SO > // Storage order of the adapted dense matrix
991 template< typename MT2 > // Type of the foreign matrix
992 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,SO>& m )
993  : matrix_() // The adapted dense matrix
994 {
995  using blaze::resize;
996 
997  typedef typename RemoveAdaptor<typename MT2::ResultType>::Type RT;
998  typedef typename If< IsComputation<MT2>, RT, const MT2& >::Type Tmp;
999 
1000  if( IsLower<MT2>::value || IsUpper<MT2>::value )
1001  throw std::invalid_argument( "Invalid setup of symmetric matrix" );
1002 
1003  if( IsSymmetric<MT2>::value ) {
1004  resize( matrix_, (~m).rows(), (~m).columns() );
1005  assign( ~m );
1006  }
1007  else {
1008  Tmp tmp( ~m );
1009 
1010  if( !isSymmetric( tmp ) )
1011  throw std::invalid_argument( "Invalid setup of symmetric matrix" );
1012 
1013  resize( matrix_, tmp.rows(), tmp.rows() );
1014  assign( tmp );
1015  }
1016 
1017  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1018  BLAZE_INTERNAL_ASSERT( isLowerOrUpper() , "Broken invariant detected" );
1019 }
1021 //*************************************************************************************************
1022 
1023 
1024 //*************************************************************************************************
1034 template< typename MT // Type of the adapted dense matrix
1035  , bool SO > // Storage order of the adapted dense matrix
1036 template< typename MT2 > // Type of the foreign matrix
1037 inline SymmetricMatrix<MT,SO,true,false>::SymmetricMatrix( const Matrix<MT2,!SO>& m )
1038  : matrix_() // The adapted dense matrix
1039 {
1040  using blaze::resize;
1041 
1042  typedef typename RemoveAdaptor<typename MT2::ResultType>::Type RT;
1043  typedef typename If< IsComputation<MT2>, RT, const MT2& >::Type Tmp;
1044 
1045  if( IsLower<MT2>::value || IsUpper<MT2>::value )
1046  throw std::invalid_argument( "Invalid setup of symmetric matrix" );
1047 
1048  if( IsSymmetric<MT2>::value ) {
1049  resize( matrix_, (~m).rows(), (~m).columns() );
1050  assign( trans( ~m ) );
1051  }
1052  else {
1053  Tmp tmp( ~m );
1054 
1055  if( !isSymmetric( tmp ) )
1056  throw std::invalid_argument( "Invalid setup of symmetric matrix" );
1057 
1058  resize( matrix_, tmp.rows(), tmp.rows() );
1059  assign( trans( tmp ) );
1060  }
1061 
1062  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1063  BLAZE_INTERNAL_ASSERT( isLowerOrUpper() , "Broken invariant detected" );
1064 }
1066 //*************************************************************************************************
1067 
1068 
1069 
1070 
1071 //=================================================================================================
1072 //
1073 // DATA ACCESS FUNCTIONS
1074 //
1075 //=================================================================================================
1076 
1077 //*************************************************************************************************
1089 template< typename MT // Type of the adapted dense matrix
1090  , bool SO > // Storage order of the adapted dense matrix
1092  SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j )
1093 {
1094  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1095  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1096 
1097  if( ( !SO && i > j ) || ( SO && i < j ) )
1098  return matrix_(i,j);
1099  else
1100  return matrix_(j,i);
1101 }
1103 //*************************************************************************************************
1104 
1105 
1106 //*************************************************************************************************
1118 template< typename MT // Type of the adapted dense matrix
1119  , bool SO > // Storage order of the adapted dense matrix
1121  SymmetricMatrix<MT,SO,true,false>::operator()( size_t i, size_t j ) const
1122 {
1123  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1124  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1125 
1126  if( ( !SO && i > j ) || ( SO && i < j ) )
1127  return matrix_(i,j);
1128  else
1129  return matrix_(j,i);
1130 }
1132 //*************************************************************************************************
1133 
1134 
1135 //*************************************************************************************************
1149 template< typename MT // Type of the adapted dense matrix
1150  , bool SO > // Storage order of the adapted dense matrix
1151 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1152  SymmetricMatrix<MT,SO,true,false>::data() const
1153 {
1154  return matrix_.data();
1155 }
1157 //*************************************************************************************************
1158 
1159 
1160 //*************************************************************************************************
1171 template< typename MT // Type of the adapted dense matrix
1172  , bool SO > // Storage order of the adapted dense matrix
1173 inline typename SymmetricMatrix<MT,SO,true,false>::ConstPointer
1174  SymmetricMatrix<MT,SO,true,false>::data( size_t i ) const
1175 {
1176  return matrix_.data(i);
1177 }
1179 //*************************************************************************************************
1180 
1181 
1182 //*************************************************************************************************
1194 template< typename MT // Type of the adapted dense matrix
1195  , bool SO > // Storage order of the adapted dense matrix
1198 {
1199  if( SO )
1200  return Iterator( matrix_, 0UL, i );
1201  else
1202  return Iterator( matrix_, i, 0UL );
1203 }
1205 //*************************************************************************************************
1206 
1207 
1208 //*************************************************************************************************
1220 template< typename MT // Type of the adapted dense matrix
1221  , bool SO > // Storage order of the adapted dense matrix
1224 {
1225  if( SO )
1226  return ConstIterator( matrix_, 0UL, i );
1227  else
1228  return ConstIterator( matrix_, i, 0UL );
1229 }
1231 //*************************************************************************************************
1232 
1233 
1234 //*************************************************************************************************
1246 template< typename MT // Type of the adapted dense matrix
1247  , bool SO > // Storage order of the adapted dense matrix
1250 {
1251  if( SO )
1252  return ConstIterator( matrix_, 0UL, i );
1253  else
1254  return ConstIterator( matrix_, i, 0UL );
1255 }
1257 //*************************************************************************************************
1258 
1259 
1260 //*************************************************************************************************
1272 template< typename MT // Type of the adapted dense matrix
1273  , bool SO > // Storage order of the adapted dense matrix
1276 {
1277  if( SO )
1278  return Iterator( matrix_, rows(), i );
1279  else
1280  return Iterator( matrix_, i, columns() );
1281 }
1283 //*************************************************************************************************
1284 
1285 
1286 //*************************************************************************************************
1298 template< typename MT // Type of the adapted dense matrix
1299  , bool SO > // Storage order of the adapted dense matrix
1301  SymmetricMatrix<MT,SO,true,false>::end( size_t i ) const
1302 {
1303  if( SO )
1304  return ConstIterator( matrix_, rows(), i );
1305  else
1306  return ConstIterator( matrix_, i, columns() );
1307 }
1309 //*************************************************************************************************
1310 
1311 
1312 //*************************************************************************************************
1324 template< typename MT // Type of the adapted dense matrix
1325  , bool SO > // Storage order of the adapted dense matrix
1327  SymmetricMatrix<MT,SO,true,false>::cend( size_t i ) const
1328 {
1329  if( SO )
1330  return ConstIterator( matrix_, rows(), i );
1331  else
1332  return ConstIterator( matrix_, i, columns() );
1333 }
1335 //*************************************************************************************************
1336 
1337 
1338 
1339 
1340 //=================================================================================================
1341 //
1342 // ASSIGNMENT OPERATORS
1343 //
1344 //=================================================================================================
1345 
1346 //*************************************************************************************************
1356 template< typename MT // Type of the adapted dense matrix
1357  , bool SO > // Storage order of the adapted dense matrix
1358 inline SymmetricMatrix<MT,SO,true,false>&
1359  SymmetricMatrix<MT,SO,true,false>::operator=( const SymmetricMatrix& rhs )
1360 {
1361  using blaze::resize;
1362 
1363  if( &rhs == this ) return *this;
1364 
1365  resize( matrix_, rhs.rows(), rhs.columns() );
1366  assign( rhs );
1367 
1368  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1369  BLAZE_INTERNAL_ASSERT( isLowerOrUpper() , "Broken invariant detected" );
1370 
1371  return *this;
1372 }
1374 //*************************************************************************************************
1375 
1376 
1377 //*************************************************************************************************
1391 template< typename MT // Type of the adapted dense matrix
1392  , bool SO > // Storage order of the adapted dense matrix
1393 template< typename MT2 > // Type of the right-hand side matrix
1394 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1395  SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1396 {
1397  using blaze::resize;
1398 
1399  if( IsLower<MT2>::value || IsUpper<MT2>::value ||
1400  ( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) )
1401  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1402 
1403  if( (~rhs).isAliased( this ) ) {
1404  SymmetricMatrix tmp( ~rhs );
1405  swap( tmp );
1406  }
1407  else {
1408  resize( matrix_, (~rhs).rows(), (~rhs).columns() );
1409  if( IsSparseMatrix<MT2>::value )
1410  reset();
1411  assign( ~rhs );
1412  }
1413 
1414  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1415  BLAZE_INTERNAL_ASSERT( isLowerOrUpper() , "Broken invariant detected" );
1416 
1417  return *this;
1418 }
1420 //*************************************************************************************************
1421 
1422 
1423 //*************************************************************************************************
1437 template< typename MT // Type of the adapted dense matrix
1438  , bool SO > // Storage order of the adapted dense matrix
1439 template< typename MT2 > // Type of the right-hand side matrix
1440 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1441  SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,SO>& rhs )
1442 {
1443  using blaze::resize;
1444 
1445  typedef typename If< IsSymmetric<MT2>
1446  , typename MT2::CompositeType
1447  , typename MT2::ResultType >::Type Tmp;
1448 
1449  if( IsLower<MT2>::value || IsUpper<MT2>::value || !isSquare( ~rhs ) )
1450  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1451 
1452  Tmp tmp( ~rhs );
1453 
1454  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) )
1455  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1456 
1457  BLAZE_INTERNAL_ASSERT( !tmp.isAliased( this ), "Aliasing detected" );
1458 
1459  resize( matrix_, tmp.rows(), tmp.columns() );
1460  if( IsSparseMatrix<Tmp>::value )
1461  reset();
1462  assign( tmp );
1463 
1464  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1465  BLAZE_INTERNAL_ASSERT( isLowerOrUpper() , "Broken invariant detected" );
1466 
1467  return *this;
1468 }
1470 //*************************************************************************************************
1471 
1472 
1473 //*************************************************************************************************
1487 template< typename MT // Type of the adapted dense matrix
1488  , bool SO > // Storage order of the adapted dense matrix
1489 template< typename MT2 > // Type of the right-hand side matrix
1490 inline SymmetricMatrix<MT,SO,true,false>&
1491  SymmetricMatrix<MT,SO,true,false>::operator=( const Matrix<MT2,!SO>& rhs )
1492 {
1493  return this->operator=( trans( ~rhs ) );
1494 }
1496 //*************************************************************************************************
1497 
1498 
1499 //*************************************************************************************************
1512 template< typename MT // Type of the adapted dense matrix
1513  , bool SO > // Storage order of the adapted dense matrix
1514 template< typename MT2 > // Type of the right-hand side matrix
1515 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1516  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1517 {
1518  if( IsLower<MT2>::value || IsUpper<MT2>::value ||
1519  ( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) )
1520  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1521 
1522  addAssign( ~rhs );
1523 
1524  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1525  BLAZE_INTERNAL_ASSERT( isLowerOrUpper() , "Broken invariant detected" );
1526 
1527  return *this;
1528 }
1530 //*************************************************************************************************
1531 
1532 
1533 //*************************************************************************************************
1546 template< typename MT // Type of the adapted dense matrix
1547  , bool SO > // Storage order of the adapted dense matrix
1548 template< typename MT2 > // Type of the right-hand side matrix
1549 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1550  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,SO>& rhs )
1551 {
1552  typedef typename If< IsSymmetric<MT2>
1553  , typename MT2::CompositeType
1554  , typename MT2::ResultType >::Type Tmp;
1555 
1556  if( IsLower<MT2>::value || IsUpper<MT2>::value || !isSquare( ~rhs ) )
1557  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1558 
1559  Tmp tmp( ~rhs );
1560 
1561  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) )
1562  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1563 
1564  BLAZE_INTERNAL_ASSERT( !tmp.isAliased( this ), "Aliasing detected" );
1565 
1566  addAssign( tmp );
1567 
1568  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1569  BLAZE_INTERNAL_ASSERT( isLowerOrUpper() , "Broken invariant detected" );
1570 
1571  return *this;
1572 }
1574 //*************************************************************************************************
1575 
1576 
1577 //*************************************************************************************************
1591 template< typename MT // Type of the adapted dense matrix
1592  , bool SO > // Storage order of the adapted dense matrix
1593 template< typename MT2 > // Type of the right-hand side matrix
1594 inline SymmetricMatrix<MT,SO,true,false>&
1595  SymmetricMatrix<MT,SO,true,false>::operator+=( const Matrix<MT2,!SO>& rhs )
1596 {
1597  return this->operator+=( trans( ~rhs ) );
1598 }
1600 //*************************************************************************************************
1601 
1602 
1603 //*************************************************************************************************
1616 template< typename MT // Type of the adapted dense matrix
1617  , bool SO > // Storage order of the adapted dense matrix
1618 template< typename MT2 > // Type of the right-hand side matrix
1619 inline typename DisableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1620  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1621 {
1622  if( IsLower<MT2>::value || IsUpper<MT2>::value ||
1623  ( !IsSymmetric<MT2>::value && !isSymmetric( ~rhs ) ) )
1624  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1625 
1626  subAssign( ~rhs );
1627 
1628  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1629  BLAZE_INTERNAL_ASSERT( isLowerOrUpper() , "Broken invariant detected" );
1630 
1631  return *this;
1632 }
1634 //*************************************************************************************************
1635 
1636 
1637 //*************************************************************************************************
1650 template< typename MT // Type of the adapted dense matrix
1651  , bool SO > // Storage order of the adapted dense matrix
1652 template< typename MT2 > // Type of the right-hand side matrix
1653 inline typename EnableIf< IsComputation<MT2>, SymmetricMatrix<MT,SO,true,false>& >::Type
1654  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,SO>& rhs )
1655 {
1656  typedef typename If< IsSymmetric<MT2>
1657  , typename MT2::CompositeType
1658  , typename MT2::ResultType >::Type Tmp;
1659 
1660  if( IsLower<MT2>::value || IsUpper<MT2>::value || !isSquare( ~rhs ) )
1661  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1662 
1663  Tmp tmp( ~rhs );
1664 
1665  if( !IsSymmetric<Tmp>::value && !isSymmetric( tmp ) )
1666  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1667 
1668  BLAZE_INTERNAL_ASSERT( !tmp.isAliased( this ), "Aliasing detected" );
1669 
1670  subAssign( tmp );
1671 
1672  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1673  BLAZE_INTERNAL_ASSERT( isLowerOrUpper() , "Broken invariant detected" );
1674 
1675  return *this;
1676 }
1678 //*************************************************************************************************
1679 
1680 
1681 //*************************************************************************************************
1695 template< typename MT // Type of the adapted dense matrix
1696  , bool SO > // Storage order of the adapted dense matrix
1697 template< typename MT2 > // Type of the right-hand side matrix
1698 inline SymmetricMatrix<MT,SO,true,false>&
1699  SymmetricMatrix<MT,SO,true,false>::operator-=( const Matrix<MT2,!SO>& rhs )
1700 {
1701  return this->operator-=( trans( ~rhs ) );
1702 }
1704 //*************************************************************************************************
1705 
1706 
1707 //*************************************************************************************************
1719 template< typename MT // Type of the adapted dense matrix
1720  , bool SO > // Storage order of the adapted dense matrix
1721 template< typename MT2 // Type of the right-hand side matrix
1722  , bool SO2 > // Storage order of the right-hand side matrix
1723 inline SymmetricMatrix<MT,SO,true,false>&
1724  SymmetricMatrix<MT,SO,true,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1725 {
1726  using blaze::resize;
1727 
1728  typedef typename MultTrait<MT,typename MT2::ResultType>::Type Tmp;
1729 
1731 
1732  if( matrix_.rows() != (~rhs).columns() )
1733  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1734 
1735  Tmp tmp( (*this) * ~rhs );
1736 
1737  if( !isSymmetric( tmp ) )
1738  throw std::invalid_argument( "Invalid assignment to symmetric matrix" );
1739 
1740  resize( matrix_, tmp.rows(), tmp.columns() );
1741  assign( tmp );
1742 
1743  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
1744  BLAZE_INTERNAL_ASSERT( isLowerOrUpper() , "Broken invariant detected" );
1745 
1746  return *this;
1747 }
1749 //*************************************************************************************************
1750 
1751 
1752 //*************************************************************************************************
1760 template< typename MT // Type of the adapted dense matrix
1761  , bool SO > // Storage order of the adapted dense matrix
1762 template< typename Other > // Data type of the right-hand side scalar
1763 inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >::Type&
1764  SymmetricMatrix<MT,SO,true,false>::operator*=( Other rhs )
1765 {
1766  if( SO ) {
1767  for( size_t j=0UL; j<columns(); ++j )
1768  for( size_t i=0UL; i<=j; ++i )
1769  matrix_(i,j) *= rhs;
1770  }
1771  else {
1772  for( size_t i=0UL; i<rows(); ++i )
1773  for( size_t j=0UL; j<=i; ++j )
1774  matrix_(i,j) *= rhs;
1775  }
1776 
1777  return *this;
1778 }
1780 //*************************************************************************************************
1781 
1782 
1783 //*************************************************************************************************
1791 template< typename MT // Type of the adapted dense matrix
1792  , bool SO > // Storage order of the adapted dense matrix
1793 template< typename Other > // Data type of the right-hand side scalar
1794 inline typename EnableIf< IsNumeric<Other>, SymmetricMatrix<MT,SO,true,false> >::Type&
1795  SymmetricMatrix<MT,SO,true,false>::operator/=( Other rhs )
1796 {
1797  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1798 
1799  if( SO ) {
1800  for( size_t j=0UL; j<columns(); ++j )
1801  for( size_t i=0UL; i<=j; ++i )
1802  matrix_(i,j) /= rhs;
1803  }
1804  else {
1805  for( size_t i=0UL; i<rows(); ++i )
1806  for( size_t j=0UL; j<=i; ++j )
1807  matrix_(i,j) /= rhs;
1808  }
1809 
1810  return *this;
1811 }
1813 //*************************************************************************************************
1814 
1815 
1816 
1817 
1818 //=================================================================================================
1819 //
1820 // UTILITY FUNCTIONS
1821 //
1822 //=================================================================================================
1823 
1824 //*************************************************************************************************
1830 template< typename MT // Type of the adapted dense matrix
1831  , bool SO > // Storage order of the adapted dense matrix
1832 inline size_t SymmetricMatrix<MT,SO,true,false>::rows() const
1833 {
1834  return matrix_.rows();
1835 }
1837 //*************************************************************************************************
1838 
1839 
1840 //*************************************************************************************************
1846 template< typename MT // Type of the adapted dense matrix
1847  , bool SO > // Storage order of the adapted dense matrix
1848 inline size_t SymmetricMatrix<MT,SO,true,false>::columns() const
1849 {
1850  return matrix_.columns();
1851 }
1853 //*************************************************************************************************
1854 
1855 
1856 //*************************************************************************************************
1868 template< typename MT // Type of the adapted dense matrix
1869  , bool SO > // Storage order of the adapted dense matrix
1870 inline size_t SymmetricMatrix<MT,SO,true,false>::spacing() const
1871 {
1872  return matrix_.spacing();
1873 }
1875 //*************************************************************************************************
1876 
1877 
1878 //*************************************************************************************************
1884 template< typename MT // Type of the adapted dense matrix
1885  , bool SO > // Storage order of the adapted dense matrix
1886 inline size_t SymmetricMatrix<MT,SO,true,false>::capacity() const
1887 {
1888  return matrix_.capacity();
1889 }
1891 //*************************************************************************************************
1892 
1893 
1894 //*************************************************************************************************
1905 template< typename MT // Type of the adapted dense matrix
1906  , bool SO > // Storage order of the adapted dense matrix
1907 inline size_t SymmetricMatrix<MT,SO,true,false>::capacity( size_t i ) const
1908 {
1909  return matrix_.capacity(i);
1910 }
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,false>::nonZeros() const
1924 {
1925  size_t nonzeros( 0UL );
1926 
1927  if( SO )
1928  {
1929  for( size_t j=0UL; j<columns(); ++j ) {
1930  for( size_t i=0UL; i<j; ++i ) {
1931  if( !isDefault( matrix_(i,j) ) )
1932  nonzeros += 2UL;
1933  }
1934  if( !isDefault( matrix_(j,j) ) )
1935  ++nonzeros;
1936  }
1937  }
1938  else
1939  {
1940  for( size_t i=0UL; i<rows(); ++i ) {
1941  for( size_t j=0UL; j<i; ++j ) {
1942  if( !isDefault( matrix_(i,j) ) )
1943  nonzeros += 2UL;
1944  }
1945  if( !isDefault( matrix_(i,i) ) )
1946  ++nonzeros;
1947  }
1948  }
1949 
1950  return nonzeros;
1951 }
1953 //*************************************************************************************************
1954 
1955 
1956 //*************************************************************************************************
1968 template< typename MT // Type of the adapted dense matrix
1969  , bool SO > // Storage order of the adapted dense matrix
1970 inline size_t SymmetricMatrix<MT,SO,true,false>::nonZeros( size_t i ) const
1971 {
1972  size_t nonzeros( 0UL );
1973 
1974  if( SO )
1975  {
1976  for( size_t j=0UL; j<i; ++j ) {
1977  if( !isDefault( matrix_(j,i) ) )
1978  ++nonzeros;
1979  }
1980  for( size_t j=i; j<rows(); ++j ) {
1981  if( !isDefault( matrix_(i,j) ) )
1982  ++nonzeros;
1983  }
1984  }
1985  else
1986  {
1987  for( size_t j=0UL; j<i; ++j ) {
1988  if( !isDefault( matrix_(i,j) ) )
1989  ++nonzeros;
1990  }
1991  for( size_t j=i; j<rows(); ++j ) {
1992  if( !isDefault( matrix_(j,i) ) )
1993  ++nonzeros;
1994  }
1995  }
1996 
1997  return nonzeros;
1998 }
2000 //*************************************************************************************************
2001 
2002 
2003 //*************************************************************************************************
2009 template< typename MT // Type of the adapted dense matrix
2010  , bool SO > // Storage order of the adapted dense matrix
2012 {
2013  using blaze::clear;
2014 
2015  if( SO ) {
2016  for( size_t j=0UL; j<columns(); ++j )
2017  for( size_t i=0UL; i<=j; ++i )
2018  clear( matrix_(i,j) );
2019  }
2020  else {
2021  for( size_t i=0UL; i<rows(); ++i )
2022  for( size_t j=0UL; j<=i; ++j )
2023  clear( matrix_(i,j) );
2024  }
2025 }
2027 //*************************************************************************************************
2028 
2029 
2030 //*************************************************************************************************
2070 template< typename MT // Type of the adapted dense matrix
2071  , bool SO > // Storage order of the adapted dense matrix
2072 inline void SymmetricMatrix<MT,SO,true,false>::reset( size_t i )
2073 {
2074  using blaze::clear;
2075 
2076  for( Iterator element=begin(i); element!=end(i); ++element )
2077  clear( *element );
2078 }
2080 //*************************************************************************************************
2081 
2082 
2083 //*************************************************************************************************
2095 template< typename MT // Type of the adapted dense matrix
2096  , bool SO > // Storage order of the adapted dense matrix
2098 {
2099  using blaze::clear;
2100 
2101  clear( matrix_ );
2102 }
2104 //*************************************************************************************************
2105 
2106 
2107 //*************************************************************************************************
2123 template< typename MT // Type of the adapted dense matrix
2124  , bool SO > // Storage order of the adapted dense matrix
2125 void SymmetricMatrix<MT,SO,true,false>::resize( size_t n, bool preserve )
2126 {
2128 
2129  UNUSED_PARAMETER( preserve );
2130 
2131  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square symmetric matrix detected" );
2132 
2133  const size_t oldsize( matrix_.rows() );
2134 
2135  matrix_.resize( n, n, true );
2136 
2137  if( n > oldsize ) {
2138  const size_t increment( n - oldsize );
2139  submatrix( matrix_, 0UL, oldsize, oldsize, increment ).reset();
2140  submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2141  }
2142 }
2144 //*************************************************************************************************
2145 
2146 
2147 //*************************************************************************************************
2160 template< typename MT // Type of the adapted dense matrix
2161  , bool SO > // Storage order of the adapted dense matrix
2162 inline void SymmetricMatrix<MT,SO,true,false>::extend( size_t n, bool preserve )
2163 {
2165 
2166  UNUSED_PARAMETER( preserve );
2167 
2168  resize( rows() + n, true );
2169 }
2171 //*************************************************************************************************
2172 
2173 
2174 //*************************************************************************************************
2184 template< typename MT // Type of the adapted dense matrix
2185  , bool SO > // Storage order of the adapted dense matrix
2186 inline void SymmetricMatrix<MT,SO,true,false>::reserve( size_t elements )
2187 {
2188  matrix_.reserve( elements );
2189 }
2191 //*************************************************************************************************
2192 
2193 
2194 //*************************************************************************************************
2200 template< typename MT // Type of the adapted dense matrix
2201  , bool SO > // Storage order of the adapted dense matrix
2202 inline SymmetricMatrix<MT,SO,true,false>& SymmetricMatrix<MT,SO,true,false>::transpose()
2203 {
2204  return *this;
2205 }
2207 //*************************************************************************************************
2208 
2209 
2210 //*************************************************************************************************
2217 template< typename MT // Type of the adapted dense matrix
2218  , bool SO > // Storage order of the adapted dense matrix
2219 template< typename Other > // Data type of the scalar value
2220 inline SymmetricMatrix<MT,SO,true,false>&
2221  SymmetricMatrix<MT,SO,true,false>::scale( const Other& scalar )
2222 {
2223  if( SO ) {
2224  for( size_t j=0UL; j<columns(); ++j )
2225  for( size_t i=0UL; i<=j; ++i )
2226  matrix_(i,j) *= scalar;
2227  }
2228  else {
2229  for( size_t i=0UL; i<rows(); ++i )
2230  for( size_t j=0UL; j<=i; ++j )
2231  matrix_(i,j) *= scalar;
2232  }
2233 
2234  return *this;
2235 }
2237 //*************************************************************************************************
2238 
2239 
2240 //*************************************************************************************************
2248 template< typename MT // Type of the adapted dense matrix
2249  , bool SO > // Storage order of the adapted dense matrix
2250 inline void SymmetricMatrix<MT,SO,true,false>::swap( SymmetricMatrix& m ) /* throw() */
2251 {
2252  using std::swap;
2253 
2254  swap( matrix_, m.matrix_ );
2255 }
2257 //*************************************************************************************************
2258 
2259 
2260 //*************************************************************************************************
2271 template< typename MT // Type of the adapted dense matrix
2272  , bool SO > // Storage order of the adapted dense matrix
2273 inline bool SymmetricMatrix<MT,SO,true,false>::isLowerOrUpper()
2274 {
2275  return ( SO ) ? ( isUpper( matrix_ ) ) : ( isLower( matrix_ ) );
2276 }
2278 //*************************************************************************************************
2279 
2280 
2281 
2282 
2283 //=================================================================================================
2284 //
2285 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2286 //
2287 //=================================================================================================
2288 
2289 //*************************************************************************************************
2300 template< typename MT // Type of the adapted dense matrix
2301  , bool SO > // Storage order of the adapted dense matrix
2302 template< typename Other > // Data type of the foreign expression
2303 inline bool SymmetricMatrix<MT,SO,true,false>::canAlias( const Other* alias ) const
2304 {
2305  return matrix_.canAlias( alias );
2306 }
2308 //*************************************************************************************************
2309 
2310 
2311 //*************************************************************************************************
2322 template< typename MT // Type of the adapted dense matrix
2323  , bool SO > // Storage order of the adapted dense matrix
2324 template< typename Other > // Data type of the foreign expression
2325 inline bool SymmetricMatrix<MT,SO,true,false>::isAliased( const Other* alias ) const
2326 {
2327  return matrix_.isAliased( alias );
2328 }
2330 //*************************************************************************************************
2331 
2332 
2333 //*************************************************************************************************
2343 template< typename MT // Type of the adapted dense matrix
2344  , bool SO > // Storage order of the adapted dense matrix
2345 inline bool SymmetricMatrix<MT,SO,true,false>::isAligned() const
2346 {
2347  return matrix_.isAligned();
2348 }
2350 //*************************************************************************************************
2351 
2352 
2353 //*************************************************************************************************
2364 template< typename MT // Type of the adapted dense matrix
2365  , bool SO > // Storage order of the adapted dense matrix
2366 inline bool SymmetricMatrix<MT,SO,true,false>::canSMPAssign() const
2367 {
2368  return matrix_.canSMPAssign();
2369 }
2371 //*************************************************************************************************
2372 
2373 
2374 //*************************************************************************************************
2386 template< typename MT // Type of the adapted dense matrix
2387  , bool SO > // Storage order of the adapted dense matrix
2388 template< typename MT2 > // Type of the right-hand side dense matrix
2389 inline void SymmetricMatrix<MT,SO,true,false>::assign( DenseMatrix<MT2,SO>& rhs )
2390 {
2391  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2392  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2393 
2394  if( SO ) {
2395  for( size_t j=0UL; j<columns(); ++j )
2396  for( size_t i=0UL; i<=j; ++i )
2397  move( matrix_(i,j), (~rhs)(i,j) );
2398  }
2399  else {
2400  for( size_t i=0UL; i<rows(); ++i )
2401  for( size_t j=0UL; j<=i; ++j )
2402  move( matrix_(i,j), (~rhs)(i,j) );
2403  }
2404 }
2406 //*************************************************************************************************
2407 
2408 
2409 //*************************************************************************************************
2421 template< typename MT // Type of the adapted dense matrix
2422  , bool SO > // Storage order of the adapted dense matrix
2423 template< typename MT2 > // Type of the right-hand side dense matrix
2424 inline void SymmetricMatrix<MT,SO,true,false>::assign( const DenseMatrix<MT2,SO>& rhs )
2425 {
2426  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2427  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2428 
2429  if( SO ) {
2430  for( size_t j=0UL; j<columns(); ++j )
2431  for( size_t i=0UL; i<=j; ++i )
2432  matrix_(i,j) = (~rhs)(i,j);
2433  }
2434  else {
2435  for( size_t i=0UL; i<rows(); ++i )
2436  for( size_t j=0UL; j<=i; ++j )
2437  matrix_(i,j) = (~rhs)(i,j);
2438  }
2439 }
2441 //*************************************************************************************************
2442 
2443 
2444 //*************************************************************************************************
2456 template< typename MT // Type of the adapted dense matrix
2457  , bool SO > // Storage order of the adapted dense matrix
2458 template< typename MT2 > // Type of the right-hand side sparse matrix
2459 inline void SymmetricMatrix<MT,SO,true,false>::assign( const SparseMatrix<MT2,SO>& rhs )
2460 {
2461  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2462  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2463 
2464  typedef typename MT2::ConstIterator ConstIterator;
2465 
2466  if( SO ) {
2467  for( size_t j=0UL; j<columns(); ++j ) {
2468  const ConstIterator last( (~rhs).upperBound(j,j) );
2469  for( ConstIterator element=(~rhs).begin(j); element!=last; ++element )
2470  matrix_(element->index(),j) = element->value();
2471  }
2472  }
2473  else {
2474  for( size_t i=0UL; i<rows(); ++i ) {
2475  const ConstIterator last( (~rhs).upperBound(i,i) );
2476  for( ConstIterator element=(~rhs).begin(i); element!=last; ++element )
2477  matrix_(i,element->index()) = element->value();
2478  }
2479  }
2480 }
2482 //*************************************************************************************************
2483 
2484 
2485 //*************************************************************************************************
2497 template< typename MT // Type of the adapted dense matrix
2498  , bool SO > // Storage order of the adapted dense matrix
2499 template< typename MT2 > // Type of the right-hand side dense matrix
2500 inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const DenseMatrix<MT2,SO>& rhs )
2501 {
2502  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2503  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2504 
2505  if( SO ) {
2506  for( size_t j=0UL; j<columns(); ++j )
2507  for( size_t i=0UL; i<=j; ++i )
2508  matrix_(i,j) += (~rhs)(i,j);
2509  }
2510  else {
2511  for( size_t i=0UL; i<rows(); ++i )
2512  for( size_t j=0UL; j<=i; ++j )
2513  matrix_(i,j) += (~rhs)(i,j);
2514  }
2515 }
2517 //*************************************************************************************************
2518 
2519 
2520 //*************************************************************************************************
2532 template< typename MT // Type of the adapted dense matrix
2533  , bool SO > // Storage order of the adapted dense matrix
2534 template< typename MT2 > // Type of the right-hand side sparse matrix
2535 inline void SymmetricMatrix<MT,SO,true,false>::addAssign( const SparseMatrix<MT2,SO>& rhs )
2536 {
2537  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2538  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2539 
2540  typedef typename MT2::ConstIterator ConstIterator;
2541 
2542  if( SO ) {
2543  for( size_t j=0UL; j<columns(); ++j ) {
2544  const ConstIterator last( (~rhs).upperBound(j,j) );
2545  for( ConstIterator element=(~rhs).begin(j); element!=last; ++element )
2546  matrix_(element->index(),j) += element->value();
2547  }
2548  }
2549  else {
2550  for( size_t i=0UL; i<rows(); ++i ) {
2551  const ConstIterator last( (~rhs).upperBound(i,i) );
2552  for( ConstIterator element=(~rhs).begin(i); element!=last; ++element )
2553  matrix_(i,element->index()) += element->value();
2554  }
2555  }
2556 }
2558 //*************************************************************************************************
2559 
2560 
2561 //*************************************************************************************************
2573 template< typename MT // Type of the adapted dense matrix
2574  , bool SO > // Storage order of the adapted dense matrix
2575 template< typename MT2 > // Type of the right-hand side dense matrix
2576 inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const DenseMatrix<MT2,SO>& rhs )
2577 {
2578  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2579  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2580 
2581  if( SO ) {
2582  for( size_t j=0UL; j<columns(); ++j )
2583  for( size_t i=0UL; i<=j; ++i )
2584  matrix_(i,j) -= (~rhs)(i,j);
2585  }
2586  else {
2587  for( size_t i=0UL; i<rows(); ++i )
2588  for( size_t j=0UL; j<=i; ++j )
2589  matrix_(i,j) -= (~rhs)(i,j);
2590  }
2591 }
2593 //*************************************************************************************************
2594 
2595 
2596 //*************************************************************************************************
2608 template< typename MT // Type of the adapted dense matrix
2609  , bool SO > // Storage order of the adapted dense matrix
2610 template< typename MT2 > // Type of the right-hand side sparse matrix
2611 inline void SymmetricMatrix<MT,SO,true,false>::subAssign( const SparseMatrix<MT2,SO>& rhs )
2612 {
2613  BLAZE_INTERNAL_ASSERT( rows() == (~rhs).rows() , "Invalid number of rows" );
2614  BLAZE_INTERNAL_ASSERT( columns() == (~rhs).columns(), "Invalid number of columns" );
2615 
2616  typedef typename MT2::ConstIterator ConstIterator;
2617 
2618  if( SO ) {
2619  for( size_t j=0UL; j<columns(); ++j ) {
2620  const ConstIterator last( (~rhs).upperBound(j,j) );
2621  for( ConstIterator element=(~rhs).begin(j); element!=last; ++element )
2622  matrix_(element->index(),j) -= element->value();
2623  }
2624  }
2625  else {
2626  for( size_t i=0UL; i<rows(); ++i ) {
2627  const ConstIterator last( (~rhs).upperBound(i,i) );
2628  for( ConstIterator element=(~rhs).begin(i); element!=last; ++element )
2629  matrix_(i,element->index()) -= element->value();
2630  }
2631  }
2632 }
2634 //*************************************************************************************************
2635 
2636 } // namespace blaze
2637 
2638 #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.
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 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
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
Header file for the IsSparseMatrix type trait.
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h: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
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
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.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2474
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:809
Constraint on the data type.
Header file for the IsSquare type trait.
Constraint on the data type.
Header file for the DenseSubmatrix class template.
bool isDefault(const CompressedMatrix< Type, SO > &m)
Returns whether the given compressed matrix is in default state.
Definition: CompressedMatrix.h:4736
Header file for the DisableIf class template.
Header file for the multiplication trait.
Header file for the IsSymmetric type trait.
Header file for the clear shim.
Header file for the If class template.
Compile time assertion.
#define BLAZE_CONSTRAINT_MUST_BE_COLUMN_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a column-major dense or sparse matri...
Definition: StorageOrder.h:161
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
Header file for the DenseMatrix base class.
BLAZE_ALWAYS_INLINE void assign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the assignment of a matrix to a matrix.
Definition: Matrix.h:635
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.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2475
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:890
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
#define BLAZE_CONSTRAINT_MUST_NOT_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is a numeric (integral or floating point) d...
Definition: Numeric.h:118
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 the RemoveAdaptor type trait.
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 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
#define BLAZE_CONSTRAINT_MUST_BE_ROW_MAJOR_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a row-major dense or sparse matrix t...
Definition: StorageOrder.h:81
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2477
Header file for run time assertion macros.
BLAZE_ALWAYS_INLINE void addAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the addition assignment of a matrix to a matrix.
Definition: Matrix.h:742
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_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
Header file for the isDefault shim.
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 the RemoveReference type trait.
Header file for the move shim.
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
#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.
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
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
BLAZE_ALWAYS_INLINE void subAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs)
Default implementation of the subtraction assignment of a matrix to matrix.
Definition: Matrix.h:849