Sparse.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_LOWERMATRIX_SPARSE_H_
36 #define _BLAZE_MATH_ADAPTORS_LOWERMATRIX_SPARSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <utility>
44 #include <vector>
48 #include <blaze/math/Aliases.h>
58 #include <blaze/math/Exception.h>
60 #include <blaze/math/shims/Clear.h>
68 #include <blaze/util/Assert.h>
73 #include <blaze/util/DisableIf.h>
74 #include <blaze/util/EnableIf.h>
77 #include <blaze/util/Types.h>
78 
79 
80 namespace blaze {
81 
82 //=================================================================================================
83 //
84 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
85 //
86 //=================================================================================================
87 
88 //*************************************************************************************************
96 template< typename MT // Type of the adapted sparse matrix
97  , bool SO > // Storage order of the adapted sparse matrix
98 class LowerMatrix<MT,SO,false>
99  : public SparseMatrix< LowerMatrix<MT,SO,false>, SO >
100 {
101  private:
102  //**Type definitions****************************************************************************
103  using OT = OppositeType_<MT>;
104  using TT = TransposeType_<MT>;
105  using ET = ElementType_<MT>;
106  //**********************************************************************************************
107 
108  public:
109  //**Type definitions****************************************************************************
110  using This = LowerMatrix<MT,SO,false>;
111  using BaseType = SparseMatrix<This,SO>;
112  using ResultType = This;
113  using OppositeType = LowerMatrix<OT,!SO,false>;
114  using TransposeType = UpperMatrix<TT,!SO,false>;
115  using ElementType = ET;
116  using ReturnType = ReturnType_<MT>;
117  using CompositeType = const This&;
118  using Reference = LowerProxy<MT>;
119  using ConstReference = ConstReference_<MT>;
120  using Iterator = Iterator_<MT>;
121  using ConstIterator = ConstIterator_<MT>;
122  //**********************************************************************************************
123 
124  //**Rebind struct definition********************************************************************
127  template< typename NewType > // Data type of the other matrix
128  struct Rebind {
130  using Other = LowerMatrix< typename MT::template Rebind<NewType>::Other >;
131  };
132  //**********************************************************************************************
133 
134  //**Resize struct definition********************************************************************
137  template< size_t NewM // Number of rows of the other matrix
138  , size_t NewN > // Number of columns of the other matrix
139  struct Resize {
141  using Other = LowerMatrix< typename MT::template Resize<NewM,NewN>::Other >;
142  };
143  //**********************************************************************************************
144 
145  //**Compilation flags***************************************************************************
147  enum : bool { smpAssignable = false };
148  //**********************************************************************************************
149 
150  //**Constructors********************************************************************************
153  explicit inline LowerMatrix();
154  explicit inline LowerMatrix( size_t n );
155  explicit inline LowerMatrix( size_t n, size_t nonzeros );
156  explicit inline LowerMatrix( size_t n, const std::vector<size_t>& nonzeros );
157 
158  inline LowerMatrix( const LowerMatrix& m );
159  inline LowerMatrix( LowerMatrix&& m ) noexcept;
160 
161  template< typename MT2, bool SO2 >
162  inline LowerMatrix( const Matrix<MT2,SO2>& m );
164  //**********************************************************************************************
165 
166  //**Destructor**********************************************************************************
167  // No explicitly declared destructor.
168  //**********************************************************************************************
169 
170  //**Data access functions***********************************************************************
173  inline Reference operator()( size_t i, size_t j );
174  inline ConstReference operator()( size_t i, size_t j ) const;
175  inline Reference at( size_t i, size_t j );
176  inline ConstReference at( size_t i, size_t j ) const;
177  inline Iterator begin ( size_t i );
178  inline ConstIterator begin ( size_t i ) const;
179  inline ConstIterator cbegin( size_t i ) const;
180  inline Iterator end ( size_t i );
181  inline ConstIterator end ( size_t i ) const;
182  inline ConstIterator cend ( size_t i ) const;
184  //**********************************************************************************************
185 
186  //**Assignment operators************************************************************************
189  inline LowerMatrix& operator=( const LowerMatrix& rhs );
190  inline LowerMatrix& operator=( LowerMatrix&& rhs ) noexcept;
191 
192  template< typename MT2, bool SO2 >
193  inline DisableIf_< IsComputation<MT2>, LowerMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
194 
195  template< typename MT2, bool SO2 >
196  inline EnableIf_< IsComputation<MT2>, LowerMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
197 
198  template< typename MT2, bool SO2 >
199  inline DisableIf_< IsComputation<MT2>, LowerMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
200 
201  template< typename MT2, bool SO2 >
202  inline EnableIf_< IsComputation<MT2>, LowerMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
203 
204  template< typename MT2, bool SO2 >
205  inline DisableIf_< IsComputation<MT2>, LowerMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
206 
207  template< typename MT2, bool SO2 >
208  inline EnableIf_< IsComputation<MT2>, LowerMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
209 
210  template< typename MT2, bool SO2 >
211  inline LowerMatrix& operator%=( const Matrix<MT2,SO2>& rhs );
212 
213  template< typename MT2, bool SO2 >
214  inline LowerMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
215 
216  template< typename Other >
217  inline EnableIf_< IsNumeric<Other>, LowerMatrix >& operator*=( Other rhs );
218 
219  template< typename Other >
220  inline EnableIf_< IsNumeric<Other>, LowerMatrix >& operator/=( Other rhs );
222  //**********************************************************************************************
223 
224  //**Utility functions***************************************************************************
227  inline size_t rows() const noexcept;
228  inline size_t columns() const noexcept;
229  inline size_t capacity() const noexcept;
230  inline size_t capacity( size_t i ) const noexcept;
231  inline size_t nonZeros() const;
232  inline size_t nonZeros( size_t i ) const;
233  inline void reset();
234  inline void reset( size_t i );
235  inline void clear();
236  inline void resize ( size_t n, bool preserve=true );
237  inline void reserve( size_t nonzeros );
238  inline void reserve( size_t i, size_t nonzeros );
239  inline void trim();
240  inline void trim( size_t i );
241  inline void shrinkToFit();
242  inline void swap( LowerMatrix& m ) noexcept;
243 
244  static inline constexpr size_t maxNonZeros() noexcept;
245  static inline constexpr size_t maxNonZeros( size_t n ) noexcept;
247  //**********************************************************************************************
248 
249  //**Insertion functions*************************************************************************
252  inline Iterator set ( size_t i, size_t j, const ElementType& value );
253  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
254  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
255  inline void finalize( size_t i );
257  //**********************************************************************************************
258 
259  //**Erase functions*****************************************************************************
262  inline void erase( size_t i, size_t j );
263  inline Iterator erase( size_t i, Iterator pos );
264  inline Iterator erase( size_t i, Iterator first, Iterator last );
265 
266  template< typename Pred >
267  inline void erase( Pred predicate );
268 
269  template< typename Pred >
270  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
272  //**********************************************************************************************
273 
274  //**Lookup functions****************************************************************************
277  inline Iterator find ( size_t i, size_t j );
278  inline ConstIterator find ( size_t i, size_t j ) const;
279  inline Iterator lowerBound( size_t i, size_t j );
280  inline ConstIterator lowerBound( size_t i, size_t j ) const;
281  inline Iterator upperBound( size_t i, size_t j );
282  inline ConstIterator upperBound( size_t i, size_t j ) const;
284  //**********************************************************************************************
285 
286  //**Numeric functions***************************************************************************
289  template< typename Other > inline LowerMatrix& scale( const Other& scalar );
290  template< typename Other > inline LowerMatrix& scaleDiagonal( const Other& scale );
292  //**********************************************************************************************
293 
294  //**Debugging functions*************************************************************************
297  inline bool isIntact() const noexcept;
299  //**********************************************************************************************
300 
301  //**Expression template evaluation functions****************************************************
304  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
305  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
306 
307  inline bool canSMPAssign() const noexcept;
309  //**********************************************************************************************
310 
311  private:
312  //**Utility functions***************************************************************************
315  inline void resetUpper();
317  //**********************************************************************************************
318 
319  //**Member variables****************************************************************************
322  MT matrix_;
323 
324  //**********************************************************************************************
325 
326  //**Friend declarations*************************************************************************
327  template< bool RF, typename MT2, bool SO2, bool DF2 >
328  friend bool isDefault( const LowerMatrix<MT2,SO2,DF2>& m );
329 
330  template< typename MT2, bool SO2, bool DF2 >
331  friend MT2& derestrict( LowerMatrix<MT2,SO2,DF2>& m );
332  //**********************************************************************************************
333 
334  //**Compile time checks*************************************************************************
347  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
348  //**********************************************************************************************
349 };
351 //*************************************************************************************************
352 
353 
354 
355 
356 //=================================================================================================
357 //
358 // CONSTRUCTORS
359 //
360 //=================================================================================================
361 
362 //*************************************************************************************************
366 template< typename MT // Type of the adapted sparse matrix
367  , bool SO > // Storage order of the adapted sparse matrix
368 inline LowerMatrix<MT,SO,false>::LowerMatrix()
369  : matrix_() // The adapted sparse matrix
370 {
371  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
372 }
374 //*************************************************************************************************
375 
376 
377 //*************************************************************************************************
385 template< typename MT // Type of the adapted sparse matrix
386  , bool SO > // Storage order of the adapted sparse matrix
387 inline LowerMatrix<MT,SO,false>::LowerMatrix( size_t n )
388  : matrix_( n, n ) // The adapted sparse matrix
389 {
391 
392  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
393 }
395 //*************************************************************************************************
396 
397 
398 //*************************************************************************************************
407 template< typename MT // Type of the adapted sparse matrix
408  , bool SO > // Storage order of the adapted sparse matrix
409 inline LowerMatrix<MT,SO,false>::LowerMatrix( size_t n, size_t nonzeros )
410  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
411 {
413 
414  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
415 }
417 //*************************************************************************************************
418 
419 
420 //*************************************************************************************************
431 template< typename MT // Type of the adapted sparse matrix
432  , bool SO > // Storage order of the adapted sparse matrix
433 inline LowerMatrix<MT,SO,false>::LowerMatrix( size_t n, const std::vector<size_t>& nonzeros )
434  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
435 {
437 
438  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
439 }
441 //*************************************************************************************************
442 
443 
444 //*************************************************************************************************
450 template< typename MT // Type of the adapted sparse matrix
451  , bool SO > // Storage order of the adapted sparse matrix
452 inline LowerMatrix<MT,SO,false>::LowerMatrix( const LowerMatrix& m )
453  : matrix_( m.matrix_ ) // The adapted sparse matrix
454 {
455  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
456  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
457 }
459 //*************************************************************************************************
460 
461 
462 //*************************************************************************************************
468 template< typename MT // Type of the adapted sparse matrix
469  , bool SO > // Storage order of the adapted sparse matrix
470 inline LowerMatrix<MT,SO,false>::LowerMatrix( LowerMatrix&& m ) noexcept
471  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
472 {
473  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
474  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
475 }
477 //*************************************************************************************************
478 
479 
480 //*************************************************************************************************
490 template< typename MT // Type of the adapted sparse matrix
491  , bool SO > // Storage order of the adapted sparse matrix
492 template< typename MT2 // Type of the foreign matrix
493  , bool SO2 > // Storage order of the foreign matrix
494 inline LowerMatrix<MT,SO,false>::LowerMatrix( const Matrix<MT2,SO2>& m )
495  : matrix_( ~m ) // The adapted sparse matrix
496 {
497  if( !IsLower<MT2>::value && !isLower( matrix_ ) ) {
498  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of lower matrix" );
499  }
500 
501  if( !IsLower<MT2>::value )
502  resetUpper();
503 
504  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
505  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
506 }
508 //*************************************************************************************************
509 
510 
511 
512 
513 //=================================================================================================
514 //
515 // DATA ACCESS FUNCTIONS
516 //
517 //=================================================================================================
518 
519 //*************************************************************************************************
535 template< typename MT // Type of the adapted sparse matrix
536  , bool SO > // Storage order of the adapted sparse matrix
538  LowerMatrix<MT,SO,false>::operator()( size_t i, size_t j )
539 {
540  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
541  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
542 
543  return Reference( matrix_, i, j );
544 }
546 //*************************************************************************************************
547 
548 
549 //*************************************************************************************************
565 template< typename MT // Type of the adapted sparse matrix
566  , bool SO > // Storage order of the adapted sparse matrix
568  LowerMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
569 {
570  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
571  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
572 
573  return matrix_(i,j);
574 }
576 //*************************************************************************************************
577 
578 
579 //*************************************************************************************************
596 template< typename MT // Type of the adapted sparse matrix
597  , bool SO > // Storage order of the adapted sparse matrix
599  LowerMatrix<MT,SO,false>::at( size_t i, size_t j )
600 {
601  if( i >= rows() ) {
602  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
603  }
604  if( j >= columns() ) {
605  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
606  }
607  return (*this)(i,j);
608 }
610 //*************************************************************************************************
611 
612 
613 //*************************************************************************************************
630 template< typename MT // Type of the adapted sparse matrix
631  , bool SO > // Storage order of the adapted sparse matrix
633  LowerMatrix<MT,SO,false>::at( size_t i, size_t j ) const
634 {
635  if( i >= rows() ) {
636  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
637  }
638  if( j >= columns() ) {
639  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
640  }
641  return (*this)(i,j);
642 }
644 //*************************************************************************************************
645 
646 
647 //*************************************************************************************************
659 template< typename MT // Type of the adapted sparse matrix
660  , bool SO > // Storage order of the adapted sparse matrix
663 {
664  return matrix_.begin(i);
665 }
667 //*************************************************************************************************
668 
669 
670 //*************************************************************************************************
682 template< typename MT // Type of the adapted sparse matrix
683  , bool SO > // Storage order of the adapted sparse matrix
685  LowerMatrix<MT,SO,false>::begin( size_t i ) const
686 {
687  return matrix_.begin(i);
688 }
690 //*************************************************************************************************
691 
692 
693 //*************************************************************************************************
705 template< typename MT // Type of the adapted sparse matrix
706  , bool SO > // Storage order of the adapted sparse matrix
708  LowerMatrix<MT,SO,false>::cbegin( size_t i ) const
709 {
710  return matrix_.cbegin(i);
711 }
713 //*************************************************************************************************
714 
715 
716 //*************************************************************************************************
728 template< typename MT // Type of the adapted sparse matrix
729  , bool SO > // Storage order of the adapted sparse matrix
732 {
733  return matrix_.end(i);
734 }
736 //*************************************************************************************************
737 
738 
739 //*************************************************************************************************
751 template< typename MT // Type of the adapted sparse matrix
752  , bool SO > // Storage order of the adapted sparse matrix
754  LowerMatrix<MT,SO,false>::end( size_t i ) const
755 {
756  return matrix_.end(i);
757 }
759 //*************************************************************************************************
760 
761 
762 //*************************************************************************************************
774 template< typename MT // Type of the adapted sparse matrix
775  , bool SO > // Storage order of the adapted sparse matrix
777  LowerMatrix<MT,SO,false>::cend( size_t i ) const
778 {
779  return matrix_.cend(i);
780 }
782 //*************************************************************************************************
783 
784 
785 
786 
787 //=================================================================================================
788 //
789 // ASSIGNMENT OPERATORS
790 //
791 //=================================================================================================
792 
793 //*************************************************************************************************
803 template< typename MT // Type of the adapted sparse matrix
804  , bool SO > // Storage order of the adapted sparse matrix
805 inline LowerMatrix<MT,SO,false>&
806  LowerMatrix<MT,SO,false>::operator=( const LowerMatrix& rhs )
807 {
808  matrix_ = rhs.matrix_;
809 
810  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
811  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
812 
813  return *this;
814 }
816 //*************************************************************************************************
817 
818 
819 //*************************************************************************************************
826 template< typename MT // Type of the adapted sparse matrix
827  , bool SO > // Storage order of the adapted sparse matrix
828 inline LowerMatrix<MT,SO,false>&
829  LowerMatrix<MT,SO,false>::operator=( LowerMatrix&& rhs ) noexcept
830 {
831  matrix_ = std::move( rhs.matrix_ );
832 
833  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
834  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
835 
836  return *this;
837 }
839 //*************************************************************************************************
840 
841 
842 //*************************************************************************************************
855 template< typename MT // Type of the adapted sparse matrix
856  , bool SO > // Storage order of the adapted sparse matrix
857 template< typename MT2 // Type of the right-hand side matrix
858  , bool SO2 > // Storage order of the right-hand side matrix
859 inline DisableIf_< IsComputation<MT2>, LowerMatrix<MT,SO,false>& >
860  LowerMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
861 {
862  if( !IsLower<MT2>::value && !isLower( ~rhs ) ) {
863  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
864  }
865 
866  matrix_ = decllow( ~rhs );
867 
868  if( !IsLower<MT2>::value )
869  resetUpper();
870 
871  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
872  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
873 
874  return *this;
875 }
877 //*************************************************************************************************
878 
879 
880 //*************************************************************************************************
893 template< typename MT // Type of the adapted sparse matrix
894  , bool SO > // Storage order of the adapted sparse matrix
895 template< typename MT2 // Type of the right-hand side matrix
896  , bool SO2 > // Storage order of the right-hand side matrix
897 inline EnableIf_< IsComputation<MT2>, LowerMatrix<MT,SO,false>& >
898  LowerMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
899 {
900  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
901  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
902  }
903 
904  if( IsLower<MT2>::value ) {
905  matrix_ = ~rhs;
906  }
907  else {
908  MT tmp( ~rhs );
909 
910  if( !isLower( tmp ) ) {
911  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
912  }
913 
914  matrix_ = std::move( tmp );
915  }
916 
917  if( !IsLower<MT2>::value )
918  resetUpper();
919 
920  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
921  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
922 
923  return *this;
924 }
926 //*************************************************************************************************
927 
928 
929 //*************************************************************************************************
942 template< typename MT // Type of the adapted sparse matrix
943  , bool SO > // Storage order of the adapted sparse matrix
944 template< typename MT2 // Type of the right-hand side matrix
945  , bool SO2 > // Storage order of the right-hand side matrix
946 inline DisableIf_< IsComputation<MT2>, LowerMatrix<MT,SO,false>& >
947  LowerMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
948 {
949  if( !IsLower<MT2>::value && !isLower( ~rhs ) ) {
950  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
951  }
952 
953  matrix_ += decllow( ~rhs );
954 
955  if( !IsLower<MT2>::value )
956  resetUpper();
957 
958  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
959  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
960 
961  return *this;
962 }
964 //*************************************************************************************************
965 
966 
967 //*************************************************************************************************
980 template< typename MT // Type of the adapted sparse matrix
981  , bool SO > // Storage order of the adapted sparse matrix
982 template< typename MT2 // Type of the right-hand side matrix
983  , bool SO2 > // Storage order of the right-hand side matrix
984 inline EnableIf_< IsComputation<MT2>, LowerMatrix<MT,SO,false>& >
985  LowerMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
986 {
987  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
988  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
989  }
990 
991  if( IsLower<MT2>::value ) {
992  matrix_ += ~rhs;
993  }
994  else {
995  const ResultType_<MT2> tmp( ~rhs );
996 
997  if( !isLower( tmp ) ) {
998  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
999  }
1000 
1001  matrix_ += decllow( tmp );
1002  }
1003 
1004  if( !IsLower<MT2>::value )
1005  resetUpper();
1006 
1007  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1008  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1009 
1010  return *this;
1011 }
1013 //*************************************************************************************************
1014 
1015 
1016 //*************************************************************************************************
1029 template< typename MT // Type of the adapted sparse matrix
1030  , bool SO > // Storage order of the adapted sparse matrix
1031 template< typename MT2 // Type of the right-hand side matrix
1032  , bool SO2 > // Storage order of the right-hand side matrix
1033 inline DisableIf_< IsComputation<MT2>, LowerMatrix<MT,SO,false>& >
1034  LowerMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1035 {
1036  if( !IsLower<MT2>::value && !isLower( ~rhs ) ) {
1037  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1038  }
1039 
1040  matrix_ -= decllow( ~rhs );
1041 
1042  if( !IsLower<MT2>::value )
1043  resetUpper();
1044 
1045  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1046  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1047 
1048  return *this;
1049 }
1051 //*************************************************************************************************
1052 
1053 
1054 //*************************************************************************************************
1067 template< typename MT // Type of the adapted sparse matrix
1068  , bool SO > // Storage order of the adapted sparse matrix
1069 template< typename MT2 // Type of the right-hand side matrix
1070  , bool SO2 > // Storage order of the right-hand side matrix
1071 inline EnableIf_< IsComputation<MT2>, LowerMatrix<MT,SO,false>& >
1072  LowerMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1073 {
1074  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1075  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1076  }
1077 
1078  if( IsLower<MT2>::value ) {
1079  matrix_ -= ~rhs;
1080  }
1081  else {
1082  const ResultType_<MT2> tmp( ~rhs );
1083 
1084  if( !isLower( tmp ) ) {
1085  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1086  }
1087 
1088  matrix_ -= decllow( tmp );
1089  }
1090 
1091  if( !IsLower<MT2>::value )
1092  resetUpper();
1093 
1094  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1095  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1096 
1097  return *this;
1098 }
1100 //*************************************************************************************************
1101 
1102 
1103 //*************************************************************************************************
1114 template< typename MT // Type of the adapted sparse matrix
1115  , bool SO > // Storage order of the adapted sparse matrix
1116 template< typename MT2 // Type of the right-hand side matrix
1117  , bool SO2 > // Storage order of the right-hand side matrix
1118 inline LowerMatrix<MT,SO,false>&
1119  LowerMatrix<MT,SO,false>::operator%=( const Matrix<MT2,SO2>& rhs )
1120 {
1121  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1122  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1123  }
1124 
1125  matrix_ %= ~rhs;
1126 
1127  if( !IsLower<MT2>::value )
1128  resetUpper();
1129 
1130  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1131  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1132 
1133  return *this;
1134 }
1136 //*************************************************************************************************
1137 
1138 
1139 //*************************************************************************************************
1151 template< typename MT // Type of the adapted sparse matrix
1152  , bool SO > // Storage order of the adapted sparse matrix
1153 template< typename MT2 // Type of the right-hand side matrix
1154  , bool SO2 > // Storage order of the right-hand side matrix
1155 inline LowerMatrix<MT,SO,false>&
1156  LowerMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1157 {
1158  if( matrix_.rows() != (~rhs).columns() ) {
1159  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1160  }
1161 
1162  MT tmp( matrix_ * ~rhs );
1163 
1164  if( !isLower( tmp ) ) {
1165  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1166  }
1167 
1168  matrix_ = std::move( tmp );
1169 
1170  if( !IsLower<MT2>::value )
1171  resetUpper();
1172 
1173  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1174  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1175 
1176  return *this;
1177 }
1179 //*************************************************************************************************
1180 
1181 
1182 //*************************************************************************************************
1190 template< typename MT // Type of the adapted sparse matrix
1191  , bool SO > // Storage order of the adapted sparse matrix
1192 template< typename Other > // Data type of the right-hand side scalar
1193 inline EnableIf_< IsNumeric<Other>, LowerMatrix<MT,SO,false> >&
1195 {
1196  matrix_ *= rhs;
1197  return *this;
1198 }
1199 //*************************************************************************************************
1200 
1201 
1202 //*************************************************************************************************
1210 template< typename MT // Type of the adapted sparse matrix
1211  , bool SO > // Storage order of the adapted sparse matrix
1212 template< typename Other > // Data type of the right-hand side scalar
1213 inline EnableIf_< IsNumeric<Other>, LowerMatrix<MT,SO,false> >&
1215 {
1216  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1217 
1218  matrix_ /= rhs;
1219  return *this;
1220 }
1222 //*************************************************************************************************
1223 
1224 
1225 
1226 
1227 //=================================================================================================
1228 //
1229 // UTILITY FUNCTIONS
1230 //
1231 //=================================================================================================
1232 
1233 //*************************************************************************************************
1239 template< typename MT // Type of the adapted sparse matrix
1240  , bool SO > // Storage order of the adapted sparse matrix
1241 inline size_t LowerMatrix<MT,SO,false>::rows() const noexcept
1242 {
1243  return matrix_.rows();
1244 }
1246 //*************************************************************************************************
1247 
1248 
1249 //*************************************************************************************************
1255 template< typename MT // Type of the adapted sparse matrix
1256  , bool SO > // Storage order of the adapted sparse matrix
1257 inline size_t LowerMatrix<MT,SO,false>::columns() const noexcept
1258 {
1259  return matrix_.columns();
1260 }
1262 //*************************************************************************************************
1263 
1264 
1265 //*************************************************************************************************
1271 template< typename MT // Type of the adapted sparse matrix
1272  , bool SO > // Storage order of the adapted sparse matrix
1273 inline size_t LowerMatrix<MT,SO,false>::capacity() const noexcept
1274 {
1275  return matrix_.capacity();
1276 }
1278 //*************************************************************************************************
1279 
1280 
1281 //*************************************************************************************************
1293 template< typename MT // Type of the adapted sparse matrix
1294  , bool SO > // Storage order of the adapted sparse matrix
1295 inline size_t LowerMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1296 {
1297  return matrix_.capacity(i);
1298 }
1300 //*************************************************************************************************
1301 
1302 
1303 //*************************************************************************************************
1309 template< typename MT // Type of the adapted sparse matrix
1310  , bool SO > // Storage order of the adapted sparse matrix
1311 inline size_t LowerMatrix<MT,SO,false>::nonZeros() const
1312 {
1313  return matrix_.nonZeros();
1314 }
1316 //*************************************************************************************************
1317 
1318 
1319 //*************************************************************************************************
1331 template< typename MT // Type of the adapted sparse matrix
1332  , bool SO > // Storage order of the adapted sparse matrix
1333 inline size_t LowerMatrix<MT,SO,false>::nonZeros( size_t i ) const
1334 {
1335  return matrix_.nonZeros(i);
1336 }
1338 //*************************************************************************************************
1339 
1340 
1341 //*************************************************************************************************
1347 template< typename MT // Type of the adapted sparse matrix
1348  , bool SO > // Storage order of the adapted sparse matrix
1349 inline void LowerMatrix<MT,SO,false>::reset()
1350 {
1351  matrix_.reset();
1352 }
1354 //*************************************************************************************************
1355 
1356 
1357 //*************************************************************************************************
1370 template< typename MT // Type of the adapted sparse matrix
1371  , bool SO > // Storage order of the adapted sparse matrix
1372 inline void LowerMatrix<MT,SO,false>::reset( size_t i )
1373 {
1374  matrix_.reset( i );
1375 }
1377 //*************************************************************************************************
1378 
1379 
1380 //*************************************************************************************************
1388 template< typename MT // Type of the adapted sparse matrix
1389  , bool SO > // Storage order of the adapted sparse matrix
1390 inline void LowerMatrix<MT,SO,false>::clear()
1391 {
1392  using blaze::clear;
1393 
1394  clear( matrix_ );
1395 }
1397 //*************************************************************************************************
1398 
1399 
1400 //*************************************************************************************************
1415 template< typename MT // Type of the adapted sparse matrix
1416  , bool SO > // Storage order of the adapted sparse matrix
1417 void LowerMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1418 {
1420 
1421  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1422 
1423  matrix_.resize( n, n, preserve );
1424 }
1426 //*************************************************************************************************
1427 
1428 
1429 //*************************************************************************************************
1440 template< typename MT // Type of the adapted sparse matrix
1441  , bool SO > // Storage order of the adapted sparse matrix
1442 inline void LowerMatrix<MT,SO,false>::reserve( size_t nonzeros )
1443 {
1444  matrix_.reserve( nonzeros );
1445 }
1447 //*************************************************************************************************
1448 
1449 
1450 //*************************************************************************************************
1464 template< typename MT // Type of the adapted sparse matrix
1465  , bool SO > // Storage order of the adapted sparse matrix
1466 inline void LowerMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1467 {
1468  matrix_.reserve( i, nonzeros );
1469 }
1471 //*************************************************************************************************
1472 
1473 
1474 //*************************************************************************************************
1485 template< typename MT // Type of the adapted sparse matrix
1486  , bool SO > // Storage order of the adapted sparse matrix
1487 inline void LowerMatrix<MT,SO,false>::trim()
1488 {
1489  matrix_.trim();
1490 }
1492 //*************************************************************************************************
1493 
1494 
1495 //*************************************************************************************************
1507 template< typename MT // Type of the adapted sparse matrix
1508  , bool SO > // Storage order of the adapted sparse matrix
1509 inline void LowerMatrix<MT,SO,false>::trim( size_t i )
1510 {
1511  matrix_.trim( i );
1512 }
1514 //*************************************************************************************************
1515 
1516 
1517 //*************************************************************************************************
1527 template< typename MT // Type of the adapted sparse matrix
1528  , bool SO > // Storage order of the adapted sparse matrix
1530 {
1531  matrix_.shrinkToFit();
1532 }
1534 //*************************************************************************************************
1535 
1536 
1537 //*************************************************************************************************
1544 template< typename MT // Type of the adapted sparse matrix
1545  , bool SO > // Storage order of the adapted sparse matrix
1546 inline void LowerMatrix<MT,SO,false>::swap( LowerMatrix& m ) noexcept
1547 {
1548  using std::swap;
1549 
1550  swap( matrix_, m.matrix_ );
1551 }
1553 //*************************************************************************************************
1554 
1555 
1556 //*************************************************************************************************
1567 template< typename MT // Type of the adapted dense matrix
1568  , bool SO > // Storage order of the adapted dense matrix
1569 inline constexpr size_t LowerMatrix<MT,SO,false>::maxNonZeros() noexcept
1570 {
1572 
1573  return maxNonZeros( Rows<MT>::value );
1574 }
1576 //*************************************************************************************************
1577 
1578 
1579 //*************************************************************************************************
1589 template< typename MT // Type of the adapted dense matrix
1590  , bool SO > // Storage order of the adapted dense matrix
1591 inline constexpr size_t LowerMatrix<MT,SO,false>::maxNonZeros( size_t n ) noexcept
1592 {
1593  return ( ( n + 1UL ) * n ) / 2UL;
1594 }
1596 //*************************************************************************************************
1597 
1598 
1599 //*************************************************************************************************
1605 template< typename MT // Type of the adapted dense matrix
1606  , bool SO > // Storage order of the adapted dense matrix
1607 inline void LowerMatrix<MT,SO,false>::resetUpper()
1608 {
1609  if( SO ) {
1610  for( size_t j=1UL; j<columns(); ++j )
1611  matrix_.erase( j, matrix_.begin( j ), matrix_.lowerBound( j, j ) );
1612  }
1613  else {
1614  for( size_t i=0UL; i<rows(); ++i )
1615  matrix_.erase( i, matrix_.upperBound( i, i ), matrix_.end( i ) );
1616  }
1617 }
1619 //*************************************************************************************************
1620 
1621 
1622 
1623 
1624 //=================================================================================================
1625 //
1626 // INSERTION FUNCTIONS
1627 //
1628 //=================================================================================================
1629 
1630 //*************************************************************************************************
1646 template< typename MT // Type of the adapted sparse matrix
1647  , bool SO > // Storage order of the adapted sparse matrix
1648 inline typename LowerMatrix<MT,SO,false>::Iterator
1649  LowerMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1650 {
1651  if( i < j ) {
1652  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1653  }
1654 
1655  return matrix_.set( i, j, value );
1656 }
1658 //*************************************************************************************************
1659 
1660 
1661 //*************************************************************************************************
1678 template< typename MT // Type of the adapted sparse matrix
1679  , bool SO > // Storage order of the adapted sparse matrix
1680 inline typename LowerMatrix<MT,SO,false>::Iterator
1681  LowerMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1682 {
1683  if( i < j ) {
1684  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1685  }
1686 
1687  return matrix_.insert( i, j, value );
1688 }
1690 //*************************************************************************************************
1691 
1692 
1693 //*************************************************************************************************
1743 template< typename MT // Type of the adapted sparse matrix
1744  , bool SO > // Storage order of the adapted sparse matrix
1745 inline void LowerMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1746 {
1747  if( i < j ) {
1748  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1749  }
1750 
1751  matrix_.append( i, j, value, check );
1752 }
1754 //*************************************************************************************************
1755 
1756 
1757 //*************************************************************************************************
1771 template< typename MT // Type of the adapted sparse matrix
1772  , bool SO > // Storage order of the adapted sparse matrix
1773 inline void LowerMatrix<MT,SO,false>::finalize( size_t i )
1774 {
1775  matrix_.finalize( i );
1776 }
1778 //*************************************************************************************************
1779 
1780 
1781 
1782 
1783 //=================================================================================================
1784 //
1785 // ERASE FUNCTIONS
1786 //
1787 //=================================================================================================
1788 
1789 //*************************************************************************************************
1799 template< typename MT // Type of the adapted sparse matrix
1800  , bool SO > // Storage order of the adapted sparse matrix
1801 inline void LowerMatrix<MT,SO,false>::erase( size_t i, size_t j )
1802 {
1803  matrix_.erase( i, j );
1804 }
1806 //*************************************************************************************************
1807 
1808 
1809 //*************************************************************************************************
1821 template< typename MT // Type of the adapted sparse matrix
1822  , bool SO > // Storage order of the adapted sparse matrix
1823 inline typename LowerMatrix<MT,SO,false>::Iterator
1824  LowerMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1825 {
1826  return matrix_.erase( i, pos );
1827 }
1829 //*************************************************************************************************
1830 
1831 
1832 //*************************************************************************************************
1845 template< typename MT // Type of the adapted sparse matrix
1846  , bool SO > // Storage order of the adapted sparse matrix
1847 inline typename LowerMatrix<MT,SO,false>::Iterator
1848  LowerMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1849 {
1850  return matrix_.erase( i, first, last );
1851 }
1853 //*************************************************************************************************
1854 
1855 
1856 //*************************************************************************************************
1878 template< typename MT // Type of the adapted sparse matrix
1879  , bool SO > // Storage order of the adapted sparse matrix
1880 template< typename Pred > // Type of the unary predicate
1881 inline void LowerMatrix<MT,SO,false>::erase( Pred predicate )
1882 {
1883  matrix_.erase( predicate );
1884 
1885  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1886 }
1888 //*************************************************************************************************
1889 
1890 
1891 //*************************************************************************************************
1919 template< typename MT // Type of the adapted sparse matrix
1920  , bool SO > // Storage order of the adapted sparse matrix
1921 template< typename Pred > // Type of the unary predicate
1922 inline void LowerMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
1923 {
1924  matrix_.erase( i, first, last, predicate );
1925 
1926  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1927 }
1929 //*************************************************************************************************
1930 
1931 
1932 
1933 
1934 //=================================================================================================
1935 //
1936 // LOOKUP FUNCTIONS
1937 //
1938 //=================================================================================================
1939 
1940 //*************************************************************************************************
1956 template< typename MT // Type of the adapted sparse matrix
1957  , bool SO > // Storage order of the adapted sparse matrix
1958 inline typename LowerMatrix<MT,SO,false>::Iterator
1959  LowerMatrix<MT,SO,false>::find( size_t i, size_t j )
1960 {
1961  return matrix_.find( i, j );
1962 }
1964 //*************************************************************************************************
1965 
1966 
1967 //*************************************************************************************************
1983 template< typename MT // Type of the adapted sparse matrix
1984  , bool SO > // Storage order of the adapted sparse matrix
1986  LowerMatrix<MT,SO,false>::find( size_t i, size_t j ) const
1987 {
1988  return matrix_.find( i, j );
1989 }
1991 //*************************************************************************************************
1992 
1993 
1994 //*************************************************************************************************
2010 template< typename MT // Type of the adapted sparse matrix
2011  , bool SO > // Storage order of the adapted sparse matrix
2012 inline typename LowerMatrix<MT,SO,false>::Iterator
2013  LowerMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
2014 {
2015  return matrix_.lowerBound( i, j );
2016 }
2018 //*************************************************************************************************
2019 
2020 
2021 //*************************************************************************************************
2037 template< typename MT // Type of the adapted sparse matrix
2038  , bool SO > // Storage order of the adapted sparse matrix
2040  LowerMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
2041 {
2042  return matrix_.lowerBound( i, j );
2043 }
2045 //*************************************************************************************************
2046 
2047 
2048 //*************************************************************************************************
2064 template< typename MT // Type of the adapted sparse matrix
2065  , bool SO > // Storage order of the adapted sparse matrix
2066 inline typename LowerMatrix<MT,SO,false>::Iterator
2067  LowerMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
2068 {
2069  return matrix_.upperBound( i, j );
2070 }
2072 //*************************************************************************************************
2073 
2074 
2075 //*************************************************************************************************
2091 template< typename MT // Type of the adapted sparse matrix
2092  , bool SO > // Storage order of the adapted sparse matrix
2094  LowerMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
2095 {
2096  return matrix_.upperBound( i, j );
2097 }
2099 //*************************************************************************************************
2100 
2101 
2102 
2103 
2104 //=================================================================================================
2105 //
2106 // NUMERIC FUNCTIONS
2107 //
2108 //=================================================================================================
2109 
2110 //*************************************************************************************************
2128 template< typename MT // Type of the adapted sparse matrix
2129  , bool SO > // Storage order of the adapted sparse matrix
2130 template< typename Other > // Data type of the scalar value
2131 inline LowerMatrix<MT,SO,false>&
2132  LowerMatrix<MT,SO,false>::scale( const Other& scalar )
2133 {
2134  matrix_.scale( scalar );
2135  return *this;
2136 }
2138 //*************************************************************************************************
2139 
2140 
2141 //*************************************************************************************************
2151 template< typename MT // Type of the adapted sparse matrix
2152  , bool SO > // Storage order of the adapted sparse matrix
2153 template< typename Other > // Data type of the scalar value
2154 inline LowerMatrix<MT,SO,false>&
2155  LowerMatrix<MT,SO,false>::scaleDiagonal( const Other& scalar )
2156 {
2157  matrix_.scaleDiagonal( scalar );
2158  return *this;
2159 }
2161 //*************************************************************************************************
2162 
2163 
2164 
2165 
2166 //=================================================================================================
2167 //
2168 // DEBUGGING FUNCTIONS
2169 //
2170 //=================================================================================================
2171 
2172 //*************************************************************************************************
2182 template< typename MT // Type of the adapted sparse matrix
2183  , bool SO > // Storage order of the adapted sparse matrix
2184 inline bool LowerMatrix<MT,SO,false>::isIntact() const noexcept
2185 {
2186  using blaze::isIntact;
2187 
2188  return ( isIntact( matrix_ ) && isLower( matrix_ ) );
2189 }
2191 //*************************************************************************************************
2192 
2193 
2194 
2195 
2196 //=================================================================================================
2197 //
2198 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2199 //
2200 //=================================================================================================
2201 
2202 //*************************************************************************************************
2213 template< typename MT // Type of the adapted sparse matrix
2214  , bool SO > // Storage order of the adapted sparse matrix
2215 template< typename Other > // Data type of the foreign expression
2216 inline bool LowerMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2217 {
2218  return matrix_.canAlias( alias );
2219 }
2221 //*************************************************************************************************
2222 
2223 
2224 //*************************************************************************************************
2235 template< typename MT // Type of the adapted sparse matrix
2236  , bool SO > // Storage order of the adapted sparse matrix
2237 template< typename Other > // Data type of the foreign expression
2238 inline bool LowerMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2239 {
2240  return matrix_.isAliased( alias );
2241 }
2243 //*************************************************************************************************
2244 
2245 
2246 //*************************************************************************************************
2257 template< typename MT // Type of the adapted sparse matrix
2258  , bool SO > // Storage order of the adapted sparse matrix
2259 inline bool LowerMatrix<MT,SO,false>::canSMPAssign() const noexcept
2260 {
2261  return matrix_.canSMPAssign();
2262 }
2264 //*************************************************************************************************
2265 
2266 } // namespace blaze
2267 
2268 #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 auxiliary alias declarations.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3079
bool isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1073
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the Rows type trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:356
Header file for basic type definitions.
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:63
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1411
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3078
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:198
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:560
BLAZE_ALWAYS_INLINE void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:609
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5845
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3080
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3085
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:394
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3086
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1393
Constraint on the data type.
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:308
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:242
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
Header file for utility functions for sparse matrices.
Header file for the IsSquare type trait.
Constraint on the data type.
Header file for the DisableIf class template.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3084
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_CONSTRAINT_MUST_BE_STATIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a static data type, i.e. a vector or matrix with dimensions fixed at compile time, a compilation error is created.
Definition: Static.h:61
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5924
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5907
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3077
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3081
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the Columns type trait.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3087
Constraint on the data type.
decltype(auto) decllow(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as lower.
Definition: DMatDeclLowExpr.h:1027
Header file for the IsLower type trait.
Header file for the LowerProxy class.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:340
Constraints on the storage order of matrix types.
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:81
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:548
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:264
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:580
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
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_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
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:270
Constraint on the data type.
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:324
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3082
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a &#39;res...
Definition: Resizable.h:61
Header file for the implementation of the base template of the LowerMatrix.
Header file for the IsComputation type trait class.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3083
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:252
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:600
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:742
#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