Sparse.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_STRICTLYUPPERMATRIX_SPARSE_H_
36 #define _BLAZE_MATH_ADAPTORS_STRICTLYUPPERMATRIX_SPARSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <utility>
44 #include <vector>
48 #include <blaze/math/Aliases.h>
57 #include <blaze/math/Exception.h>
59 #include <blaze/math/Functions.h>
60 #include <blaze/math/shims/Clear.h>
70 #include <blaze/util/Assert.h>
75 #include <blaze/util/DisableIf.h>
76 #include <blaze/util/EnableIf.h>
79 #include <blaze/util/Types.h>
80 
81 
82 namespace blaze {
83 
84 //=================================================================================================
85 //
86 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
87 //
88 //=================================================================================================
89 
90 //*************************************************************************************************
98 template< typename MT // Type of the adapted sparse matrix
99  , bool SO > // Storage order of the adapted sparse matrix
100 class StrictlyUpperMatrix<MT,SO,false>
101  : public SparseMatrix< StrictlyUpperMatrix<MT,SO,false>, SO >
102 {
103  private:
104  //**Type definitions****************************************************************************
105  typedef OppositeType_<MT> OT;
106  typedef TransposeType_<MT> TT;
107  typedef ElementType_<MT> ET;
108  //**********************************************************************************************
109 
110  public:
111  //**Type definitions****************************************************************************
112  typedef StrictlyUpperMatrix<MT,SO,false> This;
113  typedef SparseMatrix<This,SO> BaseType;
114  typedef This ResultType;
115  typedef StrictlyUpperMatrix<OT,!SO,false> OppositeType;
116  typedef StrictlyLowerMatrix<TT,!SO,false> TransposeType;
117  typedef ET ElementType;
118  typedef ReturnType_<MT> ReturnType;
119  typedef const This& CompositeType;
120  typedef StrictlyUpperProxy<MT> Reference;
121  typedef ConstReference_<MT> ConstReference;
122  typedef Iterator_<MT> Iterator;
123  typedef ConstIterator_<MT> ConstIterator;
124  //**********************************************************************************************
125 
126  //**Rebind struct definition********************************************************************
129  template< typename ET > // Data type of the other matrix
130  struct Rebind {
132  typedef StrictlyUpperMatrix< typename MT::template Rebind<ET>::Other > Other;
133  };
134  //**********************************************************************************************
135 
136  //**Compilation flags***************************************************************************
138  enum : bool { smpAssignable = false };
139  //**********************************************************************************************
140 
141  //**Constructors********************************************************************************
144  explicit inline StrictlyUpperMatrix();
145  explicit inline StrictlyUpperMatrix( size_t n );
146  explicit inline StrictlyUpperMatrix( size_t n, size_t nonzeros );
147  explicit inline StrictlyUpperMatrix( size_t n, const std::vector<size_t>& nonzeros );
148 
149  inline StrictlyUpperMatrix( const StrictlyUpperMatrix& m );
150  inline StrictlyUpperMatrix( StrictlyUpperMatrix&& m ) noexcept;
151 
152  template< typename MT2, bool SO2 >
153  inline StrictlyUpperMatrix( const Matrix<MT2,SO2>& m );
155  //**********************************************************************************************
156 
157  //**Destructor**********************************************************************************
158  // No explicitly declared destructor.
159  //**********************************************************************************************
160 
161  //**Data access functions***********************************************************************
164  inline Reference operator()( size_t i, size_t j );
165  inline ConstReference operator()( size_t i, size_t j ) const;
166  inline Reference at( size_t i, size_t j );
167  inline ConstReference at( size_t i, size_t j ) const;
168  inline Iterator begin ( size_t i );
169  inline ConstIterator begin ( size_t i ) const;
170  inline ConstIterator cbegin( size_t i ) const;
171  inline Iterator end ( size_t i );
172  inline ConstIterator end ( size_t i ) const;
173  inline ConstIterator cend ( size_t i ) const;
175  //**********************************************************************************************
176 
177  //**Assignment operators************************************************************************
180  inline StrictlyUpperMatrix& operator=( const StrictlyUpperMatrix& rhs );
181  inline StrictlyUpperMatrix& operator=( StrictlyUpperMatrix&& rhs ) noexcept;
182 
183  template< typename MT2, bool SO2 >
184  inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
185  operator=( const Matrix<MT2,SO2>& rhs );
186 
187  template< typename MT2, bool SO2 >
188  inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
189  operator=( const Matrix<MT2,SO2>& rhs );
190 
191  template< typename MT2, bool SO2 >
192  inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
193  operator+=( const Matrix<MT2,SO2>& rhs );
194 
195  template< typename MT2, bool SO2 >
196  inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
197  operator+=( const Matrix<MT2,SO2>& rhs );
198 
199  template< typename MT2, bool SO2 >
200  inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
201  operator-=( const Matrix<MT2,SO2>& rhs );
202 
203  template< typename MT2, bool SO2 >
204  inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
205  operator-=( const Matrix<MT2,SO2>& rhs );
206 
207  template< typename MT2, bool SO2 >
208  inline StrictlyUpperMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
209 
210  template< typename Other >
211  inline EnableIf_< IsNumeric<Other>, StrictlyUpperMatrix >& operator*=( Other rhs );
212 
213  template< typename Other >
214  inline EnableIf_< IsNumeric<Other>, StrictlyUpperMatrix >& operator/=( Other rhs );
216  //**********************************************************************************************
217 
218  //**Utility functions***************************************************************************
221  inline size_t rows() const noexcept;
222  inline size_t columns() const noexcept;
223  inline size_t capacity() const noexcept;
224  inline size_t capacity( size_t i ) const noexcept;
225  inline size_t nonZeros() const;
226  inline size_t nonZeros( size_t i ) const;
227  inline void reset();
228  inline void reset( size_t i );
229  inline void clear();
230  inline Iterator set( size_t i, size_t j, const ElementType& value );
231  inline Iterator insert( size_t i, size_t j, const ElementType& value );
232  inline void erase( size_t i, size_t j );
233  inline Iterator erase( size_t i, Iterator pos );
234  inline Iterator erase( size_t i, Iterator first, Iterator last );
235  inline void resize ( size_t n, bool preserve=true );
236  inline void reserve( size_t nonzeros );
237  inline void reserve( size_t i, size_t nonzeros );
238  inline void trim();
239  inline void trim( size_t i );
240 
241  template< typename Other > inline StrictlyUpperMatrix& scale( const Other& scalar );
242  template< typename Other > inline StrictlyUpperMatrix& scaleDiagonal( Other scale );
243 
244  inline void swap( StrictlyUpperMatrix& m ) noexcept;
245 
246  static inline constexpr size_t maxNonZeros() noexcept;
247  static inline constexpr size_t maxNonZeros( size_t n ) noexcept;
249  //**********************************************************************************************
250 
251  //**Lookup functions****************************************************************************
254  inline Iterator find ( size_t i, size_t j );
255  inline ConstIterator find ( size_t i, size_t j ) const;
256  inline Iterator lowerBound( size_t i, size_t j );
257  inline ConstIterator lowerBound( size_t i, size_t j ) const;
258  inline Iterator upperBound( size_t i, size_t j );
259  inline ConstIterator upperBound( size_t i, size_t j ) const;
261  //**********************************************************************************************
262 
263  //**Low-level utility functions*****************************************************************
266  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
267  inline void finalize( size_t i );
269  //**********************************************************************************************
270 
271  //**Debugging functions*************************************************************************
274  inline bool isIntact() const noexcept;
276  //**********************************************************************************************
277 
278  //**Expression template evaluation functions****************************************************
281  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
282  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
283 
284  inline bool canSMPAssign() const noexcept;
286  //**********************************************************************************************
287 
288  private:
289  //**Utility functions***************************************************************************
292  inline void resetLower();
294  //**********************************************************************************************
295 
296  //**Member variables****************************************************************************
299  MT matrix_;
300 
301  //**********************************************************************************************
302 
303  //**Friend declarations*************************************************************************
304  template< typename MT2, bool SO2, bool DF2 >
305  friend MT2& derestrict( StrictlyUpperMatrix<MT2,SO2,DF2>& m );
306  //**********************************************************************************************
307 
308  //**Compile time checks*************************************************************************
321  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
322  //**********************************************************************************************
323 };
325 //*************************************************************************************************
326 
327 
328 
329 
330 //=================================================================================================
331 //
332 // CONSTRUCTORS
333 //
334 //=================================================================================================
335 
336 //*************************************************************************************************
340 template< typename MT // Type of the adapted sparse matrix
341  , bool SO > // Storage order of the adapted sparse matrix
342 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix()
343  : matrix_() // The adapted sparse matrix
344 {
345  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
346 }
348 //*************************************************************************************************
349 
350 
351 //*************************************************************************************************
359 template< typename MT // Type of the adapted sparse matrix
360  , bool SO > // Storage order of the adapted sparse matrix
361 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( size_t n )
362  : matrix_( n, n, n ) // The adapted sparse matrix
363 {
365 
366  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
367 }
369 //*************************************************************************************************
370 
371 
372 //*************************************************************************************************
382 template< typename MT // Type of the adapted sparse matrix
383  , bool SO > // Storage order of the adapted sparse matrix
384 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( size_t n, size_t nonzeros )
385  : matrix_( n, n, max( nonzeros, n ) ) // The adapted sparse matrix
386 {
388 
389  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
390 }
392 //*************************************************************************************************
393 
394 
395 //*************************************************************************************************
409 template< typename MT // Type of the adapted sparse matrix
410  , bool SO > // Storage order of the adapted sparse matrix
411 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( size_t n, const std::vector<size_t>& nonzeros )
412  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
413 {
415 
416  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
417 }
419 //*************************************************************************************************
420 
421 
422 //*************************************************************************************************
428 template< typename MT // Type of the adapted sparse matrix
429  , bool SO > // Storage order of the adapted sparse matrix
430 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( const StrictlyUpperMatrix& m )
431  : matrix_( m.matrix_ ) // The adapted sparse matrix
432 {
433  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
434  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
435 }
437 //*************************************************************************************************
438 
439 
440 //*************************************************************************************************
446 template< typename MT // Type of the adapted sparse matrix
447  , bool SO > // Storage order of the adapted sparse matrix
448 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( StrictlyUpperMatrix&& m ) noexcept
449  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
450 {
451  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
452  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
453 }
455 //*************************************************************************************************
456 
457 
458 //*************************************************************************************************
469 template< typename MT // Type of the adapted sparse matrix
470  , bool SO > // Storage order of the adapted sparse matrix
471 template< typename MT2 // Type of the foreign matrix
472  , bool SO2 > // Storage order of the foreign matrix
473 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( const Matrix<MT2,SO2>& m )
474  : matrix_( ~m ) // The adapted sparse matrix
475 {
476  if( IsUniTriangular<MT2>::value ||
477  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( matrix_ ) ) ) {
478  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly upper matrix" );
479  }
480 
481  if( !IsStrictlyUpper<MT2>::value )
482  resetLower();
483 
484  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
485  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
486 }
488 //*************************************************************************************************
489 
490 
491 
492 
493 //=================================================================================================
494 //
495 // DATA ACCESS FUNCTIONS
496 //
497 //=================================================================================================
498 
499 //*************************************************************************************************
515 template< typename MT // Type of the adapted sparse matrix
516  , bool SO > // Storage order of the adapted sparse matrix
518  StrictlyUpperMatrix<MT,SO,false>::operator()( size_t i, size_t j )
519 {
520  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
521  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
522 
523  return Reference( matrix_, i, j );
524 }
526 //*************************************************************************************************
527 
528 
529 //*************************************************************************************************
545 template< typename MT // Type of the adapted sparse matrix
546  , bool SO > // Storage order of the adapted sparse matrix
548  StrictlyUpperMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
549 {
550  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
551  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
552 
553  return matrix_(i,j);
554 }
556 //*************************************************************************************************
557 
558 
559 //*************************************************************************************************
576 template< typename MT // Type of the adapted sparse matrix
577  , bool SO > // Storage order of the adapted sparse matrix
579  StrictlyUpperMatrix<MT,SO,false>::at( size_t i, size_t j )
580 {
581  if( i >= rows() ) {
582  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
583  }
584  if( j >= columns() ) {
585  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
586  }
587  return (*this)(i,j);
588 }
590 //*************************************************************************************************
591 
592 
593 //*************************************************************************************************
610 template< typename MT // Type of the adapted sparse matrix
611  , bool SO > // Storage order of the adapted sparse matrix
613  StrictlyUpperMatrix<MT,SO,false>::at( size_t i, size_t j ) const
614 {
615  if( i >= rows() ) {
616  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
617  }
618  if( j >= columns() ) {
619  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
620  }
621  return (*this)(i,j);
622 }
624 //*************************************************************************************************
625 
626 
627 //*************************************************************************************************
639 template< typename MT // Type of the adapted sparse matrix
640  , bool SO > // Storage order of the adapted sparse matrix
643 {
644  return matrix_.begin(i);
645 }
647 //*************************************************************************************************
648 
649 
650 //*************************************************************************************************
662 template< typename MT // Type of the adapted sparse matrix
663  , bool SO > // Storage order of the adapted sparse matrix
666 {
667  return matrix_.begin(i);
668 }
670 //*************************************************************************************************
671 
672 
673 //*************************************************************************************************
685 template< typename MT // Type of the adapted sparse matrix
686  , bool SO > // Storage order of the adapted sparse matrix
689 {
690  return matrix_.cbegin(i);
691 }
693 //*************************************************************************************************
694 
695 
696 //*************************************************************************************************
708 template< typename MT // Type of the adapted sparse matrix
709  , bool SO > // Storage order of the adapted sparse matrix
712 {
713  return matrix_.end(i);
714 }
716 //*************************************************************************************************
717 
718 
719 //*************************************************************************************************
731 template< typename MT // Type of the adapted sparse matrix
732  , bool SO > // Storage order of the adapted sparse matrix
734  StrictlyUpperMatrix<MT,SO,false>::end( size_t i ) const
735 {
736  return matrix_.end(i);
737 }
739 //*************************************************************************************************
740 
741 
742 //*************************************************************************************************
754 template< typename MT // Type of the adapted sparse matrix
755  , bool SO > // Storage order of the adapted sparse matrix
758 {
759  return matrix_.cend(i);
760 }
762 //*************************************************************************************************
763 
764 
765 
766 
767 //=================================================================================================
768 //
769 // ASSIGNMENT OPERATORS
770 //
771 //=================================================================================================
772 
773 //*************************************************************************************************
783 template< typename MT // Type of the adapted sparse matrix
784  , bool SO > // Storage order of the adapted sparse matrix
785 inline StrictlyUpperMatrix<MT,SO,false>&
786  StrictlyUpperMatrix<MT,SO,false>::operator=( const StrictlyUpperMatrix& rhs )
787 {
788  matrix_ = rhs.matrix_;
789 
790  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
791  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
792 
793  return *this;
794 }
796 //*************************************************************************************************
797 
798 
799 //*************************************************************************************************
806 template< typename MT // Type of the adapted sparse matrix
807  , bool SO > // Storage order of the adapted sparse matrix
808 inline StrictlyUpperMatrix<MT,SO,false>&
809  StrictlyUpperMatrix<MT,SO,false>::operator=( StrictlyUpperMatrix&& rhs ) noexcept
810 {
811  matrix_ = std::move( rhs.matrix_ );
812 
813  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
814  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
815 
816  return *this;
817 }
819 //*************************************************************************************************
820 
821 
822 //*************************************************************************************************
835 template< typename MT // Type of the adapted sparse matrix
836  , bool SO > // Storage order of the adapted sparse matrix
837 template< typename MT2 // Type of the right-hand side matrix
838  , bool SO2 > // Storage order of the right-hand side matrix
839 inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
840  StrictlyUpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
841 {
842  if( IsUniTriangular<MT2>::value ||
843  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
844  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
845  }
846 
847  matrix_ = ~rhs;
848 
849  if( !IsStrictlyUpper<MT2>::value )
850  resetLower();
851 
852  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
853  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
854 
855  return *this;
856 }
858 //*************************************************************************************************
859 
860 
861 //*************************************************************************************************
874 template< typename MT // Type of the adapted sparse matrix
875  , bool SO > // Storage order of the adapted sparse matrix
876 template< typename MT2 // Type of the right-hand side matrix
877  , bool SO2 > // Storage order of the right-hand side matrix
878 inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
879  StrictlyUpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
880 {
881  if( IsUniTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
882  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
883  }
884 
885  if( IsStrictlyUpper<MT2>::value ) {
886  matrix_ = ~rhs;
887  }
888  else {
889  MT tmp( ~rhs );
890 
891  if( !isStrictlyUpper( tmp ) ) {
892  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
893  }
894 
895  matrix_ = std::move( tmp );
896  }
897 
898  if( !IsStrictlyUpper<MT2>::value )
899  resetLower();
900 
901  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
902  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
903 
904  return *this;
905 }
907 //*************************************************************************************************
908 
909 
910 //*************************************************************************************************
923 template< typename MT // Type of the adapted sparse matrix
924  , bool SO > // Storage order of the adapted sparse matrix
925 template< typename MT2 // Type of the right-hand side matrix
926  , bool SO2 > // Storage order of the right-hand side matrix
927 inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
928  StrictlyUpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
929 {
930  if( IsUniTriangular<MT2>::value ||
931  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
932  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
933  }
934 
935  matrix_ += ~rhs;
936 
937  if( !IsStrictlyUpper<MT2>::value )
938  resetLower();
939 
940  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
941  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
942 
943  return *this;
944 }
946 //*************************************************************************************************
947 
948 
949 //*************************************************************************************************
962 template< typename MT // Type of the adapted sparse matrix
963  , bool SO > // Storage order of the adapted sparse matrix
964 template< typename MT2 // Type of the right-hand side matrix
965  , bool SO2 > // Storage order of the right-hand side matrix
966 inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
967  StrictlyUpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
968 {
969  if( IsUniTriangular<MT2>::value || ( IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
970  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
971  }
972 
973  if( IsStrictlyUpper<MT2>::value ) {
974  matrix_ += ~rhs;
975  }
976  else {
977  const ResultType_<MT2> tmp( ~rhs );
978 
979  if( !isStrictlyUpper( tmp ) ) {
980  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
981  }
982 
983  matrix_ += tmp;
984  }
985 
986  if( !IsStrictlyUpper<MT2>::value )
987  resetLower();
988 
989  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
990  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
991 
992  return *this;
993 }
995 //*************************************************************************************************
996 
997 
998 //*************************************************************************************************
1011 template< typename MT // Type of the adapted sparse matrix
1012  , bool SO > // Storage order of the adapted sparse matrix
1013 template< typename MT2 // Type of the right-hand side matrix
1014  , bool SO2 > // Storage order of the right-hand side matrix
1015 inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
1016  StrictlyUpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1017 {
1018  if( IsUniTriangular<MT2>::value ||
1019  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
1020  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1021  }
1022 
1023  matrix_ -= ~rhs;
1024 
1025  if( !IsStrictlyUpper<MT2>::value )
1026  resetLower();
1027 
1028  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1029  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1030 
1031  return *this;
1032 }
1034 //*************************************************************************************************
1035 
1036 
1037 //*************************************************************************************************
1050 template< typename MT // Type of the adapted sparse matrix
1051  , bool SO > // Storage order of the adapted sparse matrix
1052 template< typename MT2 // Type of the right-hand side matrix
1053  , bool SO2 > // Storage order of the right-hand side matrix
1054 inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
1055  StrictlyUpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1056 {
1057  if( IsUniTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1058  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1059  }
1060 
1061  if( IsStrictlyUpper<MT2>::value ) {
1062  matrix_ -= ~rhs;
1063  }
1064  else {
1065  const ResultType_<MT2> tmp( ~rhs );
1066 
1067  if( !isStrictlyUpper( tmp ) ) {
1068  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1069  }
1070 
1071  matrix_ -= tmp;
1072  }
1073 
1074  if( !IsStrictlyUpper<MT2>::value )
1075  resetLower();
1076 
1077  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1078  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1079 
1080  return *this;
1081 }
1083 //*************************************************************************************************
1084 
1085 
1086 //*************************************************************************************************
1098 template< typename MT // Type of the adapted sparse matrix
1099  , bool SO > // Storage order of the adapted sparse matrix
1100 template< typename MT2 // Type of the right-hand side matrix
1101  , bool SO2 > // Storage order of the right-hand side matrix
1102 inline StrictlyUpperMatrix<MT,SO,false>&
1103  StrictlyUpperMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1104 {
1105  if( matrix_.rows() != (~rhs).columns() ) {
1106  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1107  }
1108 
1109  MT tmp( matrix_ * ~rhs );
1110 
1111  if( !isStrictlyUpper( tmp ) ) {
1112  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1113  }
1114 
1115  matrix_ = std::move( tmp );
1116 
1117  if( !IsStrictlyUpper<MT2>::value )
1118  resetLower();
1119 
1120  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1121  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1122 
1123  return *this;
1124 }
1126 //*************************************************************************************************
1127 
1128 
1129 //*************************************************************************************************
1137 template< typename MT // Type of the adapted sparse matrix
1138  , bool SO > // Storage order of the adapted sparse matrix
1139 template< typename Other > // Data type of the right-hand side scalar
1140 inline EnableIf_< IsNumeric<Other>, StrictlyUpperMatrix<MT,SO,false> >&
1142 {
1143  matrix_ *= rhs;
1144  return *this;
1145 }
1146 //*************************************************************************************************
1147 
1148 
1149 //*************************************************************************************************
1157 template< typename MT // Type of the adapted sparse matrix
1158  , bool SO > // Storage order of the adapted sparse matrix
1159 template< typename Other > // Data type of the right-hand side scalar
1160 inline EnableIf_< IsNumeric<Other>, StrictlyUpperMatrix<MT,SO,false> >&
1162 {
1163  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1164 
1165  matrix_ /= rhs;
1166  return *this;
1167 }
1169 //*************************************************************************************************
1170 
1171 
1172 
1173 
1174 //=================================================================================================
1175 //
1176 // UTILITY FUNCTIONS
1177 //
1178 //=================================================================================================
1179 
1180 //*************************************************************************************************
1186 template< typename MT // Type of the adapted sparse matrix
1187  , bool SO > // Storage order of the adapted sparse matrix
1188 inline size_t StrictlyUpperMatrix<MT,SO,false>::rows() const noexcept
1189 {
1190  return matrix_.rows();
1191 }
1193 //*************************************************************************************************
1194 
1195 
1196 //*************************************************************************************************
1202 template< typename MT // Type of the adapted sparse matrix
1203  , bool SO > // Storage order of the adapted sparse matrix
1204 inline size_t StrictlyUpperMatrix<MT,SO,false>::columns() const noexcept
1205 {
1206  return matrix_.columns();
1207 }
1209 //*************************************************************************************************
1210 
1211 
1212 //*************************************************************************************************
1218 template< typename MT // Type of the adapted sparse matrix
1219  , bool SO > // Storage order of the adapted sparse matrix
1220 inline size_t StrictlyUpperMatrix<MT,SO,false>::capacity() const noexcept
1221 {
1222  return matrix_.capacity();
1223 }
1225 //*************************************************************************************************
1226 
1227 
1228 //*************************************************************************************************
1240 template< typename MT // Type of the adapted sparse matrix
1241  , bool SO > // Storage order of the adapted sparse matrix
1242 inline size_t StrictlyUpperMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1243 {
1244  return matrix_.capacity(i);
1245 }
1247 //*************************************************************************************************
1248 
1249 
1250 //*************************************************************************************************
1256 template< typename MT // Type of the adapted sparse matrix
1257  , bool SO > // Storage order of the adapted sparse matrix
1258 inline size_t StrictlyUpperMatrix<MT,SO,false>::nonZeros() const
1259 {
1260  return matrix_.nonZeros();
1261 }
1263 //*************************************************************************************************
1264 
1265 
1266 //*************************************************************************************************
1278 template< typename MT // Type of the adapted sparse matrix
1279  , bool SO > // Storage order of the adapted sparse matrix
1280 inline size_t StrictlyUpperMatrix<MT,SO,false>::nonZeros( size_t i ) const
1281 {
1282  return matrix_.nonZeros(i);
1283 }
1285 //*************************************************************************************************
1286 
1287 
1288 //*************************************************************************************************
1294 template< typename MT // Type of the adapted sparse matrix
1295  , bool SO > // Storage order of the adapted sparse matrix
1297 {
1298  if( SO ) {
1299  for( size_t j=1UL; j<columns(); ++j ) {
1300  matrix_.erase( j, matrix_.begin(j), matrix_.lowerBound(j,j) );
1301  }
1302  }
1303  else {
1304  for( size_t i=0UL; i<rows(); ++i ) {
1305  matrix_.erase( i, matrix_.lowerBound(i,i+1UL), matrix_.end(i) );
1306  }
1307  }
1308 }
1310 //*************************************************************************************************
1311 
1312 
1313 //*************************************************************************************************
1326 template< typename MT // Type of the adapted sparse matrix
1327  , bool SO > // Storage order of the adapted sparse matrix
1328 inline void StrictlyUpperMatrix<MT,SO,false>::reset( size_t i )
1329 {
1330  if( SO ) {
1331  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1332  }
1333  else {
1334  matrix_.erase( i, matrix_.lowerBound(i,i+1UL), matrix_.end(i) );
1335  }
1336 }
1338 //*************************************************************************************************
1339 
1340 
1341 //*************************************************************************************************
1349 template< typename MT // Type of the adapted sparse matrix
1350  , bool SO > // Storage order of the adapted sparse matrix
1352 {
1353  using blaze::clear;
1354 
1355  if( IsResizable<MT>::value ) {
1356  clear( matrix_ );
1357  }
1358  else {
1359  reset();
1360  }
1361 }
1363 //*************************************************************************************************
1364 
1365 
1366 //*************************************************************************************************
1382 template< typename MT // Type of the adapted sparse matrix
1383  , bool SO > // Storage order of the adapted sparse matrix
1385  StrictlyUpperMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1386 {
1387  if( i >= j ) {
1388  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1389  }
1390 
1391  return matrix_.set( i, j, value );
1392 }
1394 //*************************************************************************************************
1395 
1396 
1397 //*************************************************************************************************
1414 template< typename MT // Type of the adapted sparse matrix
1415  , bool SO > // Storage order of the adapted sparse matrix
1417  StrictlyUpperMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1418 {
1419  if( i >= j ) {
1420  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1421  }
1422 
1423  return matrix_.insert( i, j, value );
1424 }
1426 //*************************************************************************************************
1427 
1428 
1429 //*************************************************************************************************
1439 template< typename MT // Type of the adapted sparse matrix
1440  , bool SO > // Storage order of the adapted sparse matrix
1441 inline void StrictlyUpperMatrix<MT,SO,false>::erase( size_t i, size_t j )
1442 {
1443  matrix_.erase( i, j );
1444 }
1446 //*************************************************************************************************
1447 
1448 
1449 //*************************************************************************************************
1461 template< typename MT // Type of the adapted sparse matrix
1462  , bool SO > // Storage order of the adapted sparse matrix
1464  StrictlyUpperMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1465 {
1466  return matrix_.erase( i, pos );
1467 }
1469 //*************************************************************************************************
1470 
1471 
1472 //*************************************************************************************************
1486 template< typename MT // Type of the adapted sparse matrix
1487  , bool SO > // Storage order of the adapted sparse matrix
1489  StrictlyUpperMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1490 {
1491  return matrix_.erase( i, first, last );
1492 }
1494 //*************************************************************************************************
1495 
1496 
1497 //*************************************************************************************************
1512 template< typename MT // Type of the adapted sparse matrix
1513  , bool SO > // Storage order of the adapted sparse matrix
1514 void StrictlyUpperMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1515 {
1517 
1518  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1519 
1520  matrix_.resize( n, n, preserve );
1521 }
1523 //*************************************************************************************************
1524 
1525 
1526 //*************************************************************************************************
1537 template< typename MT // Type of the adapted sparse matrix
1538  , bool SO > // Storage order of the adapted sparse matrix
1539 inline void StrictlyUpperMatrix<MT,SO,false>::reserve( size_t nonzeros )
1540 {
1541  matrix_.reserve( nonzeros );
1542 }
1544 //*************************************************************************************************
1545 
1546 
1547 //*************************************************************************************************
1562 template< typename MT // Type of the adapted sparse matrix
1563  , bool SO > // Storage order of the adapted sparse matrix
1564 inline void StrictlyUpperMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1565 {
1566  matrix_.reserve( i, nonzeros );
1567 }
1569 //*************************************************************************************************
1570 
1571 
1572 //*************************************************************************************************
1583 template< typename MT // Type of the adapted sparse matrix
1584  , bool SO > // Storage order of the adapted sparse matrix
1585 inline void StrictlyUpperMatrix<MT,SO,false>::trim()
1586 {
1587  matrix_.trim();
1588 }
1590 //*************************************************************************************************
1591 
1592 
1593 //*************************************************************************************************
1605 template< typename MT // Type of the adapted sparse matrix
1606  , bool SO > // Storage order of the adapted sparse matrix
1607 inline void StrictlyUpperMatrix<MT,SO,false>::trim( size_t i )
1608 {
1609  matrix_.trim( i );
1610 }
1612 //*************************************************************************************************
1613 
1614 
1615 //*************************************************************************************************
1622 template< typename MT // Type of the adapted sparse matrix
1623  , bool SO > // Storage order of the adapted sparse matrix
1624 template< typename Other > // Data type of the scalar value
1625 inline StrictlyUpperMatrix<MT,SO,false>&
1626  StrictlyUpperMatrix<MT,SO,false>::scale( const Other& scalar )
1627 {
1628  matrix_.scale( scalar );
1629  return *this;
1630 }
1632 //*************************************************************************************************
1633 
1634 
1635 //*************************************************************************************************
1642 template< typename MT // Type of the adapted sparse matrix
1643  , bool SO > // Storage order of the adapted sparse matrix
1644 template< typename Other > // Data type of the scalar value
1645 inline StrictlyUpperMatrix<MT,SO,false>&
1646  StrictlyUpperMatrix<MT,SO,false>::scaleDiagonal( Other scalar )
1647 {
1648  matrix_.scaleDiagonal( scalar );
1649  return *this;
1650 }
1652 //*************************************************************************************************
1653 
1654 
1655 //*************************************************************************************************
1662 template< typename MT // Type of the adapted sparse matrix
1663  , bool SO > // Storage order of the adapted sparse matrix
1664 inline void StrictlyUpperMatrix<MT,SO,false>::swap( StrictlyUpperMatrix& m ) noexcept
1665 {
1666  using std::swap;
1667 
1668  swap( matrix_, m.matrix_ );
1669 }
1671 //*************************************************************************************************
1672 
1673 
1674 //*************************************************************************************************
1686 template< typename MT // Type of the adapted dense matrix
1687  , bool SO > // Storage order of the adapted dense matrix
1688 inline constexpr size_t StrictlyUpperMatrix<MT,SO,false>::maxNonZeros() noexcept
1689 {
1691 
1692  return maxNonZeros( Rows<MT>::value );
1693 }
1695 //*************************************************************************************************
1696 
1697 
1698 //*************************************************************************************************
1708 template< typename MT // Type of the adapted dense matrix
1709  , bool SO > // Storage order of the adapted dense matrix
1710 inline constexpr size_t StrictlyUpperMatrix<MT,SO,false>::maxNonZeros( size_t n ) noexcept
1711 {
1712  return ( ( n - 1UL ) * n ) / 2UL;
1713 }
1715 //*************************************************************************************************
1716 
1717 
1718 //*************************************************************************************************
1724 template< typename MT // Type of the adapted dense matrix
1725  , bool SO > // Storage order of the adapted dense matrix
1726 inline void StrictlyUpperMatrix<MT,SO,false>::resetLower()
1727 {
1728  if( SO ) {
1729  for( size_t j=0UL; j<columns(); ++j )
1730  matrix_.erase( j, matrix_.upperBound( j, j ), matrix_.end( j ) );
1731  }
1732  else {
1733  for( size_t i=1UL; i<rows(); ++i )
1734  matrix_.erase( i, matrix_.begin( i ), matrix_.lowerBound( i, i ) );
1735  }
1736 }
1738 //*************************************************************************************************
1739 
1740 
1741 
1742 
1743 //=================================================================================================
1744 //
1745 // LOOKUP FUNCTIONS
1746 //
1747 //=================================================================================================
1748 
1749 //*************************************************************************************************
1765 template< typename MT // Type of the adapted sparse matrix
1766  , bool SO > // Storage order of the adapted sparse matrix
1768  StrictlyUpperMatrix<MT,SO,false>::find( size_t i, size_t j )
1769 {
1770  return matrix_.find( i, j );
1771 }
1773 //*************************************************************************************************
1774 
1775 
1776 //*************************************************************************************************
1792 template< typename MT // Type of the adapted sparse matrix
1793  , bool SO > // Storage order of the adapted sparse matrix
1795  StrictlyUpperMatrix<MT,SO,false>::find( size_t i, size_t j ) const
1796 {
1797  return matrix_.find( i, j );
1798 }
1800 //*************************************************************************************************
1801 
1802 
1803 //*************************************************************************************************
1819 template< typename MT // Type of the adapted sparse matrix
1820  , bool SO > // Storage order of the adapted sparse matrix
1822  StrictlyUpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
1823 {
1824  return matrix_.lowerBound( i, j );
1825 }
1827 //*************************************************************************************************
1828 
1829 
1830 //*************************************************************************************************
1846 template< typename MT // Type of the adapted sparse matrix
1847  , bool SO > // Storage order of the adapted sparse matrix
1849  StrictlyUpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
1850 {
1851  return matrix_.lowerBound( i, j );
1852 }
1854 //*************************************************************************************************
1855 
1856 
1857 //*************************************************************************************************
1873 template< typename MT // Type of the adapted sparse matrix
1874  , bool SO > // Storage order of the adapted sparse matrix
1876  StrictlyUpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
1877 {
1878  return matrix_.upperBound( i, j );
1879 }
1881 //*************************************************************************************************
1882 
1883 
1884 //*************************************************************************************************
1900 template< typename MT // Type of the adapted sparse matrix
1901  , bool SO > // Storage order of the adapted sparse matrix
1903  StrictlyUpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
1904 {
1905  return matrix_.upperBound( i, j );
1906 }
1908 //*************************************************************************************************
1909 
1910 
1911 
1912 
1913 //=================================================================================================
1914 //
1915 // LOW-LEVEL UTILITY FUNCTIONS
1916 //
1917 //=================================================================================================
1918 
1919 //*************************************************************************************************
1969 template< typename MT // Type of the adapted sparse matrix
1970  , bool SO > // Storage order of the adapted sparse matrix
1971 inline void StrictlyUpperMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1972 {
1973  if( i >= j ) {
1974  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1975  }
1976 
1977  matrix_.append( i, j, value, check );
1978 }
1980 //*************************************************************************************************
1981 
1982 
1983 //*************************************************************************************************
1997 template< typename MT // Type of the adapted sparse matrix
1998  , bool SO > // Storage order of the adapted sparse matrix
1999 inline void StrictlyUpperMatrix<MT,SO,false>::finalize( size_t i )
2000 {
2001  matrix_.finalize( i );
2002 }
2004 //*************************************************************************************************
2005 
2006 
2007 
2008 
2009 //=================================================================================================
2010 //
2011 // DEBUGGING FUNCTIONS
2012 //
2013 //=================================================================================================
2014 
2015 //*************************************************************************************************
2025 template< typename MT // Type of the adapted sparse matrix
2026  , bool SO > // Storage order of the adapted sparse matrix
2027 inline bool StrictlyUpperMatrix<MT,SO,false>::isIntact() const noexcept
2028 {
2029  using blaze::isIntact;
2030 
2031  return ( isIntact( matrix_ ) && isStrictlyUpper( matrix_ ) );
2032 }
2034 //*************************************************************************************************
2035 
2036 
2037 
2038 
2039 //=================================================================================================
2040 //
2041 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2042 //
2043 //=================================================================================================
2044 
2045 //*************************************************************************************************
2056 template< typename MT // Type of the adapted sparse matrix
2057  , bool SO > // Storage order of the adapted sparse matrix
2058 template< typename Other > // Data type of the foreign expression
2059 inline bool StrictlyUpperMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2060 {
2061  return matrix_.canAlias( alias );
2062 }
2064 //*************************************************************************************************
2065 
2066 
2067 //*************************************************************************************************
2078 template< typename MT // Type of the adapted sparse matrix
2079  , bool SO > // Storage order of the adapted sparse matrix
2080 template< typename Other > // Data type of the foreign expression
2081 inline bool StrictlyUpperMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2082 {
2083  return matrix_.isAliased( alias );
2084 }
2086 //*************************************************************************************************
2087 
2088 
2089 //*************************************************************************************************
2100 template< typename MT // Type of the adapted sparse matrix
2101  , bool SO > // Storage order of the adapted sparse matrix
2102 inline bool StrictlyUpperMatrix<MT,SO,false>::canSMPAssign() const noexcept
2103 {
2104  return matrix_.canSMPAssign();
2105 }
2107 //*************************************************************************************************
2108 
2109 } // namespace blaze
2110 
2111 #endif
Header file for the StrictlyUpperProxy class.
#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.
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.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:346
Header file for basic type definitions.
bool isStrictlyUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly upper triangular matrix.
Definition: DenseMatrix.h:1423
#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:1339
Constraint on the data type.
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:188
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2643
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5077
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2636
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:384
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Constraint on the data type.
STL namespace.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1716
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2639
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:298
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:232
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
Header file for utility functions for sparse matrices.
Header file for the IsSquare type trait.
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the IsStrictlyUpper type trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5148
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5131
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the Columns type trait.
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:330
Header file for the IsUniTriangular type trait.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2640
Constraints on the storage order of matrix types.
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:81
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:538
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:254
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2641
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the implementation of the base template of the StrictlyUpperMatrix.
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
Header file for all adaptor forward declarations.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2642
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:258
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_RESIZABLE(T)
Constraint on the data type.In case the given data type T is resizable, i.e. has a 'resize' member fu...
Definition: Resizable.h:81
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:314
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2637
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a 'res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2638
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:609
Header file for the IsResizable type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:61