Dense.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_STRICTLYUPPERMATRIX_DENSE_H_
36 #define _BLAZE_MATH_ADAPTORS_STRICTLYUPPERMATRIX_DENSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
57 #include <blaze/math/Intrinsics.h>
58 #include <blaze/math/shims/Clear.h>
60 #include <blaze/math/shims/Move.h>
70 #include <blaze/system/Inline.h>
71 #include <blaze/util/Assert.h>
77 #include <blaze/util/DisableIf.h>
78 #include <blaze/util/EnableIf.h>
79 #include <blaze/util/Exception.h>
80 #include <blaze/util/FalseType.h>
82 #include <blaze/util/TrueType.h>
83 #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
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 StrictlyUpperMatrix<MT,SO,true>
106  : public DenseMatrix< StrictlyUpperMatrix<MT,SO,true>, 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  typedef IntrinsicTrait<ET> IT;
114  //**********************************************************************************************
115 
116  public:
117  //**Type definitions****************************************************************************
118  typedef StrictlyUpperMatrix<MT,SO,true> This;
119  typedef This ResultType;
120  typedef StrictlyUpperMatrix<OT,!SO,true> OppositeType;
121  typedef StrictlyLowerMatrix<TT,!SO,true> TransposeType;
122  typedef ET ElementType;
123  typedef typename MT::IntrinsicType IntrinsicType;
124  typedef typename MT::ReturnType ReturnType;
125  typedef const This& CompositeType;
126  typedef StrictlyUpperProxy<MT> Reference;
127  typedef typename MT::ConstReference ConstReference;
128  typedef typename MT::Pointer Pointer;
129  typedef typename MT::ConstPointer ConstPointer;
130  typedef typename MT::ConstIterator ConstIterator;
131  //**********************************************************************************************
132 
133  //**Rebind struct definition********************************************************************
136  template< typename ET > // Data type of the other matrix
137  struct Rebind {
139  typedef StrictlyUpperMatrix< typename MT::template Rebind<ET>::Other > Other;
140  };
141  //**********************************************************************************************
142 
143  //**Iterator class definition*******************************************************************
146  class Iterator
147  {
148  public:
149  //**Type definitions*************************************************************************
150  typedef std::random_access_iterator_tag IteratorCategory;
151  typedef typename MT::ElementType ValueType;
152  typedef StrictlyUpperProxy<MT> PointerType;
153  typedef StrictlyUpperProxy<MT> ReferenceType;
154  typedef ptrdiff_t DifferenceType;
155 
156  // STL iterator requirements
157  typedef IteratorCategory iterator_category;
158  typedef ValueType value_type;
159  typedef PointerType pointer;
160  typedef ReferenceType reference;
161  typedef DifferenceType difference_type;
162  //*******************************************************************************************
163 
164  //**Constructor******************************************************************************
167  inline Iterator()
168  : matrix_( NULL ) // Reference to the adapted dense matrix
169  , row_ ( 0UL ) // The current row index of the iterator
170  , column_( 0UL ) // The current column index of the iterator
171  {}
172  //*******************************************************************************************
173 
174  //**Constructor******************************************************************************
181  inline Iterator( MT& matrix, size_t row, size_t column )
182  : matrix_( &matrix ) // Reference to the adapted dense matrix
183  , row_ ( row ) // The current row-index of the iterator
184  , column_( column ) // The current column-index of the iterator
185  {}
186  //*******************************************************************************************
187 
188  //**Addition assignment operator*************************************************************
194  inline Iterator& operator+=( size_t inc ) {
195  ( SO )?( row_ += inc ):( column_ += inc );
196  return *this;
197  }
198  //*******************************************************************************************
199 
200  //**Subtraction assignment operator**********************************************************
206  inline Iterator& operator-=( size_t dec ) {
207  ( SO )?( row_ -= dec ):( column_ -= dec );
208  return *this;
209  }
210  //*******************************************************************************************
211 
212  //**Prefix increment operator****************************************************************
217  inline Iterator& operator++() {
218  ( SO )?( ++row_ ):( ++column_ );
219  return *this;
220  }
221  //*******************************************************************************************
222 
223  //**Postfix increment operator***************************************************************
228  inline const Iterator operator++( int ) {
229  const Iterator tmp( *this );
230  ++(*this);
231  return tmp;
232  }
233  //*******************************************************************************************
234 
235  //**Prefix decrement operator****************************************************************
240  inline Iterator& operator--() {
241  ( SO )?( --row_ ):( --column_ );
242  return *this;
243  }
244  //*******************************************************************************************
245 
246  //**Postfix decrement operator***************************************************************
251  inline const Iterator operator--( int ) {
252  const Iterator tmp( *this );
253  --(*this);
254  return tmp;
255  }
256  //*******************************************************************************************
257 
258  //**Element access operator******************************************************************
263  inline ReferenceType operator*() const {
264  return ReferenceType( *matrix_, row_, column_ );
265  }
266  //*******************************************************************************************
267 
268  //**Element access operator******************************************************************
273  inline PointerType operator->() const {
274  return PointerType( *matrix_, row_, column_ );
275  }
276  //*******************************************************************************************
277 
278  //**Conversion operator**********************************************************************
283  inline operator ConstIterator() const {
284  if( SO )
285  return matrix_->begin( column_ ) + row_;
286  else
287  return matrix_->begin( row_ ) + column_;
288  }
289  //*******************************************************************************************
290 
291  //**Equality operator************************************************************************
298  friend inline bool operator==( const Iterator& lhs, const Iterator& rhs ) {
299  return ( SO )?( lhs.row_ == rhs.row_ ):( lhs.column_ == rhs.column_ );
300  }
301  //*******************************************************************************************
302 
303  //**Equality operator************************************************************************
310  friend inline bool operator==( const Iterator& lhs, const ConstIterator& rhs ) {
311  return ( ConstIterator( lhs ) == rhs );
312  }
313  //*******************************************************************************************
314 
315  //**Equality operator************************************************************************
322  friend inline bool operator==( const ConstIterator& lhs, const Iterator& rhs ) {
323  return ( lhs == ConstIterator( rhs ) );
324  }
325  //*******************************************************************************************
326 
327  //**Inequality operator**********************************************************************
334  friend inline bool operator!=( const Iterator& lhs, const Iterator& rhs ) {
335  return ( SO )?( lhs.row_ != rhs.row_ ):( lhs.column_ != rhs.column_ );
336  }
337  //*******************************************************************************************
338 
339  //**Inequality operator**********************************************************************
346  friend inline bool operator!=( const Iterator& lhs, const ConstIterator& rhs ) {
347  return ( ConstIterator( lhs ) != rhs );
348  }
349  //*******************************************************************************************
350 
351  //**Inequality operator**********************************************************************
358  friend inline bool operator!=( const ConstIterator& lhs, const Iterator& rhs ) {
359  return ( lhs != ConstIterator( rhs ) );
360  }
361  //*******************************************************************************************
362 
363  //**Less-than operator***********************************************************************
370  friend inline bool operator<( const Iterator& lhs, const Iterator& rhs ) {
371  return ( SO )?( lhs.row_ < rhs.row_ ):( lhs.column_ < rhs.column_ );
372  }
373  //*******************************************************************************************
374 
375  //**Less-than operator***********************************************************************
382  friend inline bool operator<( const Iterator& lhs, const ConstIterator& rhs ) {
383  return ( ConstIterator( lhs ) < rhs );
384  }
385  //*******************************************************************************************
386 
387  //**Less-than operator***********************************************************************
394  friend inline bool operator<( const ConstIterator& lhs, const Iterator& rhs ) {
395  return ( lhs < ConstIterator( rhs ) );
396  }
397  //*******************************************************************************************
398 
399  //**Greater-than operator********************************************************************
406  friend inline bool operator>( const Iterator& lhs, const Iterator& rhs ) {
407  return ( SO )?( lhs.row_ > rhs.row_ ):( lhs.column_ > rhs.column_ );
408  }
409  //*******************************************************************************************
410 
411  //**Greater-than operator********************************************************************
418  friend inline bool operator>( const Iterator& lhs, const ConstIterator& rhs ) {
419  return ( ConstIterator( lhs ) > rhs );
420  }
421  //*******************************************************************************************
422 
423  //**Greater-than operator********************************************************************
430  friend inline bool operator>( const ConstIterator& lhs, const Iterator& rhs ) {
431  return ( lhs > ConstIterator( rhs ) );
432  }
433  //*******************************************************************************************
434 
435  //**Less-or-equal-than operator**************************************************************
442  friend inline bool operator<=( const Iterator& lhs, const Iterator& rhs ) {
443  return ( SO )?( lhs.row_ <= rhs.row_ ):( lhs.column_ <= rhs.column_ );
444  }
445  //*******************************************************************************************
446 
447  //**Less-or-equal-than operator**************************************************************
454  friend inline bool operator<=( const Iterator& lhs, const ConstIterator& rhs ) {
455  return ( ConstIterator( lhs ) <= rhs );
456  }
457  //*******************************************************************************************
458 
459  //**Less-or-equal-than operator**************************************************************
466  friend inline bool operator<=( const ConstIterator& lhs, const Iterator& rhs ) {
467  return ( lhs <= ConstIterator( rhs ) );
468  }
469  //*******************************************************************************************
470 
471  //**Greater-or-equal-than operator***********************************************************
478  friend inline bool operator>=( const Iterator& lhs, const Iterator& rhs ) {
479  return ( SO )?( lhs.row_ >= rhs.row_ ):( lhs.column_ >= rhs.column_ );
480  }
481  //*******************************************************************************************
482 
483  //**Greater-or-equal-than operator***********************************************************
490  friend inline bool operator>=( const Iterator& lhs, const ConstIterator& rhs ) {
491  return ( ConstIterator( lhs ) >= rhs );
492  }
493  //*******************************************************************************************
494 
495  //**Greater-or-equal-than operator***********************************************************
502  friend inline bool operator>=( const ConstIterator& lhs, const Iterator& rhs ) {
503  return ( lhs >= ConstIterator( rhs ) );
504  }
505  //*******************************************************************************************
506 
507  //**Subtraction operator*********************************************************************
513  inline DifferenceType operator-( const Iterator& rhs ) const {
514  return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
515  }
516  //*******************************************************************************************
517 
518  //**Addition operator************************************************************************
525  friend inline const Iterator operator+( const Iterator& it, size_t inc ) {
526  if( SO )
527  return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
528  else
529  return Iterator( *it.matrix_, it.row_, it.column_ + inc );
530  }
531  //*******************************************************************************************
532 
533  //**Addition operator************************************************************************
540  friend inline const Iterator operator+( size_t inc, const Iterator& it ) {
541  if( SO )
542  return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
543  else
544  return Iterator( *it.matrix_, it.row_, it.column_ + inc );
545  }
546  //*******************************************************************************************
547 
548  //**Subtraction operator*********************************************************************
555  friend inline const Iterator operator-( const Iterator& it, size_t dec ) {
556  if( SO )
557  return Iterator( *it.matrix_, it.row_ - dec, it.column_ );
558  else
559  return Iterator( *it.matrix_, it.row_, it.column_ - dec );
560  }
561  //*******************************************************************************************
562 
563  private:
564  //**Member variables*************************************************************************
565  MT* matrix_;
566  size_t row_;
567  size_t column_;
568  //*******************************************************************************************
569  };
570  //**********************************************************************************************
571 
572  //**Compilation flags***************************************************************************
574  enum { vectorizable = MT::vectorizable };
575 
577  enum { smpAssignable = MT::smpAssignable };
578  //**********************************************************************************************
579 
580  //**Constructors********************************************************************************
583  explicit inline StrictlyUpperMatrix();
584  template< typename A1 > explicit inline StrictlyUpperMatrix( const A1& a1 );
585  explicit inline StrictlyUpperMatrix( size_t n, const ElementType& init );
586 
587  explicit inline StrictlyUpperMatrix( ElementType* ptr, size_t n );
588  explicit inline StrictlyUpperMatrix( ElementType* ptr, size_t n, size_t nn );
589 
590  template< typename Deleter >
591  explicit inline StrictlyUpperMatrix( ElementType* ptr, size_t n, Deleter d );
592 
593  template< typename Deleter >
594  explicit inline StrictlyUpperMatrix( ElementType* ptr, size_t n, size_t nn, Deleter d );
595 
596  inline StrictlyUpperMatrix( const StrictlyUpperMatrix& m );
598  //**********************************************************************************************
599 
600  //**Destructor**********************************************************************************
601  // No explicitly declared destructor.
602  //**********************************************************************************************
603 
604  //**Data access functions***********************************************************************
607  inline Reference operator()( size_t i, size_t j );
608  inline ConstReference operator()( size_t i, size_t j ) const;
609  inline Reference at( size_t i, size_t j );
610  inline ConstReference at( size_t i, size_t j ) const;
611  inline ConstPointer data () const;
612  inline ConstPointer data ( size_t i ) const;
613  inline Iterator begin ( size_t i );
614  inline ConstIterator begin ( size_t i ) const;
615  inline ConstIterator cbegin( size_t i ) const;
616  inline Iterator end ( size_t i );
617  inline ConstIterator end ( size_t i ) const;
618  inline ConstIterator cend ( size_t i ) const;
620  //**********************************************************************************************
621 
622  //**Assignment operators************************************************************************
625  inline StrictlyUpperMatrix& operator=( const ElementType& rhs );
626  inline StrictlyUpperMatrix& operator=( const StrictlyUpperMatrix& rhs );
627 
628  template< typename MT2, bool SO2 >
629  inline typename DisableIf< IsComputation<MT2>, StrictlyUpperMatrix& >::Type
630  operator=( const Matrix<MT2,SO2>& rhs );
631 
632  template< typename MT2, bool SO2 >
633  inline typename EnableIf< IsComputation<MT2>, StrictlyUpperMatrix& >::Type
634  operator=( const Matrix<MT2,SO2>& rhs );
635 
636  template< typename MT2, bool SO2 >
637  inline typename DisableIf< IsComputation<MT2>, StrictlyUpperMatrix& >::Type
638  operator+=( const Matrix<MT2,SO2>& rhs );
639 
640  template< typename MT2, bool SO2 >
641  inline typename EnableIf< IsComputation<MT2>, StrictlyUpperMatrix& >::Type
642  operator+=( const Matrix<MT2,SO2>& rhs );
643 
644  template< typename MT2, bool SO2 >
645  inline typename DisableIf< IsComputation<MT2>, StrictlyUpperMatrix& >::Type
646  operator-=( const Matrix<MT2,SO2>& rhs );
647 
648  template< typename MT2, bool SO2 >
649  inline typename EnableIf< IsComputation<MT2>, StrictlyUpperMatrix& >::Type
650  operator-=( const Matrix<MT2,SO2>& rhs );
651 
652  template< typename MT2, bool SO2 >
653  inline StrictlyUpperMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
654 
655  template< typename Other >
656  inline typename EnableIf< IsNumeric<Other>, StrictlyUpperMatrix >::Type&
657  operator*=( Other rhs );
658 
659  template< typename Other >
660  inline typename EnableIf< IsNumeric<Other>, StrictlyUpperMatrix >::Type&
661  operator/=( Other rhs );
663  //**********************************************************************************************
664 
665  //**Utility functions***************************************************************************
668  inline size_t rows() const;
669  inline size_t columns() const;
670  inline size_t spacing() const;
671  inline size_t capacity() const;
672  inline size_t capacity( size_t i ) const;
673  inline size_t nonZeros() const;
674  inline size_t nonZeros( size_t i ) const;
675  inline void reset();
676  inline void reset( size_t i );
677  inline void clear();
678  void resize ( size_t n, bool preserve=true );
679  inline void extend ( size_t n, bool preserve=true );
680  inline void reserve( size_t elements );
681 
682  template< typename Other > inline StrictlyUpperMatrix& scale( const Other& scalar );
683 
684  inline void swap( StrictlyUpperMatrix& m ) /* throw() */;
685 
686  static inline size_t maxNonZeros();
687  static inline size_t maxNonZeros( size_t n );
689  //**********************************************************************************************
690 
691  //**Debugging functions*************************************************************************
694  inline bool isIntact() const;
696  //**********************************************************************************************
697 
698  //**Expression template evaluation functions****************************************************
701  template< typename Other > inline bool canAlias ( const Other* alias ) const;
702  template< typename Other > inline bool isAliased( const Other* alias ) const;
703 
704  inline bool isAligned () const;
705  inline bool canSMPAssign() const;
706 
707  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t i, size_t j ) const;
708  BLAZE_ALWAYS_INLINE IntrinsicType loada( size_t i, size_t j ) const;
709  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t i, size_t j ) const;
711  //**********************************************************************************************
712 
713  private:
714  //**Construction functions**********************************************************************
717  inline const MT construct( size_t n , TrueType );
718  inline const MT construct( const ElementType& value, FalseType );
719 
720  template< typename MT2, bool SO2, typename T >
721  inline const MT construct( const Matrix<MT2,SO2>& m, T );
723  //**********************************************************************************************
724 
725  //**Member variables****************************************************************************
728  MT matrix_;
729 
730  //**********************************************************************************************
731 
732  //**Friend declarations*************************************************************************
733  template< typename MT2, bool SO2, bool DF2 >
734  friend MT2& derestrict( StrictlyUpperMatrix<MT2,SO2,DF2>& m );
735  //**********************************************************************************************
736 
737  //**Compile time checks*************************************************************************
750  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
751  //**********************************************************************************************
752 };
754 //*************************************************************************************************
755 
756 
757 
758 
759 //=================================================================================================
760 //
761 // CONSTRUCTORS
762 //
763 //=================================================================================================
764 
765 //*************************************************************************************************
769 template< typename MT // Type of the adapted dense matrix
770  , bool SO > // Storage order of the adapted dense matrix
771 inline StrictlyUpperMatrix<MT,SO,true>::StrictlyUpperMatrix()
772  : matrix_() // The adapted dense matrix
773 {
774  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
775  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
776 }
778 //*************************************************************************************************
779 
780 
781 //*************************************************************************************************
799 template< typename MT // Type of the adapted dense matrix
800  , bool SO > // Storage order of the adapted dense matrix
801 template< typename A1 > // Type of the constructor argument
802 inline StrictlyUpperMatrix<MT,SO,true>::StrictlyUpperMatrix( const A1& a1 )
803  : matrix_( construct( a1, typename IsResizable<MT>::Type() ) ) // The adapted dense matrix
804 {
805  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
806  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
807 }
809 //*************************************************************************************************
810 
811 
812 //*************************************************************************************************
819 template< typename MT // Type of the adapted dense matrix
820  , bool SO > // Storage order of the adapted dense matrix
821 inline StrictlyUpperMatrix<MT,SO,true>::StrictlyUpperMatrix( size_t n, const ElementType& init )
822  : matrix_( n, n, ElementType() ) // The adapted dense matrix
823 {
825 
826  if( SO ) {
827  for( size_t j=0UL; j<columns(); ++j ) {
828  for( size_t i=0UL; i<j; ++i )
829  matrix_(i,j) = init;
830  }
831  }
832  else {
833  for( size_t i=0UL; i<rows(); ++i ) {
834  for( size_t j=i+1UL; j<columns(); ++j )
835  matrix_(i,j) = init;
836  }
837  }
838 
839  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
840  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
841 }
843 //*************************************************************************************************
844 
845 
846 //*************************************************************************************************
868 template< typename MT // Type of the adapted dense matrix
869  , bool SO > // Storage order of the adapted dense matrix
870 inline StrictlyUpperMatrix<MT,SO,true>::StrictlyUpperMatrix( ElementType* ptr, size_t n )
871  : matrix_( ptr, n, n ) // The adapted dense matrix
872 {
873  if( !isStrictlyUpper( matrix_ ) ) {
874  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly upper matrix" );
875  }
876 
877  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
878 }
880 //*************************************************************************************************
881 
882 
883 //*************************************************************************************************
906 template< typename MT // Type of the adapted dense matrix
907  , bool SO > // Storage order of the adapted dense matrix
908 inline StrictlyUpperMatrix<MT,SO,true>::StrictlyUpperMatrix( ElementType* ptr, size_t n, size_t nn )
909  : matrix_( ptr, n, n, nn ) // The adapted dense matrix
910 {
911  if( !isStrictlyUpper( matrix_ ) ) {
912  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly upper matrix" );
913  }
914 
915  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
916 }
918 //*************************************************************************************************
919 
920 
921 //*************************************************************************************************
942 template< typename MT // Type of the adapted dense matrix
943  , bool SO > // Storage order of the adapted dense matrix
944 template< typename Deleter > // Type of the custom deleter
945 inline StrictlyUpperMatrix<MT,SO,true>::StrictlyUpperMatrix( ElementType* ptr, size_t n, Deleter d )
946  : matrix_( ptr, n, n, d ) // The adapted dense matrix
947 {
948  if( !isStrictlyUpper( matrix_ ) ) {
949  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly upper matrix" );
950  }
951 
952  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
953 }
955 //*************************************************************************************************
956 
957 
958 //*************************************************************************************************
980 template< typename MT // Type of the adapted dense matrix
981  , bool SO > // Storage order of the adapted dense matrix
982 template< typename Deleter > // Type of the custom deleter
983 inline StrictlyUpperMatrix<MT,SO,true>::StrictlyUpperMatrix( ElementType* ptr, size_t n, size_t nn, Deleter d )
984  : matrix_( ptr, n, n, nn, d ) // The adapted dense matrix
985 {
986  if( !isStrictlyUpper( matrix_ ) ) {
987  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly upper matrix" );
988  }
989 
990  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
991 }
993 //*************************************************************************************************
994 
995 
996 //*************************************************************************************************
1002 template< typename MT // Type of the adapted dense matrix
1003  , bool SO > // Storage order of the adapted dense matrix
1004 inline StrictlyUpperMatrix<MT,SO,true>::StrictlyUpperMatrix( const StrictlyUpperMatrix& m )
1005  : matrix_( m.matrix_ ) // The adapted dense matrix
1006 {
1007  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1008  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1009 }
1011 //*************************************************************************************************
1012 
1013 
1014 
1015 
1016 //=================================================================================================
1017 //
1018 // DATA ACCESS FUNCTIONS
1019 //
1020 //=================================================================================================
1021 
1022 //*************************************************************************************************
1038 template< typename MT // Type of the adapted dense matrix
1039  , bool SO > // Storage order of the adapted dense matrix
1041  StrictlyUpperMatrix<MT,SO,true>::operator()( size_t i, size_t j )
1042 {
1043  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1044  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1045 
1046  return Reference( matrix_, i, j );
1047 }
1049 //*************************************************************************************************
1050 
1051 
1052 //*************************************************************************************************
1068 template< typename MT // Type of the adapted dense matrix
1069  , bool SO > // Storage order of the adapted dense matrix
1071  StrictlyUpperMatrix<MT,SO,true>::operator()( size_t i, size_t j ) const
1072 {
1073  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1074  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1075 
1076  return matrix_(i,j);
1077 }
1079 //*************************************************************************************************
1080 
1081 
1082 //*************************************************************************************************
1099 template< typename MT // Type of the adapted dense matrix
1100  , bool SO > // Storage order of the adapted dense matrix
1102  StrictlyUpperMatrix<MT,SO,true>::at( size_t i, size_t j )
1103 {
1104  if( i >= rows() ) {
1105  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1106  }
1107  if( j >= columns() ) {
1108  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1109  }
1110  return (*this)(i,j);
1111 }
1113 //*************************************************************************************************
1114 
1115 
1116 //*************************************************************************************************
1133 template< typename MT // Type of the adapted dense matrix
1134  , bool SO > // Storage order of the adapted dense matrix
1136  StrictlyUpperMatrix<MT,SO,true>::at( size_t i, size_t j ) const
1137 {
1138  if( i >= rows() ) {
1139  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1140  }
1141  if( j >= columns() ) {
1142  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1143  }
1144  return (*this)(i,j);
1145 }
1147 //*************************************************************************************************
1148 
1149 
1150 //*************************************************************************************************
1163 template< typename MT // Type of the adapted dense matrix
1164  , bool SO > // Storage order of the adapted dense matrix
1165 inline typename StrictlyUpperMatrix<MT,SO,true>::ConstPointer
1166  StrictlyUpperMatrix<MT,SO,true>::data() const
1167 {
1168  return matrix_.data();
1169 }
1171 //*************************************************************************************************
1172 
1173 
1174 //*************************************************************************************************
1183 template< typename MT // Type of the adapted dense matrix
1184  , bool SO > // Storage order of the adapted dense matrix
1185 inline typename StrictlyUpperMatrix<MT,SO,true>::ConstPointer
1186  StrictlyUpperMatrix<MT,SO,true>::data( size_t i ) const
1187 {
1188  return matrix_.data(i);
1189 }
1191 //*************************************************************************************************
1192 
1193 
1194 //*************************************************************************************************
1206 template< typename MT // Type of the adapted dense matrix
1207  , bool SO > // Storage order of the adapted dense matrix
1210 {
1211  if( SO )
1212  return Iterator( matrix_, 0UL, i );
1213  else
1214  return Iterator( matrix_, i, 0UL );
1215 }
1217 //*************************************************************************************************
1218 
1219 
1220 //*************************************************************************************************
1232 template< typename MT // Type of the adapted dense matrix
1233  , bool SO > // Storage order of the adapted dense matrix
1235  StrictlyUpperMatrix<MT,SO,true>::begin( size_t i ) const
1236 {
1237  return matrix_.begin(i);
1238 }
1240 //*************************************************************************************************
1241 
1242 
1243 //*************************************************************************************************
1255 template< typename MT // Type of the adapted dense matrix
1256  , bool SO > // Storage order of the adapted dense matrix
1258  StrictlyUpperMatrix<MT,SO,true>::cbegin( size_t i ) const
1259 {
1260  return matrix_.cbegin(i);
1261 }
1263 //*************************************************************************************************
1264 
1265 
1266 //*************************************************************************************************
1278 template< typename MT // Type of the adapted dense matrix
1279  , bool SO > // Storage order of the adapted dense matrix
1282 {
1283  if( SO )
1284  return Iterator( matrix_, rows(), i );
1285  else
1286  return Iterator( matrix_, i, columns() );
1287 }
1289 //*************************************************************************************************
1290 
1291 
1292 //*************************************************************************************************
1304 template< typename MT // Type of the adapted dense matrix
1305  , bool SO > // Storage order of the adapted dense matrix
1307  StrictlyUpperMatrix<MT,SO,true>::end( size_t i ) const
1308 {
1309  return matrix_.end(i);
1310 }
1312 //*************************************************************************************************
1313 
1314 
1315 //*************************************************************************************************
1327 template< typename MT // Type of the adapted dense matrix
1328  , bool SO > // Storage order of the adapted dense matrix
1330  StrictlyUpperMatrix<MT,SO,true>::cend( size_t i ) const
1331 {
1332  return matrix_.cend(i);
1333 }
1335 //*************************************************************************************************
1336 
1337 
1338 
1339 
1340 //=================================================================================================
1341 //
1342 // ASSIGNMENT OPERATORS
1343 //
1344 //=================================================================================================
1345 
1346 //*************************************************************************************************
1353 template< typename MT // Type of the adapted dense matrix
1354  , bool SO > // Storage order of the adapted dense matrix
1355 inline StrictlyUpperMatrix<MT,SO,true>&
1356  StrictlyUpperMatrix<MT,SO,true>::operator=( const ElementType& rhs )
1357 {
1358  if( SO ) {
1359  for( size_t j=1UL; j<columns(); ++j )
1360  for( size_t i=0UL; i<j; ++i )
1361  matrix_(i,j) = rhs;
1362  }
1363  else {
1364  for( size_t i=0UL; i<rows(); ++i )
1365  for( size_t j=i+1UL; j<columns(); ++j )
1366  matrix_(i,j) = rhs;
1367  }
1368 
1369  return *this;
1370 }
1372 //*************************************************************************************************
1373 
1374 
1375 //*************************************************************************************************
1385 template< typename MT // Type of the adapted dense matrix
1386  , bool SO > // Storage order of the adapted dense matrix
1387 inline StrictlyUpperMatrix<MT,SO,true>&
1388  StrictlyUpperMatrix<MT,SO,true>::operator=( const StrictlyUpperMatrix& rhs )
1389 {
1390  matrix_ = rhs.matrix_;
1391 
1392  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1393  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1394 
1395  return *this;
1396 }
1398 //*************************************************************************************************
1399 
1400 
1401 //*************************************************************************************************
1414 template< typename MT // Type of the adapted dense matrix
1415  , bool SO > // Storage order of the adapted dense matrix
1416 template< typename MT2 // Type of the right-hand side matrix
1417  , bool SO2 > // Storage order of the right-hand side matrix
1418 inline typename DisableIf< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,true>& >::Type
1419  StrictlyUpperMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1420 {
1421  if( IsUniTriangular<MT2>::value ||
1422  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
1423  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1424  }
1425 
1426  matrix_ = ~rhs;
1427 
1428  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1429  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1430 
1431  return *this;
1432 }
1434 //*************************************************************************************************
1435 
1436 
1437 //*************************************************************************************************
1450 template< typename MT // Type of the adapted dense matrix
1451  , bool SO > // Storage order of the adapted dense matrix
1452 template< typename MT2 // Type of the right-hand side matrix
1453  , bool SO2 > // Storage order of the right-hand side matrix
1454 inline typename EnableIf< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,true>& >::Type
1455  StrictlyUpperMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1456 {
1457  if( IsUniTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1458  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1459  }
1460 
1461  if( IsStrictlyUpper<MT2>::value ) {
1462  matrix_ = ~rhs;
1463  }
1464  else {
1465  MT tmp( ~rhs );
1466 
1467  if( !isStrictlyUpper( tmp ) ) {
1468  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1469  }
1470 
1471  move( matrix_, tmp );
1472  }
1473 
1474  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1475  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1476 
1477  return *this;
1478 }
1480 //*************************************************************************************************
1481 
1482 
1483 //*************************************************************************************************
1496 template< typename MT // Type of the adapted dense matrix
1497  , bool SO > // Storage order of the adapted dense matrix
1498 template< typename MT2 // Type of the right-hand side matrix
1499  , bool SO2 > // Storage order of the right-hand side matrix
1500 inline typename DisableIf< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,true>& >::Type
1501  StrictlyUpperMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1502 {
1503  if( IsUniTriangular<MT2>::value ||
1504  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
1505  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1506  }
1507 
1508  matrix_ += ~rhs;
1509 
1510  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1511  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1512 
1513  return *this;
1514 }
1516 //*************************************************************************************************
1517 
1518 
1519 //*************************************************************************************************
1532 template< typename MT // Type of the adapted dense matrix
1533  , bool SO > // Storage order of the adapted dense matrix
1534 template< typename MT2 // Type of the right-hand side matrix
1535  , bool SO2 > // Storage order of the right-hand side matrix
1536 inline typename EnableIf< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,true>& >::Type
1537  StrictlyUpperMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1538 {
1539  if( IsUniTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1540  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1541  }
1542 
1543  if( IsStrictlyUpper<MT2>::value ) {
1544  matrix_ += ~rhs;
1545  }
1546  else {
1547  typename MT2::ResultType tmp( ~rhs );
1548 
1549  if( !isStrictlyUpper( tmp ) ) {
1550  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1551  }
1552 
1553  matrix_ += tmp;
1554  }
1555 
1556  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1557  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1558 
1559  return *this;
1560 }
1562 //*************************************************************************************************
1563 
1564 
1565 //*************************************************************************************************
1578 template< typename MT // Type of the adapted dense matrix
1579  , bool SO > // Storage order of the adapted dense matrix
1580 template< typename MT2 // Type of the right-hand side matrix
1581  , bool SO2 > // Storage order of the right-hand side matrix
1582 inline typename DisableIf< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,true>& >::Type
1583  StrictlyUpperMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1584 {
1585  if( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) {
1586  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1587  }
1588 
1589  matrix_ -= ~rhs;
1590 
1591  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1592  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1593 
1594  return *this;
1595 }
1597 //*************************************************************************************************
1598 
1599 
1600 //*************************************************************************************************
1613 template< typename MT // Type of the adapted dense matrix
1614  , bool SO > // Storage order of the adapted dense matrix
1615 template< typename MT2 // Type of the right-hand side matrix
1616  , bool SO2 > // Storage order of the right-hand side matrix
1617 inline typename EnableIf< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,true>& >::Type
1618  StrictlyUpperMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1619 {
1620  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1621  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1622  }
1623 
1624  if( IsStrictlyUpper<MT2>::value ) {
1625  matrix_ -= ~rhs;
1626  }
1627  else {
1628  typename MT2::ResultType tmp( ~rhs );
1629 
1630  if( !isStrictlyUpper( tmp ) ) {
1631  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1632  }
1633 
1634  matrix_ -= tmp;
1635  }
1636 
1637  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1638  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1639 
1640  return *this;
1641 }
1643 //*************************************************************************************************
1644 
1645 
1646 //*************************************************************************************************
1658 template< typename MT // Type of the adapted dense matrix
1659  , bool SO > // Storage order of the adapted dense matrix
1660 template< typename MT2 // Type of the right-hand side matrix
1661  , bool SO2 > // Storage order of the right-hand side matrix
1662 inline StrictlyUpperMatrix<MT,SO,true>&
1663  StrictlyUpperMatrix<MT,SO,true>::operator*=( const Matrix<MT2,SO2>& rhs )
1664 {
1665  if( matrix_.rows() != (~rhs).columns() ) {
1666  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1667  }
1668 
1669  MT tmp( matrix_ * ~rhs );
1670 
1671  if( !isStrictlyUpper( tmp ) ) {
1672  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1673  }
1674 
1675  move( matrix_, tmp );
1676 
1677  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1678  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1679 
1680  return *this;
1681 }
1683 //*************************************************************************************************
1684 
1685 
1686 //*************************************************************************************************
1694 template< typename MT // Type of the adapted dense matrix
1695  , bool SO > // Storage order of the adapted dense matrix
1696 template< typename Other > // Data type of the right-hand side scalar
1697 inline typename EnableIf< IsNumeric<Other>, StrictlyUpperMatrix<MT,SO,true> >::Type&
1698  StrictlyUpperMatrix<MT,SO,true>::operator*=( Other rhs )
1699 {
1700  matrix_ *= rhs;
1701  return *this;
1702 }
1703 //*************************************************************************************************
1704 
1705 
1706 //*************************************************************************************************
1714 template< typename MT // Type of the adapted dense matrix
1715  , bool SO > // Storage order of the adapted dense matrix
1716 template< typename Other > // Data type of the right-hand side scalar
1717 inline typename EnableIf< IsNumeric<Other>, StrictlyUpperMatrix<MT,SO,true> >::Type&
1718  StrictlyUpperMatrix<MT,SO,true>::operator/=( Other rhs )
1719 {
1720  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1721 
1722  matrix_ /= rhs;
1723  return *this;
1724 }
1726 //*************************************************************************************************
1727 
1728 
1729 
1730 
1731 //=================================================================================================
1732 //
1733 // UTILITY FUNCTIONS
1734 //
1735 //=================================================================================================
1736 
1737 //*************************************************************************************************
1743 template< typename MT // Type of the adapted dense matrix
1744  , bool SO > // Storage order of the adapted dense matrix
1745 inline size_t StrictlyUpperMatrix<MT,SO,true>::rows() const
1746 {
1747  return matrix_.rows();
1748 }
1750 //*************************************************************************************************
1751 
1752 
1753 //*************************************************************************************************
1759 template< typename MT // Type of the adapted dense matrix
1760  , bool SO > // Storage order of the adapted dense matrix
1761 inline size_t StrictlyUpperMatrix<MT,SO,true>::columns() const
1762 {
1763  return matrix_.columns();
1764 }
1766 //*************************************************************************************************
1767 
1768 
1769 //*************************************************************************************************
1780 template< typename MT // Type of the adapted dense matrix
1781  , bool SO > // Storage order of the adapted dense matrix
1782 inline size_t StrictlyUpperMatrix<MT,SO,true>::spacing() const
1783 {
1784  return matrix_.spacing();
1785 }
1787 //*************************************************************************************************
1788 
1789 
1790 //*************************************************************************************************
1796 template< typename MT // Type of the adapted dense matrix
1797  , bool SO > // Storage order of the adapted dense matrix
1798 inline size_t StrictlyUpperMatrix<MT,SO,true>::capacity() const
1799 {
1800  return matrix_.capacity();
1801 }
1803 //*************************************************************************************************
1804 
1805 
1806 //*************************************************************************************************
1818 template< typename MT // Type of the adapted dense matrix
1819  , bool SO > // Storage order of the adapted dense matrix
1820 inline size_t StrictlyUpperMatrix<MT,SO,true>::capacity( size_t i ) const
1821 {
1822  return matrix_.capacity(i);
1823 }
1825 //*************************************************************************************************
1826 
1827 
1828 //*************************************************************************************************
1834 template< typename MT // Type of the adapted dense matrix
1835  , bool SO > // Storage order of the adapted dense matrix
1836 inline size_t StrictlyUpperMatrix<MT,SO,true>::nonZeros() const
1837 {
1838  return matrix_.nonZeros();
1839 }
1841 //*************************************************************************************************
1842 
1843 
1844 //*************************************************************************************************
1856 template< typename MT // Type of the adapted dense matrix
1857  , bool SO > // Storage order of the adapted dense matrix
1858 inline size_t StrictlyUpperMatrix<MT,SO,true>::nonZeros( size_t i ) const
1859 {
1860  return matrix_.nonZeros(i);
1861 }
1863 //*************************************************************************************************
1864 
1865 
1866 //*************************************************************************************************
1872 template< typename MT // Type of the adapted dense matrix
1873  , bool SO > // Storage order of the adapted dense matrix
1875 {
1876  using blaze::clear;
1877 
1878  if( SO ) {
1879  for( size_t j=1UL; j<columns(); ++j )
1880  for( size_t i=0UL; i<j; ++i )
1881  clear( matrix_(i,j) );
1882  }
1883  else {
1884  for( size_t i=0UL; i<rows(); ++i )
1885  for( size_t j=i+1UL; j<columns(); ++j )
1886  clear( matrix_(i,j) );
1887  }
1888 }
1890 //*************************************************************************************************
1891 
1892 
1893 //*************************************************************************************************
1906 template< typename MT // Type of the adapted dense matrix
1907  , bool SO > // Storage order of the adapted dense matrix
1908 inline void StrictlyUpperMatrix<MT,SO,true>::reset( size_t i )
1909 {
1910  using blaze::clear;
1911 
1912  if( SO ) {
1913  for( size_t j=0UL; j<i; ++j )
1914  clear( matrix_(j,i) );
1915  }
1916  else {
1917  for( size_t j=i+1UL; j<columns(); ++j )
1918  clear( matrix_(i,j) );
1919  }
1920 }
1922 //*************************************************************************************************
1923 
1924 
1925 //*************************************************************************************************
1937 template< typename MT // Type of the adapted dense matrix
1938  , bool SO > // Storage order of the adapted dense matrix
1940 {
1941  using blaze::clear;
1942 
1943  if( IsResizable<MT>::value ) {
1944  clear( matrix_ );
1945  }
1946  else {
1947  reset();
1948  }
1949 }
1951 //*************************************************************************************************
1952 
1953 
1954 //*************************************************************************************************
1990 template< typename MT // Type of the adapted dense matrix
1991  , bool SO > // Storage order of the adapted dense matrix
1992 void StrictlyUpperMatrix<MT,SO,true>::resize( size_t n, bool preserve )
1993 {
1995 
1996  UNUSED_PARAMETER( preserve );
1997 
1998  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1999 
2000  const size_t oldsize( matrix_.rows() );
2001 
2002  matrix_.resize( n, n, true );
2003 
2004  if( n > oldsize )
2005  {
2006  const size_t increment( n - oldsize );
2007  submatrix( matrix_, oldsize, 0UL, increment, n ).reset();
2008  }
2009 }
2011 //*************************************************************************************************
2012 
2013 
2014 //*************************************************************************************************
2027 template< typename MT // Type of the adapted dense matrix
2028  , bool SO > // Storage order of the adapted dense matrix
2029 inline void StrictlyUpperMatrix<MT,SO,true>::extend( size_t n, bool preserve )
2030 {
2032 
2033  UNUSED_PARAMETER( preserve );
2034 
2035  resize( rows() + n, true );
2036 }
2037 //*************************************************************************************************
2038 
2039 
2040 //*************************************************************************************************
2050 template< typename MT // Type of the adapted dense matrix
2051  , bool SO > // Storage order of the adapted dense matrix
2052 inline void StrictlyUpperMatrix<MT,SO,true>::reserve( size_t elements )
2053 {
2054  matrix_.reserve( elements );
2055 }
2057 //*************************************************************************************************
2058 
2059 
2060 //*************************************************************************************************
2067 template< typename MT // Type of the adapted dense matrix
2068  , bool SO > // Storage order of the adapted dense matrix
2069 template< typename Other > // Data type of the scalar value
2070 inline StrictlyUpperMatrix<MT,SO,true>&
2071  StrictlyUpperMatrix<MT,SO,true>::scale( const Other& scalar )
2072 {
2073  matrix_.scale( scalar );
2074  return *this;
2075 }
2077 //*************************************************************************************************
2078 
2079 
2080 //*************************************************************************************************
2088 template< typename MT // Type of the adapted dense matrix
2089  , bool SO > // Storage order of the adapted dense matrix
2090 inline void StrictlyUpperMatrix<MT,SO,true>::swap( StrictlyUpperMatrix& m ) /* throw() */
2091 {
2092  using std::swap;
2093 
2094  swap( matrix_, m.matrix_ );
2095 }
2097 //*************************************************************************************************
2098 
2099 
2100 //*************************************************************************************************
2112 template< typename MT // Type of the adapted dense matrix
2113  , bool SO > // Storage order of the adapted dense matrix
2114 inline size_t StrictlyUpperMatrix<MT,SO,true>::maxNonZeros()
2115 {
2117 
2118  return maxNonZeros( Rows<MT>::value );
2119 }
2121 //*************************************************************************************************
2122 
2123 
2124 //*************************************************************************************************
2134 template< typename MT // Type of the adapted dense matrix
2135  , bool SO > // Storage order of the adapted dense matrix
2136 inline size_t StrictlyUpperMatrix<MT,SO,true>::maxNonZeros( size_t n )
2137 {
2138  return ( ( n - 1UL ) * n ) / 2UL;
2139 }
2141 //*************************************************************************************************
2142 
2143 
2144 
2145 
2146 //=================================================================================================
2147 //
2148 // DEBUGGING FUNCTIONS
2149 //
2150 //=================================================================================================
2151 
2152 //*************************************************************************************************
2162 template< typename MT // Type of the adapted dense matrix
2163  , bool SO > // Storage order of the adapted dense matrix
2165 {
2166  using blaze::isIntact;
2167 
2168  return ( isIntact( matrix_ ) && isStrictlyUpper( matrix_ ) );
2169 }
2171 //*************************************************************************************************
2172 
2173 
2174 
2175 
2176 //=================================================================================================
2177 //
2178 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2179 //
2180 //=================================================================================================
2181 
2182 //*************************************************************************************************
2193 template< typename MT // Type of the adapted dense matrix
2194  , bool SO > // Storage order of the adapted dense matrix
2195 template< typename Other > // Data type of the foreign expression
2196 inline bool StrictlyUpperMatrix<MT,SO,true>::canAlias( const Other* alias ) const
2197 {
2198  return matrix_.canAlias( alias );
2199 }
2201 //*************************************************************************************************
2202 
2203 
2204 //*************************************************************************************************
2215 template< typename MT // Type of the adapted dense matrix
2216  , bool SO > // Storage order of the adapted dense matrix
2217 template< typename Other > // Data type of the foreign expression
2218 inline bool StrictlyUpperMatrix<MT,SO,true>::isAliased( const Other* alias ) const
2219 {
2220  return matrix_.isAliased( alias );
2221 }
2223 //*************************************************************************************************
2224 
2225 
2226 //*************************************************************************************************
2236 template< typename MT // Type of the adapted dense matrix
2237  , bool SO > // Storage order of the adapted dense matrix
2238 inline bool StrictlyUpperMatrix<MT,SO,true>::isAligned() const
2239 {
2240  return matrix_.isAligned();
2241 }
2243 //*************************************************************************************************
2244 
2245 
2246 //*************************************************************************************************
2257 template< typename MT // Type of the adapted dense matrix
2258  , bool SO > // Storage order of the adapted dense matrix
2259 inline bool StrictlyUpperMatrix<MT,SO,true>::canSMPAssign() const
2260 {
2261  return matrix_.canSMPAssign();
2262 }
2264 //*************************************************************************************************
2265 
2266 
2267 //*************************************************************************************************
2283 template< typename MT // Type of the adapted dense matrix
2284  , bool SO > // Storage order of the adapted dense matrix
2285 BLAZE_ALWAYS_INLINE typename StrictlyUpperMatrix<MT,SO,true>::IntrinsicType
2286  StrictlyUpperMatrix<MT,SO,true>::load( size_t i, size_t j ) const
2287 {
2288  return matrix_.load( i, j );
2289 }
2291 //*************************************************************************************************
2292 
2293 
2294 //*************************************************************************************************
2310 template< typename MT // Type of the adapted dense matrix
2311  , bool SO > // Storage order of the adapted dense matrix
2312 BLAZE_ALWAYS_INLINE typename StrictlyUpperMatrix<MT,SO,true>::IntrinsicType
2313  StrictlyUpperMatrix<MT,SO,true>::loada( size_t i, size_t j ) const
2314 {
2315  return matrix_.loada( i, j );
2316 }
2318 //*************************************************************************************************
2319 
2320 
2321 //*************************************************************************************************
2337 template< typename MT // Type of the adapted dense matrix
2338  , bool SO > // Storage order of the adapted dense matrix
2339 BLAZE_ALWAYS_INLINE typename StrictlyUpperMatrix<MT,SO,true>::IntrinsicType
2340  StrictlyUpperMatrix<MT,SO,true>::loadu( size_t i, size_t j ) const
2341 {
2342  return matrix_.loadu( i, j );
2343 }
2345 //*************************************************************************************************
2346 
2347 
2348 
2349 
2350 //=================================================================================================
2351 //
2352 // CONSTRUCTION FUNCTIONS
2353 //
2354 //=================================================================================================
2355 
2356 //*************************************************************************************************
2363 template< typename MT // Type of the adapted dense matrix
2364  , bool SO > // Storage order of the adapted dense matrix
2365 inline const MT StrictlyUpperMatrix<MT,SO,true>::construct( size_t n, TrueType )
2366 {
2368 
2369  return MT( n, n, ElementType() );
2370 }
2372 //*************************************************************************************************
2373 
2374 
2375 //*************************************************************************************************
2382 template< typename MT // Type of the adapted dense matrix
2383  , bool SO > // Storage order of the adapted dense matrix
2384 inline const MT StrictlyUpperMatrix<MT,SO,true>::construct( const ElementType& init, FalseType )
2385 {
2388 
2389  MT tmp;
2390 
2391  if( SO ) {
2392  for( size_t j=0UL; j<columns(); ++j ) {
2393  for( size_t i=0UL; i<j; ++i )
2394  tmp(i,j) = init;
2395  }
2396  }
2397  else {
2398  for( size_t i=0UL; i<rows(); ++i ) {
2399  for( size_t j=i+1UL; j<columns(); ++j )
2400  tmp(i,j) = init;
2401  }
2402  }
2403 
2404  return tmp;
2405 }
2407 //*************************************************************************************************
2408 
2409 
2410 //*************************************************************************************************
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 foreign matrix
2424  , bool SO2 // Storage order of the foreign matrix
2425  , typename T > // Type of the third argument
2426 inline const MT StrictlyUpperMatrix<MT,SO,true>::construct( const Matrix<MT2,SO2>& m, T )
2427 {
2428  const MT tmp( ~m );
2429 
2430  if( IsUniTriangular<MT2>::value ||
2431  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( tmp ) ) ) {
2432  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly upper matrix" );
2433  }
2434 
2435  return tmp;
2436 }
2438 //*************************************************************************************************
2439 
2440 } // namespace blaze
2441 
2442 #endif
Header file for the StrictlyUpperProxy class.
Constraint on the data type.
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
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the Rows type trait.
Header file for the UNUSED_PARAMETER function template.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7820
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix)
Checks if the given matrix is a square matrix.
Definition: Matrix.h:603
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:229
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:292
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:250
bool isStrictlyUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly upper triangular matrix.
Definition: DenseMatrix.h:1434
Header file for the FalseType type/value trait base class.
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:81
#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.
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:340
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:4926
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:107
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:2582
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:378
#define BLAZE_CONSTRAINT_MUST_BE_SQUARE(T)
Constraint on the data type.In case the given data type T is not a square matrix type, a compilation error is created.
Definition: Square.h:78
void move(CustomMatrix< Type, AF, PF, SO > &dst, CustomMatrix< Type, AF, PF, SO > &src)
Moving the contents of one custom matrix to another.
Definition: CustomMatrix.h:6085
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2584
Constraint on the data type.
Constraint on the data type.
Header file for the IsSquare type trait.
Constraint on the data type.
Constraint on the data type.
Header file for the DenseSubmatrix class template.
Header file for the DisableIf class template.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type loadu(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loadu.h:74
Header file for the IsStrictlyUpper type trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
Compile time assertion.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4998
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:4980
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:116
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:610
Header file for the DenseMatrix base class.
Header file for the Columns type trait.
Constraint on the data type.
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:642
Header file for the IsUniTriangular type trait.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2585
Constraints on the storage order of matrix types.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:118
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:187
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:532
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2590
Header file for the EnableIf class template.
Header file for utility functions for dense matrices.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:527
Header file for the implementation of the base template of the StrictlyUpperMatrix.
Header file for all adaptor forward declarations.
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:107
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type loada(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loada.h:77
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:116
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:118
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2591
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_RESIZABLE(T)
Constraint on the data type.In case the given data type T is resizable, i.e. has a 'resize' member fu...
Definition: Resizable.h:118
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:256
Header file for all intrinsic functionality.
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:146
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
Header file for the IsComputation type trait class.
boost::false_type FalseType
Type/value traits base class.The FalseType class is used as base class for type traits and value trai...
Definition: FalseType.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:118
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:237
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2589
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:116
Header file for exception macros.
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:143
Header file for the IsResizable type trait.
System settings for the inline keywords.
#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 the TrueType type/value trait base class.