Sparse.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_UNIUPPERMATRIX_SPARSE_H_
36 #define _BLAZE_MATH_ADAPTORS_UNIUPPERMATRIX_SPARSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <utility>
45 #include <vector>
51 #include <blaze/math/Aliases.h>
60 #include <blaze/math/Exception.h>
62 #include <blaze/math/Functions.h>
63 #include <blaze/math/shims/Clear.h>
76 #include <blaze/util/Assert.h>
82 #include <blaze/util/DisableIf.h>
83 #include <blaze/util/EnableIf.h>
86 #include <blaze/util/Types.h>
87 
88 
89 namespace blaze {
90 
91 //=================================================================================================
92 //
93 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
94 //
95 //=================================================================================================
96 
97 //*************************************************************************************************
105 template< typename MT // Type of the adapted sparse matrix
106  , bool SO > // Storage order of the adapted sparse matrix
107 class UniUpperMatrix<MT,SO,false>
108  : public SparseMatrix< UniUpperMatrix<MT,SO,false>, SO >
109 {
110  private:
111  //**Type definitions****************************************************************************
112  typedef OppositeType_<MT> OT;
113  typedef TransposeType_<MT> TT;
114  typedef ElementType_<MT> ET;
115  //**********************************************************************************************
116 
117  public:
118  //**Type definitions****************************************************************************
119  typedef UniUpperMatrix<MT,SO,false> This;
120  typedef SparseMatrix<This,SO> BaseType;
121  typedef This ResultType;
122  typedef UniUpperMatrix<OT,!SO,false> OppositeType;
123  typedef UniLowerMatrix<TT,!SO,false> TransposeType;
124  typedef ET ElementType;
125  typedef ReturnType_<MT> ReturnType;
126  typedef const This& CompositeType;
127  typedef UniUpperProxy<MT> Reference;
128  typedef ConstReference_<MT> ConstReference;
129  typedef ConstIterator_<MT> ConstIterator;
130  //**********************************************************************************************
131 
132  //**Rebind struct definition********************************************************************
135  template< typename NewType > // Data type of the other matrix
136  struct Rebind {
138  typedef UniUpperMatrix< typename MT::template Rebind<NewType>::Other > Other;
139  };
140  //**********************************************************************************************
141 
142  //**Resize struct definition********************************************************************
145  template< size_t NewM // Number of rows of the other matrix
146  , size_t NewN > // Number of columns of the other matrix
147  struct Resize {
149  typedef UniUpperMatrix< typename MT::template Resize<NewM,NewN>::Other > Other;
150  };
151  //**********************************************************************************************
152 
153  //**Iterator class definition*******************************************************************
156  class Iterator
157  {
158  public:
159  //**Type definitions*************************************************************************
160  typedef Iterator_<MT> IteratorType;
161 
162  typedef std::forward_iterator_tag IteratorCategory;
163  typedef UniUpperElement<MT> ValueType;
164  typedef ValueType PointerType;
165  typedef ValueType ReferenceType;
166  typedef ptrdiff_t DifferenceType;
167 
168  // STL iterator requirements
169  typedef IteratorCategory iterator_category;
170  typedef ValueType value_type;
171  typedef PointerType pointer;
172  typedef ReferenceType reference;
173  typedef DifferenceType difference_type;
174  //*******************************************************************************************
175 
176  //**Default constructor**********************************************************************
179  inline Iterator()
180  : pos_ ( ) // Iterator to the current upper unitriangular matrix element
181  , index_ ( 0UL ) // The row/column index of the iterator
182  {}
183  //*******************************************************************************************
184 
185  //**Constructor******************************************************************************
191  inline Iterator( IteratorType pos, size_t index )
192  : pos_ ( pos ) // Iterator to the current upper unitriangular matrix element
193  , index_( index ) // The row/column index of the iterator
194  {}
195  //*******************************************************************************************
196 
197  //**Prefix increment operator****************************************************************
202  inline Iterator& operator++() {
203  ++pos_;
204  return *this;
205  }
206  //*******************************************************************************************
207 
208  //**Postfix increment operator***************************************************************
213  inline const Iterator operator++( int ) {
214  const Iterator tmp( *this );
215  ++(*this);
216  return tmp;
217  }
218  //*******************************************************************************************
219 
220  //**Element access operator******************************************************************
225  inline ReferenceType operator*() const {
226  return ReferenceType( pos_, pos_->index() == index_ );
227  }
228  //*******************************************************************************************
229 
230  //**Element access operator******************************************************************
235  inline PointerType operator->() const {
236  return PointerType( pos_, pos_->index() == index_ );
237  }
238  //*******************************************************************************************
239 
240  //**Conversion operator**********************************************************************
245  inline operator ConstIterator() const {
246  return pos_;
247  }
248  //*******************************************************************************************
249 
250  //**Equality operator************************************************************************
256  inline bool operator==( const Iterator& rhs ) const {
257  return pos_ == rhs.pos_;
258  }
259  //*******************************************************************************************
260 
261  //**Inequality operator**********************************************************************
267  inline bool operator!=( const Iterator& rhs ) const {
268  return !( *this == rhs );
269  }
270  //*******************************************************************************************
271 
272  //**Subtraction operator*********************************************************************
278  inline DifferenceType operator-( const Iterator& rhs ) const {
279  return pos_ - rhs.pos_;
280  }
281  //*******************************************************************************************
282 
283  //**Base function****************************************************************************
288  inline IteratorType base() const {
289  return pos_;
290  }
291  //*******************************************************************************************
292 
293  private:
294  //**Member variables*************************************************************************
295  IteratorType pos_;
296  size_t index_;
297  //*******************************************************************************************
298  };
299  //**********************************************************************************************
300 
301  //**Compilation flags***************************************************************************
303  enum : bool { smpAssignable = false };
304  //**********************************************************************************************
305 
306  //**Constructors********************************************************************************
309  explicit inline UniUpperMatrix();
310  explicit inline UniUpperMatrix( size_t n );
311  explicit inline UniUpperMatrix( size_t n, size_t nonzeros );
312  explicit inline UniUpperMatrix( size_t n, const std::vector<size_t>& nonzeros );
313 
314  inline UniUpperMatrix( const UniUpperMatrix& m );
315  inline UniUpperMatrix( UniUpperMatrix&& m ) noexcept;
316 
317  template< typename MT2, bool SO2 >
318  inline UniUpperMatrix( const Matrix<MT2,SO2>& m );
320  //**********************************************************************************************
321 
322  //**Destructor**********************************************************************************
323  // No explicitly declared destructor.
324  //**********************************************************************************************
325 
326  //**Data access functions***********************************************************************
329  inline Reference operator()( size_t i, size_t j );
330  inline ConstReference operator()( size_t i, size_t j ) const;
331  inline Reference at( size_t i, size_t j );
332  inline ConstReference at( size_t i, size_t j ) const;
333  inline Iterator begin ( size_t i );
334  inline ConstIterator begin ( size_t i ) const;
335  inline ConstIterator cbegin( size_t i ) const;
336  inline Iterator end ( size_t i );
337  inline ConstIterator end ( size_t i ) const;
338  inline ConstIterator cend ( size_t i ) const;
340  //**********************************************************************************************
341 
342  //**Assignment operators************************************************************************
345  inline UniUpperMatrix& operator=( const UniUpperMatrix& rhs );
346  inline UniUpperMatrix& operator=( UniUpperMatrix&& rhs ) noexcept;
347 
348  template< typename MT2, bool SO2 >
349  inline DisableIf_< IsComputation<MT2>, UniUpperMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
350 
351  template< typename MT2, bool SO2 >
352  inline EnableIf_< IsComputation<MT2>, UniUpperMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
353 
354  template< typename MT2, bool SO2 >
355  inline DisableIf_< IsComputation<MT2>, UniUpperMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
356 
357  template< typename MT2, bool SO2 >
358  inline EnableIf_< IsComputation<MT2>, UniUpperMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
359 
360  template< typename MT2, bool SO2 >
361  inline DisableIf_< IsComputation<MT2>, UniUpperMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
362 
363  template< typename MT2, bool SO2 >
364  inline EnableIf_< IsComputation<MT2>, UniUpperMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
365 
366  template< typename MT2, bool SO2 >
367  inline UniUpperMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
369  //**********************************************************************************************
370 
371  //**Utility functions***************************************************************************
374  inline size_t rows() const noexcept;
375  inline size_t columns() const noexcept;
376  inline size_t capacity() const noexcept;
377  inline size_t capacity( size_t i ) const noexcept;
378  inline size_t nonZeros() const;
379  inline size_t nonZeros( size_t i ) const;
380  inline void reset();
381  inline void reset( size_t i );
382  inline void clear();
383  inline void resize ( size_t n, bool preserve=true );
384  inline void reserve( size_t nonzeros );
385  inline void reserve( size_t i, size_t nonzeros );
386  inline void trim();
387  inline void trim( size_t i );
388  inline void swap( UniUpperMatrix& m ) noexcept;
389 
390  static inline constexpr size_t maxNonZeros() noexcept;
391  static inline constexpr size_t maxNonZeros( size_t n ) noexcept;
393  //**********************************************************************************************
394 
395  //**Insertion functions*************************************************************************
398  inline Iterator set ( size_t i, size_t j, const ElementType& value );
399  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
400  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
401  inline void finalize( size_t i );
403  //**********************************************************************************************
404 
405  //**Erase functions*****************************************************************************
408  inline void erase( size_t i, size_t j );
409  inline Iterator erase( size_t i, Iterator pos );
410  inline Iterator erase( size_t i, Iterator first, Iterator last );
411 
412  template< typename Pred >
413  inline void erase( Pred predicate );
414 
415  template< typename Pred >
416  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
418  //**********************************************************************************************
419 
420  //**Lookup functions****************************************************************************
423  inline Iterator find ( size_t i, size_t j );
424  inline ConstIterator find ( size_t i, size_t j ) const;
425  inline Iterator lowerBound( size_t i, size_t j );
426  inline ConstIterator lowerBound( size_t i, size_t j ) const;
427  inline Iterator upperBound( size_t i, size_t j );
428  inline ConstIterator upperBound( size_t i, size_t j ) const;
430  //**********************************************************************************************
431 
432  //**Debugging functions*************************************************************************
435  inline bool isIntact() const noexcept;
437  //**********************************************************************************************
438 
439  //**Expression template evaluation functions****************************************************
442  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
443  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
444 
445  inline bool canSMPAssign() const noexcept;
447  //**********************************************************************************************
448 
449  private:
450  //**Utility functions***************************************************************************
453  inline void resetLower();
455  //**********************************************************************************************
456 
457  //**Member variables****************************************************************************
460  MT matrix_;
461 
462  //**********************************************************************************************
463 
464  //**Friend declarations*************************************************************************
465  template< typename MT2, bool SO2, bool DF2 >
466  friend MT2& derestrict( UniUpperMatrix<MT2,SO2,DF2>& m );
467  //**********************************************************************************************
468 
469  //**Compile time checks*************************************************************************
483  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
484  //**********************************************************************************************
485 };
487 //*************************************************************************************************
488 
489 
490 
491 
492 //=================================================================================================
493 //
494 // CONSTRUCTORS
495 //
496 //=================================================================================================
497 
498 //*************************************************************************************************
502 template< typename MT // Type of the adapted sparse matrix
503  , bool SO > // Storage order of the adapted sparse matrix
504 inline UniUpperMatrix<MT,SO,false>::UniUpperMatrix()
505  : matrix_() // The adapted sparse matrix
506 {
507  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
508 }
510 //*************************************************************************************************
511 
512 
513 //*************************************************************************************************
521 template< typename MT // Type of the adapted sparse matrix
522  , bool SO > // Storage order of the adapted sparse matrix
523 inline UniUpperMatrix<MT,SO,false>::UniUpperMatrix( size_t n )
524  : matrix_( n, n, n ) // The adapted sparse matrix
525 {
527 
528  for( size_t i=0UL; i<n; ++i ) {
529  matrix_.append( i, i, ElementType(1) );
530  matrix_.finalize( i );
531  }
532 
533  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
534 }
536 //*************************************************************************************************
537 
538 
539 //*************************************************************************************************
549 template< typename MT // Type of the adapted sparse matrix
550  , bool SO > // Storage order of the adapted sparse matrix
551 inline UniUpperMatrix<MT,SO,false>::UniUpperMatrix( size_t n, size_t nonzeros )
552  : matrix_( n, n, max( nonzeros, n ) ) // The adapted sparse matrix
553 {
555 
556  for( size_t i=0UL; i<n; ++i ) {
557  matrix_.append( i, i, ElementType(1) );
558  matrix_.finalize( i );
559  }
560 
561  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
562 }
564 //*************************************************************************************************
565 
566 
567 //*************************************************************************************************
581 template< typename MT // Type of the adapted sparse matrix
582  , bool SO > // Storage order of the adapted sparse matrix
583 inline UniUpperMatrix<MT,SO,false>::UniUpperMatrix( size_t n, const std::vector<size_t>& nonzeros )
584  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
585 {
587 
588  for( size_t i=0UL; i<n; ++i )
589  {
590  if( nonzeros[i] == 0UL ) {
591  BLAZE_THROW_INVALID_ARGUMENT( "Invalid capacity specification" );
592  }
593 
594  matrix_.append( i, i, ElementType(1) );
595  matrix_.finalize( i );
596  }
597 
598  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
599 }
601 //*************************************************************************************************
602 
603 
604 //*************************************************************************************************
610 template< typename MT // Type of the adapted sparse matrix
611  , bool SO > // Storage order of the adapted sparse matrix
612 inline UniUpperMatrix<MT,SO,false>::UniUpperMatrix( const UniUpperMatrix& m )
613  : matrix_( m.matrix_ ) // The adapted sparse matrix
614 {
615  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
616  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
617 }
619 //*************************************************************************************************
620 
621 
622 //*************************************************************************************************
628 template< typename MT // Type of the adapted sparse matrix
629  , bool SO > // Storage order of the adapted sparse matrix
630 inline UniUpperMatrix<MT,SO,false>::UniUpperMatrix( UniUpperMatrix&& m ) noexcept
631  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
632 {
633  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
634  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
635 }
637 //*************************************************************************************************
638 
639 
640 //*************************************************************************************************
650 template< typename MT // Type of the adapted sparse matrix
651  , bool SO > // Storage order of the adapted sparse matrix
652 template< typename MT2 // Type of the foreign matrix
653  , bool SO2 > // Storage order of the foreign matrix
654 inline UniUpperMatrix<MT,SO,false>::UniUpperMatrix( const Matrix<MT2,SO2>& m )
655  : matrix_( ~m ) // The adapted sparse matrix
656 {
657  if( !IsUniUpper<MT2>::value && !isUniUpper( matrix_ ) ) {
658  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of uniupper matrix" );
659  }
660 
661  if( !IsUniUpper<MT2>::value )
662  resetLower();
663 
664  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
665  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
666 }
668 //*************************************************************************************************
669 
670 
671 
672 
673 //=================================================================================================
674 //
675 // DATA ACCESS FUNCTIONS
676 //
677 //=================================================================================================
678 
679 //*************************************************************************************************
695 template< typename MT // Type of the adapted sparse matrix
696  , bool SO > // Storage order of the adapted sparse matrix
698  UniUpperMatrix<MT,SO,false>::operator()( size_t i, size_t j )
699 {
700  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
701  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
702 
703  return Reference( matrix_, i, j );
704 }
706 //*************************************************************************************************
707 
708 
709 //*************************************************************************************************
725 template< typename MT // Type of the adapted sparse matrix
726  , bool SO > // Storage order of the adapted sparse matrix
728  UniUpperMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
729 {
730  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
731  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
732 
733  return matrix_(i,j);
734 }
736 //*************************************************************************************************
737 
738 
739 //*************************************************************************************************
756 template< typename MT // Type of the adapted sparse matrix
757  , bool SO > // Storage order of the adapted sparse matrix
759  UniUpperMatrix<MT,SO,false>::at( size_t i, size_t j )
760 {
761  if( i >= rows() ) {
762  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
763  }
764  if( j >= columns() ) {
765  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
766  }
767  return (*this)(i,j);
768 }
770 //*************************************************************************************************
771 
772 
773 //*************************************************************************************************
790 template< typename MT // Type of the adapted sparse matrix
791  , bool SO > // Storage order of the adapted sparse matrix
793  UniUpperMatrix<MT,SO,false>::at( size_t i, size_t j ) const
794 {
795  if( i >= rows() ) {
796  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
797  }
798  if( j >= columns() ) {
799  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
800  }
801  return (*this)(i,j);
802 }
804 //*************************************************************************************************
805 
806 
807 //*************************************************************************************************
819 template< typename MT // Type of the adapted sparse matrix
820  , bool SO > // Storage order of the adapted sparse matrix
823 {
824  return Iterator( matrix_.begin(i), i );
825 }
827 //*************************************************************************************************
828 
829 
830 //*************************************************************************************************
842 template< typename MT // Type of the adapted sparse matrix
843  , bool SO > // Storage order of the adapted sparse matrix
845  UniUpperMatrix<MT,SO,false>::begin( size_t i ) const
846 {
847  return matrix_.begin(i);
848 }
850 //*************************************************************************************************
851 
852 
853 //*************************************************************************************************
865 template< typename MT // Type of the adapted sparse matrix
866  , bool SO > // Storage order of the adapted sparse matrix
868  UniUpperMatrix<MT,SO,false>::cbegin( size_t i ) const
869 {
870  return matrix_.cbegin(i);
871 }
873 //*************************************************************************************************
874 
875 
876 //*************************************************************************************************
888 template< typename MT // Type of the adapted sparse matrix
889  , bool SO > // Storage order of the adapted sparse matrix
892 {
893  return Iterator( matrix_.end(i), i );
894 }
896 //*************************************************************************************************
897 
898 
899 //*************************************************************************************************
911 template< typename MT // Type of the adapted sparse matrix
912  , bool SO > // Storage order of the adapted sparse matrix
914  UniUpperMatrix<MT,SO,false>::end( size_t i ) const
915 {
916  return matrix_.end(i);
917 }
919 //*************************************************************************************************
920 
921 
922 //*************************************************************************************************
934 template< typename MT // Type of the adapted sparse matrix
935  , bool SO > // Storage order of the adapted sparse matrix
937  UniUpperMatrix<MT,SO,false>::cend( size_t i ) const
938 {
939  return matrix_.cend(i);
940 }
942 //*************************************************************************************************
943 
944 
945 
946 
947 //=================================================================================================
948 //
949 // ASSIGNMENT OPERATORS
950 //
951 //=================================================================================================
952 
953 //*************************************************************************************************
963 template< typename MT // Type of the adapted sparse matrix
964  , bool SO > // Storage order of the adapted sparse matrix
965 inline UniUpperMatrix<MT,SO,false>&
966  UniUpperMatrix<MT,SO,false>::operator=( const UniUpperMatrix& rhs )
967 {
968  matrix_ = rhs.matrix_;
969 
970  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
971  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
972 
973  return *this;
974 }
976 //*************************************************************************************************
977 
978 
979 //*************************************************************************************************
986 template< typename MT // Type of the adapted sparse matrix
987  , bool SO > // Storage order of the adapted sparse matrix
988 inline UniUpperMatrix<MT,SO,false>&
989  UniUpperMatrix<MT,SO,false>::operator=( UniUpperMatrix&& rhs ) noexcept
990 {
991  matrix_ = std::move( rhs.matrix_ );
992 
993  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
994  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
995 
996  return *this;
997 }
999 //*************************************************************************************************
1000 
1001 
1002 //*************************************************************************************************
1015 template< typename MT // Type of the adapted sparse matrix
1016  , bool SO > // Storage order of the adapted sparse matrix
1017 template< typename MT2 // Type of the right-hand side matrix
1018  , bool SO2 > // Storage order of the right-hand side matrix
1019 inline DisableIf_< IsComputation<MT2>, UniUpperMatrix<MT,SO,false>& >
1020  UniUpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
1021 {
1022  if( IsStrictlyTriangular<MT2>::value || ( !IsUniUpper<MT2>::value && !isUniUpper( ~rhs ) ) ) {
1023  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1024  }
1025 
1026  matrix_ = ~rhs;
1027 
1028  if( !IsUniUpper<MT2>::value )
1029  resetLower();
1030 
1031  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1032  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1033 
1034  return *this;
1035 }
1037 //*************************************************************************************************
1038 
1039 
1040 //*************************************************************************************************
1053 template< typename MT // Type of the adapted sparse matrix
1054  , bool SO > // Storage order of the adapted sparse matrix
1055 template< typename MT2 // Type of the right-hand side matrix
1056  , bool SO2 > // Storage order of the right-hand side matrix
1057 inline EnableIf_< IsComputation<MT2>, UniUpperMatrix<MT,SO,false>& >
1058  UniUpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
1059 {
1060  if( IsStrictlyTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1061  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1062  }
1063 
1064  if( IsUniUpper<MT2>::value ) {
1065  matrix_ = ~rhs;
1066  }
1067  else {
1068  MT tmp( ~rhs );
1069 
1070  if( !isUniUpper( tmp ) ) {
1071  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1072  }
1073 
1074  matrix_ = std::move( tmp );
1075  }
1076 
1077  if( !IsUniUpper<MT2>::value )
1078  resetLower();
1079 
1080  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1081  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1082 
1083  return *this;
1084 }
1086 //*************************************************************************************************
1087 
1088 
1089 //*************************************************************************************************
1102 template< typename MT // Type of the adapted sparse matrix
1103  , bool SO > // Storage order of the adapted sparse matrix
1104 template< typename MT2 // Type of the right-hand side matrix
1105  , bool SO2 > // Storage order of the right-hand side matrix
1106 inline DisableIf_< IsComputation<MT2>, UniUpperMatrix<MT,SO,false>& >
1107  UniUpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1108 {
1109  if( IsLower<MT2>::value || IsUniTriangular<MT2>::value ||
1110  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
1111  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1112  }
1113 
1114  matrix_ += ~rhs;
1115 
1116  if( !IsStrictlyUpper<MT2>::value )
1117  resetLower();
1118 
1119  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1120  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1121 
1122  return *this;
1123 }
1125 //*************************************************************************************************
1126 
1127 
1128 //*************************************************************************************************
1141 template< typename MT // Type of the adapted sparse matrix
1142  , bool SO > // Storage order of the adapted sparse matrix
1143 template< typename MT2 // Type of the right-hand side matrix
1144  , bool SO2 > // Storage order of the right-hand side matrix
1145 inline EnableIf_< IsComputation<MT2>, UniUpperMatrix<MT,SO,false>& >
1146  UniUpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1147 {
1148  if( IsLower<MT2>::value || IsUniTriangular<MT2>::value ||
1149  ( IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1150  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1151  }
1152 
1153  if( IsStrictlyUpper<MT2>::value ) {
1154  matrix_ += ~rhs;
1155  }
1156  else {
1157  const ResultType_<MT2> tmp( ~rhs );
1158 
1159  if( !isStrictlyUpper( tmp ) ) {
1160  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1161  }
1162 
1163  matrix_ += tmp;
1164  }
1165 
1166  if( !IsStrictlyUpper<MT2>::value )
1167  resetLower();
1168 
1169  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1170  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1171 
1172  return *this;
1173 }
1175 //*************************************************************************************************
1176 
1177 
1178 //*************************************************************************************************
1191 template< typename MT // Type of the adapted sparse matrix
1192  , bool SO > // Storage order of the adapted sparse matrix
1193 template< typename MT2 // Type of the right-hand side matrix
1194  , bool SO2 > // Storage order of the right-hand side matrix
1195 inline DisableIf_< IsComputation<MT2>, UniUpperMatrix<MT,SO,false>& >
1196  UniUpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1197 {
1198  if( IsLower<MT2>::value || IsUniTriangular<MT2>::value ||
1199  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
1200  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1201  }
1202 
1203  matrix_ -= ~rhs;
1204 
1205  if( !IsStrictlyUpper<MT2>::value )
1206  resetLower();
1207 
1208  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1209  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1210 
1211  return *this;
1212 }
1214 //*************************************************************************************************
1215 
1216 
1217 //*************************************************************************************************
1230 template< typename MT // Type of the adapted sparse matrix
1231  , bool SO > // Storage order of the adapted sparse matrix
1232 template< typename MT2 // Type of the right-hand side matrix
1233  , bool SO2 > // Storage order of the right-hand side matrix
1234 inline EnableIf_< IsComputation<MT2>, UniUpperMatrix<MT,SO,false>& >
1235  UniUpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1236 {
1237  if( IsLower<MT2>::value || IsUniTriangular<MT2>::value ||
1238  ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1239  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1240  }
1241 
1242  if( IsStrictlyUpper<MT2>::value ) {
1243  matrix_ -= ~rhs;
1244  }
1245  else {
1246  const ResultType_<MT2> tmp( ~rhs );
1247 
1248  if( !isStrictlyUpper( tmp ) ) {
1249  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1250  }
1251 
1252  matrix_ -= tmp;
1253  }
1254 
1255  if( !IsStrictlyUpper<MT2>::value )
1256  resetLower();
1257 
1258  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1259  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1260 
1261  return *this;
1262 }
1264 //*************************************************************************************************
1265 
1266 
1267 //*************************************************************************************************
1279 template< typename MT // Type of the adapted sparse matrix
1280  , bool SO > // Storage order of the adapted sparse matrix
1281 template< typename MT2 // Type of the right-hand side matrix
1282  , bool SO2 > // Storage order of the right-hand side matrix
1283 inline UniUpperMatrix<MT,SO,false>&
1284  UniUpperMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1285 {
1286  if( matrix_.rows() != (~rhs).columns() ) {
1287  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1288  }
1289 
1290  MT tmp( matrix_ * ~rhs );
1291 
1292  if( !isUniUpper( tmp ) ) {
1293  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to uniupper matrix" );
1294  }
1295 
1296  matrix_ = std::move( tmp );
1297 
1298  if( !IsUniUpper<MT2>::value )
1299  resetLower();
1300 
1301  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1302  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1303 
1304  return *this;
1305 }
1307 //*************************************************************************************************
1308 
1309 
1310 
1311 
1312 //=================================================================================================
1313 //
1314 // UTILITY FUNCTIONS
1315 //
1316 //=================================================================================================
1317 
1318 //*************************************************************************************************
1324 template< typename MT // Type of the adapted sparse matrix
1325  , bool SO > // Storage order of the adapted sparse matrix
1326 inline size_t UniUpperMatrix<MT,SO,false>::rows() const noexcept
1327 {
1328  return matrix_.rows();
1329 }
1331 //*************************************************************************************************
1332 
1333 
1334 //*************************************************************************************************
1340 template< typename MT // Type of the adapted sparse matrix
1341  , bool SO > // Storage order of the adapted sparse matrix
1342 inline size_t UniUpperMatrix<MT,SO,false>::columns() const noexcept
1343 {
1344  return matrix_.columns();
1345 }
1347 //*************************************************************************************************
1348 
1349 
1350 //*************************************************************************************************
1356 template< typename MT // Type of the adapted sparse matrix
1357  , bool SO > // Storage order of the adapted sparse matrix
1358 inline size_t UniUpperMatrix<MT,SO,false>::capacity() const noexcept
1359 {
1360  return matrix_.capacity();
1361 }
1363 //*************************************************************************************************
1364 
1365 
1366 //*************************************************************************************************
1378 template< typename MT // Type of the adapted sparse matrix
1379  , bool SO > // Storage order of the adapted sparse matrix
1380 inline size_t UniUpperMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1381 {
1382  return matrix_.capacity(i);
1383 }
1385 //*************************************************************************************************
1386 
1387 
1388 //*************************************************************************************************
1394 template< typename MT // Type of the adapted sparse matrix
1395  , bool SO > // Storage order of the adapted sparse matrix
1396 inline size_t UniUpperMatrix<MT,SO,false>::nonZeros() const
1397 {
1398  return matrix_.nonZeros();
1399 }
1401 //*************************************************************************************************
1402 
1403 
1404 //*************************************************************************************************
1416 template< typename MT // Type of the adapted sparse matrix
1417  , bool SO > // Storage order of the adapted sparse matrix
1418 inline size_t UniUpperMatrix<MT,SO,false>::nonZeros( size_t i ) const
1419 {
1420  return matrix_.nonZeros(i);
1421 }
1423 //*************************************************************************************************
1424 
1425 
1426 //*************************************************************************************************
1432 template< typename MT // Type of the adapted sparse matrix
1433  , bool SO > // Storage order of the adapted sparse matrix
1435 {
1436  if( SO ) {
1437  for( size_t j=1UL; j<columns(); ++j ) {
1438  matrix_.erase( j, matrix_.begin(j), matrix_.lowerBound(j,j) );
1439  }
1440  }
1441  else {
1442  for( size_t i=0UL; i<rows(); ++i ) {
1443  matrix_.erase( i, matrix_.lowerBound(i,i+1UL), matrix_.end(i) );
1444  }
1445  }
1446 }
1448 //*************************************************************************************************
1449 
1450 
1451 //*************************************************************************************************
1464 template< typename MT // Type of the adapted sparse matrix
1465  , bool SO > // Storage order of the adapted sparse matrix
1466 inline void UniUpperMatrix<MT,SO,false>::reset( size_t i )
1467 {
1468  if( SO ) {
1469  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1470  }
1471  else {
1472  matrix_.erase( i, matrix_.lowerBound(i,i+1UL), matrix_.end(i) );
1473  }
1474 }
1476 //*************************************************************************************************
1477 
1478 
1479 //*************************************************************************************************
1487 template< typename MT // Type of the adapted sparse matrix
1488  , bool SO > // Storage order of the adapted sparse matrix
1490 {
1491  using blaze::clear;
1492 
1493  if( IsResizable<MT>::value ) {
1494  clear( matrix_ );
1495  }
1496  else {
1497  reset();
1498  }
1499 }
1501 //*************************************************************************************************
1502 
1503 
1504 //*************************************************************************************************
1519 template< typename MT // Type of the adapted sparse matrix
1520  , bool SO > // Storage order of the adapted sparse matrix
1521 void UniUpperMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1522 {
1524 
1525  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1526 
1527  const size_t oldsize( matrix_.rows() );
1528 
1529  matrix_.resize( n, n, preserve );
1530 
1531  if( n > oldsize ) {
1532  for( size_t i=oldsize; i<n; ++i )
1533  matrix_.insert( i, i, ElementType(1) );
1534  }
1535 }
1537 //*************************************************************************************************
1538 
1539 
1540 //*************************************************************************************************
1551 template< typename MT // Type of the adapted sparse matrix
1552  , bool SO > // Storage order of the adapted sparse matrix
1553 inline void UniUpperMatrix<MT,SO,false>::reserve( size_t nonzeros )
1554 {
1555  matrix_.reserve( nonzeros );
1556 }
1558 //*************************************************************************************************
1559 
1560 
1561 //*************************************************************************************************
1575 template< typename MT // Type of the adapted sparse matrix
1576  , bool SO > // Storage order of the adapted sparse matrix
1577 inline void UniUpperMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1578 {
1579  matrix_.reserve( i, nonzeros );
1580 }
1582 //*************************************************************************************************
1583 
1584 
1585 //*************************************************************************************************
1596 template< typename MT // Type of the adapted sparse matrix
1597  , bool SO > // Storage order of the adapted sparse matrix
1598 inline void UniUpperMatrix<MT,SO,false>::trim()
1599 {
1600  matrix_.trim();
1601 }
1603 //*************************************************************************************************
1604 
1605 
1606 //*************************************************************************************************
1618 template< typename MT // Type of the adapted sparse matrix
1619  , bool SO > // Storage order of the adapted sparse matrix
1620 inline void UniUpperMatrix<MT,SO,false>::trim( size_t i )
1621 {
1622  matrix_.trim( i );
1623 }
1625 //*************************************************************************************************
1626 
1627 
1628 //*************************************************************************************************
1635 template< typename MT // Type of the adapted sparse matrix
1636  , bool SO > // Storage order of the adapted sparse matrix
1637 inline void UniUpperMatrix<MT,SO,false>::swap( UniUpperMatrix& m ) noexcept
1638 {
1639  using std::swap;
1640 
1641  swap( matrix_, m.matrix_ );
1642 }
1644 //*************************************************************************************************
1645 
1646 
1647 //*************************************************************************************************
1658 template< typename MT // Type of the adapted dense matrix
1659  , bool SO > // Storage order of the adapted dense matrix
1660 inline constexpr size_t UniUpperMatrix<MT,SO,false>::maxNonZeros() noexcept
1661 {
1663 
1664  return maxNonZeros( Rows<MT>::value );
1665 }
1667 //*************************************************************************************************
1668 
1669 
1670 //*************************************************************************************************
1680 template< typename MT // Type of the adapted dense matrix
1681  , bool SO > // Storage order of the adapted dense matrix
1682 inline constexpr size_t UniUpperMatrix<MT,SO,false>::maxNonZeros( size_t n ) noexcept
1683 {
1684  return ( ( n + 1UL ) * n ) / 2UL;
1685 }
1687 //*************************************************************************************************
1688 
1689 
1690 //*************************************************************************************************
1696 template< typename MT // Type of the adapted dense matrix
1697  , bool SO > // Storage order of the adapted dense matrix
1698 inline void UniUpperMatrix<MT,SO,false>::resetLower()
1699 {
1700  if( SO ) {
1701  for( size_t j=0UL; j<columns(); ++j )
1702  matrix_.erase( j, matrix_.upperBound( j, j ), matrix_.end( j ) );
1703  }
1704  else {
1705  for( size_t i=1UL; i<rows(); ++i )
1706  matrix_.erase( i, matrix_.begin( i ), matrix_.lowerBound( i, i ) );
1707  }
1708 }
1710 //*************************************************************************************************
1711 
1712 
1713 
1714 
1715 //=================================================================================================
1716 //
1717 // INSERTION FUNCTIONS
1718 //
1719 //=================================================================================================
1720 
1721 //*************************************************************************************************
1737 template< typename MT // Type of the adapted sparse matrix
1738  , bool SO > // Storage order of the adapted sparse matrix
1740  UniUpperMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1741 {
1742  if( i >= j ) {
1743  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1744  }
1745 
1746  return Iterator( matrix_.set( i, j, value ), ( SO ? j : i ) );
1747 }
1749 //*************************************************************************************************
1750 
1751 
1752 //*************************************************************************************************
1769 template< typename MT // Type of the adapted sparse matrix
1770  , bool SO > // Storage order of the adapted sparse matrix
1772  UniUpperMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1773 {
1774  if( i >= j ) {
1775  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1776  }
1777 
1778  return Iterator( matrix_.insert( i, j, value ), ( SO ? j : i ) );
1779 }
1781 //*************************************************************************************************
1782 
1783 
1784 //*************************************************************************************************
1834 template< typename MT // Type of the adapted sparse matrix
1835  , bool SO > // Storage order of the adapted sparse matrix
1836 inline void UniUpperMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1837 {
1838  if( i >= j ) {
1839  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1840  }
1841 
1842  if( !check || !isDefault( value ) )
1843  matrix_.insert( i, j, value );
1844 }
1846 //*************************************************************************************************
1847 
1848 
1849 //*************************************************************************************************
1863 template< typename MT // Type of the adapted sparse matrix
1864  , bool SO > // Storage order of the adapted sparse matrix
1865 inline void UniUpperMatrix<MT,SO,false>::finalize( size_t i )
1866 {
1867  matrix_.trim( i );
1868 }
1870 //*************************************************************************************************
1871 
1872 
1873 
1874 
1875 //=================================================================================================
1876 //
1877 // ERASE FUNCTIONS
1878 //
1879 //=================================================================================================
1880 
1881 //*************************************************************************************************
1893 template< typename MT // Type of the adapted sparse matrix
1894  , bool SO > // Storage order of the adapted sparse matrix
1895 inline void UniUpperMatrix<MT,SO,false>::erase( size_t i, size_t j )
1896 {
1897  if( i == j ) {
1898  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
1899  }
1900 
1901  matrix_.erase( i, j );
1902 }
1904 //*************************************************************************************************
1905 
1906 
1907 //*************************************************************************************************
1921 template< typename MT // Type of the adapted sparse matrix
1922  , bool SO > // Storage order of the adapted sparse matrix
1924  UniUpperMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1925 {
1926  if( pos != matrix_.end(i) && pos->index() == i ) {
1927  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
1928  }
1929 
1930  return Iterator( matrix_.erase( i, pos.base() ), i );
1931 }
1933 //*************************************************************************************************
1934 
1935 
1936 //*************************************************************************************************
1951 template< typename MT // Type of the adapted sparse matrix
1952  , bool SO > // Storage order of the adapted sparse matrix
1954  UniUpperMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1955 {
1956  if( first == last )
1957  return last;
1958 
1959  if( ( !SO && first.base() == matrix_.begin(i) ) ||
1960  ( SO && last.base() == matrix_.end(i) ) ) {
1961  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
1962  }
1963 
1964  return Iterator( matrix_.erase( i, first.base(), last.base() ), i );
1965 }
1967 //*************************************************************************************************
1968 
1969 
1970 //*************************************************************************************************
1992 template< typename MT // Type of the adapted sparse matrix
1993  , bool SO > // Storage order of the adapted sparse matrix
1994 template< typename Pred > // Type of the unary predicate
1995 inline void UniUpperMatrix<MT,SO,false>::erase( Pred predicate )
1996 {
1997  if( SO ) {
1998  for( size_t j=1UL; j<columns(); ++j ) {
1999  matrix_.erase( j, matrix_.begin(j), matrix_.find(j,j), predicate );
2000  }
2001  }
2002  else {
2003  for( size_t i=0UL; (i+1UL) < rows(); ++i ) {
2004  matrix_.erase( i, matrix_.lowerBound(i,i+1UL), matrix_.end(i), predicate );
2005  }
2006  }
2007 
2008  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2009 }
2011 //*************************************************************************************************
2012 
2013 
2014 //*************************************************************************************************
2042 template< typename MT // Type of the adapted sparse matrix
2043  , bool SO > // Storage order of the adapted sparse matrix
2044 template< typename Pred > // Type of the unary predicate
2045 inline void UniUpperMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
2046 {
2047  if( first == last )
2048  return;
2049 
2050  if( ( !SO && first.base() == matrix_.begin(i) && predicate( ElementType(1) ) ) ||
2051  ( SO && last.base() == matrix_.end(i) && predicate( ElementType(1) ) ) ) {
2052  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2053  }
2054 
2055  matrix_.erase( i, first.base(), last.base(), predicate );
2056 
2057  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2058 }
2060 //*************************************************************************************************
2061 
2062 
2063 
2064 
2065 //=================================================================================================
2066 //
2067 // LOOKUP FUNCTIONS
2068 //
2069 //=================================================================================================
2070 
2071 //*************************************************************************************************
2087 template< typename MT // Type of the adapted sparse matrix
2088  , bool SO > // Storage order of the adapted sparse matrix
2090  UniUpperMatrix<MT,SO,false>::find( size_t i, size_t j )
2091 {
2092  return Iterator( matrix_.find( i, j ), ( SO ? j : i ) );
2093 }
2095 //*************************************************************************************************
2096 
2097 
2098 //*************************************************************************************************
2114 template< typename MT // Type of the adapted sparse matrix
2115  , bool SO > // Storage order of the adapted sparse matrix
2117  UniUpperMatrix<MT,SO,false>::find( size_t i, size_t j ) const
2118 {
2119  return matrix_.find( i, j );
2120 }
2122 //*************************************************************************************************
2123 
2124 
2125 //*************************************************************************************************
2141 template< typename MT // Type of the adapted sparse matrix
2142  , bool SO > // Storage order of the adapted sparse matrix
2144  UniUpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
2145 {
2146  return Iterator( matrix_.lowerBound( i, j ), ( SO ? j : i ) );
2147 }
2149 //*************************************************************************************************
2150 
2151 
2152 //*************************************************************************************************
2168 template< typename MT // Type of the adapted sparse matrix
2169  , bool SO > // Storage order of the adapted sparse matrix
2171  UniUpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
2172 {
2173  return matrix_.lowerBound( i, j );
2174 }
2176 //*************************************************************************************************
2177 
2178 
2179 //*************************************************************************************************
2195 template< typename MT // Type of the adapted sparse matrix
2196  , bool SO > // Storage order of the adapted sparse matrix
2198  UniUpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
2199 {
2200  return Iterator( matrix_.upperBound( i, j ), ( SO ? j : i ) );
2201 }
2203 //*************************************************************************************************
2204 
2205 
2206 //*************************************************************************************************
2222 template< typename MT // Type of the adapted sparse matrix
2223  , bool SO > // Storage order of the adapted sparse matrix
2225  UniUpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
2226 {
2227  return matrix_.upperBound( i, j );
2228 }
2230 //*************************************************************************************************
2231 
2232 
2233 
2234 
2235 //=================================================================================================
2236 //
2237 // DEBUGGING FUNCTIONS
2238 //
2239 //=================================================================================================
2240 
2241 //*************************************************************************************************
2251 template< typename MT // Type of the adapted sparse matrix
2252  , bool SO > // Storage order of the adapted sparse matrix
2253 inline bool UniUpperMatrix<MT,SO,false>::isIntact() const noexcept
2254 {
2255  using blaze::isIntact;
2256 
2257  return ( isIntact( matrix_ ) && isUniUpper( matrix_ ) );
2258 }
2260 //*************************************************************************************************
2261 
2262 
2263 
2264 
2265 //=================================================================================================
2266 //
2267 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2268 //
2269 //=================================================================================================
2270 
2271 //*************************************************************************************************
2282 template< typename MT // Type of the adapted sparse matrix
2283  , bool SO > // Storage order of the adapted sparse matrix
2284 template< typename Other > // Data type of the foreign expression
2285 inline bool UniUpperMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2286 {
2287  return matrix_.canAlias( alias );
2288 }
2290 //*************************************************************************************************
2291 
2292 
2293 //*************************************************************************************************
2304 template< typename MT // Type of the adapted sparse matrix
2305  , bool SO > // Storage order of the adapted sparse matrix
2306 template< typename Other > // Data type of the foreign expression
2307 inline bool UniUpperMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2308 {
2309  return matrix_.isAliased( alias );
2310 }
2312 //*************************************************************************************************
2313 
2314 
2315 //*************************************************************************************************
2326 template< typename MT // Type of the adapted sparse matrix
2327  , bool SO > // Storage order of the adapted sparse matrix
2328 inline bool UniUpperMatrix<MT,SO,false>::canSMPAssign() const noexcept
2329 {
2330  return matrix_.canSMPAssign();
2331 }
2333 //*************************************************************************************************
2334 
2335 } // namespace blaze
2336 
2337 #endif
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
Constraint on the data type.
Header file for mathematical functions.
#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 IsUniUpper type trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:352
Header file for basic type definitions.
#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:63
Constraint on the data type.
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:194
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2935
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5556
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2928
#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:79
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:390
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:731
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Constraint on the data type.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1802
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2931
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:304
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:238
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
Header file for utility functions for sparse matrices.
Header file for the IsSquare type trait.
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the IsStrictlyUpper type trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5635
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5618
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2939
#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:79
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the Columns type trait.
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:250
Constraint on the data type.
Header file for the IsLower type trait.
Header file for the UniUpperProxy class.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:336
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:2932
Constraints on the storage order of matrix types.
Header file for the exception macros of the math module.
#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:81
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:544
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:260
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:2933
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:290
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2937
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
Header file for all adaptor forward declarations.
Header file for the UniUpperValue class.
#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:79
bool isStrictlyUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly upper triangular matrix.
Definition: DenseMatrix.h:1493
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2934
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
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:61
#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:81
#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:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2938
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:267
Constraint on the data type.
Header file for the UniUpperElement class.
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 &#39;resize&#39; member fu...
Definition: Resizable.h:81
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:320
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2929
#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 &#39;res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2930
bool isUniUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper unitriangular matrix.
Definition: DenseMatrix.h:1406
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:249
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2936
#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:79
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
#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:112
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:677
Header file for the IsResizable type trait.
const DMatDMatMultExpr< T1, T2, false, false, false, false > 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:7505
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61
Header file for the implementation of the base template of the UniUpperMatrix.