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>
63 #include <blaze/math/Exception.h>
66 #include <blaze/math/shims/Clear.h>
68 #include <blaze/math/shims/IsOne.h>
80 #include <blaze/util/Assert.h>
86 #include <blaze/util/DisableIf.h>
87 #include <blaze/util/EnableIf.h>
89 #include <blaze/util/Types.h>
90 
91 
92 namespace blaze {
93 
94 //=================================================================================================
95 //
96 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
97 //
98 //=================================================================================================
99 
100 //*************************************************************************************************
108 template< typename MT // Type of the adapted sparse matrix
109  , bool SO > // Storage order of the adapted sparse matrix
110 class UniLowerMatrix<MT,SO,false>
111  : public SparseMatrix< UniLowerMatrix<MT,SO,false>, SO >
112 {
113  private:
114  //**Type definitions****************************************************************************
115  using OT = OppositeType_t<MT>;
116  using TT = TransposeType_t<MT>;
117  using ET = ElementType_t<MT>;
118  //**********************************************************************************************
119 
120  public:
121  //**Type definitions****************************************************************************
122  using This = UniLowerMatrix<MT,SO,false>;
123  using BaseType = SparseMatrix<This,SO>;
124  using ResultType = This;
125  using OppositeType = UniLowerMatrix<OT,!SO,false>;
126  using TransposeType = UniUpperMatrix<TT,!SO,false>;
127  using ElementType = ET;
128  using ReturnType = ReturnType_t<MT>;
129  using CompositeType = const This&;
130  using Reference = UniLowerProxy<MT>;
131  using ConstReference = ConstReference_t<MT>;
132  using ConstIterator = ConstIterator_t<MT>;
133  //**********************************************************************************************
134 
135  //**Rebind struct definition********************************************************************
138  template< typename NewType > // Data type of the other matrix
139  struct Rebind {
141  using Other = UniLowerMatrix< typename MT::template Rebind<NewType>::Other >;
142  };
143  //**********************************************************************************************
144 
145  //**Resize struct definition********************************************************************
148  template< size_t NewM // Number of rows of the other matrix
149  , size_t NewN > // Number of columns of the other matrix
150  struct Resize {
152  using Other = UniLowerMatrix< typename MT::template Resize<NewM,NewN>::Other >;
153  };
154  //**********************************************************************************************
155 
156  //**Iterator class definition*******************************************************************
159  class Iterator
160  {
161  public:
162  //**Type definitions*************************************************************************
163  using IteratorType = Iterator_t<MT>;
164 
165  using IteratorCategory = std::forward_iterator_tag;
166  using ValueType = UniLowerElement<MT>;
167  using PointerType = ValueType;
168  using ReferenceType = ValueType;
169  using DifferenceType = ptrdiff_t;
170 
171  // STL iterator requirements
172  using iterator_category = IteratorCategory;
173  using value_type = ValueType;
174  using pointer = PointerType;
175  using reference = ReferenceType;
176  using difference_type = DifferenceType;
177  //*******************************************************************************************
178 
179  //**Default constructor**********************************************************************
182  inline Iterator()
183  : pos_ ( ) // Iterator to the current lower unitriangular matrix element
184  , index_ ( 0UL ) // The row/column index of the iterator
185  {}
186  //*******************************************************************************************
187 
188  //**Constructor******************************************************************************
194  inline Iterator( IteratorType pos, size_t index )
195  : pos_ ( pos ) // Iterator to the current lower unitriangular matrix element
196  , index_( index ) // The row/column index of the iterator
197  {}
198  //*******************************************************************************************
199 
200  //**Prefix increment operator****************************************************************
205  inline Iterator& operator++() {
206  ++pos_;
207  return *this;
208  }
209  //*******************************************************************************************
210 
211  //**Postfix increment operator***************************************************************
216  inline const Iterator operator++( int ) {
217  const Iterator tmp( *this );
218  ++(*this);
219  return tmp;
220  }
221  //*******************************************************************************************
222 
223  //**Element access operator******************************************************************
228  inline ReferenceType operator*() const {
229  return ReferenceType( pos_, pos_->index() == index_ );
230  }
231  //*******************************************************************************************
232 
233  //**Element access operator******************************************************************
238  inline PointerType operator->() const {
239  return PointerType( pos_, pos_->index() == index_ );
240  }
241  //*******************************************************************************************
242 
243  //**Conversion operator**********************************************************************
248  inline operator ConstIterator() const {
249  return pos_;
250  }
251  //*******************************************************************************************
252 
253  //**Equality operator************************************************************************
259  inline bool operator==( const Iterator& rhs ) const {
260  return pos_ == rhs.pos_;
261  }
262  //*******************************************************************************************
263 
264  //**Inequality operator**********************************************************************
270  inline bool operator!=( const Iterator& rhs ) const {
271  return !( *this == rhs );
272  }
273  //*******************************************************************************************
274 
275  //**Subtraction operator*********************************************************************
281  inline DifferenceType operator-( const Iterator& rhs ) const {
282  return pos_ - rhs.pos_;
283  }
284  //*******************************************************************************************
285 
286  //**Base function****************************************************************************
291  inline IteratorType base() const {
292  return pos_;
293  }
294  //*******************************************************************************************
295 
296  private:
297  //**Member variables*************************************************************************
298  IteratorType pos_;
299  size_t index_;
300  //*******************************************************************************************
301  };
302  //**********************************************************************************************
303 
304  //**Compilation flags***************************************************************************
306  static constexpr bool smpAssignable = false;
307  //**********************************************************************************************
308 
309  //**Constructors********************************************************************************
312  explicit inline UniLowerMatrix();
313  explicit inline UniLowerMatrix( size_t n );
314  explicit inline UniLowerMatrix( size_t n, size_t nonzeros );
315  explicit inline UniLowerMatrix( size_t n, const std::vector<size_t>& nonzeros );
316  explicit inline UniLowerMatrix( initializer_list< initializer_list<ElementType> > list );
317 
318  inline UniLowerMatrix( const UniLowerMatrix& m );
319  inline UniLowerMatrix( UniLowerMatrix&& m ) noexcept;
320 
321  template< typename MT2, bool SO2 >
322  inline UniLowerMatrix( const Matrix<MT2,SO2>& m );
324  //**********************************************************************************************
325 
326  //**Destructor**********************************************************************************
329  ~UniLowerMatrix() = default;
331  //**********************************************************************************************
332 
333  //**Data access functions***********************************************************************
336  inline Reference operator()( size_t i, size_t j );
337  inline ConstReference operator()( size_t i, size_t j ) const;
338  inline Reference at( size_t i, size_t j );
339  inline ConstReference at( size_t i, size_t j ) const;
340  inline Iterator begin ( size_t i );
341  inline ConstIterator begin ( size_t i ) const;
342  inline ConstIterator cbegin( size_t i ) const;
343  inline Iterator end ( size_t i );
344  inline ConstIterator end ( size_t i ) const;
345  inline ConstIterator cend ( size_t i ) const;
347  //**********************************************************************************************
348 
349  //**Assignment operators************************************************************************
352  inline UniLowerMatrix& operator=( initializer_list< initializer_list<ElementType> > list );
353 
354  inline UniLowerMatrix& operator=( const UniLowerMatrix& rhs );
355  inline UniLowerMatrix& operator=( UniLowerMatrix&& rhs ) noexcept;
356 
357  template< typename MT2, bool SO2 >
358  inline auto operator=( const Matrix<MT2,SO2>& rhs )
359  -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
360 
361  template< typename MT2, bool SO2 >
362  inline auto operator=( const Matrix<MT2,SO2>& rhs )
363  -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
364 
365  template< typename MT2, bool SO2 >
366  inline auto operator+=( const Matrix<MT2,SO2>& rhs )
367  -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
368 
369  template< typename MT2, bool SO2 >
370  inline auto operator+=( const Matrix<MT2,SO2>& rhs )
371  -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
372 
373  template< typename MT2, bool SO2 >
374  inline auto operator-=( const Matrix<MT2,SO2>& rhs )
375  -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
376 
377  template< typename MT2, bool SO2 >
378  inline auto operator-=( const Matrix<MT2,SO2>& rhs )
379  -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
380 
381  template< typename MT2, bool SO2 >
382  inline auto operator%=( const Matrix<MT2,SO2>& rhs ) -> UniLowerMatrix&;
384  //**********************************************************************************************
385 
386  //**Utility functions***************************************************************************
389  inline size_t rows() const noexcept;
390  inline size_t columns() const noexcept;
391  inline size_t capacity() const noexcept;
392  inline size_t capacity( size_t i ) const noexcept;
393  inline size_t nonZeros() const;
394  inline size_t nonZeros( size_t i ) const;
395  inline void reset();
396  inline void reset( size_t i );
397  inline void clear();
398  inline void resize ( size_t n, bool preserve=true );
399  inline void reserve( size_t nonzeros );
400  inline void reserve( size_t i, size_t nonzeros );
401  inline void trim();
402  inline void trim( size_t i );
403  inline void shrinkToFit();
404  inline void swap( UniLowerMatrix& m ) noexcept;
405 
406  static inline constexpr size_t maxNonZeros() noexcept;
407  static inline constexpr size_t maxNonZeros( size_t n ) noexcept;
409  //**********************************************************************************************
410 
411  //**Insertion functions*************************************************************************
414  inline Iterator set ( size_t i, size_t j, const ElementType& value );
415  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
416  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
417  inline void finalize( size_t i );
419  //**********************************************************************************************
420 
421  //**Erase functions*****************************************************************************
424  inline void erase( size_t i, size_t j );
425  inline Iterator erase( size_t i, Iterator pos );
426  inline Iterator erase( size_t i, Iterator first, Iterator last );
427 
428  template< typename Pred >
429  inline void erase( Pred predicate );
430 
431  template< typename Pred >
432  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
434  //**********************************************************************************************
435 
436  //**Lookup functions****************************************************************************
439  inline Iterator find ( size_t i, size_t j );
440  inline ConstIterator find ( size_t i, size_t j ) const;
441  inline Iterator lowerBound( size_t i, size_t j );
442  inline ConstIterator lowerBound( size_t i, size_t j ) const;
443  inline Iterator upperBound( size_t i, size_t j );
444  inline ConstIterator upperBound( size_t i, size_t j ) const;
446  //**********************************************************************************************
447 
448  //**Debugging functions*************************************************************************
451  inline bool isIntact() const noexcept;
453  //**********************************************************************************************
454 
455  //**Expression template evaluation functions****************************************************
458  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
459  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
460 
461  inline bool canSMPAssign() const noexcept;
463  //**********************************************************************************************
464 
465  private:
466  //**Utility functions***************************************************************************
469  inline void resetUpper();
471  //**********************************************************************************************
472 
473  //**Member variables****************************************************************************
476  MT matrix_;
477 
478  //**********************************************************************************************
479 
480  //**Friend declarations*************************************************************************
481  template< typename MT2, bool SO2, bool DF2 >
482  friend MT2& derestrict( UniLowerMatrix<MT2,SO2,DF2>& m );
483  //**********************************************************************************************
484 
485  //**Compile time checks*************************************************************************
500  BLAZE_STATIC_ASSERT( ( Size_v<MT,0UL> == Size_v<MT,1UL> ) );
501  //**********************************************************************************************
502 };
504 //*************************************************************************************************
505 
506 
507 
508 
509 //=================================================================================================
510 //
511 // CONSTRUCTORS
512 //
513 //=================================================================================================
514 
515 //*************************************************************************************************
519 template< typename MT // Type of the adapted sparse matrix
520  , bool SO > // Storage order of the adapted sparse matrix
521 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix()
522  : matrix_() // The adapted sparse matrix
523 {
524  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
525 }
527 //*************************************************************************************************
528 
529 
530 //*************************************************************************************************
538 template< typename MT // Type of the adapted sparse matrix
539  , bool SO > // Storage order of the adapted sparse matrix
540 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n )
541  : matrix_( n, n, n ) // The adapted sparse matrix
542 {
544 
545  for( size_t i=0UL; i<n; ++i ) {
546  matrix_.append( i, i, ElementType(1) );
547  matrix_.finalize( i );
548  }
549 
550  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
551 }
553 //*************************************************************************************************
554 
555 
556 //*************************************************************************************************
566 template< typename MT // Type of the adapted sparse matrix
567  , bool SO > // Storage order of the adapted sparse matrix
568 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n, size_t nonzeros )
569  : matrix_( n, n, max( nonzeros, n ) ) // The adapted sparse matrix
570 {
572 
573  for( size_t i=0UL; i<n; ++i ) {
574  matrix_.append( i, i, ElementType(1) );
575  matrix_.finalize( i );
576  }
577 
578  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
579 }
581 //*************************************************************************************************
582 
583 
584 //*************************************************************************************************
598 template< typename MT // Type of the adapted sparse matrix
599  , bool SO > // Storage order of the adapted sparse matrix
600 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n, const std::vector<size_t>& nonzeros )
601  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
602 {
604 
605  for( size_t i=0UL; i<n; ++i )
606  {
607  if( nonzeros[i] == 0UL ) {
608  BLAZE_THROW_INVALID_ARGUMENT( "Invalid capacity specification" );
609  }
610 
611  matrix_.append( i, i, ElementType(1) );
612  matrix_.finalize( i );
613  }
614 
615  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
616 }
618 //*************************************************************************************************
619 
620 
621 //*************************************************************************************************
645 template< typename MT // Type of the adapted sparse matrix
646  , bool SO > // Storage order of the adapted sparse matrix
647 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( initializer_list< initializer_list<ElementType> > list )
648  : matrix_( list ) // The adapted sparse matrix
649 {
650  if( !isUniLower( matrix_ ) ) {
651  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
652  }
653 
654  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
655 }
657 //*************************************************************************************************
658 
659 
660 //*************************************************************************************************
666 template< typename MT // Type of the adapted sparse matrix
667  , bool SO > // Storage order of the adapted sparse matrix
668 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( const UniLowerMatrix& m )
669  : matrix_( m.matrix_ ) // The adapted sparse matrix
670 {
671  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
672  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
673 }
675 //*************************************************************************************************
676 
677 
678 //*************************************************************************************************
684 template< typename MT // Type of the adapted sparse matrix
685  , bool SO > // Storage order of the adapted sparse matrix
686 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( UniLowerMatrix&& m ) noexcept
687  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
688 {
689  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
690  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
691 }
693 //*************************************************************************************************
694 
695 
696 //*************************************************************************************************
706 template< typename MT // Type of the adapted sparse matrix
707  , bool SO > // Storage order of the adapted sparse matrix
708 template< typename MT2 // Type of the foreign matrix
709  , bool SO2 > // Storage order of the foreign matrix
710 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( const Matrix<MT2,SO2>& m )
711  : matrix_( ~m ) // The adapted sparse matrix
712 {
713  if( !IsUniLower_v<MT2> && !isUniLower( matrix_ ) ) {
714  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
715  }
716 
717  if( !IsUniLower_v<MT2> )
718  resetUpper();
719 
720  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
721  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
722 }
724 //*************************************************************************************************
725 
726 
727 
728 
729 //=================================================================================================
730 //
731 // DATA ACCESS FUNCTIONS
732 //
733 //=================================================================================================
734 
735 //*************************************************************************************************
751 template< typename MT // Type of the adapted sparse matrix
752  , bool SO > // Storage order of the adapted sparse matrix
754  UniLowerMatrix<MT,SO,false>::operator()( size_t i, size_t j )
755 {
756  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
757  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
758 
759  return Reference( matrix_, i, j );
760 }
762 //*************************************************************************************************
763 
764 
765 //*************************************************************************************************
781 template< typename MT // Type of the adapted sparse matrix
782  , bool SO > // Storage order of the adapted sparse matrix
784  UniLowerMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
785 {
786  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
787  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
788 
789  return matrix_(i,j);
790 }
792 //*************************************************************************************************
793 
794 
795 //*************************************************************************************************
812 template< typename MT // Type of the adapted sparse matrix
813  , bool SO > // Storage order of the adapted sparse matrix
815  UniLowerMatrix<MT,SO,false>::at( size_t i, size_t j )
816 {
817  if( i >= rows() ) {
818  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
819  }
820  if( j >= columns() ) {
821  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
822  }
823  return (*this)(i,j);
824 }
826 //*************************************************************************************************
827 
828 
829 //*************************************************************************************************
846 template< typename MT // Type of the adapted sparse matrix
847  , bool SO > // Storage order of the adapted sparse matrix
849  UniLowerMatrix<MT,SO,false>::at( size_t i, size_t j ) const
850 {
851  if( i >= rows() ) {
852  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
853  }
854  if( j >= columns() ) {
855  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
856  }
857  return (*this)(i,j);
858 }
860 //*************************************************************************************************
861 
862 
863 //*************************************************************************************************
875 template< typename MT // Type of the adapted sparse matrix
876  , bool SO > // Storage order of the adapted sparse matrix
879 {
880  return Iterator( matrix_.begin(i), i );
881 }
883 //*************************************************************************************************
884 
885 
886 //*************************************************************************************************
898 template< typename MT // Type of the adapted sparse matrix
899  , bool SO > // Storage order of the adapted sparse matrix
901  UniLowerMatrix<MT,SO,false>::begin( size_t i ) const
902 {
903  return matrix_.begin(i);
904 }
906 //*************************************************************************************************
907 
908 
909 //*************************************************************************************************
921 template< typename MT // Type of the adapted sparse matrix
922  , bool SO > // Storage order of the adapted sparse matrix
924  UniLowerMatrix<MT,SO,false>::cbegin( size_t i ) const
925 {
926  return matrix_.cbegin(i);
927 }
929 //*************************************************************************************************
930 
931 
932 //*************************************************************************************************
944 template< typename MT // Type of the adapted sparse matrix
945  , bool SO > // Storage order of the adapted sparse matrix
948 {
949  return Iterator( matrix_.end(i), i );
950 }
952 //*************************************************************************************************
953 
954 
955 //*************************************************************************************************
967 template< typename MT // Type of the adapted sparse matrix
968  , bool SO > // Storage order of the adapted sparse matrix
970  UniLowerMatrix<MT,SO,false>::end( size_t i ) const
971 {
972  return matrix_.end(i);
973 }
975 //*************************************************************************************************
976 
977 
978 //*************************************************************************************************
990 template< typename MT // Type of the adapted sparse matrix
991  , bool SO > // Storage order of the adapted sparse matrix
993  UniLowerMatrix<MT,SO,false>::cend( size_t i ) const
994 {
995  return matrix_.cend(i);
996 }
998 //*************************************************************************************************
999 
1000 
1001 
1002 
1003 //=================================================================================================
1004 //
1005 // ASSIGNMENT OPERATORS
1006 //
1007 //=================================================================================================
1008 
1009 //*************************************************************************************************
1034 template< typename MT // Type of the adapted sparse matrix
1035  , bool SO > // Storage order of the adapted sparse matrix
1036 inline UniLowerMatrix<MT,SO,false>&
1037  UniLowerMatrix<MT,SO,false>::operator=( initializer_list< initializer_list<ElementType> > list )
1038 {
1039  const InitializerMatrix<ElementType> tmp( list, list.size() );
1040 
1041  if( !isUniLower( tmp ) ) {
1042  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1043  }
1044 
1045  matrix_ = list;
1046 
1047  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1048  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1049 
1050  return *this;
1051 }
1053 //*************************************************************************************************
1054 
1055 
1056 //*************************************************************************************************
1066 template< typename MT // Type of the adapted sparse matrix
1067  , bool SO > // Storage order of the adapted sparse matrix
1068 inline UniLowerMatrix<MT,SO,false>&
1069  UniLowerMatrix<MT,SO,false>::operator=( const UniLowerMatrix& rhs )
1070 {
1071  matrix_ = rhs.matrix_;
1072 
1073  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1074  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1075 
1076  return *this;
1077 }
1079 //*************************************************************************************************
1080 
1081 
1082 //*************************************************************************************************
1089 template< typename MT // Type of the adapted sparse matrix
1090  , bool SO > // Storage order of the adapted sparse matrix
1091 inline UniLowerMatrix<MT,SO,false>&
1092  UniLowerMatrix<MT,SO,false>::operator=( UniLowerMatrix&& rhs ) noexcept
1093 {
1094  matrix_ = std::move( rhs.matrix_ );
1095 
1096  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1097  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1098 
1099  return *this;
1100 }
1102 //*************************************************************************************************
1103 
1104 
1105 //*************************************************************************************************
1118 template< typename MT // Type of the adapted sparse matrix
1119  , bool SO > // Storage order of the adapted sparse matrix
1120 template< typename MT2 // Type of the right-hand side matrix
1121  , bool SO2 > // Storage order of the right-hand side matrix
1122 inline auto UniLowerMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
1123  -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1124 {
1125  if( IsStrictlyTriangular_v<MT2> || ( !IsUniLower_v<MT2> && !isUniLower( ~rhs ) ) ) {
1126  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1127  }
1128 
1129  matrix_ = decllow( ~rhs );
1130 
1131  if( !IsUniLower_v<MT2> )
1132  resetUpper();
1133 
1134  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1135  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1136 
1137  return *this;
1138 }
1140 //*************************************************************************************************
1141 
1142 
1143 //*************************************************************************************************
1156 template< typename MT // Type of the adapted sparse matrix
1157  , bool SO > // Storage order of the adapted sparse matrix
1158 template< typename MT2 // Type of the right-hand side matrix
1159  , bool SO2 > // Storage order of the right-hand side matrix
1160 inline auto UniLowerMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
1161  -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1162 {
1163  if( IsStrictlyTriangular_v<MT2> || ( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) ) {
1164  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1165  }
1166 
1167  if( IsUniLower_v<MT2> ) {
1168  matrix_ = ~rhs;
1169  }
1170  else {
1171  MT tmp( ~rhs );
1172 
1173  if( !isUniLower( tmp ) ) {
1174  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1175  }
1176 
1177  matrix_ = std::move( tmp );
1178  }
1179 
1180  if( !IsUniLower_v<MT2> )
1181  resetUpper();
1182 
1183  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1184  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1185 
1186  return *this;
1187 }
1189 //*************************************************************************************************
1190 
1191 
1192 //*************************************************************************************************
1205 template< typename MT // Type of the adapted sparse matrix
1206  , bool SO > // Storage order of the adapted sparse matrix
1207 template< typename MT2 // Type of the right-hand side matrix
1208  , bool SO2 > // Storage order of the right-hand side matrix
1209 inline auto UniLowerMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1210  -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1211 {
1212  if( IsUpper_v<MT2> || IsUniTriangular_v<MT2> ||
1213  ( !IsStrictlyLower_v<MT2> && !isStrictlyLower( ~rhs ) ) ) {
1214  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1215  }
1216 
1217  matrix_ += decllow( ~rhs );
1218 
1219  if( !IsStrictlyLower_v<MT2> )
1220  resetUpper();
1221 
1222  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1223  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1224 
1225  return *this;
1226 }
1228 //*************************************************************************************************
1229 
1230 
1231 //*************************************************************************************************
1244 template< typename MT // Type of the adapted sparse matrix
1245  , bool SO > // Storage order of the adapted sparse matrix
1246 template< typename MT2 // Type of the right-hand side matrix
1247  , bool SO2 > // Storage order of the right-hand side matrix
1248 inline auto UniLowerMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1249  -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1250 {
1251  if( IsUpper_v<MT2> || IsUniTriangular_v<MT2> ||
1252  ( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) ) {
1253  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1254  }
1255 
1256  if( IsStrictlyLower_v<MT2> ) {
1257  matrix_ += ~rhs;
1258  }
1259  else {
1260  const ResultType_t<MT2> tmp( ~rhs );
1261 
1262  if( !isStrictlyLower( tmp ) ) {
1263  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1264  }
1265 
1266  matrix_ += decllow( tmp );
1267  }
1268 
1269  if( !IsStrictlyLower_v<MT2> )
1270  resetUpper();
1271 
1272  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1273  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1274 
1275  return *this;
1276 }
1278 //*************************************************************************************************
1279 
1280 
1281 //*************************************************************************************************
1294 template< typename MT // Type of the adapted sparse matrix
1295  , bool SO > // Storage order of the adapted sparse matrix
1296 template< typename MT2 // Type of the right-hand side matrix
1297  , bool SO2 > // Storage order of the right-hand side matrix
1298 inline auto UniLowerMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1299  -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1300 {
1301  if( IsUpper_v<MT2> || IsUniTriangular_v<MT2> ||
1302  ( !IsStrictlyLower_v<MT2> && !isStrictlyLower( ~rhs ) ) ) {
1303  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1304  }
1305 
1306  matrix_ -= decllow( ~rhs );
1307 
1308  if( !IsStrictlyLower_v<MT2> )
1309  resetUpper();
1310 
1311  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1312  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1313 
1314  return *this;
1315 }
1317 //*************************************************************************************************
1318 
1319 
1320 //*************************************************************************************************
1333 template< typename MT // Type of the adapted sparse matrix
1334  , bool SO > // Storage order of the adapted sparse matrix
1335 template< typename MT2 // Type of the right-hand side matrix
1336  , bool SO2 > // Storage order of the right-hand side matrix
1337 inline auto UniLowerMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1338  -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1339 {
1340  if( IsUpper_v<MT2> || IsUniTriangular_v<MT2> ||
1341  ( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) ) {
1342  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1343  }
1344 
1345  if( IsStrictlyLower_v<MT2> ) {
1346  matrix_ -= ~rhs;
1347  }
1348  else {
1349  const ResultType_t<MT2> tmp( ~rhs );
1350 
1351  if( !isStrictlyLower( tmp ) ) {
1352  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1353  }
1354 
1355  matrix_ -= decllow( tmp );
1356  }
1357 
1358  if( !IsStrictlyLower_v<MT2> )
1359  resetUpper();
1360 
1361  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1362  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1363 
1364  return *this;
1365 }
1367 //*************************************************************************************************
1368 
1369 
1370 //*************************************************************************************************
1383 template< typename MT // Type of the adapted sparse matrix
1384  , bool SO > // Storage order of the adapted sparse matrix
1385 template< typename MT2 // Type of the right-hand side matrix
1386  , bool SO2 > // Storage order of the right-hand side matrix
1387 inline auto UniLowerMatrix<MT,SO,false>::operator%=( const Matrix<MT2,SO2>& rhs )
1388  -> UniLowerMatrix&
1389 {
1390  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1391  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1392  }
1393 
1394  If_t< IsComputation_v<MT2>, ResultType_t<MT2>, const MT2& > tmp( ~rhs );
1395 
1396  for( size_t i=0UL; i<(~rhs).rows(); ++i ) {
1397  if( !isOne( tmp(i,i) ) ) {
1398  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1399  }
1400  }
1401 
1402  matrix_ %= tmp;
1403 
1404  if( !IsUniLower_v<MT2> )
1405  resetUpper();
1406 
1407  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1408  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1409 
1410  return *this;
1411 }
1413 //*************************************************************************************************
1414 
1415 
1416 
1417 
1418 //=================================================================================================
1419 //
1420 // UTILITY FUNCTIONS
1421 //
1422 //=================================================================================================
1423 
1424 //*************************************************************************************************
1430 template< typename MT // Type of the adapted sparse matrix
1431  , bool SO > // Storage order of the adapted sparse matrix
1432 inline size_t UniLowerMatrix<MT,SO,false>::rows() const noexcept
1433 {
1434  return matrix_.rows();
1435 }
1437 //*************************************************************************************************
1438 
1439 
1440 //*************************************************************************************************
1446 template< typename MT // Type of the adapted sparse matrix
1447  , bool SO > // Storage order of the adapted sparse matrix
1448 inline size_t UniLowerMatrix<MT,SO,false>::columns() const noexcept
1449 {
1450  return matrix_.columns();
1451 }
1453 //*************************************************************************************************
1454 
1455 
1456 //*************************************************************************************************
1462 template< typename MT // Type of the adapted sparse matrix
1463  , bool SO > // Storage order of the adapted sparse matrix
1464 inline size_t UniLowerMatrix<MT,SO,false>::capacity() const noexcept
1465 {
1466  return matrix_.capacity();
1467 }
1469 //*************************************************************************************************
1470 
1471 
1472 //*************************************************************************************************
1484 template< typename MT // Type of the adapted sparse matrix
1485  , bool SO > // Storage order of the adapted sparse matrix
1486 inline size_t UniLowerMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1487 {
1488  return matrix_.capacity(i);
1489 }
1491 //*************************************************************************************************
1492 
1493 
1494 //*************************************************************************************************
1500 template< typename MT // Type of the adapted sparse matrix
1501  , bool SO > // Storage order of the adapted sparse matrix
1502 inline size_t UniLowerMatrix<MT,SO,false>::nonZeros() const
1503 {
1504  return matrix_.nonZeros();
1505 }
1507 //*************************************************************************************************
1508 
1509 
1510 //*************************************************************************************************
1522 template< typename MT // Type of the adapted sparse matrix
1523  , bool SO > // Storage order of the adapted sparse matrix
1524 inline size_t UniLowerMatrix<MT,SO,false>::nonZeros( size_t i ) const
1525 {
1526  return matrix_.nonZeros(i);
1527 }
1529 //*************************************************************************************************
1530 
1531 
1532 //*************************************************************************************************
1538 template< typename MT // Type of the adapted sparse matrix
1539  , bool SO > // Storage order of the adapted sparse matrix
1541 {
1542  if( SO ) {
1543  for( size_t j=0UL; j<columns(); ++j ) {
1544  matrix_.erase( j, matrix_.lowerBound(j+1UL,j), matrix_.end(j) );
1545  }
1546  }
1547  else {
1548  for( size_t i=1UL; i<rows(); ++i ) {
1549  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1550  }
1551  }
1552 }
1554 //*************************************************************************************************
1555 
1556 
1557 //*************************************************************************************************
1570 template< typename MT // Type of the adapted sparse matrix
1571  , bool SO > // Storage order of the adapted sparse matrix
1572 inline void UniLowerMatrix<MT,SO,false>::reset( size_t i )
1573 {
1574  if( SO ) {
1575  matrix_.erase( i, matrix_.lowerBound(i+1UL,i), matrix_.end(i) );
1576  }
1577  else {
1578  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1579  }
1580 }
1582 //*************************************************************************************************
1583 
1584 
1585 //*************************************************************************************************
1593 template< typename MT // Type of the adapted sparse matrix
1594  , bool SO > // Storage order of the adapted sparse matrix
1596 {
1597  using blaze::clear;
1598 
1599  if( IsResizable_v<MT> ) {
1600  clear( matrix_ );
1601  }
1602  else {
1603  reset();
1604  }
1605 }
1607 //*************************************************************************************************
1608 
1609 
1610 //*************************************************************************************************
1625 template< typename MT // Type of the adapted sparse matrix
1626  , bool SO > // Storage order of the adapted sparse matrix
1627 void UniLowerMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1628 {
1630 
1631  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1632 
1633  const size_t oldsize( matrix_.rows() );
1634 
1635  matrix_.resize( n, n, preserve );
1636 
1637  if( n > oldsize ) {
1638  for( size_t i=oldsize; i<n; ++i )
1639  matrix_.insert( i, i, ElementType(1) );
1640  }
1641 }
1643 //*************************************************************************************************
1644 
1645 
1646 //*************************************************************************************************
1657 template< typename MT // Type of the adapted sparse matrix
1658  , bool SO > // Storage order of the adapted sparse matrix
1659 inline void UniLowerMatrix<MT,SO,false>::reserve( size_t nonzeros )
1660 {
1661  matrix_.reserve( nonzeros );
1662 }
1664 //*************************************************************************************************
1665 
1666 
1667 //*************************************************************************************************
1681 template< typename MT // Type of the adapted sparse matrix
1682  , bool SO > // Storage order of the adapted sparse matrix
1683 inline void UniLowerMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1684 {
1685  matrix_.reserve( i, nonzeros );
1686 }
1688 //*************************************************************************************************
1689 
1690 
1691 //*************************************************************************************************
1702 template< typename MT // Type of the adapted sparse matrix
1703  , bool SO > // Storage order of the adapted sparse matrix
1704 inline void UniLowerMatrix<MT,SO,false>::trim()
1705 {
1706  matrix_.trim();
1707 }
1709 //*************************************************************************************************
1710 
1711 
1712 //*************************************************************************************************
1724 template< typename MT // Type of the adapted sparse matrix
1725  , bool SO > // Storage order of the adapted sparse matrix
1726 inline void UniLowerMatrix<MT,SO,false>::trim( size_t i )
1727 {
1728  matrix_.trim( i );
1729 }
1731 //*************************************************************************************************
1732 
1733 
1734 //*************************************************************************************************
1744 template< typename MT // Type of the adapted sparse matrix
1745  , bool SO > // Storage order of the adapted sparse matrix
1747 {
1748  matrix_.shrinkToFit();
1749 }
1751 //*************************************************************************************************
1752 
1753 
1754 //*************************************************************************************************
1761 template< typename MT // Type of the adapted sparse matrix
1762  , bool SO > // Storage order of the adapted sparse matrix
1763 inline void UniLowerMatrix<MT,SO,false>::swap( UniLowerMatrix& m ) noexcept
1764 {
1765  using std::swap;
1766 
1767  swap( matrix_, m.matrix_ );
1768 }
1770 //*************************************************************************************************
1771 
1772 
1773 //*************************************************************************************************
1784 template< typename MT // Type of the adapted dense matrix
1785  , bool SO > // Storage order of the adapted dense matrix
1786 inline constexpr size_t UniLowerMatrix<MT,SO,false>::maxNonZeros() noexcept
1787 {
1789 
1790  return maxNonZeros( Size_v<MT,0UL> );
1791 }
1793 //*************************************************************************************************
1794 
1795 
1796 //*************************************************************************************************
1806 template< typename MT // Type of the adapted dense matrix
1807  , bool SO > // Storage order of the adapted dense matrix
1808 inline constexpr size_t UniLowerMatrix<MT,SO,false>::maxNonZeros( size_t n ) noexcept
1809 {
1810  return ( ( n + 1UL ) * n ) / 2UL;
1811 }
1813 //*************************************************************************************************
1814 
1815 
1816 //*************************************************************************************************
1822 template< typename MT // Type of the adapted dense matrix
1823  , bool SO > // Storage order of the adapted dense matrix
1824 inline void UniLowerMatrix<MT,SO,false>::resetUpper()
1825 {
1826  if( SO ) {
1827  for( size_t j=1UL; j<columns(); ++j )
1828  matrix_.erase( j, matrix_.begin( j ), matrix_.lowerBound( j, j ) );
1829  }
1830  else {
1831  for( size_t i=0UL; i<rows(); ++i )
1832  matrix_.erase( i, matrix_.upperBound( i, i ), matrix_.end( i ) );
1833  }
1834 }
1836 //*************************************************************************************************
1837 
1838 
1839 
1840 
1841 //=================================================================================================
1842 //
1843 // INSERTION FUNCTIONS
1844 //
1845 //=================================================================================================
1846 
1847 //*************************************************************************************************
1863 template< typename MT // Type of the adapted sparse matrix
1864  , bool SO > // Storage order of the adapted sparse matrix
1866  UniLowerMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1867 {
1868  if( i <= j ) {
1869  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1870  }
1871 
1872  return Iterator( matrix_.set( i, j, value ), ( SO ? j : i ) );
1873 }
1875 //*************************************************************************************************
1876 
1877 
1878 //*************************************************************************************************
1895 template< typename MT // Type of the adapted sparse matrix
1896  , bool SO > // Storage order of the adapted sparse matrix
1898  UniLowerMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1899 {
1900  if( i <= j ) {
1901  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1902  }
1903 
1904  return Iterator( matrix_.insert( i, j, value ), ( SO ? j : i ) );
1905 }
1907 //*************************************************************************************************
1908 
1909 
1910 //*************************************************************************************************
1960 template< typename MT // Type of the adapted sparse matrix
1961  , bool SO > // Storage order of the adapted sparse matrix
1962 inline void UniLowerMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1963 {
1964  if( i <= j ) {
1965  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1966  }
1967 
1968  if( !check || !isDefault<strict>( value ) )
1969  matrix_.insert( i, j, value );
1970 }
1972 //*************************************************************************************************
1973 
1974 
1975 //*************************************************************************************************
1989 template< typename MT // Type of the adapted sparse matrix
1990  , bool SO > // Storage order of the adapted sparse matrix
1991 inline void UniLowerMatrix<MT,SO,false>::finalize( size_t i )
1992 {
1993  matrix_.trim( i );
1994 }
1996 //*************************************************************************************************
1997 
1998 
1999 
2000 
2001 //=================================================================================================
2002 //
2003 // ERASE FUNCTIONS
2004 //
2005 //=================================================================================================
2006 
2007 //*************************************************************************************************
2019 template< typename MT // Type of the adapted sparse matrix
2020  , bool SO > // Storage order of the adapted sparse matrix
2021 inline void UniLowerMatrix<MT,SO,false>::erase( size_t i, size_t j )
2022 {
2023  if( i == j ) {
2024  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2025  }
2026 
2027  matrix_.erase( i, j );
2028 }
2030 //*************************************************************************************************
2031 
2032 
2033 //*************************************************************************************************
2047 template< typename MT // Type of the adapted sparse matrix
2048  , bool SO > // Storage order of the adapted sparse matrix
2050  UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
2051 {
2052  if( pos != matrix_.end(i) && pos->index() == i ) {
2053  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2054  }
2055 
2056  return Iterator( matrix_.erase( i, pos.base() ), i );
2057 }
2059 //*************************************************************************************************
2060 
2061 
2062 //*************************************************************************************************
2077 template< typename MT // Type of the adapted sparse matrix
2078  , bool SO > // Storage order of the adapted sparse matrix
2080  UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
2081 {
2082  if( first == last )
2083  return last;
2084 
2085  if( ( !SO && last.base() == matrix_.end(i) ) ||
2086  ( SO && first.base() == matrix_.begin(i) ) ) {
2087  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2088  }
2089 
2090  return Iterator( matrix_.erase( i, first.base(), last.base() ), i );
2091 }
2093 //*************************************************************************************************
2094 
2095 
2096 //*************************************************************************************************
2118 template< typename MT // Type of the adapted sparse matrix
2119  , bool SO > // Storage order of the adapted sparse matrix
2120 template< typename Pred > // Type of the unary predicate
2121 inline void UniLowerMatrix<MT,SO,false>::erase( Pred predicate )
2122 {
2123  if( SO ) {
2124  for( size_t j=0UL; (j+1UL) < columns(); ++j ) {
2125  matrix_.erase( j, matrix_.lowerBound(j+1UL,j), matrix_.end(j), predicate );
2126  }
2127  }
2128  else {
2129  for( size_t i=1UL; i<rows(); ++i ) {
2130  matrix_.erase( i, matrix_.begin(i), matrix_.find(i,i), predicate );
2131  }
2132  }
2133 
2134  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2135 }
2137 //*************************************************************************************************
2138 
2139 
2140 //*************************************************************************************************
2171 template< typename MT // Type of the adapted sparse matrix
2172  , bool SO > // Storage order of the adapted sparse matrix
2173 template< typename Pred > // Type of the unary predicate
2174 inline void UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
2175 {
2176  if( first == last )
2177  return;
2178 
2179  if( ( !SO && last.base() == matrix_.end(i) && predicate( ElementType(1) ) ) ||
2180  ( SO && first.base() == matrix_.begin(i) && predicate( ElementType(1) ) ) ) {
2181  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2182  }
2183 
2184  matrix_.erase( i, first.base(), last.base(), predicate );
2185 
2186  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2187 }
2189 //*************************************************************************************************
2190 
2191 
2192 
2193 
2194 //=================================================================================================
2195 //
2196 // LOOKUP FUNCTIONS
2197 //
2198 //=================================================================================================
2199 
2200 //*************************************************************************************************
2216 template< typename MT // Type of the adapted sparse matrix
2217  , bool SO > // Storage order of the adapted sparse matrix
2219  UniLowerMatrix<MT,SO,false>::find( size_t i, size_t j )
2220 {
2221  return Iterator( matrix_.find( i, j ), ( SO ? j : i ) );
2222 }
2224 //*************************************************************************************************
2225 
2226 
2227 //*************************************************************************************************
2243 template< typename MT // Type of the adapted sparse matrix
2244  , bool SO > // Storage order of the adapted sparse matrix
2246  UniLowerMatrix<MT,SO,false>::find( size_t i, size_t j ) const
2247 {
2248  return matrix_.find( i, j );
2249 }
2251 //*************************************************************************************************
2252 
2253 
2254 //*************************************************************************************************
2270 template< typename MT // Type of the adapted sparse matrix
2271  , bool SO > // Storage order of the adapted sparse matrix
2273  UniLowerMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
2274 {
2275  return Iterator( matrix_.lowerBound( i, j ), ( SO ? j : i ) );
2276 }
2278 //*************************************************************************************************
2279 
2280 
2281 //*************************************************************************************************
2297 template< typename MT // Type of the adapted sparse matrix
2298  , bool SO > // Storage order of the adapted sparse matrix
2300  UniLowerMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
2301 {
2302  return matrix_.lowerBound( i, j );
2303 }
2305 //*************************************************************************************************
2306 
2307 
2308 //*************************************************************************************************
2324 template< typename MT // Type of the adapted sparse matrix
2325  , bool SO > // Storage order of the adapted sparse matrix
2327  UniLowerMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
2328 {
2329  return Iterator( matrix_.upperBound( i, j ), ( SO ? j : i ) );
2330 }
2332 //*************************************************************************************************
2333 
2334 
2335 //*************************************************************************************************
2351 template< typename MT // Type of the adapted sparse matrix
2352  , bool SO > // Storage order of the adapted sparse matrix
2354  UniLowerMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
2355 {
2356  return matrix_.upperBound( i, j );
2357 }
2359 //*************************************************************************************************
2360 
2361 
2362 
2363 
2364 //=================================================================================================
2365 //
2366 // DEBUGGING FUNCTIONS
2367 //
2368 //=================================================================================================
2369 
2370 //*************************************************************************************************
2380 template< typename MT // Type of the adapted sparse matrix
2381  , bool SO > // Storage order of the adapted sparse matrix
2382 inline bool UniLowerMatrix<MT,SO,false>::isIntact() const noexcept
2383 {
2384  using blaze::isIntact;
2385 
2386  return ( isIntact( matrix_ ) && isUniLower( matrix_ ) );
2387 }
2389 //*************************************************************************************************
2390 
2391 
2392 
2393 
2394 //=================================================================================================
2395 //
2396 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2397 //
2398 //=================================================================================================
2399 
2400 //*************************************************************************************************
2411 template< typename MT // Type of the adapted sparse matrix
2412  , bool SO > // Storage order of the adapted sparse matrix
2413 template< typename Other > // Data type of the foreign expression
2414 inline bool UniLowerMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2415 {
2416  return matrix_.canAlias( alias );
2417 }
2419 //*************************************************************************************************
2420 
2421 
2422 //*************************************************************************************************
2433 template< typename MT // Type of the adapted sparse matrix
2434  , bool SO > // Storage order of the adapted sparse matrix
2435 template< typename Other > // Data type of the foreign expression
2436 inline bool UniLowerMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2437 {
2438  return matrix_.isAliased( alias );
2439 }
2441 //*************************************************************************************************
2442 
2443 
2444 //*************************************************************************************************
2455 template< typename MT // Type of the adapted sparse matrix
2456  , bool SO > // Storage order of the adapted sparse matrix
2457 inline bool UniLowerMatrix<MT,SO,false>::canSMPAssign() const noexcept
2458 {
2459  return matrix_.canSMPAssign();
2460 }
2462 //*************************************************************************************************
2463 
2464 } // namespace blaze
2465 
2466 #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:3078
bool isStrictlyLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly lower triangular matrix.
Definition: DenseMatrix.h:1179
#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
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
Header file for basic type definitions.
constexpr 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:750
#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:3077
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
bool isUniLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower unitriangular matrix.
Definition: DenseMatrix.h:1092
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:799
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5828
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3079
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3084
#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
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
Header file for the extended initializer_list functionality.
Constraint on the data type.
Header file for the IsUniLower type trait.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
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:482
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:416
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.
Header file for the implementation of a matrix representation of an initializer list.
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:3083
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#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:5907
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5890
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
#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:3080
#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
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:253
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:1002
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
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1179
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
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:438
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:8908
Constraint on the data type.
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
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:611
Header file for the UniLowerElement class.
Header file for the UniLowerProxy class.
Header file for the isOne shim.
Header file for the UniLowerValue class.
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.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNIFORM_TYPE(T)
Constraint on the data type.In case the given data type T is a uniform vector or matrix type...
Definition: Uniform.h:81
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:693
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:281
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
Constraint on the data type.
Constraint on the data type.
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
#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:3082
#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:263
#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
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:951
Header file for the IsResizable type trait.
Header file for the Size 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
constexpr ptrdiff_t Size_v
Auxiliary variable template for the Size type trait.The Size_v variable template provides a convenien...
Definition: Size.h:176
Header file for the clear shim.