Dense.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_UNIUPPERMATRIX_DENSE_H_
36 #define _BLAZE_MATH_ADAPTORS_UNIUPPERMATRIX_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>
73 #include <blaze/system/Inline.h>
74 #include <blaze/util/Assert.h>
81 #include <blaze/util/DisableIf.h>
82 #include <blaze/util/EnableIf.h>
83 #include <blaze/util/Exception.h>
84 #include <blaze/util/FalseType.h>
86 #include <blaze/util/TrueType.h>
87 #include <blaze/util/Types.h>
88 #include <blaze/util/Unused.h>
89 
90 
91 namespace blaze {
92 
93 //=================================================================================================
94 //
95 // CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES
96 //
97 //=================================================================================================
98 
99 //*************************************************************************************************
107 template< typename MT // Type of the adapted dense matrix
108  , bool SO > // Storage order of the adapted dense matrix
109 class UniUpperMatrix<MT,SO,true>
110  : public DenseMatrix< UniUpperMatrix<MT,SO,true>, SO >
111 {
112  private:
113  //**Type definitions****************************************************************************
114  typedef typename MT::OppositeType OT;
115  typedef typename MT::TransposeType TT;
116  typedef typename MT::ElementType ET;
117  typedef IntrinsicTrait<ET> IT;
118  //**********************************************************************************************
119 
120  public:
121  //**Type definitions****************************************************************************
122  typedef UniUpperMatrix<MT,SO,true> This;
123  typedef This ResultType;
124  typedef UniUpperMatrix<OT,!SO,true> OppositeType;
125  typedef UniLowerMatrix<TT,!SO,true> TransposeType;
126  typedef ET ElementType;
127  typedef typename MT::IntrinsicType IntrinsicType;
128  typedef typename MT::ReturnType ReturnType;
129  typedef const This& CompositeType;
130  typedef UniUpperProxy<MT> Reference;
131  typedef typename MT::ConstReference ConstReference;
132  typedef typename MT::Pointer Pointer;
133  typedef typename MT::ConstPointer ConstPointer;
134  typedef typename MT::ConstIterator ConstIterator;
135  //**********************************************************************************************
136 
137  //**Rebind struct definition********************************************************************
140  template< typename ET > // Data type of the other matrix
141  struct Rebind {
143  typedef UniUpperMatrix< typename MT::template Rebind<ET>::Other > Other;
144  };
145  //**********************************************************************************************
146 
147  //**Iterator class definition*******************************************************************
150  class Iterator
151  {
152  public:
153  //**Type definitions*************************************************************************
154  typedef std::random_access_iterator_tag IteratorCategory;
155  typedef typename MT::ElementType ValueType;
156  typedef UniUpperProxy<MT> PointerType;
157  typedef UniUpperProxy<MT> ReferenceType;
158  typedef ptrdiff_t DifferenceType;
159 
160  // STL iterator requirements
161  typedef IteratorCategory iterator_category;
162  typedef ValueType value_type;
163  typedef PointerType pointer;
164  typedef ReferenceType reference;
165  typedef DifferenceType difference_type;
166  //*******************************************************************************************
167 
168  //**Constructor******************************************************************************
171  inline Iterator()
172  : matrix_( NULL ) // Reference to the adapted dense matrix
173  , row_ ( 0UL ) // The current row index of the iterator
174  , column_( 0UL ) // The current column index of the iterator
175  {}
176  //*******************************************************************************************
177 
178  //**Constructor******************************************************************************
185  inline Iterator( MT& matrix, size_t row, size_t column )
186  : matrix_( &matrix ) // Reference to the adapted dense matrix
187  , row_ ( row ) // The current row-index of the iterator
188  , column_( column ) // The current column-index of the iterator
189  {}
190  //*******************************************************************************************
191 
192  //**Addition assignment operator*************************************************************
198  inline Iterator& operator+=( size_t inc ) {
199  ( SO )?( row_ += inc ):( column_ += inc );
200  return *this;
201  }
202  //*******************************************************************************************
203 
204  //**Subtraction assignment operator**********************************************************
210  inline Iterator& operator-=( size_t dec ) {
211  ( SO )?( row_ -= dec ):( column_ -= dec );
212  return *this;
213  }
214  //*******************************************************************************************
215 
216  //**Prefix increment operator****************************************************************
221  inline Iterator& operator++() {
222  ( SO )?( ++row_ ):( ++column_ );
223  return *this;
224  }
225  //*******************************************************************************************
226 
227  //**Postfix increment operator***************************************************************
232  inline const Iterator operator++( int ) {
233  const Iterator tmp( *this );
234  ++(*this);
235  return tmp;
236  }
237  //*******************************************************************************************
238 
239  //**Prefix decrement operator****************************************************************
244  inline Iterator& operator--() {
245  ( SO )?( --row_ ):( --column_ );
246  return *this;
247  }
248  //*******************************************************************************************
249 
250  //**Postfix decrement operator***************************************************************
255  inline const Iterator operator--( int ) {
256  const Iterator tmp( *this );
257  --(*this);
258  return tmp;
259  }
260  //*******************************************************************************************
261 
262  //**Element access operator******************************************************************
267  inline ReferenceType operator*() const {
268  return ReferenceType( *matrix_, row_, column_ );
269  }
270  //*******************************************************************************************
271 
272  //**Element access operator******************************************************************
277  inline PointerType operator->() const {
278  return PointerType( *matrix_, row_, column_ );
279  }
280  //*******************************************************************************************
281 
282  //**Conversion operator**********************************************************************
287  inline operator ConstIterator() const {
288  if( SO )
289  return matrix_->begin( column_ ) + row_;
290  else
291  return matrix_->begin( row_ ) + column_;
292  }
293  //*******************************************************************************************
294 
295  //**Equality operator************************************************************************
302  friend inline bool operator==( const Iterator& lhs, const Iterator& rhs ) {
303  return ( SO )?( lhs.row_ == rhs.row_ ):( lhs.column_ == rhs.column_ );
304  }
305  //*******************************************************************************************
306 
307  //**Equality operator************************************************************************
314  friend inline bool operator==( const Iterator& lhs, const ConstIterator& rhs ) {
315  return ( ConstIterator( lhs ) == rhs );
316  }
317  //*******************************************************************************************
318 
319  //**Equality operator************************************************************************
326  friend inline bool operator==( const ConstIterator& lhs, const Iterator& rhs ) {
327  return ( lhs == ConstIterator( rhs ) );
328  }
329  //*******************************************************************************************
330 
331  //**Inequality operator**********************************************************************
338  friend inline bool operator!=( const Iterator& lhs, const Iterator& rhs ) {
339  return ( SO )?( lhs.row_ != rhs.row_ ):( lhs.column_ != rhs.column_ );
340  }
341  //*******************************************************************************************
342 
343  //**Inequality operator**********************************************************************
350  friend inline bool operator!=( const Iterator& lhs, const ConstIterator& rhs ) {
351  return ( ConstIterator( lhs ) != rhs );
352  }
353  //*******************************************************************************************
354 
355  //**Inequality operator**********************************************************************
362  friend inline bool operator!=( const ConstIterator& lhs, const Iterator& rhs ) {
363  return ( lhs != ConstIterator( rhs ) );
364  }
365  //*******************************************************************************************
366 
367  //**Less-than operator***********************************************************************
374  friend inline bool operator<( const Iterator& lhs, const Iterator& rhs ) {
375  return ( SO )?( lhs.row_ < rhs.row_ ):( lhs.column_ < rhs.column_ );
376  }
377  //*******************************************************************************************
378 
379  //**Less-than operator***********************************************************************
386  friend inline bool operator<( const Iterator& lhs, const ConstIterator& rhs ) {
387  return ( ConstIterator( lhs ) < rhs );
388  }
389  //*******************************************************************************************
390 
391  //**Less-than operator***********************************************************************
398  friend inline bool operator<( const ConstIterator& lhs, const Iterator& rhs ) {
399  return ( lhs < ConstIterator( rhs ) );
400  }
401  //*******************************************************************************************
402 
403  //**Greater-than operator********************************************************************
410  friend inline bool operator>( const Iterator& lhs, const Iterator& rhs ) {
411  return ( SO )?( lhs.row_ > rhs.row_ ):( lhs.column_ > rhs.column_ );
412  }
413  //*******************************************************************************************
414 
415  //**Greater-than operator********************************************************************
422  friend inline bool operator>( const Iterator& lhs, const ConstIterator& rhs ) {
423  return ( ConstIterator( lhs ) > rhs );
424  }
425  //*******************************************************************************************
426 
427  //**Greater-than operator********************************************************************
434  friend inline bool operator>( const ConstIterator& lhs, const Iterator& rhs ) {
435  return ( lhs > ConstIterator( rhs ) );
436  }
437  //*******************************************************************************************
438 
439  //**Less-or-equal-than operator**************************************************************
446  friend inline bool operator<=( const Iterator& lhs, const Iterator& rhs ) {
447  return ( SO )?( lhs.row_ <= rhs.row_ ):( lhs.column_ <= rhs.column_ );
448  }
449  //*******************************************************************************************
450 
451  //**Less-or-equal-than operator**************************************************************
458  friend inline bool operator<=( const Iterator& lhs, const ConstIterator& rhs ) {
459  return ( ConstIterator( lhs ) <= rhs );
460  }
461  //*******************************************************************************************
462 
463  //**Less-or-equal-than operator**************************************************************
470  friend inline bool operator<=( const ConstIterator& lhs, const Iterator& rhs ) {
471  return ( lhs <= ConstIterator( rhs ) );
472  }
473  //*******************************************************************************************
474 
475  //**Greater-or-equal-than operator***********************************************************
482  friend inline bool operator>=( const Iterator& lhs, const Iterator& rhs ) {
483  return ( SO )?( lhs.row_ >= rhs.row_ ):( lhs.column_ >= rhs.column_ );
484  }
485  //*******************************************************************************************
486 
487  //**Greater-or-equal-than operator***********************************************************
494  friend inline bool operator>=( const Iterator& lhs, const ConstIterator& rhs ) {
495  return ( ConstIterator( lhs ) >= rhs );
496  }
497  //*******************************************************************************************
498 
499  //**Greater-or-equal-than operator***********************************************************
506  friend inline bool operator>=( const ConstIterator& lhs, const Iterator& rhs ) {
507  return ( lhs >= ConstIterator( rhs ) );
508  }
509  //*******************************************************************************************
510 
511  //**Subtraction operator*********************************************************************
517  inline DifferenceType operator-( const Iterator& rhs ) const {
518  return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
519  }
520  //*******************************************************************************************
521 
522  //**Addition operator************************************************************************
529  friend inline const Iterator operator+( const Iterator& it, size_t inc ) {
530  if( SO )
531  return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
532  else
533  return Iterator( *it.matrix_, it.row_, it.column_ + inc );
534  }
535  //*******************************************************************************************
536 
537  //**Addition operator************************************************************************
544  friend inline const Iterator operator+( size_t inc, const Iterator& it ) {
545  if( SO )
546  return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
547  else
548  return Iterator( *it.matrix_, it.row_, it.column_ + inc );
549  }
550  //*******************************************************************************************
551 
552  //**Subtraction operator*********************************************************************
559  friend inline const Iterator operator-( const Iterator& it, size_t dec ) {
560  if( SO )
561  return Iterator( *it.matrix_, it.row_ - dec, it.column_ );
562  else
563  return Iterator( *it.matrix_, it.row_, it.column_ - dec );
564  }
565  //*******************************************************************************************
566 
567  private:
568  //**Member variables*************************************************************************
569  MT* matrix_;
570  size_t row_;
571  size_t column_;
572  //*******************************************************************************************
573  };
574  //**********************************************************************************************
575 
576  //**Compilation flags***************************************************************************
578  enum { vectorizable = MT::vectorizable };
579 
581  enum { smpAssignable = MT::smpAssignable };
582  //**********************************************************************************************
583 
584  //**Constructors********************************************************************************
587  explicit inline UniUpperMatrix();
588  template< typename A1 > explicit inline UniUpperMatrix( const A1& a1 );
589  explicit inline UniUpperMatrix( size_t n, const ElementType& init );
590 
591  explicit inline UniUpperMatrix( ElementType* ptr, size_t n );
592  explicit inline UniUpperMatrix( ElementType* ptr, size_t n, size_t nn );
593 
594  template< typename Deleter >
595  explicit inline UniUpperMatrix( ElementType* ptr, size_t n, Deleter d );
596 
597  template< typename Deleter >
598  explicit inline UniUpperMatrix( ElementType* ptr, size_t n, size_t nn, Deleter d );
599 
600  inline UniUpperMatrix( const UniUpperMatrix& m );
602  //**********************************************************************************************
603 
604  //**Destructor**********************************************************************************
605  // No explicitly declared destructor.
606  //**********************************************************************************************
607 
608  //**Data access functions***********************************************************************
611  inline Reference operator()( size_t i, size_t j );
612  inline ConstReference operator()( size_t i, size_t j ) const;
613  inline Reference at( size_t i, size_t j );
614  inline ConstReference at( size_t i, size_t j ) const;
615  inline ConstPointer data () const;
616  inline ConstPointer data ( size_t i ) const;
617  inline Iterator begin ( size_t i );
618  inline ConstIterator begin ( size_t i ) const;
619  inline ConstIterator cbegin( size_t i ) const;
620  inline Iterator end ( size_t i );
621  inline ConstIterator end ( size_t i ) const;
622  inline ConstIterator cend ( size_t i ) const;
624  //**********************************************************************************************
625 
626  //**Assignment operators************************************************************************
629  inline UniUpperMatrix& operator=( const ElementType& rhs );
630  inline UniUpperMatrix& operator=( const UniUpperMatrix& rhs );
631 
632  template< typename MT2, bool SO2 >
633  inline typename DisableIf< IsComputation<MT2>, UniUpperMatrix& >::Type
634  operator=( const Matrix<MT2,SO2>& rhs );
635 
636  template< typename MT2, bool SO2 >
637  inline typename EnableIf< IsComputation<MT2>, UniUpperMatrix& >::Type
638  operator=( const Matrix<MT2,SO2>& rhs );
639 
640  template< typename MT2, bool SO2 >
641  inline typename DisableIf< IsComputation<MT2>, UniUpperMatrix& >::Type
642  operator+=( const Matrix<MT2,SO2>& rhs );
643 
644  template< typename MT2, bool SO2 >
645  inline typename EnableIf< IsComputation<MT2>, UniUpperMatrix& >::Type
646  operator+=( const Matrix<MT2,SO2>& rhs );
647 
648  template< typename MT2, bool SO2 >
649  inline typename DisableIf< IsComputation<MT2>, UniUpperMatrix& >::Type
650  operator-=( const Matrix<MT2,SO2>& rhs );
651 
652  template< typename MT2, bool SO2 >
653  inline typename EnableIf< IsComputation<MT2>, UniUpperMatrix& >::Type
654  operator-=( const Matrix<MT2,SO2>& rhs );
655 
656  template< typename MT2, bool SO2 >
657  inline UniUpperMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
659  //**********************************************************************************************
660 
661  //**Utility functions***************************************************************************
664  inline size_t rows() const;
665  inline size_t columns() const;
666  inline size_t spacing() const;
667  inline size_t capacity() const;
668  inline size_t capacity( size_t i ) const;
669  inline size_t nonZeros() const;
670  inline size_t nonZeros( size_t i ) const;
671  inline void reset();
672  inline void reset( size_t i );
673  inline void clear();
674  void resize ( size_t n, bool preserve=true );
675  inline void extend ( size_t n, bool preserve=true );
676  inline void reserve( size_t elements );
677  inline void swap( UniUpperMatrix& m ) /* throw() */;
678 
679  static inline size_t maxNonZeros();
680  static inline size_t maxNonZeros( size_t n );
682  //**********************************************************************************************
683 
684  //**Debugging functions*************************************************************************
687  inline bool isIntact() const;
689  //**********************************************************************************************
690 
691  //**Expression template evaluation functions****************************************************
694  template< typename Other > inline bool canAlias ( const Other* alias ) const;
695  template< typename Other > inline bool isAliased( const Other* alias ) const;
696 
697  inline bool isAligned () const;
698  inline bool canSMPAssign() const;
699 
700  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t i, size_t j ) const;
701  BLAZE_ALWAYS_INLINE IntrinsicType loada( size_t i, size_t j ) const;
702  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t i, size_t j ) const;
704  //**********************************************************************************************
705 
706  private:
707  //**Construction functions**********************************************************************
710  inline const MT construct( size_t n , TrueType );
711  inline const MT construct( const ElementType& value, FalseType );
712 
713  template< typename MT2, bool SO2, typename T >
714  inline const MT construct( const Matrix<MT2,SO2>& m, T );
716  //**********************************************************************************************
717 
718  //**Member variables****************************************************************************
721  MT matrix_;
722 
723  //**********************************************************************************************
724 
725  //**Friend declarations*************************************************************************
726  template< typename MT2, bool SO2, bool DF2 >
727  friend MT2& derestrict( UniUpperMatrix<MT2,SO2,DF2>& m );
728  //**********************************************************************************************
729 
730  //**Compile time checks*************************************************************************
744  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
745  //**********************************************************************************************
746 };
748 //*************************************************************************************************
749 
750 
751 
752 
753 //=================================================================================================
754 //
755 // CONSTRUCTORS
756 //
757 //=================================================================================================
758 
759 //*************************************************************************************************
763 template< typename MT // Type of the adapted dense matrix
764  , bool SO > // Storage order of the adapted dense matrix
765 inline UniUpperMatrix<MT,SO,true>::UniUpperMatrix()
766  : matrix_() // The adapted dense matrix
767 {
768  for( size_t i=0UL; i<Rows<MT>::value; ++i )
769  matrix_(i,i) = ElementType(1);
770 
771  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
772  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
773 }
775 //*************************************************************************************************
776 
777 
778 //*************************************************************************************************
796 template< typename MT // Type of the adapted dense matrix
797  , bool SO > // Storage order of the adapted dense matrix
798 template< typename A1 > // Type of the constructor argument
799 inline UniUpperMatrix<MT,SO,true>::UniUpperMatrix( const A1& a1 )
800  : matrix_( construct( a1, typename IsResizable<MT>::Type() ) ) // The adapted dense matrix
801 {
802  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
803  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
804 }
806 //*************************************************************************************************
807 
808 
809 //*************************************************************************************************
816 template< typename MT // Type of the adapted dense matrix
817  , bool SO > // Storage order of the adapted dense matrix
818 inline UniUpperMatrix<MT,SO,true>::UniUpperMatrix( size_t n, const ElementType& init )
819  : matrix_( n, n, ElementType() ) // The adapted dense matrix
820 {
822 
823  if( SO ) {
824  for( size_t j=0UL; j<columns(); ++j ) {
825  for( size_t i=0UL; i<j; ++i )
826  matrix_(i,j) = init;
827  matrix_(j,j) = ElementType(1);
828  }
829  }
830  else {
831  for( size_t i=0UL; i<rows(); ++i ) {
832  matrix_(i,i) = ElementType(1);
833  for( size_t j=i+1UL; j<columns(); ++j )
834  matrix_(i,j) = init;
835  }
836  }
837 
838  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
839  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
840 }
842 //*************************************************************************************************
843 
844 
845 //*************************************************************************************************
866 template< typename MT // Type of the adapted dense matrix
867  , bool SO > // Storage order of the adapted dense matrix
868 inline UniUpperMatrix<MT,SO,true>::UniUpperMatrix( ElementType* ptr, size_t n )
869  : matrix_( ptr, n, n ) // The adapted dense matrix
870 {
871  if( !isUniUpper( matrix_ ) ) {
872  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of uniupper matrix" );
873  }
874 
875  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
876 }
878 //*************************************************************************************************
879 
880 
881 //*************************************************************************************************
904 template< typename MT // Type of the adapted dense matrix
905  , bool SO > // Storage order of the adapted dense matrix
906 inline UniUpperMatrix<MT,SO,true>::UniUpperMatrix( ElementType* ptr, size_t n, size_t nn )
907  : matrix_( ptr, n, n, nn ) // The adapted dense matrix
908 {
909  if( !isUniUpper( matrix_ ) ) {
910  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of uniupper matrix" );
911  }
912 
913  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
914 }
916 //*************************************************************************************************
917 
918 
919 //*************************************************************************************************
940 template< typename MT // Type of the adapted dense matrix
941  , bool SO > // Storage order of the adapted dense matrix
942 template< typename Deleter > // Type of the custom deleter
943 inline UniUpperMatrix<MT,SO,true>::UniUpperMatrix( ElementType* ptr, size_t n, Deleter d )
944  : matrix_( ptr, n, n, d ) // The adapted dense matrix
945 {
946  if( !isUniUpper( matrix_ ) ) {
947  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of uniupper matrix" );
948  }
949 
950  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
951 }
953 //*************************************************************************************************
954 
955 
956 //*************************************************************************************************
978 template< typename MT // Type of the adapted dense matrix
979  , bool SO > // Storage order of the adapted dense matrix
980 template< typename Deleter > // Type of the custom deleter
981 inline UniUpperMatrix<MT,SO,true>::UniUpperMatrix( ElementType* ptr, size_t n, size_t nn, Deleter d )
982  : matrix_( ptr, n, n, nn, d ) // The adapted dense matrix
983 {
984  if( !isUniUpper( matrix_ ) ) {
985  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of uniupper matrix" );
986  }
987 
988  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
989 }
991 //*************************************************************************************************
992 
993 
994 //*************************************************************************************************
1000 template< typename MT // Type of the adapted dense matrix
1001  , bool SO > // Storage order of the adapted dense matrix
1002 inline UniUpperMatrix<MT,SO,true>::UniUpperMatrix( const UniUpperMatrix& m )
1003  : matrix_( m.matrix_ ) // The adapted dense matrix
1004 {
1005  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1006  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1007 }
1009 //*************************************************************************************************
1010 
1011 
1012 
1013 
1014 //=================================================================================================
1015 //
1016 // DATA ACCESS FUNCTIONS
1017 //
1018 //=================================================================================================
1019 
1020 //*************************************************************************************************
1036 template< typename MT // Type of the adapted dense matrix
1037  , bool SO > // Storage order of the adapted dense matrix
1039  UniUpperMatrix<MT,SO,true>::operator()( size_t i, size_t j )
1040 {
1041  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1042  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1043 
1044  return Reference( matrix_, i, j );
1045 }
1047 //*************************************************************************************************
1048 
1049 
1050 //*************************************************************************************************
1066 template< typename MT // Type of the adapted dense matrix
1067  , bool SO > // Storage order of the adapted dense matrix
1069  UniUpperMatrix<MT,SO,true>::operator()( size_t i, size_t j ) const
1070 {
1071  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1072  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1073 
1074  return matrix_(i,j);
1075 }
1077 //*************************************************************************************************
1078 
1079 
1080 //*************************************************************************************************
1097 template< typename MT // Type of the adapted dense matrix
1098  , bool SO > // Storage order of the adapted dense matrix
1100  UniUpperMatrix<MT,SO,true>::at( size_t i, size_t j )
1101 {
1102  if( i >= rows() ) {
1103  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1104  }
1105  if( j >= columns() ) {
1106  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1107  }
1108  return (*this)(i,j);
1109 }
1111 //*************************************************************************************************
1112 
1113 
1114 //*************************************************************************************************
1131 template< typename MT // Type of the adapted dense matrix
1132  , bool SO > // Storage order of the adapted dense matrix
1134  UniUpperMatrix<MT,SO,true>::at( size_t i, size_t j ) const
1135 {
1136  if( i >= rows() ) {
1137  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1138  }
1139  if( j >= columns() ) {
1140  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1141  }
1142  return (*this)(i,j);
1143 }
1145 //*************************************************************************************************
1146 
1147 
1148 //*************************************************************************************************
1161 template< typename MT // Type of the adapted dense matrix
1162  , bool SO > // Storage order of the adapted dense matrix
1163 inline typename UniUpperMatrix<MT,SO,true>::ConstPointer
1164  UniUpperMatrix<MT,SO,true>::data() const
1165 {
1166  return matrix_.data();
1167 }
1169 //*************************************************************************************************
1170 
1171 
1172 //*************************************************************************************************
1181 template< typename MT // Type of the adapted dense matrix
1182  , bool SO > // Storage order of the adapted dense matrix
1183 inline typename UniUpperMatrix<MT,SO,true>::ConstPointer
1184  UniUpperMatrix<MT,SO,true>::data( size_t i ) const
1185 {
1186  return matrix_.data(i);
1187 }
1189 //*************************************************************************************************
1190 
1191 
1192 //*************************************************************************************************
1204 template< typename MT // Type of the adapted dense matrix
1205  , bool SO > // Storage order of the adapted dense matrix
1208 {
1209  if( SO )
1210  return Iterator( matrix_, 0UL, i );
1211  else
1212  return Iterator( matrix_, i, 0UL );
1213 }
1215 //*************************************************************************************************
1216 
1217 
1218 //*************************************************************************************************
1230 template< typename MT // Type of the adapted dense matrix
1231  , bool SO > // Storage order of the adapted dense matrix
1233  UniUpperMatrix<MT,SO,true>::begin( size_t i ) const
1234 {
1235  return matrix_.begin(i);
1236 }
1238 //*************************************************************************************************
1239 
1240 
1241 //*************************************************************************************************
1253 template< typename MT // Type of the adapted dense matrix
1254  , bool SO > // Storage order of the adapted dense matrix
1256  UniUpperMatrix<MT,SO,true>::cbegin( size_t i ) const
1257 {
1258  return matrix_.cbegin(i);
1259 }
1261 //*************************************************************************************************
1262 
1263 
1264 //*************************************************************************************************
1276 template< typename MT // Type of the adapted dense matrix
1277  , bool SO > // Storage order of the adapted dense matrix
1280 {
1281  if( SO )
1282  return Iterator( matrix_, rows(), i );
1283  else
1284  return Iterator( matrix_, i, columns() );
1285 }
1287 //*************************************************************************************************
1288 
1289 
1290 //*************************************************************************************************
1302 template< typename MT // Type of the adapted dense matrix
1303  , bool SO > // Storage order of the adapted dense matrix
1305  UniUpperMatrix<MT,SO,true>::end( size_t i ) const
1306 {
1307  return matrix_.end(i);
1308 }
1310 //*************************************************************************************************
1311 
1312 
1313 //*************************************************************************************************
1325 template< typename MT // Type of the adapted dense matrix
1326  , bool SO > // Storage order of the adapted dense matrix
1328  UniUpperMatrix<MT,SO,true>::cend( size_t i ) const
1329 {
1330  return matrix_.cend(i);
1331 }
1333 //*************************************************************************************************
1334 
1335 
1336 
1337 
1338 //=================================================================================================
1339 //
1340 // ASSIGNMENT OPERATORS
1341 //
1342 //=================================================================================================
1343 
1344 //*************************************************************************************************
1351 template< typename MT // Type of the adapted dense matrix
1352  , bool SO > // Storage order of the adapted dense matrix
1353 inline UniUpperMatrix<MT,SO,true>&
1354  UniUpperMatrix<MT,SO,true>::operator=( const ElementType& rhs )
1355 {
1356  if( SO ) {
1357  for( size_t j=1UL; j<columns(); ++j )
1358  for( size_t i=0UL; i<j; ++i )
1359  matrix_(i,j) = rhs;
1360  }
1361  else {
1362  for( size_t i=0UL; i<rows(); ++i )
1363  for( size_t j=i+1UL; j<columns(); ++j )
1364  matrix_(i,j) = rhs;
1365  }
1366 
1367  return *this;
1368 }
1370 //*************************************************************************************************
1371 
1372 
1373 //*************************************************************************************************
1383 template< typename MT // Type of the adapted dense matrix
1384  , bool SO > // Storage order of the adapted dense matrix
1385 inline UniUpperMatrix<MT,SO,true>&
1386  UniUpperMatrix<MT,SO,true>::operator=( const UniUpperMatrix& rhs )
1387 {
1388  matrix_ = rhs.matrix_;
1389 
1390  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1391  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1392 
1393  return *this;
1394 }
1396 //*************************************************************************************************
1397 
1398 
1399 //*************************************************************************************************
1412 template< typename MT // Type of the adapted dense matrix
1413  , bool SO > // Storage order of the adapted dense matrix
1414 template< typename MT2 // Type of the right-hand side matrix
1415  , bool SO2 > // Storage order of the right-hand side matrix
1416 inline typename DisableIf< IsComputation<MT2>, UniUpperMatrix<MT,SO,true>& >::Type
1417  UniUpperMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1418 {
1419  if( IsStrictlyTriangular<MT2>::value || ( !IsUniUpper<MT2>::value && !isUniUpper( ~rhs ) ) ) {
1420  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1421  }
1422 
1423  matrix_ = ~rhs;
1424 
1425  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1426  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1427 
1428  return *this;
1429 }
1431 //*************************************************************************************************
1432 
1433 
1434 //*************************************************************************************************
1447 template< typename MT // Type of the adapted dense matrix
1448  , bool SO > // Storage order of the adapted dense matrix
1449 template< typename MT2 // Type of the right-hand side matrix
1450  , bool SO2 > // Storage order of the right-hand side matrix
1451 inline typename EnableIf< IsComputation<MT2>, UniUpperMatrix<MT,SO,true>& >::Type
1452  UniUpperMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1453 {
1454  if( IsStrictlyTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1455  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1456  }
1457 
1458  if( IsUniUpper<MT2>::value ) {
1459  matrix_ = ~rhs;
1460  }
1461  else {
1462  MT tmp( ~rhs );
1463 
1464  if( !isUniUpper( tmp ) ) {
1465  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1466  }
1467 
1468  move( matrix_, tmp );
1469  }
1470 
1471  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1472  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1473 
1474  return *this;
1475 }
1477 //*************************************************************************************************
1478 
1479 
1480 //*************************************************************************************************
1493 template< typename MT // Type of the adapted dense matrix
1494  , bool SO > // Storage order of the adapted dense matrix
1495 template< typename MT2 // Type of the right-hand side matrix
1496  , bool SO2 > // Storage order of the right-hand side matrix
1497 inline typename DisableIf< IsComputation<MT2>, UniUpperMatrix<MT,SO,true>& >::Type
1498  UniUpperMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1499 {
1500  if( IsLower<MT2>::value || IsUniTriangular<MT2>::value ||
1501  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
1502  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1503  }
1504 
1505  matrix_ += ~rhs;
1506 
1507  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1508  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1509 
1510  return *this;
1511 }
1513 //*************************************************************************************************
1514 
1515 
1516 //*************************************************************************************************
1529 template< typename MT // Type of the adapted dense matrix
1530  , bool SO > // Storage order of the adapted dense matrix
1531 template< typename MT2 // Type of the right-hand side matrix
1532  , bool SO2 > // Storage order of the right-hand side matrix
1533 inline typename EnableIf< IsComputation<MT2>, UniUpperMatrix<MT,SO,true>& >::Type
1534  UniUpperMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1535 {
1536  if( IsLower<MT2>::value || IsUniTriangular<MT2>::value ||
1537  ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1538  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1539  }
1540 
1541  if( IsStrictlyUpper<MT2>::value ) {
1542  matrix_ += ~rhs;
1543  }
1544  else {
1545  typename MT2::ResultType tmp( ~rhs );
1546 
1547  if( !isStrictlyUpper( tmp ) ) {
1548  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1549  }
1550 
1551  matrix_ += tmp;
1552  }
1553 
1554  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1555  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1556 
1557  return *this;
1558 }
1560 //*************************************************************************************************
1561 
1562 
1563 //*************************************************************************************************
1576 template< typename MT // Type of the adapted dense matrix
1577  , bool SO > // Storage order of the adapted dense matrix
1578 template< typename MT2 // Type of the right-hand side matrix
1579  , bool SO2 > // Storage order of the right-hand side matrix
1580 inline typename DisableIf< IsComputation<MT2>, UniUpperMatrix<MT,SO,true>& >::Type
1581  UniUpperMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1582 {
1583  if( IsLower<MT2>::value || IsUniTriangular<MT2>::value ||
1584  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
1585  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1586  }
1587 
1588  matrix_ -= ~rhs;
1589 
1590  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1591  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1592 
1593  return *this;
1594 }
1596 //*************************************************************************************************
1597 
1598 
1599 //*************************************************************************************************
1612 template< typename MT // Type of the adapted dense matrix
1613  , bool SO > // Storage order of the adapted dense matrix
1614 template< typename MT2 // Type of the right-hand side matrix
1615  , bool SO2 > // Storage order of the right-hand side matrix
1616 inline typename EnableIf< IsComputation<MT2>, UniUpperMatrix<MT,SO,true>& >::Type
1617  UniUpperMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1618 {
1619  if( IsLower<MT2>::value || IsUniTriangular<MT2>::value ||
1620  ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1621  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper 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 uniupper matrix" );
1632  }
1633 
1634  matrix_ -= tmp;
1635  }
1636 
1637  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper 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 UniUpperMatrix<MT,SO,true>&
1663  UniUpperMatrix<MT,SO,true>::operator*=( const Matrix<MT2,SO2>& rhs )
1664 {
1665  if( matrix_.rows() != (~rhs).columns() ) {
1666  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1667  }
1668 
1669  MT tmp( matrix_ * ~rhs );
1670 
1671  if( !isUniUpper( tmp ) ) {
1672  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1673  }
1674 
1675  move( matrix_, tmp );
1676 
1677  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1678  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1679 
1680  return *this;
1681 }
1683 //*************************************************************************************************
1684 
1685 
1686 
1687 
1688 //=================================================================================================
1689 //
1690 // UTILITY FUNCTIONS
1691 //
1692 //=================================================================================================
1693 
1694 //*************************************************************************************************
1700 template< typename MT // Type of the adapted dense matrix
1701  , bool SO > // Storage order of the adapted dense matrix
1702 inline size_t UniUpperMatrix<MT,SO,true>::rows() const
1703 {
1704  return matrix_.rows();
1705 }
1707 //*************************************************************************************************
1708 
1709 
1710 //*************************************************************************************************
1716 template< typename MT // Type of the adapted dense matrix
1717  , bool SO > // Storage order of the adapted dense matrix
1718 inline size_t UniUpperMatrix<MT,SO,true>::columns() const
1719 {
1720  return matrix_.columns();
1721 }
1723 //*************************************************************************************************
1724 
1725 
1726 //*************************************************************************************************
1737 template< typename MT // Type of the adapted dense matrix
1738  , bool SO > // Storage order of the adapted dense matrix
1739 inline size_t UniUpperMatrix<MT,SO,true>::spacing() const
1740 {
1741  return matrix_.spacing();
1742 }
1744 //*************************************************************************************************
1745 
1746 
1747 //*************************************************************************************************
1753 template< typename MT // Type of the adapted dense matrix
1754  , bool SO > // Storage order of the adapted dense matrix
1755 inline size_t UniUpperMatrix<MT,SO,true>::capacity() const
1756 {
1757  return matrix_.capacity();
1758 }
1760 //*************************************************************************************************
1761 
1762 
1763 //*************************************************************************************************
1775 template< typename MT // Type of the adapted dense matrix
1776  , bool SO > // Storage order of the adapted dense matrix
1777 inline size_t UniUpperMatrix<MT,SO,true>::capacity( size_t i ) const
1778 {
1779  return matrix_.capacity(i);
1780 }
1782 //*************************************************************************************************
1783 
1784 
1785 //*************************************************************************************************
1791 template< typename MT // Type of the adapted dense matrix
1792  , bool SO > // Storage order of the adapted dense matrix
1793 inline size_t UniUpperMatrix<MT,SO,true>::nonZeros() const
1794 {
1795  return matrix_.nonZeros();
1796 }
1798 //*************************************************************************************************
1799 
1800 
1801 //*************************************************************************************************
1813 template< typename MT // Type of the adapted dense matrix
1814  , bool SO > // Storage order of the adapted dense matrix
1815 inline size_t UniUpperMatrix<MT,SO,true>::nonZeros( size_t i ) const
1816 {
1817  return matrix_.nonZeros(i);
1818 }
1820 //*************************************************************************************************
1821 
1822 
1823 //*************************************************************************************************
1829 template< typename MT // Type of the adapted dense matrix
1830  , bool SO > // Storage order of the adapted dense matrix
1832 {
1833  using blaze::clear;
1834 
1835  if( SO ) {
1836  for( size_t j=1UL; j<columns(); ++j )
1837  for( size_t i=0UL; i<j; ++i )
1838  clear( matrix_(i,j) );
1839  }
1840  else {
1841  for( size_t i=0UL; i<rows(); ++i )
1842  for( size_t j=i+1UL; j<columns(); ++j )
1843  clear( matrix_(i,j) );
1844  }
1845 }
1847 //*************************************************************************************************
1848 
1849 
1850 //*************************************************************************************************
1863 template< typename MT // Type of the adapted dense matrix
1864  , bool SO > // Storage order of the adapted dense matrix
1865 inline void UniUpperMatrix<MT,SO,true>::reset( size_t i )
1866 {
1867  using blaze::clear;
1868 
1869  if( SO ) {
1870  for( size_t j=0UL; j<i; ++j )
1871  clear( matrix_(j,i) );
1872  }
1873  else {
1874  for( size_t j=i+1UL; j<columns(); ++j )
1875  clear( matrix_(i,j) );
1876  }
1877 }
1879 //*************************************************************************************************
1880 
1881 
1882 //*************************************************************************************************
1894 template< typename MT // Type of the adapted dense matrix
1895  , bool SO > // Storage order of the adapted dense matrix
1897 {
1898  using blaze::clear;
1899 
1900  if( IsResizable<MT>::value ) {
1901  clear( matrix_ );
1902  }
1903  else {
1904  reset();
1905  }
1906 }
1908 //*************************************************************************************************
1909 
1910 
1911 //*************************************************************************************************
1947 template< typename MT // Type of the adapted dense matrix
1948  , bool SO > // Storage order of the adapted dense matrix
1949 void UniUpperMatrix<MT,SO,true>::resize( size_t n, bool preserve )
1950 {
1952 
1953  UNUSED_PARAMETER( preserve );
1954 
1955  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1956 
1957  const size_t oldsize( matrix_.rows() );
1958 
1959  matrix_.resize( n, n, true );
1960 
1961  if( n > oldsize )
1962  {
1963  const size_t increment( n - oldsize );
1964  submatrix( matrix_, oldsize, 0UL, increment, n-1UL ).reset();
1965 
1966  for( size_t i=oldsize; i<n; ++i )
1967  matrix_(i,i) = ElementType(1);
1968  }
1969 }
1971 //*************************************************************************************************
1972 
1973 
1974 //*************************************************************************************************
1987 template< typename MT // Type of the adapted dense matrix
1988  , bool SO > // Storage order of the adapted dense matrix
1989 inline void UniUpperMatrix<MT,SO,true>::extend( size_t n, bool preserve )
1990 {
1992 
1993  UNUSED_PARAMETER( preserve );
1994 
1995  resize( rows() + n, true );
1996 }
1997 //*************************************************************************************************
1998 
1999 
2000 //*************************************************************************************************
2010 template< typename MT // Type of the adapted dense matrix
2011  , bool SO > // Storage order of the adapted dense matrix
2012 inline void UniUpperMatrix<MT,SO,true>::reserve( size_t elements )
2013 {
2014  matrix_.reserve( elements );
2015 }
2017 //*************************************************************************************************
2018 
2019 
2020 //*************************************************************************************************
2028 template< typename MT // Type of the adapted dense matrix
2029  , bool SO > // Storage order of the adapted dense matrix
2030 inline void UniUpperMatrix<MT,SO,true>::swap( UniUpperMatrix& m ) /* throw() */
2031 {
2032  using std::swap;
2033 
2034  swap( matrix_, m.matrix_ );
2035 }
2037 //*************************************************************************************************
2038 
2039 
2040 //*************************************************************************************************
2052 template< typename MT // Type of the adapted dense matrix
2053  , bool SO > // Storage order of the adapted dense matrix
2054 inline size_t UniUpperMatrix<MT,SO,true>::maxNonZeros()
2055 {
2057 
2058  return maxNonZeros( Rows<MT>::value );
2059 }
2061 //*************************************************************************************************
2062 
2063 
2064 //*************************************************************************************************
2074 template< typename MT // Type of the adapted dense matrix
2075  , bool SO > // Storage order of the adapted dense matrix
2076 inline size_t UniUpperMatrix<MT,SO,true>::maxNonZeros( size_t n )
2077 {
2078  return ( ( n + 1UL ) * n ) / 2UL;
2079 }
2081 //*************************************************************************************************
2082 
2083 
2084 
2085 
2086 //=================================================================================================
2087 //
2088 // DEBUGGING FUNCTIONS
2089 //
2090 //=================================================================================================
2091 
2092 //*************************************************************************************************
2102 template< typename MT // Type of the adapted dense matrix
2103  , bool SO > // Storage order of the adapted dense matrix
2104 inline bool UniUpperMatrix<MT,SO,true>::isIntact() const
2105 {
2106  using blaze::isIntact;
2107 
2108  return ( isIntact( matrix_ ) && isUniUpper( matrix_ ) );
2109 }
2111 //*************************************************************************************************
2112 
2113 
2114 
2115 
2116 //=================================================================================================
2117 //
2118 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2119 //
2120 //=================================================================================================
2121 
2122 //*************************************************************************************************
2133 template< typename MT // Type of the adapted dense matrix
2134  , bool SO > // Storage order of the adapted dense matrix
2135 template< typename Other > // Data type of the foreign expression
2136 inline bool UniUpperMatrix<MT,SO,true>::canAlias( const Other* alias ) const
2137 {
2138  return matrix_.canAlias( alias );
2139 }
2141 //*************************************************************************************************
2142 
2143 
2144 //*************************************************************************************************
2155 template< typename MT // Type of the adapted dense matrix
2156  , bool SO > // Storage order of the adapted dense matrix
2157 template< typename Other > // Data type of the foreign expression
2158 inline bool UniUpperMatrix<MT,SO,true>::isAliased( const Other* alias ) const
2159 {
2160  return matrix_.isAliased( alias );
2161 }
2163 //*************************************************************************************************
2164 
2165 
2166 //*************************************************************************************************
2176 template< typename MT // Type of the adapted dense matrix
2177  , bool SO > // Storage order of the adapted dense matrix
2178 inline bool UniUpperMatrix<MT,SO,true>::isAligned() const
2179 {
2180  return matrix_.isAligned();
2181 }
2183 //*************************************************************************************************
2184 
2185 
2186 //*************************************************************************************************
2197 template< typename MT // Type of the adapted dense matrix
2198  , bool SO > // Storage order of the adapted dense matrix
2199 inline bool UniUpperMatrix<MT,SO,true>::canSMPAssign() const
2200 {
2201  return matrix_.canSMPAssign();
2202 }
2204 //*************************************************************************************************
2205 
2206 
2207 //*************************************************************************************************
2223 template< typename MT // Type of the adapted dense matrix
2224  , bool SO > // Storage order of the adapted dense matrix
2225 BLAZE_ALWAYS_INLINE typename UniUpperMatrix<MT,SO,true>::IntrinsicType
2226  UniUpperMatrix<MT,SO,true>::load( size_t i, size_t j ) const
2227 {
2228  return matrix_.load( i, j );
2229 }
2231 //*************************************************************************************************
2232 
2233 
2234 //*************************************************************************************************
2250 template< typename MT // Type of the adapted dense matrix
2251  , bool SO > // Storage order of the adapted dense matrix
2252 BLAZE_ALWAYS_INLINE typename UniUpperMatrix<MT,SO,true>::IntrinsicType
2253  UniUpperMatrix<MT,SO,true>::loada( size_t i, size_t j ) const
2254 {
2255  return matrix_.loada( i, j );
2256 }
2258 //*************************************************************************************************
2259 
2260 
2261 //*************************************************************************************************
2277 template< typename MT // Type of the adapted dense matrix
2278  , bool SO > // Storage order of the adapted dense matrix
2279 BLAZE_ALWAYS_INLINE typename UniUpperMatrix<MT,SO,true>::IntrinsicType
2280  UniUpperMatrix<MT,SO,true>::loadu( size_t i, size_t j ) const
2281 {
2282  return matrix_.loadu( i, j );
2283 }
2285 //*************************************************************************************************
2286 
2287 
2288 
2289 
2290 //=================================================================================================
2291 //
2292 // CONSTRUCTION FUNCTIONS
2293 //
2294 //=================================================================================================
2295 
2296 //*************************************************************************************************
2303 template< typename MT // Type of the adapted dense matrix
2304  , bool SO > // Storage order of the adapted dense matrix
2305 inline const MT UniUpperMatrix<MT,SO,true>::construct( size_t n, TrueType )
2306 {
2308 
2309  MT tmp( n, n, ElementType() );
2310 
2311  for( size_t i=0UL; i<n; ++i )
2312  tmp(i,i) = ElementType(1);
2313 
2314  return tmp;
2315 }
2317 //*************************************************************************************************
2318 
2319 
2320 //*************************************************************************************************
2327 template< typename MT // Type of the adapted dense matrix
2328  , bool SO > // Storage order of the adapted dense matrix
2329 inline const MT UniUpperMatrix<MT,SO,true>::construct( const ElementType& init, FalseType )
2330 {
2333 
2334  MT tmp;
2335 
2336  if( SO ) {
2337  for( size_t j=0UL; j<columns(); ++j ) {
2338  for( size_t i=0UL; i<j; ++i )
2339  tmp(i,j) = init;
2340  tmp(j,j) = ElementType(1);
2341  }
2342  }
2343  else {
2344  for( size_t i=0UL; i<rows(); ++i ) {
2345  tmp(i,i) = ElementType(1);
2346  for( size_t j=i+1UL; j<columns(); ++j )
2347  tmp(i,j) = init;
2348  }
2349  }
2350 
2351  return tmp;
2352 }
2354 //*************************************************************************************************
2355 
2356 
2357 //*************************************************************************************************
2368 template< typename MT // Type of the adapted dense matrix
2369  , bool SO > // Storage order of the adapted dense matrix
2370 template< typename MT2 // Type of the foreign matrix
2371  , bool SO2 // Storage order of the foreign matrix
2372  , typename T > // Type of the third argument
2373 inline const MT UniUpperMatrix<MT,SO,true>::construct( const Matrix<MT2,SO2>& m, T )
2374 {
2375  const MT tmp( ~m );
2376 
2377  if( IsStrictlyTriangular<MT2>::value || ( !IsUniUpper<MT2>::value && !isUniUpper( tmp ) ) ) {
2378  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of uniupper matrix" );
2379  }
2380 
2381  return tmp;
2382 }
2384 //*************************************************************************************************
2385 
2386 } // namespace blaze
2387 
2388 #endif
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
Constraint on the data type.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the Rows type trait.
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
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
Header file for the implementation of the base template of the UniUpperMatrix.
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.
Header file for the IsLower type trait.
Header file for the UniUpperProxy class.
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.
Header file for the IsStrictlyTriangular 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 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_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:118
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2591
Header file for the isDefault shim.
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
bool isUniUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper unitriangular matrix.
Definition: DenseMatrix.h:1354
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.