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 <algorithm>
44 #include <vector>
59 #include <blaze/math/Functions.h>
60 #include <blaze/math/shims/Clear.h>
62 #include <blaze/math/shims/Move.h>
74 #include <blaze/util/Assert.h>
80 #include <blaze/util/DisableIf.h>
81 #include <blaze/util/EnableIf.h>
82 #include <blaze/util/Exception.h>
85 #include <blaze/util/Types.h>
86 
87 
88 namespace blaze {
89 
90 //=================================================================================================
91 //
92 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
93 //
94 //=================================================================================================
95 
96 //*************************************************************************************************
104 template< typename MT // Type of the adapted sparse matrix
105  , bool SO > // Storage order of the adapted sparse matrix
106 class UniLowerMatrix<MT,SO,false>
107  : public SparseMatrix< UniLowerMatrix<MT,SO,false>, SO >
108 {
109  private:
110  //**Type definitions****************************************************************************
111  typedef typename MT::OppositeType OT;
112  typedef typename MT::TransposeType TT;
113  typedef typename MT::ElementType ET;
114  //**********************************************************************************************
115 
116  public:
117  //**Type definitions****************************************************************************
118  typedef UniLowerMatrix<MT,SO,false> This;
119  typedef This ResultType;
120  typedef UniLowerMatrix<OT,!SO,false> OppositeType;
121  typedef UniUpperMatrix<TT,!SO,false> TransposeType;
122  typedef ET ElementType;
123  typedef typename MT::ReturnType ReturnType;
124  typedef const This& CompositeType;
125  typedef UniLowerProxy<MT> Reference;
126  typedef typename MT::ConstReference ConstReference;
127  typedef typename MT::ConstIterator ConstIterator;
128  //**********************************************************************************************
129 
130  //**Rebind struct definition********************************************************************
133  template< typename ET > // Data type of the other matrix
134  struct Rebind {
136  typedef UniLowerMatrix< typename MT::template Rebind<ET>::Other > Other;
137  };
138  //**********************************************************************************************
139 
140  //**Iterator class definition*******************************************************************
143  class Iterator
144  {
145  public:
146  //**Type definitions*************************************************************************
147  typedef typename MT::Iterator IteratorType;
148 
149  typedef std::forward_iterator_tag IteratorCategory;
150  typedef UniLowerElement<MT> ValueType;
151  typedef ValueType PointerType;
152  typedef ValueType ReferenceType;
153  typedef ptrdiff_t DifferenceType;
154 
155  // STL iterator requirements
156  typedef IteratorCategory iterator_category;
157  typedef ValueType value_type;
158  typedef PointerType pointer;
159  typedef ReferenceType reference;
160  typedef DifferenceType difference_type;
161  //*******************************************************************************************
162 
163  //**Default constructor**********************************************************************
166  inline Iterator()
167  : pos_ ( ) // Iterator to the current lower unitriangular matrix element
168  , index_ ( 0UL ) // The row/column index of the iterator
169  {}
170  //*******************************************************************************************
171 
172  //**Constructor******************************************************************************
178  inline Iterator( IteratorType pos, size_t index )
179  : pos_ ( pos ) // Iterator to the current lower unitriangular matrix element
180  , index_( index ) // The row/column index of the iterator
181  {}
182  //*******************************************************************************************
183 
184  //**Prefix increment operator****************************************************************
189  inline Iterator& operator++() {
190  ++pos_;
191  return *this;
192  }
193  //*******************************************************************************************
194 
195  //**Postfix increment operator***************************************************************
200  inline const Iterator operator++( int ) {
201  const Iterator tmp( *this );
202  ++(*this);
203  return tmp;
204  }
205  //*******************************************************************************************
206 
207  //**Element access operator******************************************************************
212  inline ReferenceType operator*() const {
213  return ReferenceType( pos_, pos_->index() == index_ );
214  }
215  //*******************************************************************************************
216 
217  //**Element access operator******************************************************************
222  inline PointerType operator->() const {
223  return PointerType( pos_, pos_->index() == index_ );
224  }
225  //*******************************************************************************************
226 
227  //**Conversion operator**********************************************************************
232  inline operator ConstIterator() const {
233  return pos_;
234  }
235  //*******************************************************************************************
236 
237  //**Equality operator************************************************************************
243  inline bool operator==( const Iterator& rhs ) const {
244  return pos_ == rhs.pos_;
245  }
246  //*******************************************************************************************
247 
248  //**Inequality operator**********************************************************************
254  inline bool operator!=( const Iterator& rhs ) const {
255  return !( *this == rhs );
256  }
257  //*******************************************************************************************
258 
259  //**Subtraction operator*********************************************************************
265  inline DifferenceType operator-( const Iterator& rhs ) const {
266  return pos_ - rhs.pos_;
267  }
268  //*******************************************************************************************
269 
270  //**Base function****************************************************************************
275  inline IteratorType base() const {
276  return pos_;
277  }
278  //*******************************************************************************************
279 
280  private:
281  //**Member variables*************************************************************************
282  IteratorType pos_;
283  size_t index_;
284  //*******************************************************************************************
285  };
286  //**********************************************************************************************
287 
288  //**Compilation flags***************************************************************************
290  enum { smpAssignable = 0 };
291  //**********************************************************************************************
292 
293  //**Constructors********************************************************************************
296  explicit inline UniLowerMatrix();
297  explicit inline UniLowerMatrix( size_t n );
298  explicit inline UniLowerMatrix( size_t n, size_t nonzeros );
299  explicit inline UniLowerMatrix( size_t n, const std::vector<size_t>& nonzeros );
300 
301  inline UniLowerMatrix( const UniLowerMatrix& m );
302  template< typename MT2, bool SO2 > inline UniLowerMatrix( const Matrix<MT2,SO2>& m );
304  //**********************************************************************************************
305 
306  //**Destructor**********************************************************************************
307  // No explicitly declared destructor.
308  //**********************************************************************************************
309 
310  //**Data access functions***********************************************************************
313  inline Reference operator()( size_t i, size_t j );
314  inline ConstReference operator()( size_t i, size_t j ) const;
315  inline Reference at( size_t i, size_t j );
316  inline ConstReference at( size_t i, size_t j ) const;
317  inline Iterator begin ( size_t i );
318  inline ConstIterator begin ( size_t i ) const;
319  inline ConstIterator cbegin( size_t i ) const;
320  inline Iterator end ( size_t i );
321  inline ConstIterator end ( size_t i ) const;
322  inline ConstIterator cend ( size_t i ) const;
324  //**********************************************************************************************
325 
326  //**Assignment operators************************************************************************
329  inline UniLowerMatrix& operator=( const UniLowerMatrix& rhs );
330 
331  template< typename MT2, bool SO2 >
332  inline typename DisableIf< IsComputation<MT2>, UniLowerMatrix& >::Type
333  operator=( const Matrix<MT2,SO2>& rhs );
334 
335  template< typename MT2, bool SO2 >
336  inline typename EnableIf< IsComputation<MT2>, UniLowerMatrix& >::Type
337  operator=( const Matrix<MT2,SO2>& rhs );
338 
339  template< typename MT2, bool SO2 >
340  inline typename DisableIf< IsComputation<MT2>, UniLowerMatrix& >::Type
341  operator+=( const Matrix<MT2,SO2>& rhs );
342 
343  template< typename MT2, bool SO2 >
344  inline typename EnableIf< IsComputation<MT2>, UniLowerMatrix& >::Type
345  operator+=( const Matrix<MT2,SO2>& rhs );
346 
347  template< typename MT2, bool SO2 >
348  inline typename DisableIf< IsComputation<MT2>, UniLowerMatrix& >::Type
349  operator-=( const Matrix<MT2,SO2>& rhs );
350 
351  template< typename MT2, bool SO2 >
352  inline typename EnableIf< IsComputation<MT2>, UniLowerMatrix& >::Type
353  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;
364  inline size_t columns() const;
365  inline size_t capacity() const;
366  inline size_t capacity( size_t i ) const;
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 ) /* throw() */;
383 
384  static inline size_t maxNonZeros();
385  static inline size_t maxNonZeros( size_t n );
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;
414  //**********************************************************************************************
415 
416  //**Expression template evaluation functions****************************************************
419  template< typename Other > inline bool canAlias ( const Other* alias ) const;
420  template< typename Other > inline bool isAliased( const Other* alias ) const;
421 
422  inline bool canSMPAssign() const;
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 //*************************************************************************************************
609 template< typename MT // Type of the adapted sparse matrix
610  , bool SO > // Storage order of the adapted sparse matrix
611 template< typename MT2 // Type of the foreign matrix
612  , bool SO2 > // Storage order of the foreign matrix
613 inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( const Matrix<MT2,SO2>& m )
614  : matrix_( ~m ) // The adapted sparse matrix
615 {
616  if( !IsUniLower<MT2>::value && !isUniLower( matrix_ ) ) {
617  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
618  }
619 
620  if( !IsUniLower<MT2>::value )
621  resetUpper();
622 
623  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
624  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
625 }
627 //*************************************************************************************************
628 
629 
630 
631 
632 //=================================================================================================
633 //
634 // DATA ACCESS FUNCTIONS
635 //
636 //=================================================================================================
637 
638 //*************************************************************************************************
654 template< typename MT // Type of the adapted sparse matrix
655  , bool SO > // Storage order of the adapted sparse matrix
657  UniLowerMatrix<MT,SO,false>::operator()( size_t i, size_t j )
658 {
659  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
660  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
661 
662  return Reference( matrix_, i, j );
663 }
665 //*************************************************************************************************
666 
667 
668 //*************************************************************************************************
684 template< typename MT // Type of the adapted sparse matrix
685  , bool SO > // Storage order of the adapted sparse matrix
687  UniLowerMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
688 {
689  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
690  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
691 
692  return matrix_(i,j);
693 }
695 //*************************************************************************************************
696 
697 
698 //*************************************************************************************************
715 template< typename MT // Type of the adapted sparse matrix
716  , bool SO > // Storage order of the adapted sparse matrix
718  UniLowerMatrix<MT,SO,false>::at( size_t i, size_t j )
719 {
720  if( i >= rows() ) {
721  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
722  }
723  if( j >= columns() ) {
724  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
725  }
726  return (*this)(i,j);
727 }
729 //*************************************************************************************************
730 
731 
732 //*************************************************************************************************
749 template< typename MT // Type of the adapted sparse matrix
750  , bool SO > // Storage order of the adapted sparse matrix
752  UniLowerMatrix<MT,SO,false>::at( size_t i, size_t j ) const
753 {
754  if( i >= rows() ) {
755  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
756  }
757  if( j >= columns() ) {
758  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
759  }
760  return (*this)(i,j);
761 }
763 //*************************************************************************************************
764 
765 
766 //*************************************************************************************************
778 template< typename MT // Type of the adapted sparse matrix
779  , bool SO > // Storage order of the adapted sparse matrix
782 {
783  return Iterator( matrix_.begin(i), i );
784 }
786 //*************************************************************************************************
787 
788 
789 //*************************************************************************************************
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>::begin( size_t i ) const
805 {
806  return matrix_.begin(i);
807 }
809 //*************************************************************************************************
810 
811 
812 //*************************************************************************************************
824 template< typename MT // Type of the adapted sparse matrix
825  , bool SO > // Storage order of the adapted sparse matrix
827  UniLowerMatrix<MT,SO,false>::cbegin( size_t i ) const
828 {
829  return matrix_.cbegin(i);
830 }
832 //*************************************************************************************************
833 
834 
835 //*************************************************************************************************
847 template< typename MT // Type of the adapted sparse matrix
848  , bool SO > // Storage order of the adapted sparse matrix
851 {
852  return Iterator( matrix_.end(i), i );
853 }
855 //*************************************************************************************************
856 
857 
858 //*************************************************************************************************
870 template< typename MT // Type of the adapted sparse matrix
871  , bool SO > // Storage order of the adapted sparse matrix
873  UniLowerMatrix<MT,SO,false>::end( size_t i ) const
874 {
875  return matrix_.end(i);
876 }
878 //*************************************************************************************************
879 
880 
881 //*************************************************************************************************
893 template< typename MT // Type of the adapted sparse matrix
894  , bool SO > // Storage order of the adapted sparse matrix
896  UniLowerMatrix<MT,SO,false>::cend( size_t i ) const
897 {
898  return matrix_.cend(i);
899 }
901 //*************************************************************************************************
902 
903 
904 
905 
906 //=================================================================================================
907 //
908 // ASSIGNMENT OPERATORS
909 //
910 //=================================================================================================
911 
912 //*************************************************************************************************
922 template< typename MT // Type of the adapted sparse matrix
923  , bool SO > // Storage order of the adapted sparse matrix
924 inline UniLowerMatrix<MT,SO,false>&
925  UniLowerMatrix<MT,SO,false>::operator=( const UniLowerMatrix& rhs )
926 {
927  matrix_ = rhs.matrix_;
928 
929  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
930  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
931 
932  return *this;
933 }
935 //*************************************************************************************************
936 
937 
938 //*************************************************************************************************
951 template< typename MT // Type of the adapted sparse matrix
952  , bool SO > // Storage order of the adapted sparse matrix
953 template< typename MT2 // Type of the right-hand side matrix
954  , bool SO2 > // Storage order of the right-hand side matrix
955 inline typename DisableIf< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >::Type
956  UniLowerMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
957 {
958  if( IsStrictlyTriangular<MT2>::value || ( !IsUniLower<MT2>::value && !isUniLower( ~rhs ) ) ) {
959  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
960  }
961 
962  matrix_ = ~rhs;
963 
964  if( !IsUniLower<MT2>::value )
965  resetUpper();
966 
967  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
968  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
969 
970  return *this;
971 }
973 //*************************************************************************************************
974 
975 
976 //*************************************************************************************************
989 template< typename MT // Type of the adapted sparse matrix
990  , bool SO > // Storage order of the adapted sparse matrix
991 template< typename MT2 // Type of the right-hand side matrix
992  , bool SO2 > // Storage order of the right-hand side matrix
993 inline typename EnableIf< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >::Type
994  UniLowerMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
995 {
996  if( IsStrictlyTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
997  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
998  }
999 
1000  if( IsUniLower<MT2>::value ) {
1001  matrix_ = ~rhs;
1002  }
1003  else {
1004  MT tmp( ~rhs );
1005 
1006  if( !isUniLower( tmp ) ) {
1007  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1008  }
1009 
1010  move( matrix_, tmp );
1011  }
1012 
1013  if( !IsUniLower<MT2>::value )
1014  resetUpper();
1015 
1016  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1017  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1018 
1019  return *this;
1020 }
1022 //*************************************************************************************************
1023 
1024 
1025 //*************************************************************************************************
1038 template< typename MT // Type of the adapted sparse matrix
1039  , bool SO > // Storage order of the adapted sparse matrix
1040 template< typename MT2 // Type of the right-hand side matrix
1041  , bool SO2 > // Storage order of the right-hand side matrix
1042 inline typename DisableIf< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >::Type
1043  UniLowerMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1044 {
1045  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1046  ( !IsStrictlyLower<MT2>::value && !isStrictlyLower( ~rhs ) ) ) {
1047  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1048  }
1049 
1050  matrix_ += ~rhs;
1051 
1052  if( !IsStrictlyLower<MT2>::value )
1053  resetUpper();
1054 
1055  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1056  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1057 
1058  return *this;
1059 }
1061 //*************************************************************************************************
1062 
1063 
1064 //*************************************************************************************************
1077 template< typename MT // Type of the adapted sparse matrix
1078  , bool SO > // Storage order of the adapted sparse matrix
1079 template< typename MT2 // Type of the right-hand side matrix
1080  , bool SO2 > // Storage order of the right-hand side matrix
1081 inline typename EnableIf< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >::Type
1082  UniLowerMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1083 {
1084  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1085  ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1086  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1087  }
1088 
1089  if( IsStrictlyLower<MT2>::value ) {
1090  matrix_ += ~rhs;
1091  }
1092  else {
1093  typename MT2::ResultType tmp( ~rhs );
1094 
1095  if( !isStrictlyLower( tmp ) ) {
1096  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1097  }
1098 
1099  matrix_ += tmp;
1100  }
1101 
1102  if( !IsStrictlyLower<MT2>::value )
1103  resetUpper();
1104 
1105  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1106  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1107 
1108  return *this;
1109 }
1111 //*************************************************************************************************
1112 
1113 
1114 //*************************************************************************************************
1127 template< typename MT // Type of the adapted sparse matrix
1128  , bool SO > // Storage order of the adapted sparse matrix
1129 template< typename MT2 // Type of the right-hand side matrix
1130  , bool SO2 > // Storage order of the right-hand side matrix
1131 inline typename DisableIf< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >::Type
1132  UniLowerMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1133 {
1134  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1135  ( !IsStrictlyLower<MT2>::value && !isStrictlyLower( ~rhs ) ) ) {
1136  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1137  }
1138 
1139  matrix_ -= ~rhs;
1140 
1141  if( !IsStrictlyLower<MT2>::value )
1142  resetUpper();
1143 
1144  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1145  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1146 
1147  return *this;
1148 }
1150 //*************************************************************************************************
1151 
1152 
1153 //*************************************************************************************************
1166 template< typename MT // Type of the adapted sparse matrix
1167  , bool SO > // Storage order of the adapted sparse matrix
1168 template< typename MT2 // Type of the right-hand side matrix
1169  , bool SO2 > // Storage order of the right-hand side matrix
1170 inline typename EnableIf< IsComputation<MT2>, UniLowerMatrix<MT,SO,false>& >::Type
1171  UniLowerMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1172 {
1173  if( IsUpper<MT2>::value || IsUniTriangular<MT2>::value ||
1174  ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1175  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1176  }
1177 
1178  if( IsStrictlyLower<MT2>::value ) {
1179  matrix_ -= ~rhs;
1180  }
1181  else {
1182  typename MT2::ResultType tmp( ~rhs );
1183 
1184  if( !isStrictlyLower( tmp ) ) {
1185  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1186  }
1187 
1188  matrix_ -= tmp;
1189  }
1190 
1191  if( !IsStrictlyLower<MT2>::value )
1192  resetUpper();
1193 
1194  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1195  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1196 
1197  return *this;
1198 }
1200 //*************************************************************************************************
1201 
1202 
1203 //*************************************************************************************************
1215 template< typename MT // Type of the adapted sparse matrix
1216  , bool SO > // Storage order of the adapted sparse matrix
1217 template< typename MT2 // Type of the right-hand side matrix
1218  , bool SO2 > // Storage order of the right-hand side matrix
1219 inline UniLowerMatrix<MT,SO,false>&
1220  UniLowerMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1221 {
1222  if( matrix_.rows() != (~rhs).columns() ) {
1223  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1224  }
1225 
1226  MT tmp( matrix_ * ~rhs );
1227 
1228  if( !isUniLower( tmp ) ) {
1229  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1230  }
1231 
1232  move( matrix_, tmp );
1233 
1234  if( !IsUniLower<MT2>::value )
1235  resetUpper();
1236 
1237  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1238  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1239 
1240  return *this;
1241 }
1243 //*************************************************************************************************
1244 
1245 
1246 
1247 
1248 //=================================================================================================
1249 //
1250 // UTILITY FUNCTIONS
1251 //
1252 //=================================================================================================
1253 
1254 //*************************************************************************************************
1260 template< typename MT // Type of the adapted sparse matrix
1261  , bool SO > // Storage order of the adapted sparse matrix
1262 inline size_t UniLowerMatrix<MT,SO,false>::rows() const
1263 {
1264  return matrix_.rows();
1265 }
1267 //*************************************************************************************************
1268 
1269 
1270 //*************************************************************************************************
1276 template< typename MT // Type of the adapted sparse matrix
1277  , bool SO > // Storage order of the adapted sparse matrix
1278 inline size_t UniLowerMatrix<MT,SO,false>::columns() const
1279 {
1280  return matrix_.columns();
1281 }
1283 //*************************************************************************************************
1284 
1285 
1286 //*************************************************************************************************
1292 template< typename MT // Type of the adapted sparse matrix
1293  , bool SO > // Storage order of the adapted sparse matrix
1294 inline size_t UniLowerMatrix<MT,SO,false>::capacity() const
1295 {
1296  return matrix_.capacity();
1297 }
1299 //*************************************************************************************************
1300 
1301 
1302 //*************************************************************************************************
1314 template< typename MT // Type of the adapted sparse matrix
1315  , bool SO > // Storage order of the adapted sparse matrix
1316 inline size_t UniLowerMatrix<MT,SO,false>::capacity( size_t i ) const
1317 {
1318  return matrix_.capacity(i);
1319 }
1321 //*************************************************************************************************
1322 
1323 
1324 //*************************************************************************************************
1330 template< typename MT // Type of the adapted sparse matrix
1331  , bool SO > // Storage order of the adapted sparse matrix
1332 inline size_t UniLowerMatrix<MT,SO,false>::nonZeros() const
1333 {
1334  return matrix_.nonZeros();
1335 }
1337 //*************************************************************************************************
1338 
1339 
1340 //*************************************************************************************************
1352 template< typename MT // Type of the adapted sparse matrix
1353  , bool SO > // Storage order of the adapted sparse matrix
1354 inline size_t UniLowerMatrix<MT,SO,false>::nonZeros( size_t i ) const
1355 {
1356  return matrix_.nonZeros(i);
1357 }
1359 //*************************************************************************************************
1360 
1361 
1362 //*************************************************************************************************
1368 template< typename MT // Type of the adapted sparse matrix
1369  , bool SO > // Storage order of the adapted sparse matrix
1371 {
1372  if( SO ) {
1373  for( size_t j=0UL; j<columns(); ++j ) {
1374  matrix_.erase( j, matrix_.lowerBound(j+1UL,j), matrix_.end(j) );
1375  }
1376  }
1377  else {
1378  for( size_t i=1UL; i<rows(); ++i ) {
1379  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1380  }
1381  }
1382 }
1384 //*************************************************************************************************
1385 
1386 
1387 //*************************************************************************************************
1400 template< typename MT // Type of the adapted sparse matrix
1401  , bool SO > // Storage order of the adapted sparse matrix
1402 inline void UniLowerMatrix<MT,SO,false>::reset( size_t i )
1403 {
1404  if( SO ) {
1405  matrix_.erase( i, matrix_.lowerBound(i+1UL,i), matrix_.end(i) );
1406  }
1407  else {
1408  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1409  }
1410 }
1412 //*************************************************************************************************
1413 
1414 
1415 //*************************************************************************************************
1423 template< typename MT // Type of the adapted sparse matrix
1424  , bool SO > // Storage order of the adapted sparse matrix
1426 {
1427  using blaze::clear;
1428 
1429  if( IsResizable<MT>::value ) {
1430  clear( matrix_ );
1431  }
1432  else {
1433  reset();
1434  }
1435 }
1437 //*************************************************************************************************
1438 
1439 
1440 //*************************************************************************************************
1456 template< typename MT // Type of the adapted sparse matrix
1457  , bool SO > // Storage order of the adapted sparse matrix
1459  UniLowerMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1460 {
1461  if( i <= j ) {
1462  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1463  }
1464 
1465  return Iterator( matrix_.set( i, j, value ), ( SO ? j : i ) );
1466 }
1468 //*************************************************************************************************
1469 
1470 
1471 //*************************************************************************************************
1488 template< typename MT // Type of the adapted sparse matrix
1489  , bool SO > // Storage order of the adapted sparse matrix
1491  UniLowerMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1492 {
1493  if( i <= j ) {
1494  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1495  }
1496 
1497  return Iterator( matrix_.insert( i, j, value ), ( SO ? j : i ) );
1498 }
1500 //*************************************************************************************************
1501 
1502 
1503 //*************************************************************************************************
1515 template< typename MT // Type of the adapted sparse matrix
1516  , bool SO > // Storage order of the adapted sparse matrix
1517 inline void UniLowerMatrix<MT,SO,false>::erase( size_t i, size_t j )
1518 {
1519  if( i == j ) {
1520  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
1521  }
1522 
1523  matrix_.erase( i, j );
1524 }
1526 //*************************************************************************************************
1527 
1528 
1529 //*************************************************************************************************
1543 template< typename MT // Type of the adapted sparse matrix
1544  , bool SO > // Storage order of the adapted sparse matrix
1546  UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1547 {
1548  if( pos != matrix_.end(i) && pos->index() == i ) {
1549  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
1550  }
1551 
1552  return Iterator( matrix_.erase( i, pos.base() ), i );
1553 }
1555 //*************************************************************************************************
1556 
1557 
1558 //*************************************************************************************************
1573 template< typename MT // Type of the adapted sparse matrix
1574  , bool SO > // Storage order of the adapted sparse matrix
1576  UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1577 {
1578  for( Iterator element=first; element!=last; ++element ) {
1579  if( element->index() == i ) {
1580  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
1581  }
1582  }
1583 
1584  return Iterator( matrix_.erase( i, first.base(), last.base() ), i );
1585 }
1587 //*************************************************************************************************
1588 
1589 
1590 //*************************************************************************************************
1605 template< typename MT // Type of the adapted sparse matrix
1606  , bool SO > // Storage order of the adapted sparse matrix
1607 void UniLowerMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1608 {
1610 
1611  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1612 
1613  const size_t oldsize( matrix_.rows() );
1614 
1615  matrix_.resize( n, n, preserve );
1616 
1617  if( n > oldsize ) {
1618  for( size_t i=oldsize; i<n; ++i )
1619  matrix_.insert( i, i, ElementType(1) );
1620  }
1621 }
1623 //*************************************************************************************************
1624 
1625 
1626 //*************************************************************************************************
1637 template< typename MT // Type of the adapted sparse matrix
1638  , bool SO > // Storage order of the adapted sparse matrix
1639 inline void UniLowerMatrix<MT,SO,false>::reserve( size_t nonzeros )
1640 {
1641  matrix_.reserve( nonzeros );
1642 }
1644 //*************************************************************************************************
1645 
1646 
1647 //*************************************************************************************************
1661 template< typename MT // Type of the adapted sparse matrix
1662  , bool SO > // Storage order of the adapted sparse matrix
1663 inline void UniLowerMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1664 {
1665  matrix_.reserve( i, nonzeros );
1666 }
1668 //*************************************************************************************************
1669 
1670 
1671 //*************************************************************************************************
1682 template< typename MT // Type of the adapted sparse matrix
1683  , bool SO > // Storage order of the adapted sparse matrix
1684 inline void UniLowerMatrix<MT,SO,false>::trim()
1685 {
1686  matrix_.trim();
1687 }
1689 //*************************************************************************************************
1690 
1691 
1692 //*************************************************************************************************
1704 template< typename MT // Type of the adapted sparse matrix
1705  , bool SO > // Storage order of the adapted sparse matrix
1706 inline void UniLowerMatrix<MT,SO,false>::trim( size_t i )
1707 {
1708  matrix_.trim( i );
1709 }
1711 //*************************************************************************************************
1712 
1713 
1714 //*************************************************************************************************
1722 template< typename MT // Type of the adapted sparse matrix
1723  , bool SO > // Storage order of the adapted sparse matrix
1724 inline void UniLowerMatrix<MT,SO,false>::swap( UniLowerMatrix& m ) /* throw() */
1725 {
1726  using std::swap;
1727 
1728  swap( matrix_, m.matrix_ );
1729 }
1731 //*************************************************************************************************
1732 
1733 
1734 //*************************************************************************************************
1745 template< typename MT // Type of the adapted dense matrix
1746  , bool SO > // Storage order of the adapted dense matrix
1747 inline size_t UniLowerMatrix<MT,SO,false>::maxNonZeros()
1748 {
1750 
1751  return maxNonZeros( Rows<MT>::value );
1752 }
1754 //*************************************************************************************************
1755 
1756 
1757 //*************************************************************************************************
1767 template< typename MT // Type of the adapted dense matrix
1768  , bool SO > // Storage order of the adapted dense matrix
1769 inline size_t UniLowerMatrix<MT,SO,false>::maxNonZeros( size_t n )
1770 {
1771  return ( ( n + 1UL ) * n ) / 2UL;
1772 }
1774 //*************************************************************************************************
1775 
1776 
1777 //*************************************************************************************************
1783 template< typename MT // Type of the adapted dense matrix
1784  , bool SO > // Storage order of the adapted dense matrix
1785 inline void UniLowerMatrix<MT,SO,false>::resetUpper()
1786 {
1787  if( SO ) {
1788  for( size_t j=1UL; j<columns(); ++j )
1789  matrix_.erase( j, matrix_.begin( j ), matrix_.lowerBound( j, j ) );
1790  }
1791  else {
1792  for( size_t i=0UL; i<rows(); ++i )
1793  matrix_.erase( i, matrix_.upperBound( i, i ), matrix_.end( i ) );
1794  }
1795 }
1797 //*************************************************************************************************
1798 
1799 
1800 
1801 
1802 //=================================================================================================
1803 //
1804 // LOOKUP FUNCTIONS
1805 //
1806 //=================================================================================================
1807 
1808 //*************************************************************************************************
1824 template< typename MT // Type of the adapted sparse matrix
1825  , bool SO > // Storage order of the adapted sparse matrix
1827  UniLowerMatrix<MT,SO,false>::find( size_t i, size_t j )
1828 {
1829  return Iterator( matrix_.find( i, j ), ( SO ? j : i ) );
1830 }
1832 //*************************************************************************************************
1833 
1834 
1835 //*************************************************************************************************
1851 template< typename MT // Type of the adapted sparse matrix
1852  , bool SO > // Storage order of the adapted sparse matrix
1854  UniLowerMatrix<MT,SO,false>::find( size_t i, size_t j ) const
1855 {
1856  return matrix_.find( i, j );
1857 }
1859 //*************************************************************************************************
1860 
1861 
1862 //*************************************************************************************************
1878 template< typename MT // Type of the adapted sparse matrix
1879  , bool SO > // Storage order of the adapted sparse matrix
1881  UniLowerMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
1882 {
1883  return Iterator( matrix_.lowerBound( i, j ), ( SO ? j : i ) );
1884 }
1886 //*************************************************************************************************
1887 
1888 
1889 //*************************************************************************************************
1905 template< typename MT // Type of the adapted sparse matrix
1906  , bool SO > // Storage order of the adapted sparse matrix
1908  UniLowerMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
1909 {
1910  return matrix_.lowerBound( i, j );
1911 }
1913 //*************************************************************************************************
1914 
1915 
1916 //*************************************************************************************************
1932 template< typename MT // Type of the adapted sparse matrix
1933  , bool SO > // Storage order of the adapted sparse matrix
1935  UniLowerMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
1936 {
1937  return Iterator( matrix_.upperBound( i, j ), ( SO ? j : i ) );
1938 }
1940 //*************************************************************************************************
1941 
1942 
1943 //*************************************************************************************************
1959 template< typename MT // Type of the adapted sparse matrix
1960  , bool SO > // Storage order of the adapted sparse matrix
1962  UniLowerMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
1963 {
1964  return matrix_.upperBound( i, j );
1965 }
1967 //*************************************************************************************************
1968 
1969 
1970 
1971 
1972 //=================================================================================================
1973 //
1974 // LOW-LEVEL UTILITY FUNCTIONS
1975 //
1976 //=================================================================================================
1977 
1978 //*************************************************************************************************
2028 template< typename MT // Type of the adapted sparse matrix
2029  , bool SO > // Storage order of the adapted sparse matrix
2030 inline void UniLowerMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
2031 {
2032  if( i <= j ) {
2033  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
2034  }
2035 
2036  if( !check || !isDefault( value ) )
2037  matrix_.insert( i, j, value );
2038 }
2040 //*************************************************************************************************
2041 
2042 
2043 //*************************************************************************************************
2057 template< typename MT // Type of the adapted sparse matrix
2058  , bool SO > // Storage order of the adapted sparse matrix
2059 inline void UniLowerMatrix<MT,SO,false>::finalize( size_t i )
2060 {
2061  matrix_.trim( i );
2062 }
2064 //*************************************************************************************************
2065 
2066 
2067 
2068 
2069 //=================================================================================================
2070 //
2071 // DEBUGGING FUNCTIONS
2072 //
2073 //=================================================================================================
2074 
2075 //*************************************************************************************************
2085 template< typename MT // Type of the adapted sparse matrix
2086  , bool SO > // Storage order of the adapted sparse matrix
2087 inline bool UniLowerMatrix<MT,SO,false>::isIntact() const
2088 {
2089  using blaze::isIntact;
2090 
2091  return ( isIntact( matrix_ ) && isUniLower( matrix_ ) );
2092 }
2094 //*************************************************************************************************
2095 
2096 
2097 
2098 
2099 //=================================================================================================
2100 //
2101 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2102 //
2103 //=================================================================================================
2104 
2105 //*************************************************************************************************
2116 template< typename MT // Type of the adapted sparse matrix
2117  , bool SO > // Storage order of the adapted sparse matrix
2118 template< typename Other > // Data type of the foreign expression
2119 inline bool UniLowerMatrix<MT,SO,false>::canAlias( const Other* alias ) const
2120 {
2121  return matrix_.canAlias( alias );
2122 }
2124 //*************************************************************************************************
2125 
2126 
2127 //*************************************************************************************************
2138 template< typename MT // Type of the adapted sparse matrix
2139  , bool SO > // Storage order of the adapted sparse matrix
2140 template< typename Other > // Data type of the foreign expression
2141 inline bool UniLowerMatrix<MT,SO,false>::isAliased( const Other* alias ) const
2142 {
2143  return matrix_.isAliased( alias );
2144 }
2146 //*************************************************************************************************
2147 
2148 
2149 //*************************************************************************************************
2160 template< typename MT // Type of the adapted sparse matrix
2161  , bool SO > // Storage order of the adapted sparse matrix
2162 inline bool UniLowerMatrix<MT,SO,false>::canSMPAssign() const
2163 {
2164  return matrix_.canSMPAssign();
2165 }
2167 //*************************************************************************************************
2168 
2169 } // namespace blaze
2170 
2171 #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:116
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1729
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type set(T value)
Sets all values in the vector to the given 2-byte integral value.
Definition: Set.h:73
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:7820
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix)
Checks if the given matrix is a square matrix.
Definition: Matrix.h:603
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:229
void move(CompressedMatrix< Type, SO > &dst, CompressedMatrix< Type, SO > &src)
Moving the contents of one compressed matrix to another.
Definition: CompressedMatrix.h:5016
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:292
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:250
bool isStrictlyLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly lower triangular matrix.
Definition: DenseMatrix.h:1201
#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:81
Constraint on the data type.
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:340
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:4926
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2582
#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:116
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:378
Constraint on the data type.
Header file for the IsUniLower type trait.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2584
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:4953
Header file for the DisableIf class template.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Compile time assertion.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4998
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:4980
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
#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:116
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
Header file for the Columns type trait.
Constraint on the data type.
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:642
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:2585
Constraints on the storage order of matrix types.
#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:118
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:187
bool isUniLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower unitriangular matrix.
Definition: DenseMatrix.h:1121
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:532
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2590
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:527
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.
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:116
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
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:79
#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:118
#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:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2591
Header file for the isDefault shim.
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:118
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:256
Header file for the move shim.
#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:79
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:118
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:2583
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
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:237
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2589
#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:116
Header file for the IsUpper type trait.
Header file for exception macros.
#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:143
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:79
Header file for the implementation of the base template of the UniLowerMatrix.