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>
60 #include <blaze/math/Exception.h>
62 #include <blaze/math/Functions.h>
63 #include <blaze/math/shims/Clear.h>
76 #include <blaze/util/Assert.h>
82 #include <blaze/util/DisableIf.h>
83 #include <blaze/util/EnableIf.h>
86 #include <blaze/util/Types.h>
87 
88 
89 namespace blaze {
90 
91 //=================================================================================================
92 //
93 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
94 //
95 //=================================================================================================
96 
97 //*************************************************************************************************
105 template< typename MT // Type of the adapted sparse matrix
106  , bool SO > // Storage order of the adapted sparse matrix
107 class UniLowerMatrix<MT,SO,false>
108  : public SparseMatrix< UniLowerMatrix<MT,SO,false>, SO >
109 {
110  private:
111  //**Type definitions****************************************************************************
112  typedef OppositeType_<MT> OT;
113  typedef TransposeType_<MT> TT;
114  typedef ElementType_<MT> ET;
115  //**********************************************************************************************
116 
117  public:
118  //**Type definitions****************************************************************************
119  typedef UniLowerMatrix<MT,SO,false> This;
120  typedef SparseMatrix<This,SO> BaseType;
121  typedef This ResultType;
122  typedef UniLowerMatrix<OT,!SO,false> OppositeType;
123  typedef UniUpperMatrix<TT,!SO,false> TransposeType;
124  typedef ET ElementType;
125  typedef ReturnType_<MT> ReturnType;
126  typedef const This& CompositeType;
127  typedef UniLowerProxy<MT> Reference;
128  typedef ConstReference_<MT> ConstReference;
129  typedef ConstIterator_<MT> ConstIterator;
130  //**********************************************************************************************
131 
132  //**Rebind struct definition********************************************************************
135  template< typename ET > // Data type of the other matrix
136  struct Rebind {
138  typedef UniLowerMatrix< typename MT::template Rebind<ET>::Other > Other;
139  };
140  //**********************************************************************************************
141 
142  //**Iterator class definition*******************************************************************
145  class Iterator
146  {
147  public:
148  //**Type definitions*************************************************************************
149  typedef Iterator_<MT> IteratorType;
150 
151  typedef std::forward_iterator_tag IteratorCategory;
152  typedef UniLowerElement<MT> ValueType;
153  typedef ValueType PointerType;
154  typedef ValueType ReferenceType;
155  typedef ptrdiff_t DifferenceType;
156 
157  // STL iterator requirements
158  typedef IteratorCategory iterator_category;
159  typedef ValueType value_type;
160  typedef PointerType pointer;
161  typedef ReferenceType reference;
162  typedef DifferenceType difference_type;
163  //*******************************************************************************************
164 
165  //**Default constructor**********************************************************************
168  inline Iterator()
169  : pos_ ( ) // Iterator to the current lower unitriangular matrix element
170  , index_ ( 0UL ) // The row/column index of the iterator
171  {}
172  //*******************************************************************************************
173 
174  //**Constructor******************************************************************************
180  inline Iterator( IteratorType pos, size_t index )
181  : pos_ ( pos ) // Iterator to the current lower unitriangular matrix element
182  , index_( index ) // The row/column index of the iterator
183  {}
184  //*******************************************************************************************
185 
186  //**Prefix increment operator****************************************************************
191  inline Iterator& operator++() {
192  ++pos_;
193  return *this;
194  }
195  //*******************************************************************************************
196 
197  //**Postfix increment operator***************************************************************
202  inline const Iterator operator++( int ) {
203  const Iterator tmp( *this );
204  ++(*this);
205  return tmp;
206  }
207  //*******************************************************************************************
208 
209  //**Element access operator******************************************************************
214  inline ReferenceType operator*() const {
215  return ReferenceType( pos_, pos_->index() == index_ );
216  }
217  //*******************************************************************************************
218 
219  //**Element access operator******************************************************************
224  inline PointerType operator->() const {
225  return PointerType( pos_, pos_->index() == index_ );
226  }
227  //*******************************************************************************************
228 
229  //**Conversion operator**********************************************************************
234  inline operator ConstIterator() const {
235  return pos_;
236  }
237  //*******************************************************************************************
238 
239  //**Equality operator************************************************************************
245  inline bool operator==( const Iterator& rhs ) const {
246  return pos_ == rhs.pos_;
247  }
248  //*******************************************************************************************
249 
250  //**Inequality operator**********************************************************************
256  inline bool operator!=( const Iterator& rhs ) const {
257  return !( *this == rhs );
258  }
259  //*******************************************************************************************
260 
261  //**Subtraction operator*********************************************************************
267  inline DifferenceType operator-( const Iterator& rhs ) const {
268  return pos_ - rhs.pos_;
269  }
270  //*******************************************************************************************
271 
272  //**Base function****************************************************************************
277  inline IteratorType base() const {
278  return pos_;
279  }
280  //*******************************************************************************************
281 
282  private:
283  //**Member variables*************************************************************************
284  IteratorType pos_;
285  size_t index_;
286  //*******************************************************************************************
287  };
288  //**********************************************************************************************
289 
290  //**Compilation flags***************************************************************************
292  enum : bool { smpAssignable = false };
293  //**********************************************************************************************
294 
295  //**Constructors********************************************************************************
298  explicit inline UniLowerMatrix();
299  explicit inline UniLowerMatrix( size_t n );
300  explicit inline UniLowerMatrix( size_t n, size_t nonzeros );
301  explicit inline UniLowerMatrix( size_t n, const std::vector<size_t>& nonzeros );
302 
303  inline UniLowerMatrix( const UniLowerMatrix& m );
304  inline UniLowerMatrix( UniLowerMatrix&& m ) noexcept;
305 
306  template< typename MT2, bool SO2 >
307  inline UniLowerMatrix( const Matrix<MT2,SO2>& m );
309  //**********************************************************************************************
310 
311  //**Destructor**********************************************************************************
312  // No explicitly declared destructor.
313  //**********************************************************************************************
314 
315  //**Data access functions***********************************************************************
318  inline Reference operator()( size_t i, size_t j );
319  inline ConstReference operator()( size_t i, size_t j ) const;
320  inline Reference at( size_t i, size_t j );
321  inline ConstReference at( size_t i, size_t j ) const;
322  inline Iterator begin ( size_t i );
323  inline ConstIterator begin ( size_t i ) const;
324  inline ConstIterator cbegin( size_t i ) const;
325  inline Iterator end ( size_t i );
326  inline ConstIterator end ( size_t i ) const;
327  inline ConstIterator cend ( size_t i ) const;
329  //**********************************************************************************************
330 
331  //**Assignment operators************************************************************************
334  inline UniLowerMatrix& operator=( const UniLowerMatrix& rhs );
335  inline UniLowerMatrix& operator=( UniLowerMatrix&& rhs ) noexcept;
336 
337  template< typename MT2, bool SO2 >
338  inline DisableIf_< IsComputation<MT2>, UniLowerMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
339 
340  template< typename MT2, bool SO2 >
341  inline EnableIf_< IsComputation<MT2>, UniLowerMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
342 
343  template< typename MT2, bool SO2 >
344  inline DisableIf_< IsComputation<MT2>, UniLowerMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
345 
346  template< typename MT2, bool SO2 >
347  inline EnableIf_< IsComputation<MT2>, UniLowerMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
348 
349  template< typename MT2, bool SO2 >
350  inline DisableIf_< IsComputation<MT2>, UniLowerMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
351 
352  template< typename MT2, bool SO2 >
353  inline EnableIf_< IsComputation<MT2>, UniLowerMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
354 
355  template< typename MT2, bool SO2 >
356  inline UniLowerMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
358  //**********************************************************************************************
359 
360  //**Utility functions***************************************************************************
363  inline size_t rows() const noexcept;
364  inline size_t columns() const noexcept;
365  inline size_t capacity() const noexcept;
366  inline size_t capacity( size_t i ) const noexcept;
367  inline size_t nonZeros() const;
368  inline size_t nonZeros( size_t i ) const;
369  inline void reset();
370  inline void reset( size_t i );
371  inline void clear();
372  inline Iterator set( size_t i, size_t j, const ElementType& value );
373  inline Iterator insert( size_t i, size_t j, const ElementType& value );
374  inline void erase( size_t i, size_t j );
375  inline Iterator erase( size_t i, Iterator pos );
376  inline Iterator erase( size_t i, Iterator first, Iterator last );
377  inline void resize ( size_t n, bool preserve=true );
378  inline void reserve( size_t nonzeros );
379  inline void reserve( size_t i, size_t nonzeros );
380  inline void trim();
381  inline void trim( size_t i );
382  inline void swap( UniLowerMatrix& m ) noexcept;
383 
384  static inline constexpr size_t maxNonZeros() noexcept;
385  static inline constexpr size_t maxNonZeros( size_t n ) noexcept;
387  //**********************************************************************************************
388 
389  //**Lookup functions****************************************************************************
392  inline Iterator find ( size_t i, size_t j );
393  inline ConstIterator find ( size_t i, size_t j ) const;
394  inline Iterator lowerBound( size_t i, size_t j );
395  inline ConstIterator lowerBound( size_t i, size_t j ) const;
396  inline Iterator upperBound( size_t i, size_t j );
397  inline ConstIterator upperBound( size_t i, size_t j ) const;
399  //**********************************************************************************************
400 
401  //**Low-level utility functions*****************************************************************
404  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
405  inline void finalize( size_t i );
407  //**********************************************************************************************
408 
409  //**Debugging functions*************************************************************************
412  inline bool isIntact() const noexcept;
414  //**********************************************************************************************
415 
416  //**Expression template evaluation functions****************************************************
419  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
420  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
421 
422  inline bool canSMPAssign() const noexcept;
424  //**********************************************************************************************
425 
426  private:
427  //**Utility functions***************************************************************************
430  inline void resetUpper();
432  //**********************************************************************************************
433 
434  //**Member variables****************************************************************************
437  MT matrix_;
438 
439  //**********************************************************************************************
440 
441  //**Friend declarations*************************************************************************
442  template< typename MT2, bool SO2, bool DF2 >
443  friend MT2& derestrict( UniLowerMatrix<MT2,SO2,DF2>& m );
444  //**********************************************************************************************
445 
446  //**Compile time checks*************************************************************************
460  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
461  //**********************************************************************************************
462 };
464 //*************************************************************************************************
465 
466 
467 
468 
469 //=================================================================================================
470 //
471 // CONSTRUCTORS
472 //
473 //=================================================================================================
474 
475 //*************************************************************************************************
479 template< typename MT // Type of the adapted sparse matrix
480  , bool SO > // Storage order of the adapted sparse matrix
481 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix()
482  : matrix_() // The adapted sparse matrix
483 {
484  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
485 }
487 //*************************************************************************************************
488 
489 
490 //*************************************************************************************************
498 template< typename MT // Type of the adapted sparse matrix
499  , bool SO > // Storage order of the adapted sparse matrix
500 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n )
501  : matrix_( n, n, n ) // The adapted sparse matrix
502 {
504 
505  for( size_t i=0UL; i<n; ++i ) {
506  matrix_.append( i, i, ElementType(1) );
507  matrix_.finalize( i );
508  }
509 
510  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
511 }
513 //*************************************************************************************************
514 
515 
516 //*************************************************************************************************
526 template< typename MT // Type of the adapted sparse matrix
527  , bool SO > // Storage order of the adapted sparse matrix
528 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n, size_t nonzeros )
529  : matrix_( n, n, max( nonzeros, n ) ) // The adapted sparse matrix
530 {
532 
533  for( size_t i=0UL; i<n; ++i ) {
534  matrix_.append( i, i, ElementType(1) );
535  matrix_.finalize( i );
536  }
537 
538  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
539 }
541 //*************************************************************************************************
542 
543 
544 //*************************************************************************************************
558 template< typename MT // Type of the adapted sparse matrix
559  , bool SO > // Storage order of the adapted sparse matrix
560 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n, const std::vector<size_t>& nonzeros )
561  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
562 {
564 
565  for( size_t i=0UL; i<n; ++i )
566  {
567  if( nonzeros[i] == 0UL ) {
568  BLAZE_THROW_INVALID_ARGUMENT( "Invalid capacity specification" );
569  }
570 
571  matrix_.append( i, i, ElementType(1) );
572  matrix_.finalize( i );
573  }
574 
575  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
576 }
578 //*************************************************************************************************
579 
580 
581 //*************************************************************************************************
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( const UniLowerMatrix& m )
590  : matrix_( m.matrix_ ) // The adapted sparse matrix
591 {
592  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
593  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
594 }
596 //*************************************************************************************************
597 
598 
599 //*************************************************************************************************
605 template< typename MT // Type of the adapted sparse matrix
606  , bool SO > // Storage order of the adapted sparse matrix
607 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( UniLowerMatrix&& m ) noexcept
608  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
609 {
610  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
611  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
612 }
614 //*************************************************************************************************
615 
616 
617 //*************************************************************************************************
627 template< typename MT // Type of the adapted sparse matrix
628  , bool SO > // Storage order of the adapted sparse matrix
629 template< typename MT2 // Type of the foreign matrix
630  , bool SO2 > // Storage order of the foreign matrix
631 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( const Matrix<MT2,SO2>& m )
632  : matrix_( ~m ) // The adapted sparse matrix
633 {
634  if( !IsUniLower<MT2>::value && !isUniLower( matrix_ ) ) {
635  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
636  }
637 
638  if( !IsUniLower<MT2>::value )
639  resetUpper();
640 
641  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
642  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
643 }
645 //*************************************************************************************************
646 
647 
648 
649 
650 //=================================================================================================
651 //
652 // DATA ACCESS FUNCTIONS
653 //
654 //=================================================================================================
655 
656 //*************************************************************************************************
672 template< typename MT // Type of the adapted sparse matrix
673  , bool SO > // Storage order of the adapted sparse matrix
675  UniLowerMatrix<MT,SO,false>::operator()( size_t i, size_t j )
676 {
677  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
678  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
679 
680  return Reference( matrix_, i, j );
681 }
683 //*************************************************************************************************
684 
685 
686 //*************************************************************************************************
702 template< typename MT // Type of the adapted sparse matrix
703  , bool SO > // Storage order of the adapted sparse matrix
705  UniLowerMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
706 {
707  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
708  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
709 
710  return matrix_(i,j);
711 }
713 //*************************************************************************************************
714 
715 
716 //*************************************************************************************************
733 template< typename MT // Type of the adapted sparse matrix
734  , bool SO > // Storage order of the adapted sparse matrix
736  UniLowerMatrix<MT,SO,false>::at( size_t i, size_t j )
737 {
738  if( i >= rows() ) {
739  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
740  }
741  if( j >= columns() ) {
742  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
743  }
744  return (*this)(i,j);
745 }
747 //*************************************************************************************************
748 
749 
750 //*************************************************************************************************
767 template< typename MT // Type of the adapted sparse matrix
768  , bool SO > // Storage order of the adapted sparse matrix
770  UniLowerMatrix<MT,SO,false>::at( size_t i, size_t j ) const
771 {
772  if( i >= rows() ) {
773  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
774  }
775  if( j >= columns() ) {
776  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
777  }
778  return (*this)(i,j);
779 }
781 //*************************************************************************************************
782 
783 
784 //*************************************************************************************************
796 template< typename MT // Type of the adapted sparse matrix
797  , bool SO > // Storage order of the adapted sparse matrix
800 {
801  return Iterator( matrix_.begin(i), i );
802 }
804 //*************************************************************************************************
805 
806 
807 //*************************************************************************************************
819 template< typename MT // Type of the adapted sparse matrix
820  , bool SO > // Storage order of the adapted sparse matrix
822  UniLowerMatrix<MT,SO,false>::begin( size_t i ) const
823 {
824  return matrix_.begin(i);
825 }
827 //*************************************************************************************************
828 
829 
830 //*************************************************************************************************
842 template< typename MT // Type of the adapted sparse matrix
843  , bool SO > // Storage order of the adapted sparse matrix
845  UniLowerMatrix<MT,SO,false>::cbegin( size_t i ) const
846 {
847  return matrix_.cbegin(i);
848 }
850 //*************************************************************************************************
851 
852 
853 //*************************************************************************************************
865 template< typename MT // Type of the adapted sparse matrix
866  , bool SO > // Storage order of the adapted sparse matrix
869 {
870  return Iterator( matrix_.end(i), i );
871 }
873 //*************************************************************************************************
874 
875 
876 //*************************************************************************************************
888 template< typename MT // Type of the adapted sparse matrix
889  , bool SO > // Storage order of the adapted sparse matrix
891  UniLowerMatrix<MT,SO,false>::end( size_t i ) const
892 {
893  return matrix_.end(i);
894 }
896 //*************************************************************************************************
897 
898 
899 //*************************************************************************************************
911 template< typename MT // Type of the adapted sparse matrix
912  , bool SO > // Storage order of the adapted sparse matrix
914  UniLowerMatrix<MT,SO,false>::cend( size_t i ) const
915 {
916  return matrix_.cend(i);
917 }
919 //*************************************************************************************************
920 
921 
922 
923 
924 //=================================================================================================
925 //
926 // ASSIGNMENT OPERATORS
927 //
928 //=================================================================================================
929 
930 //*************************************************************************************************
940 template< typename MT // Type of the adapted sparse matrix
941  , bool SO > // Storage order of the adapted sparse matrix
942 inline UniLowerMatrix<MT,SO,false>&
943  UniLowerMatrix<MT,SO,false>::operator=( const UniLowerMatrix& rhs )
944 {
945  matrix_ = rhs.matrix_;
946 
947  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
948  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
949 
950  return *this;
951 }
953 //*************************************************************************************************
954 
955 
956 //*************************************************************************************************
963 template< typename MT // Type of the adapted sparse matrix
964  , bool SO > // Storage order of the adapted sparse matrix
965 inline UniLowerMatrix<MT,SO,false>&
966  UniLowerMatrix<MT,SO,false>::operator=( UniLowerMatrix&& rhs ) noexcept
967 {
968  matrix_ = std::move( rhs.matrix_ );
969 
970  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
971  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
972 
973  return *this;
974 }
976 //*************************************************************************************************
977 
978 
979 //*************************************************************************************************
992 template< typename MT // Type of the adapted sparse matrix
993  , bool SO > // Storage order of the adapted sparse matrix
994 template< typename MT2 // Type of the right-hand side matrix
995  , bool SO2 > // Storage order of the right-hand side matrix
996 inline DisableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
997  UniLowerMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
998 {
999  if( IsStrictlyTriangular<MT2>::value || ( !IsUniLower<MT2>::value && !isUniLower( ~rhs ) ) ) {
1000  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1001  }
1002 
1003  matrix_ = ~rhs;
1004 
1005  if( !IsUniLower<MT2>::value )
1006  resetUpper();
1007 
1008  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1009  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1010 
1011  return *this;
1012 }
1014 //*************************************************************************************************
1015 
1016 
1017 //*************************************************************************************************
1030 template< typename MT // Type of the adapted sparse matrix
1031  , bool SO > // Storage order of the adapted sparse matrix
1032 template< typename MT2 // Type of the right-hand side matrix
1033  , bool SO2 > // Storage order of the right-hand side matrix
1034 inline EnableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1035  UniLowerMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
1036 {
1037  if( IsStrictlyTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1038  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1039  }
1040 
1041  if( IsUniLower<MT2>::value ) {
1042  matrix_ = ~rhs;
1043  }
1044  else {
1045  MT tmp( ~rhs );
1046 
1047  if( !isUniLower( tmp ) ) {
1048  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1049  }
1050 
1051  matrix_ = std::move( tmp );
1052  }
1053 
1054  if( !IsUniLower<MT2>::value )
1055  resetUpper();
1056 
1057  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1058  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1059 
1060  return *this;
1061 }
1063 //*************************************************************************************************
1064 
1065 
1066 //*************************************************************************************************
1079 template< typename MT // Type of the adapted sparse matrix
1080  , bool SO > // Storage order of the adapted sparse matrix
1081 template< typename MT2 // Type of the right-hand side matrix
1082  , bool SO2 > // Storage order of the right-hand side matrix
1083 inline DisableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1084  UniLowerMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1085 {
1086  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1087  ( !IsStrictlyLower<MT2>::value && !isStrictlyLower( ~rhs ) ) ) {
1088  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1089  }
1090 
1091  matrix_ += ~rhs;
1092 
1093  if( !IsStrictlyLower<MT2>::value )
1094  resetUpper();
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 EnableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1123  UniLowerMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1124 {
1125  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1126  ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1127  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1128  }
1129 
1130  if( IsStrictlyLower<MT2>::value ) {
1131  matrix_ += ~rhs;
1132  }
1133  else {
1134  const ResultType_<MT2> tmp( ~rhs );
1135 
1136  if( !isStrictlyLower( tmp ) ) {
1137  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1138  }
1139 
1140  matrix_ += tmp;
1141  }
1142 
1143  if( !IsStrictlyLower<MT2>::value )
1144  resetUpper();
1145 
1146  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1147  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1148 
1149  return *this;
1150 }
1152 //*************************************************************************************************
1153 
1154 
1155 //*************************************************************************************************
1168 template< typename MT // Type of the adapted sparse matrix
1169  , bool SO > // Storage order of the adapted sparse matrix
1170 template< typename MT2 // Type of the right-hand side matrix
1171  , bool SO2 > // Storage order of the right-hand side matrix
1172 inline DisableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1173  UniLowerMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1174 {
1175  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1176  ( !IsStrictlyLower<MT2>::value && !isStrictlyLower( ~rhs ) ) ) {
1177  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1178  }
1179 
1180  matrix_ -= ~rhs;
1181 
1182  if( !IsStrictlyLower<MT2>::value )
1183  resetUpper();
1184 
1185  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1186  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1187 
1188  return *this;
1189 }
1191 //*************************************************************************************************
1192 
1193 
1194 //*************************************************************************************************
1207 template< typename MT // Type of the adapted sparse matrix
1208  , bool SO > // Storage order of the adapted sparse matrix
1209 template< typename MT2 // Type of the right-hand side matrix
1210  , bool SO2 > // Storage order of the right-hand side matrix
1211 inline EnableIf_< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >
1212  UniLowerMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1213 {
1214  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1215  ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1216  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1217  }
1218 
1219  if( IsStrictlyLower<MT2>::value ) {
1220  matrix_ -= ~rhs;
1221  }
1222  else {
1223  const ResultType_<MT2> tmp( ~rhs );
1224 
1225  if( !isStrictlyLower( tmp ) ) {
1226  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1227  }
1228 
1229  matrix_ -= tmp;
1230  }
1231 
1232  if( !IsStrictlyLower<MT2>::value )
1233  resetUpper();
1234 
1235  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1236  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1237 
1238  return *this;
1239 }
1241 //*************************************************************************************************
1242 
1243 
1244 //*************************************************************************************************
1256 template< typename MT // Type of the adapted sparse matrix
1257  , bool SO > // Storage order of the adapted sparse matrix
1258 template< typename MT2 // Type of the right-hand side matrix
1259  , bool SO2 > // Storage order of the right-hand side matrix
1260 inline UniLowerMatrix<MT,SO,false>&
1261  UniLowerMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1262 {
1263  if( matrix_.rows() != (~rhs).columns() ) {
1264  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1265  }
1266 
1267  MT tmp( matrix_ * ~rhs );
1268 
1269  if( !isUniLower( tmp ) ) {
1270  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1271  }
1272 
1273  matrix_ = std::move( tmp );
1274 
1275  if( !IsUniLower<MT2>::value )
1276  resetUpper();
1277 
1278  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1279  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1280 
1281  return *this;
1282 }
1284 //*************************************************************************************************
1285 
1286 
1287 
1288 
1289 //=================================================================================================
1290 //
1291 // UTILITY FUNCTIONS
1292 //
1293 //=================================================================================================
1294 
1295 //*************************************************************************************************
1301 template< typename MT // Type of the adapted sparse matrix
1302  , bool SO > // Storage order of the adapted sparse matrix
1303 inline size_t UniLowerMatrix<MT,SO,false>::rows() const noexcept
1304 {
1305  return matrix_.rows();
1306 }
1308 //*************************************************************************************************
1309 
1310 
1311 //*************************************************************************************************
1317 template< typename MT // Type of the adapted sparse matrix
1318  , bool SO > // Storage order of the adapted sparse matrix
1319 inline size_t UniLowerMatrix<MT,SO,false>::columns() const noexcept
1320 {
1321  return matrix_.columns();
1322 }
1324 //*************************************************************************************************
1325 
1326 
1327 //*************************************************************************************************
1333 template< typename MT // Type of the adapted sparse matrix
1334  , bool SO > // Storage order of the adapted sparse matrix
1335 inline size_t UniLowerMatrix<MT,SO,false>::capacity() const noexcept
1336 {
1337  return matrix_.capacity();
1338 }
1340 //*************************************************************************************************
1341 
1342 
1343 //*************************************************************************************************
1355 template< typename MT // Type of the adapted sparse matrix
1356  , bool SO > // Storage order of the adapted sparse matrix
1357 inline size_t UniLowerMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1358 {
1359  return matrix_.capacity(i);
1360 }
1362 //*************************************************************************************************
1363 
1364 
1365 //*************************************************************************************************
1371 template< typename MT // Type of the adapted sparse matrix
1372  , bool SO > // Storage order of the adapted sparse matrix
1373 inline size_t UniLowerMatrix<MT,SO,false>::nonZeros() const
1374 {
1375  return matrix_.nonZeros();
1376 }
1378 //*************************************************************************************************
1379 
1380 
1381 //*************************************************************************************************
1393 template< typename MT // Type of the adapted sparse matrix
1394  , bool SO > // Storage order of the adapted sparse matrix
1395 inline size_t UniLowerMatrix<MT,SO,false>::nonZeros( size_t i ) const
1396 {
1397  return matrix_.nonZeros(i);
1398 }
1400 //*************************************************************************************************
1401 
1402 
1403 //*************************************************************************************************
1409 template< typename MT // Type of the adapted sparse matrix
1410  , bool SO > // Storage order of the adapted sparse matrix
1412 {
1413  if( SO ) {
1414  for( size_t j=0UL; j<columns(); ++j ) {
1415  matrix_.erase( j, matrix_.lowerBound(j+1UL,j), matrix_.end(j) );
1416  }
1417  }
1418  else {
1419  for( size_t i=1UL; i<rows(); ++i ) {
1420  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1421  }
1422  }
1423 }
1425 //*************************************************************************************************
1426 
1427 
1428 //*************************************************************************************************
1441 template< typename MT // Type of the adapted sparse matrix
1442  , bool SO > // Storage order of the adapted sparse matrix
1443 inline void UniLowerMatrix<MT,SO,false>::reset( size_t i )
1444 {
1445  if( SO ) {
1446  matrix_.erase( i, matrix_.lowerBound(i+1UL,i), matrix_.end(i) );
1447  }
1448  else {
1449  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1450  }
1451 }
1453 //*************************************************************************************************
1454 
1455 
1456 //*************************************************************************************************
1464 template< typename MT // Type of the adapted sparse matrix
1465  , bool SO > // Storage order of the adapted sparse matrix
1467 {
1468  using blaze::clear;
1469 
1470  if( IsResizable<MT>::value ) {
1471  clear( matrix_ );
1472  }
1473  else {
1474  reset();
1475  }
1476 }
1478 //*************************************************************************************************
1479 
1480 
1481 //*************************************************************************************************
1497 template< typename MT // Type of the adapted sparse matrix
1498  , bool SO > // Storage order of the adapted sparse matrix
1500  UniLowerMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1501 {
1502  if( i <= j ) {
1503  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1504  }
1505 
1506  return Iterator( matrix_.set( i, j, value ), ( SO ? j : i ) );
1507 }
1509 //*************************************************************************************************
1510 
1511 
1512 //*************************************************************************************************
1529 template< typename MT // Type of the adapted sparse matrix
1530  , bool SO > // Storage order of the adapted sparse matrix
1532  UniLowerMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1533 {
1534  if( i <= j ) {
1535  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1536  }
1537 
1538  return Iterator( matrix_.insert( i, j, value ), ( SO ? j : i ) );
1539 }
1541 //*************************************************************************************************
1542 
1543 
1544 //*************************************************************************************************
1556 template< typename MT // Type of the adapted sparse matrix
1557  , bool SO > // Storage order of the adapted sparse matrix
1558 inline void UniLowerMatrix<MT,SO,false>::erase( size_t i, size_t j )
1559 {
1560  if( i == j ) {
1561  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
1562  }
1563 
1564  matrix_.erase( i, j );
1565 }
1567 //*************************************************************************************************
1568 
1569 
1570 //*************************************************************************************************
1584 template< typename MT // Type of the adapted sparse matrix
1585  , bool SO > // Storage order of the adapted sparse matrix
1587  UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1588 {
1589  if( pos != matrix_.end(i) && pos->index() == i ) {
1590  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
1591  }
1592 
1593  return Iterator( matrix_.erase( i, pos.base() ), i );
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
1617  UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1618 {
1619  for( Iterator element=first; element!=last; ++element ) {
1620  if( element->index() == i ) {
1621  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
1622  }
1623  }
1624 
1625  return Iterator( matrix_.erase( i, first.base(), last.base() ), i );
1626 }
1628 //*************************************************************************************************
1629 
1630 
1631 //*************************************************************************************************
1646 template< typename MT // Type of the adapted sparse matrix
1647  , bool SO > // Storage order of the adapted sparse matrix
1648 void UniLowerMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1649 {
1651 
1652  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1653 
1654  const size_t oldsize( matrix_.rows() );
1655 
1656  matrix_.resize( n, n, preserve );
1657 
1658  if( n > oldsize ) {
1659  for( size_t i=oldsize; i<n; ++i )
1660  matrix_.insert( i, i, ElementType(1) );
1661  }
1662 }
1664 //*************************************************************************************************
1665 
1666 
1667 //*************************************************************************************************
1678 template< typename MT // Type of the adapted sparse matrix
1679  , bool SO > // Storage order of the adapted sparse matrix
1680 inline void UniLowerMatrix<MT,SO,false>::reserve( size_t nonzeros )
1681 {
1682  matrix_.reserve( nonzeros );
1683 }
1685 //*************************************************************************************************
1686 
1687 
1688 //*************************************************************************************************
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>::reserve( size_t i, size_t nonzeros )
1705 {
1706  matrix_.reserve( i, nonzeros );
1707 }
1709 //*************************************************************************************************
1710 
1711 
1712 //*************************************************************************************************
1723 template< typename MT // Type of the adapted sparse matrix
1724  , bool SO > // Storage order of the adapted sparse matrix
1725 inline void UniLowerMatrix<MT,SO,false>::trim()
1726 {
1727  matrix_.trim();
1728 }
1730 //*************************************************************************************************
1731 
1732 
1733 //*************************************************************************************************
1745 template< typename MT // Type of the adapted sparse matrix
1746  , bool SO > // Storage order of the adapted sparse matrix
1747 inline void UniLowerMatrix<MT,SO,false>::trim( size_t i )
1748 {
1749  matrix_.trim( i );
1750 }
1752 //*************************************************************************************************
1753 
1754 
1755 //*************************************************************************************************
1762 template< typename MT // Type of the adapted sparse matrix
1763  , bool SO > // Storage order of the adapted sparse matrix
1764 inline void UniLowerMatrix<MT,SO,false>::swap( UniLowerMatrix& m ) noexcept
1765 {
1766  using std::swap;
1767 
1768  swap( matrix_, m.matrix_ );
1769 }
1771 //*************************************************************************************************
1772 
1773 
1774 //*************************************************************************************************
1785 template< typename MT // Type of the adapted dense matrix
1786  , bool SO > // Storage order of the adapted dense matrix
1787 inline constexpr size_t UniLowerMatrix<MT,SO,false>::maxNonZeros() noexcept
1788 {
1790 
1791  return maxNonZeros( Rows<MT>::value );
1792 }
1794 //*************************************************************************************************
1795 
1796 
1797 //*************************************************************************************************
1807 template< typename MT // Type of the adapted dense matrix
1808  , bool SO > // Storage order of the adapted dense matrix
1809 inline constexpr size_t UniLowerMatrix<MT,SO,false>::maxNonZeros( size_t n ) noexcept
1810 {
1811  return ( ( n + 1UL ) * n ) / 2UL;
1812 }
1814 //*************************************************************************************************
1815 
1816 
1817 //*************************************************************************************************
1823 template< typename MT // Type of the adapted dense matrix
1824  , bool SO > // Storage order of the adapted dense matrix
1825 inline void UniLowerMatrix<MT,SO,false>::resetUpper()
1826 {
1827  if( SO ) {
1828  for( size_t j=1UL; j<columns(); ++j )
1829  matrix_.erase( j, matrix_.begin( j ), matrix_.lowerBound( j, j ) );
1830  }
1831  else {
1832  for( size_t i=0UL; i<rows(); ++i )
1833  matrix_.erase( i, matrix_.upperBound( i, i ), matrix_.end( i ) );
1834  }
1835 }
1837 //*************************************************************************************************
1838 
1839 
1840 
1841 
1842 //=================================================================================================
1843 //
1844 // LOOKUP FUNCTIONS
1845 //
1846 //=================================================================================================
1847 
1848 //*************************************************************************************************
1864 template< typename MT // Type of the adapted sparse matrix
1865  , bool SO > // Storage order of the adapted sparse matrix
1867  UniLowerMatrix<MT,SO,false>::find( size_t i, size_t j )
1868 {
1869  return Iterator( matrix_.find( i, j ), ( SO ? j : i ) );
1870 }
1872 //*************************************************************************************************
1873 
1874 
1875 //*************************************************************************************************
1891 template< typename MT // Type of the adapted sparse matrix
1892  , bool SO > // Storage order of the adapted sparse matrix
1894  UniLowerMatrix<MT,SO,false>::find( size_t i, size_t j ) const
1895 {
1896  return matrix_.find( i, j );
1897 }
1899 //*************************************************************************************************
1900 
1901 
1902 //*************************************************************************************************
1918 template< typename MT // Type of the adapted sparse matrix
1919  , bool SO > // Storage order of the adapted sparse matrix
1921  UniLowerMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
1922 {
1923  return Iterator( matrix_.lowerBound( i, j ), ( SO ? j : i ) );
1924 }
1926 //*************************************************************************************************
1927 
1928 
1929 //*************************************************************************************************
1945 template< typename MT // Type of the adapted sparse matrix
1946  , bool SO > // Storage order of the adapted sparse matrix
1948  UniLowerMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
1949 {
1950  return matrix_.lowerBound( i, j );
1951 }
1953 //*************************************************************************************************
1954 
1955 
1956 //*************************************************************************************************
1972 template< typename MT // Type of the adapted sparse matrix
1973  , bool SO > // Storage order of the adapted sparse matrix
1975  UniLowerMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
1976 {
1977  return Iterator( matrix_.upperBound( i, j ), ( SO ? j : i ) );
1978 }
1980 //*************************************************************************************************
1981 
1982 
1983 //*************************************************************************************************
1999 template< typename MT // Type of the adapted sparse matrix
2000  , bool SO > // Storage order of the adapted sparse matrix
2002  UniLowerMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
2003 {
2004  return matrix_.upperBound( i, j );
2005 }
2007 //*************************************************************************************************
2008 
2009 
2010 
2011 
2012 //=================================================================================================
2013 //
2014 // LOW-LEVEL UTILITY FUNCTIONS
2015 //
2016 //=================================================================================================
2017 
2018 //*************************************************************************************************
2068 template< typename MT // Type of the adapted sparse matrix
2069  , bool SO > // Storage order of the adapted sparse matrix
2070 inline void UniLowerMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
2071 {
2072  if( i <= j ) {
2073  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
2074  }
2075 
2076  if( !check || !isDefault( value ) )
2077  matrix_.insert( i, j, value );
2078 }
2080 //*************************************************************************************************
2081 
2082 
2083 //*************************************************************************************************
2097 template< typename MT // Type of the adapted sparse matrix
2098  , bool SO > // Storage order of the adapted sparse matrix
2099 inline void UniLowerMatrix<MT,SO,false>::finalize( size_t i )
2100 {
2101  matrix_.trim( i );
2102 }
2104 //*************************************************************************************************
2105 
2106 
2107 
2108 
2109 //=================================================================================================
2110 //
2111 // DEBUGGING FUNCTIONS
2112 //
2113 //=================================================================================================
2114 
2115 //*************************************************************************************************
2125 template< typename MT // Type of the adapted sparse matrix
2126  , bool SO > // Storage order of the adapted sparse matrix
2127 inline bool UniLowerMatrix<MT,SO,false>::isIntact() const noexcept
2128 {
2129  using blaze::isIntact;
2130 
2131  return ( isIntact( matrix_ ) && isUniLower( matrix_ ) );
2132 }
2134 //*************************************************************************************************
2135 
2136 
2137 
2138 
2139 //=================================================================================================
2140 //
2141 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2142 //
2143 //=================================================================================================
2144 
2145 //*************************************************************************************************
2156 template< typename MT // Type of the adapted sparse matrix
2157  , bool SO > // Storage order of the adapted sparse matrix
2158 template< typename Other > // Data type of the foreign expression
2159 inline bool UniLowerMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2160 {
2161  return matrix_.canAlias( alias );
2162 }
2164 //*************************************************************************************************
2165 
2166 
2167 //*************************************************************************************************
2178 template< typename MT // Type of the adapted sparse matrix
2179  , bool SO > // Storage order of the adapted sparse matrix
2180 template< typename Other > // Data type of the foreign expression
2181 inline bool UniLowerMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2182 {
2183  return matrix_.isAliased( alias );
2184 }
2186 //*************************************************************************************************
2187 
2188 
2189 //*************************************************************************************************
2200 template< typename MT // Type of the adapted sparse matrix
2201  , bool SO > // Storage order of the adapted sparse matrix
2202 inline bool UniLowerMatrix<MT,SO,false>::canSMPAssign() const noexcept
2203 {
2204  return matrix_.canSMPAssign();
2205 }
2207 //*************************************************************************************************
2208 
2209 } // namespace blaze
2210 
2211 #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.
Header file for mathematical functions.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the Rows type trait.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:7800
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:346
Header file for basic type definitions.
bool isStrictlyLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly lower triangular matrix.
Definition: DenseMatrix.h:1192
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:63
Constraint on the data type.
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:188
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2643
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5077
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2636
#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:384
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:731
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Constraint on the data type.
STL namespace.
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:1716
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2639
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:298
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:232
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.
bool isDefault(const CompressedMatrix< Type, SO > &m)
Returns whether the given compressed matrix is in default state.
Definition: CompressedMatrix.h:5104
Header file for the DisableIf class template.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5148
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5131
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the Columns type trait.
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:330
Header file for the IsUniTriangular type trait.
Header file for the IsStrictlyTriangular type trait.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2640
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
bool isUniLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower unitriangular matrix.
Definition: DenseMatrix.h:1113
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:538
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:254
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2641
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
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:553
Header file for the UniLowerElement class.
Header file for the UniLowerProxy class.
Header file for the UniLowerValue class.
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
Header file for all adaptor forward declarations.
#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
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2642
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
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:258
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_RESIZABLE(T)
Constraint on the data type.In case the given data type T is resizable, i.e. has a 'resize' member fu...
Definition: Resizable.h:81
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:314
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2637
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a 'res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2638
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
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:609
Header file for the IsResizable type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61