Sparse.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_UNILOWERMATRIX_SPARSE_H_
36 #define _BLAZE_MATH_ADAPTORS_UNILOWERMATRIX_SPARSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <iterator>
44 #include <utility>
45 #include <vector>
51 #include <blaze/math/Aliases.h>
61 #include <blaze/math/Exception.h>
63 #include <blaze/math/shims/Clear.h>
65 #include <blaze/math/shims/IsOne.h>
78 #include <blaze/util/Assert.h>
84 #include <blaze/util/DisableIf.h>
85 #include <blaze/util/EnableIf.h>
87 #include <blaze/util/Types.h>
88 
89 
90 namespace blaze {
91 
92 //=================================================================================================
93 //
94 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
95 //
96 //=================================================================================================
97 
98 //*************************************************************************************************
106 template< typename MT // Type of the adapted sparse matrix
107  , bool SO > // Storage order of the adapted sparse matrix
108 class UniLowerMatrix<MT,SO,false>
109  : public SparseMatrix< UniLowerMatrix<MT,SO,false>, SO >
110 {
111  private:
112  //**Type definitions****************************************************************************
113  using OT = OppositeType_<MT>;
114  using TT = TransposeType_<MT>;
115  using ET = ElementType_<MT>;
116  //**********************************************************************************************
117 
118  public:
119  //**Type definitions****************************************************************************
120  using This = UniLowerMatrix<MT,SO,false>;
121  using BaseType = SparseMatrix<This,SO>;
122  using ResultType = This;
123  using OppositeType = UniLowerMatrix<OT,!SO,false>;
124  using TransposeType = UniUpperMatrix<TT,!SO,false>;
125  using ElementType = ET;
126  using ReturnType = ReturnType_<MT>;
127  using CompositeType = const This&;
128  using Reference = UniLowerProxy<MT>;
129  using ConstReference = ConstReference_<MT>;
130  using ConstIterator = ConstIterator_<MT>;
131  //**********************************************************************************************
132 
133  //**Rebind struct definition********************************************************************
136  template< typename NewType > // Data type of the other matrix
137  struct Rebind {
139  using Other = UniLowerMatrix< typename MT::template Rebind<NewType>::Other >;
140  };
141  //**********************************************************************************************
142 
143  //**Resize struct definition********************************************************************
146  template< size_t NewM // Number of rows of the other matrix
147  , size_t NewN > // Number of columns of the other matrix
148  struct Resize {
150  using Other = UniLowerMatrix< typename MT::template Resize<NewM,NewN>::Other >;
151  };
152  //**********************************************************************************************
153 
154  //**Iterator class definition*******************************************************************
157  class Iterator
158  {
159  public:
160  //**Type definitions*************************************************************************
161  using IteratorType = Iterator_<MT>;
162 
163  using IteratorCategory = std::forward_iterator_tag;
164  using ValueType = UniLowerElement<MT>;
165  using PointerType = ValueType;
166  using ReferenceType = ValueType;
167  using DifferenceType = ptrdiff_t;
168 
169  // STL iterator requirements
170  using iterator_category = IteratorCategory;
171  using value_type = ValueType;
172  using pointer = PointerType;
173  using reference = ReferenceType;
174  using difference_type = DifferenceType;
175  //*******************************************************************************************
176 
177  //**Default constructor**********************************************************************
180  inline Iterator()
181  : pos_ ( ) // Iterator to the current lower unitriangular matrix element
182  , index_ ( 0UL ) // The row/column index of the iterator
183  {}
184  //*******************************************************************************************
185 
186  //**Constructor******************************************************************************
192  inline Iterator( IteratorType pos, size_t index )
193  : pos_ ( pos ) // Iterator to the current lower unitriangular matrix element
194  , index_( index ) // The row/column index of the iterator
195  {}
196  //*******************************************************************************************
197 
198  //**Prefix increment operator****************************************************************
203  inline Iterator& operator++() {
204  ++pos_;
205  return *this;
206  }
207  //*******************************************************************************************
208 
209  //**Postfix increment operator***************************************************************
214  inline const Iterator operator++( int ) {
215  const Iterator tmp( *this );
216  ++(*this);
217  return tmp;
218  }
219  //*******************************************************************************************
220 
221  //**Element access operator******************************************************************
226  inline ReferenceType operator*() const {
227  return ReferenceType( pos_, pos_->index() == index_ );
228  }
229  //*******************************************************************************************
230 
231  //**Element access operator******************************************************************
236  inline PointerType operator->() const {
237  return PointerType( pos_, pos_->index() == index_ );
238  }
239  //*******************************************************************************************
240 
241  //**Conversion operator**********************************************************************
246  inline operator ConstIterator() const {
247  return pos_;
248  }
249  //*******************************************************************************************
250 
251  //**Equality operator************************************************************************
257  inline bool operator==( const Iterator& rhs ) const {
258  return pos_ == rhs.pos_;
259  }
260  //*******************************************************************************************
261 
262  //**Inequality operator**********************************************************************
268  inline bool operator!=( const Iterator& rhs ) const {
269  return !( *this == rhs );
270  }
271  //*******************************************************************************************
272 
273  //**Subtraction operator*********************************************************************
279  inline DifferenceType operator-( const Iterator& rhs ) const {
280  return pos_ - rhs.pos_;
281  }
282  //*******************************************************************************************
283 
284  //**Base function****************************************************************************
289  inline IteratorType base() const {
290  return pos_;
291  }
292  //*******************************************************************************************
293 
294  private:
295  //**Member variables*************************************************************************
296  IteratorType pos_;
297  size_t index_;
298  //*******************************************************************************************
299  };
300  //**********************************************************************************************
301 
302  //**Compilation flags***************************************************************************
304  enum : bool { smpAssignable = false };
305  //**********************************************************************************************
306 
307  //**Constructors********************************************************************************
310  explicit inline UniLowerMatrix();
311  explicit inline UniLowerMatrix( size_t n );
312  explicit inline UniLowerMatrix( size_t n, size_t nonzeros );
313  explicit inline UniLowerMatrix( size_t n, const std::vector<size_t>& nonzeros );
314 
315  inline UniLowerMatrix( const UniLowerMatrix& m );
316  inline UniLowerMatrix( UniLowerMatrix&& m ) noexcept;
317 
318  template< typename MT2, bool SO2 >
319  inline UniLowerMatrix( const Matrix<MT2,SO2>& m );
321  //**********************************************************************************************
322 
323  //**Destructor**********************************************************************************
324  // No explicitly declared destructor.
325  //**********************************************************************************************
326 
327  //**Data access functions***********************************************************************
330  inline Reference operator()( size_t i, size_t j );
331  inline ConstReference operator()( size_t i, size_t j ) const;
332  inline Reference at( size_t i, size_t j );
333  inline ConstReference at( size_t i, size_t j ) const;
334  inline Iterator begin ( size_t i );
335  inline ConstIterator begin ( size_t i ) const;
336  inline ConstIterator cbegin( size_t i ) const;
337  inline Iterator end ( size_t i );
338  inline ConstIterator end ( size_t i ) const;
339  inline ConstIterator cend ( size_t i ) const;
341  //**********************************************************************************************
342 
343  //**Assignment operators************************************************************************
346  inline UniLowerMatrix& operator=( const UniLowerMatrix& rhs );
347  inline UniLowerMatrix& operator=( UniLowerMatrix&& rhs ) noexcept;
348 
349  template< typename MT2, bool SO2 >
350  inline DisableIf_< IsComputation<MT2>, UniLowerMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
351 
352  template< typename MT2, bool SO2 >
353  inline EnableIf_< IsComputation<MT2>, UniLowerMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
354 
355  template< typename MT2, bool SO2 >
356  inline DisableIf_< IsComputation<MT2>, UniLowerMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
357 
358  template< typename MT2, bool SO2 >
359  inline EnableIf_< IsComputation<MT2>, UniLowerMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
360 
361  template< typename MT2, bool SO2 >
362  inline DisableIf_< IsComputation<MT2>, UniLowerMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
363 
364  template< typename MT2, bool SO2 >
365  inline EnableIf_< IsComputation<MT2>, UniLowerMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
366 
367  template< typename MT2, bool SO2 >
368  inline UniLowerMatrix& operator%=( const Matrix<MT2,SO2>& rhs );
369 
370  template< typename MT2, bool SO2 >
371  inline UniLowerMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
373  //**********************************************************************************************
374 
375  //**Utility functions***************************************************************************
378  inline size_t rows() const noexcept;
379  inline size_t columns() const noexcept;
380  inline size_t capacity() const noexcept;
381  inline size_t capacity( size_t i ) const noexcept;
382  inline size_t nonZeros() const;
383  inline size_t nonZeros( size_t i ) const;
384  inline void reset();
385  inline void reset( size_t i );
386  inline void clear();
387  inline void resize ( size_t n, bool preserve=true );
388  inline void reserve( size_t nonzeros );
389  inline void reserve( size_t i, size_t nonzeros );
390  inline void trim();
391  inline void trim( size_t i );
392  inline void shrinkToFit();
393  inline void swap( UniLowerMatrix& m ) noexcept;
394 
395  static inline constexpr size_t maxNonZeros() noexcept;
396  static inline constexpr size_t maxNonZeros( size_t n ) noexcept;
398  //**********************************************************************************************
399 
400  //**Insertion functions*************************************************************************
403  inline Iterator set ( size_t i, size_t j, const ElementType& value );
404  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
405  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
406  inline void finalize( size_t i );
408  //**********************************************************************************************
409 
410  //**Erase functions*****************************************************************************
413  inline void erase( size_t i, size_t j );
414  inline Iterator erase( size_t i, Iterator pos );
415  inline Iterator erase( size_t i, Iterator first, Iterator last );
416 
417  template< typename Pred >
418  inline void erase( Pred predicate );
419 
420  template< typename Pred >
421  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
423  //**********************************************************************************************
424 
425  //**Lookup functions****************************************************************************
428  inline Iterator find ( size_t i, size_t j );
429  inline ConstIterator find ( size_t i, size_t j ) const;
430  inline Iterator lowerBound( size_t i, size_t j );
431  inline ConstIterator lowerBound( size_t i, size_t j ) const;
432  inline Iterator upperBound( size_t i, size_t j );
433  inline ConstIterator upperBound( size_t i, size_t j ) const;
435  //**********************************************************************************************
436 
437  //**Debugging functions*************************************************************************
440  inline bool isIntact() const noexcept;
442  //**********************************************************************************************
443 
444  //**Expression template evaluation functions****************************************************
447  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
448  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
449 
450  inline bool canSMPAssign() const noexcept;
452  //**********************************************************************************************
453 
454  private:
455  //**Utility functions***************************************************************************
458  inline void resetUpper();
460  //**********************************************************************************************
461 
462  //**Member variables****************************************************************************
465  MT matrix_;
466 
467  //**********************************************************************************************
468 
469  //**Friend declarations*************************************************************************
470  template< typename MT2, bool SO2, bool DF2 >
471  friend MT2& derestrict( UniLowerMatrix<MT2,SO2,DF2>& m );
472  //**********************************************************************************************
473 
474  //**Compile time checks*************************************************************************
488  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
489  //**********************************************************************************************
490 };
492 //*************************************************************************************************
493 
494 
495 
496 
497 //=================================================================================================
498 //
499 // CONSTRUCTORS
500 //
501 //=================================================================================================
502 
503 //*************************************************************************************************
507 template< typename MT // Type of the adapted sparse matrix
508  , bool SO > // Storage order of the adapted sparse matrix
509 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix()
510  : matrix_() // The adapted sparse matrix
511 {
512  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
513 }
515 //*************************************************************************************************
516 
517 
518 //*************************************************************************************************
526 template< typename MT // Type of the adapted sparse matrix
527  , bool SO > // Storage order of the adapted sparse matrix
528 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n )
529  : matrix_( n, n, n ) // The adapted sparse matrix
530 {
532 
533  for( size_t i=0UL; i<n; ++i ) {
534  matrix_.append( i, i, ElementType(1) );
535  matrix_.finalize( i );
536  }
537 
538  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
539 }
541 //*************************************************************************************************
542 
543 
544 //*************************************************************************************************
554 template< typename MT // Type of the adapted sparse matrix
555  , bool SO > // Storage order of the adapted sparse matrix
556 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n, size_t nonzeros )
557  : matrix_( n, n, max( nonzeros, n ) ) // The adapted sparse matrix
558 {
560 
561  for( size_t i=0UL; i<n; ++i ) {
562  matrix_.append( i, i, ElementType(1) );
563  matrix_.finalize( i );
564  }
565 
566  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
567 }
569 //*************************************************************************************************
570 
571 
572 //*************************************************************************************************
586 template< typename MT // Type of the adapted sparse matrix
587  , bool SO > // Storage order of the adapted sparse matrix
588 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n, const std::vector<size_t>& nonzeros )
589  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
590 {
592 
593  for( size_t i=0UL; i<n; ++i )
594  {
595  if( nonzeros[i] == 0UL ) {
596  BLAZE_THROW_INVALID_ARGUMENT( "Invalid capacity specification" );
597  }
598 
599  matrix_.append( i, i, ElementType(1) );
600  matrix_.finalize( i );
601  }
602 
603  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
604 }
606 //*************************************************************************************************
607 
608 
609 //*************************************************************************************************
615 template< typename MT // Type of the adapted sparse matrix
616  , bool SO > // Storage order of the adapted sparse matrix
617 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( const UniLowerMatrix& m )
618  : matrix_( m.matrix_ ) // The adapted sparse matrix
619 {
620  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
621  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
622 }
624 //*************************************************************************************************
625 
626 
627 //*************************************************************************************************
633 template< typename MT // Type of the adapted sparse matrix
634  , bool SO > // Storage order of the adapted sparse matrix
635 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( UniLowerMatrix&& m ) noexcept
636  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
637 {
638  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
639  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
640 }
642 //*************************************************************************************************
643 
644 
645 //*************************************************************************************************
655 template< typename MT // Type of the adapted sparse matrix
656  , bool SO > // Storage order of the adapted sparse matrix
657 template< typename MT2 // Type of the foreign matrix
658  , bool SO2 > // Storage order of the foreign matrix
659 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( const Matrix<MT2,SO2>& m )
660  : matrix_( ~m ) // The adapted sparse matrix
661 {
662  if( !IsUniLower<MT2>::value && !isUniLower( matrix_ ) ) {
663  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
664  }
665 
666  if( !IsUniLower<MT2>::value )
667  resetUpper();
668 
669  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
670  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
671 }
673 //*************************************************************************************************
674 
675 
676 
677 
678 //=================================================================================================
679 //
680 // DATA ACCESS FUNCTIONS
681 //
682 //=================================================================================================
683 
684 //*************************************************************************************************
700 template< typename MT // Type of the adapted sparse matrix
701  , bool SO > // Storage order of the adapted sparse matrix
703  UniLowerMatrix<MT,SO,false>::operator()( size_t i, size_t j )
704 {
705  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
706  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
707 
708  return Reference( matrix_, i, j );
709 }
711 //*************************************************************************************************
712 
713 
714 //*************************************************************************************************
730 template< typename MT // Type of the adapted sparse matrix
731  , bool SO > // Storage order of the adapted sparse matrix
733  UniLowerMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
734 {
735  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
736  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
737 
738  return matrix_(i,j);
739 }
741 //*************************************************************************************************
742 
743 
744 //*************************************************************************************************
761 template< typename MT // Type of the adapted sparse matrix
762  , bool SO > // Storage order of the adapted sparse matrix
764  UniLowerMatrix<MT,SO,false>::at( size_t i, size_t j )
765 {
766  if( i >= rows() ) {
767  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
768  }
769  if( j >= columns() ) {
770  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
771  }
772  return (*this)(i,j);
773 }
775 //*************************************************************************************************
776 
777 
778 //*************************************************************************************************
795 template< typename MT // Type of the adapted sparse matrix
796  , bool SO > // Storage order of the adapted sparse matrix
798  UniLowerMatrix<MT,SO,false>::at( size_t i, size_t j ) const
799 {
800  if( i >= rows() ) {
801  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
802  }
803  if( j >= columns() ) {
804  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
805  }
806  return (*this)(i,j);
807 }
809 //*************************************************************************************************
810 
811 
812 //*************************************************************************************************
824 template< typename MT // Type of the adapted sparse matrix
825  , bool SO > // Storage order of the adapted sparse matrix
828 {
829  return Iterator( matrix_.begin(i), i );
830 }
832 //*************************************************************************************************
833 
834 
835 //*************************************************************************************************
847 template< typename MT // Type of the adapted sparse matrix
848  , bool SO > // Storage order of the adapted sparse matrix
850  UniLowerMatrix<MT,SO,false>::begin( size_t i ) const
851 {
852  return matrix_.begin(i);
853 }
855 //*************************************************************************************************
856 
857 
858 //*************************************************************************************************
870 template< typename MT // Type of the adapted sparse matrix
871  , bool SO > // Storage order of the adapted sparse matrix
873  UniLowerMatrix<MT,SO,false>::cbegin( size_t i ) const
874 {
875  return matrix_.cbegin(i);
876 }
878 //*************************************************************************************************
879 
880 
881 //*************************************************************************************************
893 template< typename MT // Type of the adapted sparse matrix
894  , bool SO > // Storage order of the adapted sparse matrix
897 {
898  return Iterator( matrix_.end(i), i );
899 }
901 //*************************************************************************************************
902 
903 
904 //*************************************************************************************************
916 template< typename MT // Type of the adapted sparse matrix
917  , bool SO > // Storage order of the adapted sparse matrix
919  UniLowerMatrix<MT,SO,false>::end( size_t i ) const
920 {
921  return matrix_.end(i);
922 }
924 //*************************************************************************************************
925 
926 
927 //*************************************************************************************************
939 template< typename MT // Type of the adapted sparse matrix
940  , bool SO > // Storage order of the adapted sparse matrix
942  UniLowerMatrix<MT,SO,false>::cend( size_t i ) const
943 {
944  return matrix_.cend(i);
945 }
947 //*************************************************************************************************
948 
949 
950 
951 
952 //=================================================================================================
953 //
954 // ASSIGNMENT OPERATORS
955 //
956 //=================================================================================================
957 
958 //*************************************************************************************************
968 template< typename MT // Type of the adapted sparse matrix
969  , bool SO > // Storage order of the adapted sparse matrix
970 inline UniLowerMatrix<MT,SO,false>&
971  UniLowerMatrix<MT,SO,false>::operator=( const UniLowerMatrix& rhs )
972 {
973  matrix_ = rhs.matrix_;
974 
975  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
976  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
977 
978  return *this;
979 }
981 //*************************************************************************************************
982 
983 
984 //*************************************************************************************************
991 template< typename MT // Type of the adapted sparse matrix
992  , bool SO > // Storage order of the adapted sparse matrix
993 inline UniLowerMatrix<MT,SO,false>&
994  UniLowerMatrix<MT,SO,false>::operator=( UniLowerMatrix&& rhs ) noexcept
995 {
996  matrix_ = std::move( rhs.matrix_ );
997 
998  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
999  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1000 
1001  return *this;
1002 }
1004 //*************************************************************************************************
1005 
1006 
1007 //*************************************************************************************************
1020 template< typename MT // Type of the adapted sparse matrix
1021  , bool SO > // Storage order of the adapted sparse matrix
1022 template< typename MT2 // Type of the right-hand side matrix
1023  , bool SO2 > // Storage order of the right-hand side matrix
1024 inline DisableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1025  UniLowerMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
1026 {
1027  if( IsStrictlyTriangular<MT2>::value || ( !IsUniLower<MT2>::value && !isUniLower( ~rhs ) ) ) {
1028  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1029  }
1030 
1031  matrix_ = decllow( ~rhs );
1032 
1033  if( !IsUniLower<MT2>::value )
1034  resetUpper();
1035 
1036  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1037  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1038 
1039  return *this;
1040 }
1042 //*************************************************************************************************
1043 
1044 
1045 //*************************************************************************************************
1058 template< typename MT // Type of the adapted sparse matrix
1059  , bool SO > // Storage order of the adapted sparse matrix
1060 template< typename MT2 // Type of the right-hand side matrix
1061  , bool SO2 > // Storage order of the right-hand side matrix
1062 inline EnableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1063  UniLowerMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
1064 {
1065  if( IsStrictlyTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1066  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1067  }
1068 
1069  if( IsUniLower<MT2>::value ) {
1070  matrix_ = ~rhs;
1071  }
1072  else {
1073  MT tmp( ~rhs );
1074 
1075  if( !isUniLower( tmp ) ) {
1076  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1077  }
1078 
1079  matrix_ = std::move( tmp );
1080  }
1081 
1082  if( !IsUniLower<MT2>::value )
1083  resetUpper();
1084 
1085  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1086  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1087 
1088  return *this;
1089 }
1091 //*************************************************************************************************
1092 
1093 
1094 //*************************************************************************************************
1107 template< typename MT // Type of the adapted sparse matrix
1108  , bool SO > // Storage order of the adapted sparse matrix
1109 template< typename MT2 // Type of the right-hand side matrix
1110  , bool SO2 > // Storage order of the right-hand side matrix
1111 inline DisableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1112  UniLowerMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1113 {
1114  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1115  ( !IsStrictlyLower<MT2>::value && !isStrictlyLower( ~rhs ) ) ) {
1116  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1117  }
1118 
1119  matrix_ += decllow( ~rhs );
1120 
1121  if( !IsStrictlyLower<MT2>::value )
1122  resetUpper();
1123 
1124  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1125  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1126 
1127  return *this;
1128 }
1130 //*************************************************************************************************
1131 
1132 
1133 //*************************************************************************************************
1146 template< typename MT // Type of the adapted sparse matrix
1147  , bool SO > // Storage order of the adapted sparse matrix
1148 template< typename MT2 // Type of the right-hand side matrix
1149  , bool SO2 > // Storage order of the right-hand side matrix
1150 inline EnableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1151  UniLowerMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1152 {
1153  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1154  ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1155  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1156  }
1157 
1158  if( IsStrictlyLower<MT2>::value ) {
1159  matrix_ += ~rhs;
1160  }
1161  else {
1162  const ResultType_<MT2> tmp( ~rhs );
1163 
1164  if( !isStrictlyLower( tmp ) ) {
1165  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1166  }
1167 
1168  matrix_ += decllow( tmp );
1169  }
1170 
1171  if( !IsStrictlyLower<MT2>::value )
1172  resetUpper();
1173 
1174  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1175  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1176 
1177  return *this;
1178 }
1180 //*************************************************************************************************
1181 
1182 
1183 //*************************************************************************************************
1196 template< typename MT // Type of the adapted sparse matrix
1197  , bool SO > // Storage order of the adapted sparse matrix
1198 template< typename MT2 // Type of the right-hand side matrix
1199  , bool SO2 > // Storage order of the right-hand side matrix
1200 inline DisableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1201  UniLowerMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1202 {
1203  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1204  ( !IsStrictlyLower<MT2>::value && !isStrictlyLower( ~rhs ) ) ) {
1205  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1206  }
1207 
1208  matrix_ -= decllow( ~rhs );
1209 
1210  if( !IsStrictlyLower<MT2>::value )
1211  resetUpper();
1212 
1213  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1214  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1215 
1216  return *this;
1217 }
1219 //*************************************************************************************************
1220 
1221 
1222 //*************************************************************************************************
1235 template< typename MT // Type of the adapted sparse matrix
1236  , bool SO > // Storage order of the adapted sparse matrix
1237 template< typename MT2 // Type of the right-hand side matrix
1238  , bool SO2 > // Storage order of the right-hand side matrix
1239 inline EnableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1240  UniLowerMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1241 {
1242  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1243  ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1244  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1245  }
1246 
1247  if( IsStrictlyLower<MT2>::value ) {
1248  matrix_ -= ~rhs;
1249  }
1250  else {
1251  const ResultType_<MT2> tmp( ~rhs );
1252 
1253  if( !isStrictlyLower( tmp ) ) {
1254  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1255  }
1256 
1257  matrix_ -= decllow( tmp );
1258  }
1259 
1260  if( !IsStrictlyLower<MT2>::value )
1261  resetUpper();
1262 
1263  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1264  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1265 
1266  return *this;
1267 }
1269 //*************************************************************************************************
1270 
1271 
1272 //*************************************************************************************************
1285 template< typename MT // Type of the adapted sparse matrix
1286  , bool SO > // Storage order of the adapted sparse matrix
1287 template< typename MT2 // Type of the right-hand side matrix
1288  , bool SO2 > // Storage order of the right-hand side matrix
1289 inline UniLowerMatrix<MT,SO,false>&
1290  UniLowerMatrix<MT,SO,false>::operator%=( const Matrix<MT2,SO2>& rhs )
1291 {
1292  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1293  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1294  }
1295 
1296  If_< IsComputation<MT2>, ResultType_<MT2>, const MT2& > tmp( ~rhs );
1297 
1298  for( size_t i=0UL; i<(~rhs).rows(); ++i ) {
1299  if( !isOne( tmp(i,i) ) ) {
1300  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1301  }
1302  }
1303 
1304  matrix_ %= tmp;
1305 
1306  if( !IsUniLower<MT2>::value )
1307  resetUpper();
1308 
1309  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1310  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1311 
1312  return *this;
1313 }
1315 //*************************************************************************************************
1316 
1317 
1318 //*************************************************************************************************
1330 template< typename MT // Type of the adapted sparse matrix
1331  , bool SO > // Storage order of the adapted sparse matrix
1332 template< typename MT2 // Type of the right-hand side matrix
1333  , bool SO2 > // Storage order of the right-hand side matrix
1334 inline UniLowerMatrix<MT,SO,false>&
1335  UniLowerMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1336 {
1337  if( matrix_.rows() != (~rhs).columns() ) {
1338  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1339  }
1340 
1341  MT tmp( matrix_ * ~rhs );
1342 
1343  if( !isUniLower( tmp ) ) {
1344  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1345  }
1346 
1347  matrix_ = std::move( tmp );
1348 
1349  if( !IsUniLower<MT2>::value )
1350  resetUpper();
1351 
1352  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1353  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1354 
1355  return *this;
1356 }
1358 //*************************************************************************************************
1359 
1360 
1361 
1362 
1363 //=================================================================================================
1364 //
1365 // UTILITY FUNCTIONS
1366 //
1367 //=================================================================================================
1368 
1369 //*************************************************************************************************
1375 template< typename MT // Type of the adapted sparse matrix
1376  , bool SO > // Storage order of the adapted sparse matrix
1377 inline size_t UniLowerMatrix<MT,SO,false>::rows() const noexcept
1378 {
1379  return matrix_.rows();
1380 }
1382 //*************************************************************************************************
1383 
1384 
1385 //*************************************************************************************************
1391 template< typename MT // Type of the adapted sparse matrix
1392  , bool SO > // Storage order of the adapted sparse matrix
1393 inline size_t UniLowerMatrix<MT,SO,false>::columns() const noexcept
1394 {
1395  return matrix_.columns();
1396 }
1398 //*************************************************************************************************
1399 
1400 
1401 //*************************************************************************************************
1407 template< typename MT // Type of the adapted sparse matrix
1408  , bool SO > // Storage order of the adapted sparse matrix
1409 inline size_t UniLowerMatrix<MT,SO,false>::capacity() const noexcept
1410 {
1411  return matrix_.capacity();
1412 }
1414 //*************************************************************************************************
1415 
1416 
1417 //*************************************************************************************************
1429 template< typename MT // Type of the adapted sparse matrix
1430  , bool SO > // Storage order of the adapted sparse matrix
1431 inline size_t UniLowerMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1432 {
1433  return matrix_.capacity(i);
1434 }
1436 //*************************************************************************************************
1437 
1438 
1439 //*************************************************************************************************
1445 template< typename MT // Type of the adapted sparse matrix
1446  , bool SO > // Storage order of the adapted sparse matrix
1447 inline size_t UniLowerMatrix<MT,SO,false>::nonZeros() const
1448 {
1449  return matrix_.nonZeros();
1450 }
1452 //*************************************************************************************************
1453 
1454 
1455 //*************************************************************************************************
1467 template< typename MT // Type of the adapted sparse matrix
1468  , bool SO > // Storage order of the adapted sparse matrix
1469 inline size_t UniLowerMatrix<MT,SO,false>::nonZeros( size_t i ) const
1470 {
1471  return matrix_.nonZeros(i);
1472 }
1474 //*************************************************************************************************
1475 
1476 
1477 //*************************************************************************************************
1483 template< typename MT // Type of the adapted sparse matrix
1484  , bool SO > // Storage order of the adapted sparse matrix
1486 {
1487  if( SO ) {
1488  for( size_t j=0UL; j<columns(); ++j ) {
1489  matrix_.erase( j, matrix_.lowerBound(j+1UL,j), matrix_.end(j) );
1490  }
1491  }
1492  else {
1493  for( size_t i=1UL; i<rows(); ++i ) {
1494  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1495  }
1496  }
1497 }
1499 //*************************************************************************************************
1500 
1501 
1502 //*************************************************************************************************
1515 template< typename MT // Type of the adapted sparse matrix
1516  , bool SO > // Storage order of the adapted sparse matrix
1517 inline void UniLowerMatrix<MT,SO,false>::reset( size_t i )
1518 {
1519  if( SO ) {
1520  matrix_.erase( i, matrix_.lowerBound(i+1UL,i), matrix_.end(i) );
1521  }
1522  else {
1523  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1524  }
1525 }
1527 //*************************************************************************************************
1528 
1529 
1530 //*************************************************************************************************
1538 template< typename MT // Type of the adapted sparse matrix
1539  , bool SO > // Storage order of the adapted sparse matrix
1541 {
1542  using blaze::clear;
1543 
1544  if( IsResizable<MT>::value ) {
1545  clear( matrix_ );
1546  }
1547  else {
1548  reset();
1549  }
1550 }
1552 //*************************************************************************************************
1553 
1554 
1555 //*************************************************************************************************
1570 template< typename MT // Type of the adapted sparse matrix
1571  , bool SO > // Storage order of the adapted sparse matrix
1572 void UniLowerMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1573 {
1575 
1576  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1577 
1578  const size_t oldsize( matrix_.rows() );
1579 
1580  matrix_.resize( n, n, preserve );
1581 
1582  if( n > oldsize ) {
1583  for( size_t i=oldsize; i<n; ++i )
1584  matrix_.insert( i, i, ElementType(1) );
1585  }
1586 }
1588 //*************************************************************************************************
1589 
1590 
1591 //*************************************************************************************************
1602 template< typename MT // Type of the adapted sparse matrix
1603  , bool SO > // Storage order of the adapted sparse matrix
1604 inline void UniLowerMatrix<MT,SO,false>::reserve( size_t nonzeros )
1605 {
1606  matrix_.reserve( nonzeros );
1607 }
1609 //*************************************************************************************************
1610 
1611 
1612 //*************************************************************************************************
1626 template< typename MT // Type of the adapted sparse matrix
1627  , bool SO > // Storage order of the adapted sparse matrix
1628 inline void UniLowerMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1629 {
1630  matrix_.reserve( i, nonzeros );
1631 }
1633 //*************************************************************************************************
1634 
1635 
1636 //*************************************************************************************************
1647 template< typename MT // Type of the adapted sparse matrix
1648  , bool SO > // Storage order of the adapted sparse matrix
1649 inline void UniLowerMatrix<MT,SO,false>::trim()
1650 {
1651  matrix_.trim();
1652 }
1654 //*************************************************************************************************
1655 
1656 
1657 //*************************************************************************************************
1669 template< typename MT // Type of the adapted sparse matrix
1670  , bool SO > // Storage order of the adapted sparse matrix
1671 inline void UniLowerMatrix<MT,SO,false>::trim( size_t i )
1672 {
1673  matrix_.trim( i );
1674 }
1676 //*************************************************************************************************
1677 
1678 
1679 //*************************************************************************************************
1689 template< typename MT // Type of the adapted sparse matrix
1690  , bool SO > // Storage order of the adapted sparse matrix
1692 {
1693  matrix_.shrinkToFit();
1694 }
1696 //*************************************************************************************************
1697 
1698 
1699 //*************************************************************************************************
1706 template< typename MT // Type of the adapted sparse matrix
1707  , bool SO > // Storage order of the adapted sparse matrix
1708 inline void UniLowerMatrix<MT,SO,false>::swap( UniLowerMatrix& m ) noexcept
1709 {
1710  using std::swap;
1711 
1712  swap( matrix_, m.matrix_ );
1713 }
1715 //*************************************************************************************************
1716 
1717 
1718 //*************************************************************************************************
1729 template< typename MT // Type of the adapted dense matrix
1730  , bool SO > // Storage order of the adapted dense matrix
1731 inline constexpr size_t UniLowerMatrix<MT,SO,false>::maxNonZeros() noexcept
1732 {
1734 
1735  return maxNonZeros( Rows<MT>::value );
1736 }
1738 //*************************************************************************************************
1739 
1740 
1741 //*************************************************************************************************
1751 template< typename MT // Type of the adapted dense matrix
1752  , bool SO > // Storage order of the adapted dense matrix
1753 inline constexpr size_t UniLowerMatrix<MT,SO,false>::maxNonZeros( size_t n ) noexcept
1754 {
1755  return ( ( n + 1UL ) * n ) / 2UL;
1756 }
1758 //*************************************************************************************************
1759 
1760 
1761 //*************************************************************************************************
1767 template< typename MT // Type of the adapted dense matrix
1768  , bool SO > // Storage order of the adapted dense matrix
1769 inline void UniLowerMatrix<MT,SO,false>::resetUpper()
1770 {
1771  if( SO ) {
1772  for( size_t j=1UL; j<columns(); ++j )
1773  matrix_.erase( j, matrix_.begin( j ), matrix_.lowerBound( j, j ) );
1774  }
1775  else {
1776  for( size_t i=0UL; i<rows(); ++i )
1777  matrix_.erase( i, matrix_.upperBound( i, i ), matrix_.end( i ) );
1778  }
1779 }
1781 //*************************************************************************************************
1782 
1783 
1784 
1785 
1786 //=================================================================================================
1787 //
1788 // INSERTION FUNCTIONS
1789 //
1790 //=================================================================================================
1791 
1792 //*************************************************************************************************
1808 template< typename MT // Type of the adapted sparse matrix
1809  , bool SO > // Storage order of the adapted sparse matrix
1811  UniLowerMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1812 {
1813  if( i <= j ) {
1814  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1815  }
1816 
1817  return Iterator( matrix_.set( i, j, value ), ( SO ? j : i ) );
1818 }
1820 //*************************************************************************************************
1821 
1822 
1823 //*************************************************************************************************
1840 template< typename MT // Type of the adapted sparse matrix
1841  , bool SO > // Storage order of the adapted sparse matrix
1843  UniLowerMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1844 {
1845  if( i <= j ) {
1846  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1847  }
1848 
1849  return Iterator( matrix_.insert( i, j, value ), ( SO ? j : i ) );
1850 }
1852 //*************************************************************************************************
1853 
1854 
1855 //*************************************************************************************************
1905 template< typename MT // Type of the adapted sparse matrix
1906  , bool SO > // Storage order of the adapted sparse matrix
1907 inline void UniLowerMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1908 {
1909  if( i <= j ) {
1910  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1911  }
1912 
1913  if( !check || !isDefault<strict>( value ) )
1914  matrix_.insert( i, j, value );
1915 }
1917 //*************************************************************************************************
1918 
1919 
1920 //*************************************************************************************************
1934 template< typename MT // Type of the adapted sparse matrix
1935  , bool SO > // Storage order of the adapted sparse matrix
1936 inline void UniLowerMatrix<MT,SO,false>::finalize( size_t i )
1937 {
1938  matrix_.trim( i );
1939 }
1941 //*************************************************************************************************
1942 
1943 
1944 
1945 
1946 //=================================================================================================
1947 //
1948 // ERASE FUNCTIONS
1949 //
1950 //=================================================================================================
1951 
1952 //*************************************************************************************************
1964 template< typename MT // Type of the adapted sparse matrix
1965  , bool SO > // Storage order of the adapted sparse matrix
1966 inline void UniLowerMatrix<MT,SO,false>::erase( size_t i, size_t j )
1967 {
1968  if( i == j ) {
1969  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
1970  }
1971 
1972  matrix_.erase( i, j );
1973 }
1975 //*************************************************************************************************
1976 
1977 
1978 //*************************************************************************************************
1992 template< typename MT // Type of the adapted sparse matrix
1993  , bool SO > // Storage order of the adapted sparse matrix
1995  UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1996 {
1997  if( pos != matrix_.end(i) && pos->index() == i ) {
1998  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
1999  }
2000 
2001  return Iterator( matrix_.erase( i, pos.base() ), i );
2002 }
2004 //*************************************************************************************************
2005 
2006 
2007 //*************************************************************************************************
2022 template< typename MT // Type of the adapted sparse matrix
2023  , bool SO > // Storage order of the adapted sparse matrix
2025  UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
2026 {
2027  if( first == last )
2028  return last;
2029 
2030  if( ( !SO && last.base() == matrix_.end(i) ) ||
2031  ( SO && first.base() == matrix_.begin(i) ) ) {
2032  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2033  }
2034 
2035  return Iterator( matrix_.erase( i, first.base(), last.base() ), i );
2036 }
2038 //*************************************************************************************************
2039 
2040 
2041 //*************************************************************************************************
2063 template< typename MT // Type of the adapted sparse matrix
2064  , bool SO > // Storage order of the adapted sparse matrix
2065 template< typename Pred > // Type of the unary predicate
2066 inline void UniLowerMatrix<MT,SO,false>::erase( Pred predicate )
2067 {
2068  if( SO ) {
2069  for( size_t j=0UL; (j+1UL) < columns(); ++j ) {
2070  matrix_.erase( j, matrix_.lowerBound(j+1UL,j), matrix_.end(j), predicate );
2071  }
2072  }
2073  else {
2074  for( size_t i=1UL; i<rows(); ++i ) {
2075  matrix_.erase( i, matrix_.begin(i), matrix_.find(i,i), predicate );
2076  }
2077  }
2078 
2079  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2080 }
2082 //*************************************************************************************************
2083 
2084 
2085 //*************************************************************************************************
2116 template< typename MT // Type of the adapted sparse matrix
2117  , bool SO > // Storage order of the adapted sparse matrix
2118 template< typename Pred > // Type of the unary predicate
2119 inline void UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
2120 {
2121  if( first == last )
2122  return;
2123 
2124  if( ( !SO && last.base() == matrix_.end(i) && predicate( ElementType(1) ) ) ||
2125  ( SO && first.base() == matrix_.begin(i) && predicate( ElementType(1) ) ) ) {
2126  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2127  }
2128 
2129  matrix_.erase( i, first.base(), last.base(), predicate );
2130 
2131  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2132 }
2134 //*************************************************************************************************
2135 
2136 
2137 
2138 
2139 //=================================================================================================
2140 //
2141 // LOOKUP FUNCTIONS
2142 //
2143 //=================================================================================================
2144 
2145 //*************************************************************************************************
2161 template< typename MT // Type of the adapted sparse matrix
2162  , bool SO > // Storage order of the adapted sparse matrix
2164  UniLowerMatrix<MT,SO,false>::find( size_t i, size_t j )
2165 {
2166  return Iterator( matrix_.find( i, j ), ( SO ? j : i ) );
2167 }
2169 //*************************************************************************************************
2170 
2171 
2172 //*************************************************************************************************
2188 template< typename MT // Type of the adapted sparse matrix
2189  , bool SO > // Storage order of the adapted sparse matrix
2191  UniLowerMatrix<MT,SO,false>::find( size_t i, size_t j ) const
2192 {
2193  return matrix_.find( i, j );
2194 }
2196 //*************************************************************************************************
2197 
2198 
2199 //*************************************************************************************************
2215 template< typename MT // Type of the adapted sparse matrix
2216  , bool SO > // Storage order of the adapted sparse matrix
2218  UniLowerMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
2219 {
2220  return Iterator( matrix_.lowerBound( i, j ), ( SO ? j : i ) );
2221 }
2223 //*************************************************************************************************
2224 
2225 
2226 //*************************************************************************************************
2242 template< typename MT // Type of the adapted sparse matrix
2243  , bool SO > // Storage order of the adapted sparse matrix
2245  UniLowerMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
2246 {
2247  return matrix_.lowerBound( i, j );
2248 }
2250 //*************************************************************************************************
2251 
2252 
2253 //*************************************************************************************************
2269 template< typename MT // Type of the adapted sparse matrix
2270  , bool SO > // Storage order of the adapted sparse matrix
2272  UniLowerMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
2273 {
2274  return Iterator( matrix_.upperBound( i, j ), ( SO ? j : i ) );
2275 }
2277 //*************************************************************************************************
2278 
2279 
2280 //*************************************************************************************************
2296 template< typename MT // Type of the adapted sparse matrix
2297  , bool SO > // Storage order of the adapted sparse matrix
2299  UniLowerMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
2300 {
2301  return matrix_.upperBound( i, j );
2302 }
2304 //*************************************************************************************************
2305 
2306 
2307 
2308 
2309 //=================================================================================================
2310 //
2311 // DEBUGGING FUNCTIONS
2312 //
2313 //=================================================================================================
2314 
2315 //*************************************************************************************************
2325 template< typename MT // Type of the adapted sparse matrix
2326  , bool SO > // Storage order of the adapted sparse matrix
2327 inline bool UniLowerMatrix<MT,SO,false>::isIntact() const noexcept
2328 {
2329  using blaze::isIntact;
2330 
2331  return ( isIntact( matrix_ ) && isUniLower( matrix_ ) );
2332 }
2334 //*************************************************************************************************
2335 
2336 
2337 
2338 
2339 //=================================================================================================
2340 //
2341 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2342 //
2343 //=================================================================================================
2344 
2345 //*************************************************************************************************
2356 template< typename MT // Type of the adapted sparse matrix
2357  , bool SO > // Storage order of the adapted sparse matrix
2358 template< typename Other > // Data type of the foreign expression
2359 inline bool UniLowerMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2360 {
2361  return matrix_.canAlias( alias );
2362 }
2364 //*************************************************************************************************
2365 
2366 
2367 //*************************************************************************************************
2378 template< typename MT // Type of the adapted sparse matrix
2379  , bool SO > // Storage order of the adapted sparse matrix
2380 template< typename Other > // Data type of the foreign expression
2381 inline bool UniLowerMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2382 {
2383  return matrix_.isAliased( alias );
2384 }
2386 //*************************************************************************************************
2387 
2388 
2389 //*************************************************************************************************
2400 template< typename MT // Type of the adapted sparse matrix
2401  , bool SO > // Storage order of the adapted sparse matrix
2402 inline bool UniLowerMatrix<MT,SO,false>::canSMPAssign() const noexcept
2403 {
2404  return matrix_.canSMPAssign();
2405 }
2407 //*************************************************************************************************
2408 
2409 } // namespace blaze
2410 
2411 #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 the implementation of the base template of the UniLowerMatrix.
Header file for auxiliary alias declarations.
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3079
bool isStrictlyLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly lower triangular matrix.
Definition: DenseMatrix.h:1245
#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.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:356
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.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3078
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:198
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:560
bool isUniLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower unitriangular matrix.
Definition: DenseMatrix.h:1158
BLAZE_ALWAYS_INLINE void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:609
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5845
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3080
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3085
#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:394
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
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3086
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:1393
Constraint on the data type.
Header file for the IsUniLower type trait.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1809
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:308
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:242
Constraint on the data type.
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.
Headerfile for the generic max algorithm.
Header file for the DisableIf class template.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3084
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_CONSTRAINT_MUST_BE_STATIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a static data type, i.e. a vector or matrix with dimensions fixed at compile time, a compilation error is created.
Definition: Static.h:61
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5924
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5907
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3077
#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
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3081
#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.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3087
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.
decltype(auto) decllow(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as lower.
Definition: DMatDeclLowExpr.h:1027
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:340
Header file for the IsUniTriangular type trait.
Header file for the IsStrictlyTriangular type trait.
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:548
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:264
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8893
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
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:580
Header file for the UniLowerElement class.
Header file for the UniLowerProxy class.
Header file for the isOne shim.
Header file for the UniLowerValue class.
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.
#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
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:1357
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
bool isOne(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 1.
Definition: DiagonalProxy.h:662
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:270
Constraint on the data type.
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:324
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3082
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(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.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3083
#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
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:252
#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:1375
Header file for the IsUpper type trait.
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:742
Header file for the IsResizable type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#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