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>
62 #include <blaze/math/Exception.h>
65 #include <blaze/math/shims/Clear.h>
67 #include <blaze/math/shims/IsOne.h>
79 #include <blaze/util/Assert.h>
85 #include <blaze/util/DisableIf.h>
86 #include <blaze/util/EnableIf.h>
88 #include <blaze/util/Types.h>
89 
90 
91 namespace blaze {
92 
93 //=================================================================================================
94 //
95 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
96 //
97 //=================================================================================================
98 
99 //*************************************************************************************************
107 template< typename MT // Type of the adapted sparse matrix
108  , bool SO > // Storage order of the adapted sparse matrix
109 class UniLowerMatrix<MT,SO,false>
110  : public SparseMatrix< UniLowerMatrix<MT,SO,false>, SO >
111 {
112  private:
113  //**Type definitions****************************************************************************
114  using OT = OppositeType_<MT>;
115  using TT = TransposeType_<MT>;
116  using ET = ElementType_<MT>;
117  //**********************************************************************************************
118 
119  public:
120  //**Type definitions****************************************************************************
121  using This = UniLowerMatrix<MT,SO,false>;
122  using BaseType = SparseMatrix<This,SO>;
123  using ResultType = This;
124  using OppositeType = UniLowerMatrix<OT,!SO,false>;
125  using TransposeType = UniUpperMatrix<TT,!SO,false>;
126  using ElementType = ET;
127  using ReturnType = ReturnType_<MT>;
128  using CompositeType = const This&;
129  using Reference = UniLowerProxy<MT>;
130  using ConstReference = ConstReference_<MT>;
131  using ConstIterator = ConstIterator_<MT>;
132  //**********************************************************************************************
133 
134  //**Rebind struct definition********************************************************************
137  template< typename NewType > // Data type of the other matrix
138  struct Rebind {
140  using Other = UniLowerMatrix< typename MT::template Rebind<NewType>::Other >;
141  };
142  //**********************************************************************************************
143 
144  //**Resize struct definition********************************************************************
147  template< size_t NewM // Number of rows of the other matrix
148  , size_t NewN > // Number of columns of the other matrix
149  struct Resize {
151  using Other = UniLowerMatrix< typename MT::template Resize<NewM,NewN>::Other >;
152  };
153  //**********************************************************************************************
154 
155  //**Iterator class definition*******************************************************************
158  class Iterator
159  {
160  public:
161  //**Type definitions*************************************************************************
162  using IteratorType = Iterator_<MT>;
163 
164  using IteratorCategory = std::forward_iterator_tag;
165  using ValueType = UniLowerElement<MT>;
166  using PointerType = ValueType;
167  using ReferenceType = ValueType;
168  using DifferenceType = ptrdiff_t;
169 
170  // STL iterator requirements
171  using iterator_category = IteratorCategory;
172  using value_type = ValueType;
173  using pointer = PointerType;
174  using reference = ReferenceType;
175  using difference_type = DifferenceType;
176  //*******************************************************************************************
177 
178  //**Default constructor**********************************************************************
181  inline Iterator()
182  : pos_ ( ) // Iterator to the current lower unitriangular matrix element
183  , index_ ( 0UL ) // The row/column index of the iterator
184  {}
185  //*******************************************************************************************
186 
187  //**Constructor******************************************************************************
193  inline Iterator( IteratorType pos, size_t index )
194  : pos_ ( pos ) // Iterator to the current lower unitriangular matrix element
195  , index_( index ) // The row/column index of the iterator
196  {}
197  //*******************************************************************************************
198 
199  //**Prefix increment operator****************************************************************
204  inline Iterator& operator++() {
205  ++pos_;
206  return *this;
207  }
208  //*******************************************************************************************
209 
210  //**Postfix increment operator***************************************************************
215  inline const Iterator operator++( int ) {
216  const Iterator tmp( *this );
217  ++(*this);
218  return tmp;
219  }
220  //*******************************************************************************************
221 
222  //**Element access operator******************************************************************
227  inline ReferenceType operator*() const {
228  return ReferenceType( pos_, pos_->index() == index_ );
229  }
230  //*******************************************************************************************
231 
232  //**Element access operator******************************************************************
237  inline PointerType operator->() const {
238  return PointerType( pos_, pos_->index() == index_ );
239  }
240  //*******************************************************************************************
241 
242  //**Conversion operator**********************************************************************
247  inline operator ConstIterator() const {
248  return pos_;
249  }
250  //*******************************************************************************************
251 
252  //**Equality operator************************************************************************
258  inline bool operator==( const Iterator& rhs ) const {
259  return pos_ == rhs.pos_;
260  }
261  //*******************************************************************************************
262 
263  //**Inequality operator**********************************************************************
269  inline bool operator!=( const Iterator& rhs ) const {
270  return !( *this == rhs );
271  }
272  //*******************************************************************************************
273 
274  //**Subtraction operator*********************************************************************
280  inline DifferenceType operator-( const Iterator& rhs ) const {
281  return pos_ - rhs.pos_;
282  }
283  //*******************************************************************************************
284 
285  //**Base function****************************************************************************
290  inline IteratorType base() const {
291  return pos_;
292  }
293  //*******************************************************************************************
294 
295  private:
296  //**Member variables*************************************************************************
297  IteratorType pos_;
298  size_t index_;
299  //*******************************************************************************************
300  };
301  //**********************************************************************************************
302 
303  //**Compilation flags***************************************************************************
305  enum : bool { smpAssignable = false };
306  //**********************************************************************************************
307 
308  //**Constructors********************************************************************************
311  explicit inline UniLowerMatrix();
312  explicit inline UniLowerMatrix( size_t n );
313  explicit inline UniLowerMatrix( size_t n, size_t nonzeros );
314  explicit inline UniLowerMatrix( size_t n, const std::vector<size_t>& nonzeros );
315  explicit inline UniLowerMatrix( initializer_list< initializer_list<ElementType> > list );
316 
317  inline UniLowerMatrix( const UniLowerMatrix& m );
318  inline UniLowerMatrix( UniLowerMatrix&& m ) noexcept;
319 
320  template< typename MT2, bool SO2 >
321  inline UniLowerMatrix( const Matrix<MT2,SO2>& m );
323  //**********************************************************************************************
324 
325  //**Destructor**********************************************************************************
326  // No explicitly declared destructor.
327  //**********************************************************************************************
328 
329  //**Data access functions***********************************************************************
332  inline Reference operator()( size_t i, size_t j );
333  inline ConstReference operator()( size_t i, size_t j ) const;
334  inline Reference at( size_t i, size_t j );
335  inline ConstReference at( size_t i, size_t j ) const;
336  inline Iterator begin ( size_t i );
337  inline ConstIterator begin ( size_t i ) const;
338  inline ConstIterator cbegin( size_t i ) const;
339  inline Iterator end ( size_t i );
340  inline ConstIterator end ( size_t i ) const;
341  inline ConstIterator cend ( size_t i ) const;
343  //**********************************************************************************************
344 
345  //**Assignment operators************************************************************************
348  inline UniLowerMatrix& operator=( initializer_list< initializer_list<ElementType> > list );
349 
350  inline UniLowerMatrix& operator=( const UniLowerMatrix& rhs );
351  inline UniLowerMatrix& operator=( UniLowerMatrix&& rhs ) noexcept;
352 
353  template< typename MT2, bool SO2 >
354  inline DisableIf_< IsComputation<MT2>, UniLowerMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
355 
356  template< typename MT2, bool SO2 >
357  inline EnableIf_< IsComputation<MT2>, UniLowerMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
358 
359  template< typename MT2, bool SO2 >
360  inline DisableIf_< IsComputation<MT2>, UniLowerMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
361 
362  template< typename MT2, bool SO2 >
363  inline EnableIf_< IsComputation<MT2>, UniLowerMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
364 
365  template< typename MT2, bool SO2 >
366  inline DisableIf_< IsComputation<MT2>, UniLowerMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
367 
368  template< typename MT2, bool SO2 >
369  inline EnableIf_< IsComputation<MT2>, UniLowerMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
370 
371  template< typename MT2, bool SO2 >
372  inline UniLowerMatrix& operator%=( const Matrix<MT2,SO2>& rhs );
374  //**********************************************************************************************
375 
376  //**Utility functions***************************************************************************
379  inline size_t rows() const noexcept;
380  inline size_t columns() const noexcept;
381  inline size_t capacity() const noexcept;
382  inline size_t capacity( size_t i ) const noexcept;
383  inline size_t nonZeros() const;
384  inline size_t nonZeros( size_t i ) const;
385  inline void reset();
386  inline void reset( size_t i );
387  inline void clear();
388  inline void resize ( size_t n, bool preserve=true );
389  inline void reserve( size_t nonzeros );
390  inline void reserve( size_t i, size_t nonzeros );
391  inline void trim();
392  inline void trim( size_t i );
393  inline void shrinkToFit();
394  inline void swap( UniLowerMatrix& m ) noexcept;
395 
396  static inline constexpr size_t maxNonZeros() noexcept;
397  static inline constexpr size_t maxNonZeros( size_t n ) noexcept;
399  //**********************************************************************************************
400 
401  //**Insertion functions*************************************************************************
404  inline Iterator set ( size_t i, size_t j, const ElementType& value );
405  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
406  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
407  inline void finalize( size_t i );
409  //**********************************************************************************************
410 
411  //**Erase functions*****************************************************************************
414  inline void erase( size_t i, size_t j );
415  inline Iterator erase( size_t i, Iterator pos );
416  inline Iterator erase( size_t i, Iterator first, Iterator last );
417 
418  template< typename Pred >
419  inline void erase( Pred predicate );
420 
421  template< typename Pred >
422  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
424  //**********************************************************************************************
425 
426  //**Lookup functions****************************************************************************
429  inline Iterator find ( size_t i, size_t j );
430  inline ConstIterator find ( size_t i, size_t j ) const;
431  inline Iterator lowerBound( size_t i, size_t j );
432  inline ConstIterator lowerBound( size_t i, size_t j ) const;
433  inline Iterator upperBound( size_t i, size_t j );
434  inline ConstIterator upperBound( size_t i, size_t j ) const;
436  //**********************************************************************************************
437 
438  //**Debugging functions*************************************************************************
441  inline bool isIntact() const noexcept;
443  //**********************************************************************************************
444 
445  //**Expression template evaluation functions****************************************************
448  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
449  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
450 
451  inline bool canSMPAssign() const noexcept;
453  //**********************************************************************************************
454 
455  private:
456  //**Utility functions***************************************************************************
459  inline void resetUpper();
461  //**********************************************************************************************
462 
463  //**Member variables****************************************************************************
466  MT matrix_;
467 
468  //**********************************************************************************************
469 
470  //**Friend declarations*************************************************************************
471  template< typename MT2, bool SO2, bool DF2 >
472  friend MT2& derestrict( UniLowerMatrix<MT2,SO2,DF2>& m );
473  //**********************************************************************************************
474 
475  //**Compile time checks*************************************************************************
489  BLAZE_STATIC_ASSERT( ( Size<MT,0UL>::value == Size<MT,1UL>::value ) );
490  //**********************************************************************************************
491 };
493 //*************************************************************************************************
494 
495 
496 
497 
498 //=================================================================================================
499 //
500 // CONSTRUCTORS
501 //
502 //=================================================================================================
503 
504 //*************************************************************************************************
508 template< typename MT // Type of the adapted sparse matrix
509  , bool SO > // Storage order of the adapted sparse matrix
510 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix()
511  : matrix_() // The adapted sparse matrix
512 {
513  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
514 }
516 //*************************************************************************************************
517 
518 
519 //*************************************************************************************************
527 template< typename MT // Type of the adapted sparse matrix
528  , bool SO > // Storage order of the adapted sparse matrix
529 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n )
530  : matrix_( n, n, n ) // The adapted sparse matrix
531 {
533 
534  for( size_t i=0UL; i<n; ++i ) {
535  matrix_.append( i, i, ElementType(1) );
536  matrix_.finalize( i );
537  }
538 
539  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
540 }
542 //*************************************************************************************************
543 
544 
545 //*************************************************************************************************
555 template< typename MT // Type of the adapted sparse matrix
556  , bool SO > // Storage order of the adapted sparse matrix
557 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n, size_t nonzeros )
558  : matrix_( n, n, max( nonzeros, n ) ) // The adapted sparse matrix
559 {
561 
562  for( size_t i=0UL; i<n; ++i ) {
563  matrix_.append( i, i, ElementType(1) );
564  matrix_.finalize( i );
565  }
566 
567  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
568 }
570 //*************************************************************************************************
571 
572 
573 //*************************************************************************************************
587 template< typename MT // Type of the adapted sparse matrix
588  , bool SO > // Storage order of the adapted sparse matrix
589 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n, const std::vector<size_t>& nonzeros )
590  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
591 {
593 
594  for( size_t i=0UL; i<n; ++i )
595  {
596  if( nonzeros[i] == 0UL ) {
597  BLAZE_THROW_INVALID_ARGUMENT( "Invalid capacity specification" );
598  }
599 
600  matrix_.append( i, i, ElementType(1) );
601  matrix_.finalize( i );
602  }
603 
604  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
605 }
607 //*************************************************************************************************
608 
609 
610 //*************************************************************************************************
634 template< typename MT // Type of the adapted sparse matrix
635  , bool SO > // Storage order of the adapted sparse matrix
636 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( initializer_list< initializer_list<ElementType> > list )
637  : matrix_( list ) // The adapted sparse matrix
638 {
639  if( !isUniLower( matrix_ ) ) {
640  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
641  }
642 
643  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
644 }
646 //*************************************************************************************************
647 
648 
649 //*************************************************************************************************
655 template< typename MT // Type of the adapted sparse matrix
656  , bool SO > // Storage order of the adapted sparse matrix
657 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( const UniLowerMatrix& m )
658  : matrix_( m.matrix_ ) // The adapted sparse matrix
659 {
660  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
661  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
662 }
664 //*************************************************************************************************
665 
666 
667 //*************************************************************************************************
673 template< typename MT // Type of the adapted sparse matrix
674  , bool SO > // Storage order of the adapted sparse matrix
675 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( UniLowerMatrix&& m ) noexcept
676  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
677 {
678  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
679  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
680 }
682 //*************************************************************************************************
683 
684 
685 //*************************************************************************************************
695 template< typename MT // Type of the adapted sparse matrix
696  , bool SO > // Storage order of the adapted sparse matrix
697 template< typename MT2 // Type of the foreign matrix
698  , bool SO2 > // Storage order of the foreign matrix
699 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( const Matrix<MT2,SO2>& m )
700  : matrix_( ~m ) // The adapted sparse matrix
701 {
702  if( !IsUniLower<MT2>::value && !isUniLower( matrix_ ) ) {
703  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
704  }
705 
706  if( !IsUniLower<MT2>::value )
707  resetUpper();
708 
709  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
710  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
711 }
713 //*************************************************************************************************
714 
715 
716 
717 
718 //=================================================================================================
719 //
720 // DATA ACCESS FUNCTIONS
721 //
722 //=================================================================================================
723 
724 //*************************************************************************************************
740 template< typename MT // Type of the adapted sparse matrix
741  , bool SO > // Storage order of the adapted sparse matrix
743  UniLowerMatrix<MT,SO,false>::operator()( size_t i, size_t j )
744 {
745  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
746  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
747 
748  return Reference( matrix_, i, j );
749 }
751 //*************************************************************************************************
752 
753 
754 //*************************************************************************************************
770 template< typename MT // Type of the adapted sparse matrix
771  , bool SO > // Storage order of the adapted sparse matrix
773  UniLowerMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
774 {
775  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
776  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
777 
778  return matrix_(i,j);
779 }
781 //*************************************************************************************************
782 
783 
784 //*************************************************************************************************
801 template< typename MT // Type of the adapted sparse matrix
802  , bool SO > // Storage order of the adapted sparse matrix
804  UniLowerMatrix<MT,SO,false>::at( size_t i, size_t j )
805 {
806  if( i >= rows() ) {
807  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
808  }
809  if( j >= columns() ) {
810  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
811  }
812  return (*this)(i,j);
813 }
815 //*************************************************************************************************
816 
817 
818 //*************************************************************************************************
835 template< typename MT // Type of the adapted sparse matrix
836  , bool SO > // Storage order of the adapted sparse matrix
838  UniLowerMatrix<MT,SO,false>::at( size_t i, size_t j ) const
839 {
840  if( i >= rows() ) {
841  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
842  }
843  if( j >= columns() ) {
844  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
845  }
846  return (*this)(i,j);
847 }
849 //*************************************************************************************************
850 
851 
852 //*************************************************************************************************
864 template< typename MT // Type of the adapted sparse matrix
865  , bool SO > // Storage order of the adapted sparse matrix
868 {
869  return Iterator( matrix_.begin(i), i );
870 }
872 //*************************************************************************************************
873 
874 
875 //*************************************************************************************************
887 template< typename MT // Type of the adapted sparse matrix
888  , bool SO > // Storage order of the adapted sparse matrix
890  UniLowerMatrix<MT,SO,false>::begin( size_t i ) const
891 {
892  return matrix_.begin(i);
893 }
895 //*************************************************************************************************
896 
897 
898 //*************************************************************************************************
910 template< typename MT // Type of the adapted sparse matrix
911  , bool SO > // Storage order of the adapted sparse matrix
913  UniLowerMatrix<MT,SO,false>::cbegin( size_t i ) const
914 {
915  return matrix_.cbegin(i);
916 }
918 //*************************************************************************************************
919 
920 
921 //*************************************************************************************************
933 template< typename MT // Type of the adapted sparse matrix
934  , bool SO > // Storage order of the adapted sparse matrix
937 {
938  return Iterator( matrix_.end(i), i );
939 }
941 //*************************************************************************************************
942 
943 
944 //*************************************************************************************************
956 template< typename MT // Type of the adapted sparse matrix
957  , bool SO > // Storage order of the adapted sparse matrix
959  UniLowerMatrix<MT,SO,false>::end( size_t i ) const
960 {
961  return matrix_.end(i);
962 }
964 //*************************************************************************************************
965 
966 
967 //*************************************************************************************************
979 template< typename MT // Type of the adapted sparse matrix
980  , bool SO > // Storage order of the adapted sparse matrix
982  UniLowerMatrix<MT,SO,false>::cend( size_t i ) const
983 {
984  return matrix_.cend(i);
985 }
987 //*************************************************************************************************
988 
989 
990 
991 
992 //=================================================================================================
993 //
994 // ASSIGNMENT OPERATORS
995 //
996 //=================================================================================================
997 
998 //*************************************************************************************************
1023 template< typename MT // Type of the adapted sparse matrix
1024  , bool SO > // Storage order of the adapted sparse matrix
1025 inline UniLowerMatrix<MT,SO,false>&
1026  UniLowerMatrix<MT,SO,false>::operator=( initializer_list< initializer_list<ElementType> > list )
1027 {
1028  const InitializerMatrix<ElementType> tmp( list, list.size() );
1029 
1030  if( !isUniLower( tmp ) ) {
1031  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1032  }
1033 
1034  matrix_ = list;
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 //*************************************************************************************************
1055 template< typename MT // Type of the adapted sparse matrix
1056  , bool SO > // Storage order of the adapted sparse matrix
1057 inline UniLowerMatrix<MT,SO,false>&
1058  UniLowerMatrix<MT,SO,false>::operator=( const UniLowerMatrix& rhs )
1059 {
1060  matrix_ = rhs.matrix_;
1061 
1062  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1063  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1064 
1065  return *this;
1066 }
1068 //*************************************************************************************************
1069 
1070 
1071 //*************************************************************************************************
1078 template< typename MT // Type of the adapted sparse matrix
1079  , bool SO > // Storage order of the adapted sparse matrix
1080 inline UniLowerMatrix<MT,SO,false>&
1081  UniLowerMatrix<MT,SO,false>::operator=( UniLowerMatrix&& rhs ) noexcept
1082 {
1083  matrix_ = std::move( rhs.matrix_ );
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( IsStrictlyTriangular<MT2>::value || ( !IsUniLower<MT2>::value && !isUniLower( ~rhs ) ) ) {
1115  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1116  }
1117 
1118  matrix_ = decllow( ~rhs );
1119 
1120  if( !IsUniLower<MT2>::value )
1121  resetUpper();
1122 
1123  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1124  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1125 
1126  return *this;
1127 }
1129 //*************************************************************************************************
1130 
1131 
1132 //*************************************************************************************************
1145 template< typename MT // Type of the adapted sparse matrix
1146  , bool SO > // Storage order of the adapted sparse matrix
1147 template< typename MT2 // Type of the right-hand side matrix
1148  , bool SO2 > // Storage order of the right-hand side matrix
1149 inline EnableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1150  UniLowerMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
1151 {
1152  if( IsStrictlyTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1153  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1154  }
1155 
1156  if( IsUniLower<MT2>::value ) {
1157  matrix_ = ~rhs;
1158  }
1159  else {
1160  MT tmp( ~rhs );
1161 
1162  if( !isUniLower( tmp ) ) {
1163  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1164  }
1165 
1166  matrix_ = std::move( tmp );
1167  }
1168 
1169  if( !IsUniLower<MT2>::value )
1170  resetUpper();
1171 
1172  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1173  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1174 
1175  return *this;
1176 }
1178 //*************************************************************************************************
1179 
1180 
1181 //*************************************************************************************************
1194 template< typename MT // Type of the adapted sparse matrix
1195  , bool SO > // Storage order of the adapted sparse matrix
1196 template< typename MT2 // Type of the right-hand side matrix
1197  , bool SO2 > // Storage order of the right-hand side matrix
1198 inline DisableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1199  UniLowerMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1200 {
1201  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1202  ( !IsStrictlyLower<MT2>::value && !isStrictlyLower( ~rhs ) ) ) {
1203  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1204  }
1205 
1206  matrix_ += decllow( ~rhs );
1207 
1208  if( !IsStrictlyLower<MT2>::value )
1209  resetUpper();
1210 
1211  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1212  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1213 
1214  return *this;
1215 }
1217 //*************************************************************************************************
1218 
1219 
1220 //*************************************************************************************************
1233 template< typename MT // Type of the adapted sparse matrix
1234  , bool SO > // Storage order of the adapted sparse matrix
1235 template< typename MT2 // Type of the right-hand side matrix
1236  , bool SO2 > // Storage order of the right-hand side matrix
1237 inline EnableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1238  UniLowerMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1239 {
1240  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1241  ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1242  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1243  }
1244 
1245  if( IsStrictlyLower<MT2>::value ) {
1246  matrix_ += ~rhs;
1247  }
1248  else {
1249  const ResultType_<MT2> tmp( ~rhs );
1250 
1251  if( !isStrictlyLower( tmp ) ) {
1252  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1253  }
1254 
1255  matrix_ += decllow( tmp );
1256  }
1257 
1258  if( !IsStrictlyLower<MT2>::value )
1259  resetUpper();
1260 
1261  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1262  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1263 
1264  return *this;
1265 }
1267 //*************************************************************************************************
1268 
1269 
1270 //*************************************************************************************************
1283 template< typename MT // Type of the adapted sparse matrix
1284  , bool SO > // Storage order of the adapted sparse matrix
1285 template< typename MT2 // Type of the right-hand side matrix
1286  , bool SO2 > // Storage order of the right-hand side matrix
1287 inline DisableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1288  UniLowerMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1289 {
1290  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1291  ( !IsStrictlyLower<MT2>::value && !isStrictlyLower( ~rhs ) ) ) {
1292  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1293  }
1294 
1295  matrix_ -= decllow( ~rhs );
1296 
1297  if( !IsStrictlyLower<MT2>::value )
1298  resetUpper();
1299 
1300  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1301  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1302 
1303  return *this;
1304 }
1306 //*************************************************************************************************
1307 
1308 
1309 //*************************************************************************************************
1322 template< typename MT // Type of the adapted sparse matrix
1323  , bool SO > // Storage order of the adapted sparse matrix
1324 template< typename MT2 // Type of the right-hand side matrix
1325  , bool SO2 > // Storage order of the right-hand side matrix
1326 inline EnableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1327  UniLowerMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1328 {
1329  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1330  ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1331  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1332  }
1333 
1334  if( IsStrictlyLower<MT2>::value ) {
1335  matrix_ -= ~rhs;
1336  }
1337  else {
1338  const ResultType_<MT2> tmp( ~rhs );
1339 
1340  if( !isStrictlyLower( tmp ) ) {
1341  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1342  }
1343 
1344  matrix_ -= decllow( tmp );
1345  }
1346 
1347  if( !IsStrictlyLower<MT2>::value )
1348  resetUpper();
1349 
1350  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1351  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1352 
1353  return *this;
1354 }
1356 //*************************************************************************************************
1357 
1358 
1359 //*************************************************************************************************
1372 template< typename MT // Type of the adapted sparse matrix
1373  , bool SO > // Storage order of the adapted sparse matrix
1374 template< typename MT2 // Type of the right-hand side matrix
1375  , bool SO2 > // Storage order of the right-hand side matrix
1376 inline UniLowerMatrix<MT,SO,false>&
1377  UniLowerMatrix<MT,SO,false>::operator%=( const Matrix<MT2,SO2>& rhs )
1378 {
1379  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1380  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1381  }
1382 
1383  If_< IsComputation<MT2>, ResultType_<MT2>, const MT2& > tmp( ~rhs );
1384 
1385  for( size_t i=0UL; i<(~rhs).rows(); ++i ) {
1386  if( !isOne( tmp(i,i) ) ) {
1387  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1388  }
1389  }
1390 
1391  matrix_ %= tmp;
1392 
1393  if( !IsUniLower<MT2>::value )
1394  resetUpper();
1395 
1396  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1397  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1398 
1399  return *this;
1400 }
1402 //*************************************************************************************************
1403 
1404 
1405 
1406 
1407 //=================================================================================================
1408 //
1409 // UTILITY FUNCTIONS
1410 //
1411 //=================================================================================================
1412 
1413 //*************************************************************************************************
1419 template< typename MT // Type of the adapted sparse matrix
1420  , bool SO > // Storage order of the adapted sparse matrix
1421 inline size_t UniLowerMatrix<MT,SO,false>::rows() const noexcept
1422 {
1423  return matrix_.rows();
1424 }
1426 //*************************************************************************************************
1427 
1428 
1429 //*************************************************************************************************
1435 template< typename MT // Type of the adapted sparse matrix
1436  , bool SO > // Storage order of the adapted sparse matrix
1437 inline size_t UniLowerMatrix<MT,SO,false>::columns() const noexcept
1438 {
1439  return matrix_.columns();
1440 }
1442 //*************************************************************************************************
1443 
1444 
1445 //*************************************************************************************************
1451 template< typename MT // Type of the adapted sparse matrix
1452  , bool SO > // Storage order of the adapted sparse matrix
1453 inline size_t UniLowerMatrix<MT,SO,false>::capacity() const noexcept
1454 {
1455  return matrix_.capacity();
1456 }
1458 //*************************************************************************************************
1459 
1460 
1461 //*************************************************************************************************
1473 template< typename MT // Type of the adapted sparse matrix
1474  , bool SO > // Storage order of the adapted sparse matrix
1475 inline size_t UniLowerMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1476 {
1477  return matrix_.capacity(i);
1478 }
1480 //*************************************************************************************************
1481 
1482 
1483 //*************************************************************************************************
1489 template< typename MT // Type of the adapted sparse matrix
1490  , bool SO > // Storage order of the adapted sparse matrix
1491 inline size_t UniLowerMatrix<MT,SO,false>::nonZeros() const
1492 {
1493  return matrix_.nonZeros();
1494 }
1496 //*************************************************************************************************
1497 
1498 
1499 //*************************************************************************************************
1511 template< typename MT // Type of the adapted sparse matrix
1512  , bool SO > // Storage order of the adapted sparse matrix
1513 inline size_t UniLowerMatrix<MT,SO,false>::nonZeros( size_t i ) const
1514 {
1515  return matrix_.nonZeros(i);
1516 }
1518 //*************************************************************************************************
1519 
1520 
1521 //*************************************************************************************************
1527 template< typename MT // Type of the adapted sparse matrix
1528  , bool SO > // Storage order of the adapted sparse matrix
1530 {
1531  if( SO ) {
1532  for( size_t j=0UL; j<columns(); ++j ) {
1533  matrix_.erase( j, matrix_.lowerBound(j+1UL,j), matrix_.end(j) );
1534  }
1535  }
1536  else {
1537  for( size_t i=1UL; i<rows(); ++i ) {
1538  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1539  }
1540  }
1541 }
1543 //*************************************************************************************************
1544 
1545 
1546 //*************************************************************************************************
1559 template< typename MT // Type of the adapted sparse matrix
1560  , bool SO > // Storage order of the adapted sparse matrix
1561 inline void UniLowerMatrix<MT,SO,false>::reset( size_t i )
1562 {
1563  if( SO ) {
1564  matrix_.erase( i, matrix_.lowerBound(i+1UL,i), matrix_.end(i) );
1565  }
1566  else {
1567  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1568  }
1569 }
1571 //*************************************************************************************************
1572 
1573 
1574 //*************************************************************************************************
1582 template< typename MT // Type of the adapted sparse matrix
1583  , bool SO > // Storage order of the adapted sparse matrix
1585 {
1586  using blaze::clear;
1587 
1588  if( IsResizable<MT>::value ) {
1589  clear( matrix_ );
1590  }
1591  else {
1592  reset();
1593  }
1594 }
1596 //*************************************************************************************************
1597 
1598 
1599 //*************************************************************************************************
1614 template< typename MT // Type of the adapted sparse matrix
1615  , bool SO > // Storage order of the adapted sparse matrix
1616 void UniLowerMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1617 {
1619 
1620  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1621 
1622  const size_t oldsize( matrix_.rows() );
1623 
1624  matrix_.resize( n, n, preserve );
1625 
1626  if( n > oldsize ) {
1627  for( size_t i=oldsize; i<n; ++i )
1628  matrix_.insert( i, i, ElementType(1) );
1629  }
1630 }
1632 //*************************************************************************************************
1633 
1634 
1635 //*************************************************************************************************
1646 template< typename MT // Type of the adapted sparse matrix
1647  , bool SO > // Storage order of the adapted sparse matrix
1648 inline void UniLowerMatrix<MT,SO,false>::reserve( size_t nonzeros )
1649 {
1650  matrix_.reserve( nonzeros );
1651 }
1653 //*************************************************************************************************
1654 
1655 
1656 //*************************************************************************************************
1670 template< typename MT // Type of the adapted sparse matrix
1671  , bool SO > // Storage order of the adapted sparse matrix
1672 inline void UniLowerMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1673 {
1674  matrix_.reserve( i, nonzeros );
1675 }
1677 //*************************************************************************************************
1678 
1679 
1680 //*************************************************************************************************
1691 template< typename MT // Type of the adapted sparse matrix
1692  , bool SO > // Storage order of the adapted sparse matrix
1693 inline void UniLowerMatrix<MT,SO,false>::trim()
1694 {
1695  matrix_.trim();
1696 }
1698 //*************************************************************************************************
1699 
1700 
1701 //*************************************************************************************************
1713 template< typename MT // Type of the adapted sparse matrix
1714  , bool SO > // Storage order of the adapted sparse matrix
1715 inline void UniLowerMatrix<MT,SO,false>::trim( size_t i )
1716 {
1717  matrix_.trim( i );
1718 }
1720 //*************************************************************************************************
1721 
1722 
1723 //*************************************************************************************************
1733 template< typename MT // Type of the adapted sparse matrix
1734  , bool SO > // Storage order of the adapted sparse matrix
1736 {
1737  matrix_.shrinkToFit();
1738 }
1740 //*************************************************************************************************
1741 
1742 
1743 //*************************************************************************************************
1750 template< typename MT // Type of the adapted sparse matrix
1751  , bool SO > // Storage order of the adapted sparse matrix
1752 inline void UniLowerMatrix<MT,SO,false>::swap( UniLowerMatrix& m ) noexcept
1753 {
1754  using std::swap;
1755 
1756  swap( matrix_, m.matrix_ );
1757 }
1759 //*************************************************************************************************
1760 
1761 
1762 //*************************************************************************************************
1773 template< typename MT // Type of the adapted dense matrix
1774  , bool SO > // Storage order of the adapted dense matrix
1775 inline constexpr size_t UniLowerMatrix<MT,SO,false>::maxNonZeros() noexcept
1776 {
1778 
1779  return maxNonZeros( Size<MT,0UL>::value );
1780 }
1782 //*************************************************************************************************
1783 
1784 
1785 //*************************************************************************************************
1795 template< typename MT // Type of the adapted dense matrix
1796  , bool SO > // Storage order of the adapted dense matrix
1797 inline constexpr size_t UniLowerMatrix<MT,SO,false>::maxNonZeros( size_t n ) noexcept
1798 {
1799  return ( ( n + 1UL ) * n ) / 2UL;
1800 }
1802 //*************************************************************************************************
1803 
1804 
1805 //*************************************************************************************************
1811 template< typename MT // Type of the adapted dense matrix
1812  , bool SO > // Storage order of the adapted dense matrix
1813 inline void UniLowerMatrix<MT,SO,false>::resetUpper()
1814 {
1815  if( SO ) {
1816  for( size_t j=1UL; j<columns(); ++j )
1817  matrix_.erase( j, matrix_.begin( j ), matrix_.lowerBound( j, j ) );
1818  }
1819  else {
1820  for( size_t i=0UL; i<rows(); ++i )
1821  matrix_.erase( i, matrix_.upperBound( i, i ), matrix_.end( i ) );
1822  }
1823 }
1825 //*************************************************************************************************
1826 
1827 
1828 
1829 
1830 //=================================================================================================
1831 //
1832 // INSERTION FUNCTIONS
1833 //
1834 //=================================================================================================
1835 
1836 //*************************************************************************************************
1852 template< typename MT // Type of the adapted sparse matrix
1853  , bool SO > // Storage order of the adapted sparse matrix
1855  UniLowerMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1856 {
1857  if( i <= j ) {
1858  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1859  }
1860 
1861  return Iterator( matrix_.set( i, j, value ), ( SO ? j : i ) );
1862 }
1864 //*************************************************************************************************
1865 
1866 
1867 //*************************************************************************************************
1884 template< typename MT // Type of the adapted sparse matrix
1885  , bool SO > // Storage order of the adapted sparse matrix
1887  UniLowerMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1888 {
1889  if( i <= j ) {
1890  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1891  }
1892 
1893  return Iterator( matrix_.insert( i, j, value ), ( SO ? j : i ) );
1894 }
1896 //*************************************************************************************************
1897 
1898 
1899 //*************************************************************************************************
1949 template< typename MT // Type of the adapted sparse matrix
1950  , bool SO > // Storage order of the adapted sparse matrix
1951 inline void UniLowerMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1952 {
1953  if( i <= j ) {
1954  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1955  }
1956 
1957  if( !check || !isDefault<strict>( value ) )
1958  matrix_.insert( i, j, value );
1959 }
1961 //*************************************************************************************************
1962 
1963 
1964 //*************************************************************************************************
1978 template< typename MT // Type of the adapted sparse matrix
1979  , bool SO > // Storage order of the adapted sparse matrix
1980 inline void UniLowerMatrix<MT,SO,false>::finalize( size_t i )
1981 {
1982  matrix_.trim( i );
1983 }
1985 //*************************************************************************************************
1986 
1987 
1988 
1989 
1990 //=================================================================================================
1991 //
1992 // ERASE FUNCTIONS
1993 //
1994 //=================================================================================================
1995 
1996 //*************************************************************************************************
2008 template< typename MT // Type of the adapted sparse matrix
2009  , bool SO > // Storage order of the adapted sparse matrix
2010 inline void UniLowerMatrix<MT,SO,false>::erase( size_t i, size_t j )
2011 {
2012  if( i == j ) {
2013  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2014  }
2015 
2016  matrix_.erase( i, j );
2017 }
2019 //*************************************************************************************************
2020 
2021 
2022 //*************************************************************************************************
2036 template< typename MT // Type of the adapted sparse matrix
2037  , bool SO > // Storage order of the adapted sparse matrix
2039  UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
2040 {
2041  if( pos != matrix_.end(i) && pos->index() == i ) {
2042  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2043  }
2044 
2045  return Iterator( matrix_.erase( i, pos.base() ), i );
2046 }
2048 //*************************************************************************************************
2049 
2050 
2051 //*************************************************************************************************
2066 template< typename MT // Type of the adapted sparse matrix
2067  , bool SO > // Storage order of the adapted sparse matrix
2069  UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
2070 {
2071  if( first == last )
2072  return last;
2073 
2074  if( ( !SO && last.base() == matrix_.end(i) ) ||
2075  ( SO && first.base() == matrix_.begin(i) ) ) {
2076  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2077  }
2078 
2079  return Iterator( matrix_.erase( i, first.base(), last.base() ), i );
2080 }
2082 //*************************************************************************************************
2083 
2084 
2085 //*************************************************************************************************
2107 template< typename MT // Type of the adapted sparse matrix
2108  , bool SO > // Storage order of the adapted sparse matrix
2109 template< typename Pred > // Type of the unary predicate
2110 inline void UniLowerMatrix<MT,SO,false>::erase( Pred predicate )
2111 {
2112  if( SO ) {
2113  for( size_t j=0UL; (j+1UL) < columns(); ++j ) {
2114  matrix_.erase( j, matrix_.lowerBound(j+1UL,j), matrix_.end(j), predicate );
2115  }
2116  }
2117  else {
2118  for( size_t i=1UL; i<rows(); ++i ) {
2119  matrix_.erase( i, matrix_.begin(i), matrix_.find(i,i), predicate );
2120  }
2121  }
2122 
2123  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2124 }
2126 //*************************************************************************************************
2127 
2128 
2129 //*************************************************************************************************
2160 template< typename MT // Type of the adapted sparse matrix
2161  , bool SO > // Storage order of the adapted sparse matrix
2162 template< typename Pred > // Type of the unary predicate
2163 inline void UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
2164 {
2165  if( first == last )
2166  return;
2167 
2168  if( ( !SO && last.base() == matrix_.end(i) && predicate( ElementType(1) ) ) ||
2169  ( SO && first.base() == matrix_.begin(i) && predicate( ElementType(1) ) ) ) {
2170  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2171  }
2172 
2173  matrix_.erase( i, first.base(), last.base(), predicate );
2174 
2175  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2176 }
2178 //*************************************************************************************************
2179 
2180 
2181 
2182 
2183 //=================================================================================================
2184 //
2185 // LOOKUP FUNCTIONS
2186 //
2187 //=================================================================================================
2188 
2189 //*************************************************************************************************
2205 template< typename MT // Type of the adapted sparse matrix
2206  , bool SO > // Storage order of the adapted sparse matrix
2208  UniLowerMatrix<MT,SO,false>::find( size_t i, size_t j )
2209 {
2210  return Iterator( matrix_.find( i, j ), ( SO ? j : i ) );
2211 }
2213 //*************************************************************************************************
2214 
2215 
2216 //*************************************************************************************************
2232 template< typename MT // Type of the adapted sparse matrix
2233  , bool SO > // Storage order of the adapted sparse matrix
2235  UniLowerMatrix<MT,SO,false>::find( size_t i, size_t j ) const
2236 {
2237  return matrix_.find( i, j );
2238 }
2240 //*************************************************************************************************
2241 
2242 
2243 //*************************************************************************************************
2259 template< typename MT // Type of the adapted sparse matrix
2260  , bool SO > // Storage order of the adapted sparse matrix
2262  UniLowerMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
2263 {
2264  return Iterator( matrix_.lowerBound( i, j ), ( SO ? j : i ) );
2265 }
2267 //*************************************************************************************************
2268 
2269 
2270 //*************************************************************************************************
2286 template< typename MT // Type of the adapted sparse matrix
2287  , bool SO > // Storage order of the adapted sparse matrix
2289  UniLowerMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
2290 {
2291  return matrix_.lowerBound( i, j );
2292 }
2294 //*************************************************************************************************
2295 
2296 
2297 //*************************************************************************************************
2313 template< typename MT // Type of the adapted sparse matrix
2314  , bool SO > // Storage order of the adapted sparse matrix
2316  UniLowerMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
2317 {
2318  return Iterator( matrix_.upperBound( i, j ), ( SO ? j : i ) );
2319 }
2321 //*************************************************************************************************
2322 
2323 
2324 //*************************************************************************************************
2340 template< typename MT // Type of the adapted sparse matrix
2341  , bool SO > // Storage order of the adapted sparse matrix
2343  UniLowerMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
2344 {
2345  return matrix_.upperBound( i, j );
2346 }
2348 //*************************************************************************************************
2349 
2350 
2351 
2352 
2353 //=================================================================================================
2354 //
2355 // DEBUGGING FUNCTIONS
2356 //
2357 //=================================================================================================
2358 
2359 //*************************************************************************************************
2369 template< typename MT // Type of the adapted sparse matrix
2370  , bool SO > // Storage order of the adapted sparse matrix
2371 inline bool UniLowerMatrix<MT,SO,false>::isIntact() const noexcept
2372 {
2373  using blaze::isIntact;
2374 
2375  return ( isIntact( matrix_ ) && isUniLower( matrix_ ) );
2376 }
2378 //*************************************************************************************************
2379 
2380 
2381 
2382 
2383 //=================================================================================================
2384 //
2385 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
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 template< typename Other > // Data type of the foreign expression
2403 inline bool UniLowerMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2404 {
2405  return matrix_.canAlias( alias );
2406 }
2408 //*************************************************************************************************
2409 
2410 
2411 //*************************************************************************************************
2422 template< typename MT // Type of the adapted sparse matrix
2423  , bool SO > // Storage order of the adapted sparse matrix
2424 template< typename Other > // Data type of the foreign expression
2425 inline bool UniLowerMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2426 {
2427  return matrix_.isAliased( alias );
2428 }
2430 //*************************************************************************************************
2431 
2432 
2433 //*************************************************************************************************
2444 template< typename MT // Type of the adapted sparse matrix
2445  , bool SO > // Storage order of the adapted sparse matrix
2446 inline bool UniLowerMatrix<MT,SO,false>::canSMPAssign() const noexcept
2447 {
2448  return matrix_.canSMPAssign();
2449 }
2451 //*************************************************************************************************
2452 
2453 } // namespace blaze
2454 
2455 #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:3077
bool isStrictlyLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly lower triangular matrix.
Definition: DenseMatrix.h:1386
#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
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:522
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:3076
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:364
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3074
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:588
bool isUniLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower unitriangular matrix.
Definition: DenseMatrix.h:1299
BLAZE_ALWAYS_INLINE void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:775
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5829
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3078
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3083
#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:560
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:733
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3084
Header file for the extended initializer_list functionality.
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:1950
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:474
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:408
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:3082
Header file for the clear shim.
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:5908
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5891
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
#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:3079
#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:3085
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:1026
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:506
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:714
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:430
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:608
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:690
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:272
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:490
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3080
#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:3081
#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:254
#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:908
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