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 NewType > // Data type of the other matrix
130  struct Rebind {
132  typedef StrictlyUpperMatrix< typename MT::template Rebind<NewType>::Other > Other;
133  };
134  //**********************************************************************************************
135 
136  //**Resize struct definition********************************************************************
139  template< size_t NewM // Number of rows of the other matrix
140  , size_t NewN > // Number of columns of the other matrix
141  struct Resize {
143  typedef StrictlyUpperMatrix< typename MT::template Resize<NewM,NewN>::Other > Other;
144  };
145  //**********************************************************************************************
146 
147  //**Compilation flags***************************************************************************
149  enum : bool { smpAssignable = false };
150  //**********************************************************************************************
151 
152  //**Constructors********************************************************************************
155  explicit inline StrictlyUpperMatrix();
156  explicit inline StrictlyUpperMatrix( size_t n );
157  explicit inline StrictlyUpperMatrix( size_t n, size_t nonzeros );
158  explicit inline StrictlyUpperMatrix( size_t n, const std::vector<size_t>& nonzeros );
159 
160  inline StrictlyUpperMatrix( const StrictlyUpperMatrix& m );
161  inline StrictlyUpperMatrix( StrictlyUpperMatrix&& m ) noexcept;
162 
163  template< typename MT2, bool SO2 >
164  inline StrictlyUpperMatrix( const Matrix<MT2,SO2>& m );
166  //**********************************************************************************************
167 
168  //**Destructor**********************************************************************************
169  // No explicitly declared destructor.
170  //**********************************************************************************************
171 
172  //**Data access functions***********************************************************************
175  inline Reference operator()( size_t i, size_t j );
176  inline ConstReference operator()( size_t i, size_t j ) const;
177  inline Reference at( size_t i, size_t j );
178  inline ConstReference at( size_t i, size_t j ) const;
179  inline Iterator begin ( size_t i );
180  inline ConstIterator begin ( size_t i ) const;
181  inline ConstIterator cbegin( size_t i ) const;
182  inline Iterator end ( size_t i );
183  inline ConstIterator end ( size_t i ) const;
184  inline ConstIterator cend ( size_t i ) const;
186  //**********************************************************************************************
187 
188  //**Assignment operators************************************************************************
191  inline StrictlyUpperMatrix& operator=( const StrictlyUpperMatrix& rhs );
192  inline StrictlyUpperMatrix& operator=( StrictlyUpperMatrix&& rhs ) noexcept;
193 
194  template< typename MT2, bool SO2 >
195  inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
196  operator=( const Matrix<MT2,SO2>& rhs );
197 
198  template< typename MT2, bool SO2 >
199  inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
200  operator=( const Matrix<MT2,SO2>& rhs );
201 
202  template< typename MT2, bool SO2 >
203  inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
204  operator+=( const Matrix<MT2,SO2>& rhs );
205 
206  template< typename MT2, bool SO2 >
207  inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
208  operator+=( const Matrix<MT2,SO2>& rhs );
209 
210  template< typename MT2, bool SO2 >
211  inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
212  operator-=( const Matrix<MT2,SO2>& rhs );
213 
214  template< typename MT2, bool SO2 >
215  inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
216  operator-=( const Matrix<MT2,SO2>& rhs );
217 
218  template< typename MT2, bool SO2 >
219  inline StrictlyUpperMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
220 
221  template< typename Other >
222  inline EnableIf_< IsNumeric<Other>, StrictlyUpperMatrix >& operator*=( Other rhs );
223 
224  template< typename Other >
225  inline EnableIf_< IsNumeric<Other>, StrictlyUpperMatrix >& operator/=( Other rhs );
227  //**********************************************************************************************
228 
229  //**Utility functions***************************************************************************
232  inline size_t rows() const noexcept;
233  inline size_t columns() const noexcept;
234  inline size_t capacity() const noexcept;
235  inline size_t capacity( size_t i ) const noexcept;
236  inline size_t nonZeros() const;
237  inline size_t nonZeros( size_t i ) const;
238  inline void reset();
239  inline void reset( size_t i );
240  inline void clear();
241  inline void resize ( size_t n, bool preserve=true );
242  inline void reserve( size_t nonzeros );
243  inline void reserve( size_t i, size_t nonzeros );
244  inline void trim();
245  inline void trim( size_t i );
246  inline void swap( StrictlyUpperMatrix& m ) noexcept;
247 
248  static inline constexpr size_t maxNonZeros() noexcept;
249  static inline constexpr size_t maxNonZeros( size_t n ) noexcept;
251  //**********************************************************************************************
252 
253  //**Insertion functions*************************************************************************
256  inline Iterator set ( size_t i, size_t j, const ElementType& value );
257  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
258  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
259  inline void finalize( size_t i );
261  //**********************************************************************************************
262 
263  //**Erase functions*****************************************************************************
266  inline void erase( size_t i, size_t j );
267  inline Iterator erase( size_t i, Iterator pos );
268  inline Iterator erase( size_t i, Iterator first, Iterator last );
269 
270  template< typename Pred >
271  inline void erase( Pred predicate );
272 
273  template< typename Pred >
274  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
276  //**********************************************************************************************
277 
278  //**Lookup functions****************************************************************************
281  inline Iterator find ( size_t i, size_t j );
282  inline ConstIterator find ( size_t i, size_t j ) const;
283  inline Iterator lowerBound( size_t i, size_t j );
284  inline ConstIterator lowerBound( size_t i, size_t j ) const;
285  inline Iterator upperBound( size_t i, size_t j );
286  inline ConstIterator upperBound( size_t i, size_t j ) const;
288  //**********************************************************************************************
289 
290  //**Numeric functions***************************************************************************
293  template< typename Other > inline StrictlyUpperMatrix& scale( const Other& scalar );
294  template< typename Other > inline StrictlyUpperMatrix& scaleDiagonal( const Other& scale );
296  //**********************************************************************************************
297 
298  //**Debugging functions*************************************************************************
301  inline bool isIntact() const noexcept;
303  //**********************************************************************************************
304 
305  //**Expression template evaluation functions****************************************************
308  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
309  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
310 
311  inline bool canSMPAssign() const noexcept;
313  //**********************************************************************************************
314 
315  private:
316  //**Utility functions***************************************************************************
319  inline void resetLower();
321  //**********************************************************************************************
322 
323  //**Member variables****************************************************************************
326  MT matrix_;
327 
328  //**********************************************************************************************
329 
330  //**Friend declarations*************************************************************************
331  template< typename MT2, bool SO2, bool DF2 >
332  friend MT2& derestrict( StrictlyUpperMatrix<MT2,SO2,DF2>& m );
333  //**********************************************************************************************
334 
335  //**Compile time checks*************************************************************************
348  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
349  //**********************************************************************************************
350 };
352 //*************************************************************************************************
353 
354 
355 
356 
357 //=================================================================================================
358 //
359 // CONSTRUCTORS
360 //
361 //=================================================================================================
362 
363 //*************************************************************************************************
367 template< typename MT // Type of the adapted sparse matrix
368  , bool SO > // Storage order of the adapted sparse matrix
369 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix()
370  : matrix_() // The adapted sparse matrix
371 {
372  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
373 }
375 //*************************************************************************************************
376 
377 
378 //*************************************************************************************************
386 template< typename MT // Type of the adapted sparse matrix
387  , bool SO > // Storage order of the adapted sparse matrix
388 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( size_t n )
389  : matrix_( n, n, n ) // The adapted sparse matrix
390 {
392 
393  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
394 }
396 //*************************************************************************************************
397 
398 
399 //*************************************************************************************************
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, size_t nonzeros )
412  : matrix_( n, n, max( nonzeros, n ) ) // The adapted sparse matrix
413 {
415 
416  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
417 }
419 //*************************************************************************************************
420 
421 
422 //*************************************************************************************************
436 template< typename MT // Type of the adapted sparse matrix
437  , bool SO > // Storage order of the adapted sparse matrix
438 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( size_t n, const std::vector<size_t>& nonzeros )
439  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
440 {
442 
443  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
444 }
446 //*************************************************************************************************
447 
448 
449 //*************************************************************************************************
455 template< typename MT // Type of the adapted sparse matrix
456  , bool SO > // Storage order of the adapted sparse matrix
457 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( const StrictlyUpperMatrix& m )
458  : matrix_( m.matrix_ ) // The adapted sparse matrix
459 {
460  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
461  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
462 }
464 //*************************************************************************************************
465 
466 
467 //*************************************************************************************************
473 template< typename MT // Type of the adapted sparse matrix
474  , bool SO > // Storage order of the adapted sparse matrix
475 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( StrictlyUpperMatrix&& m ) noexcept
476  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
477 {
478  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
479  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
480 }
482 //*************************************************************************************************
483 
484 
485 //*************************************************************************************************
496 template< typename MT // Type of the adapted sparse matrix
497  , bool SO > // Storage order of the adapted sparse matrix
498 template< typename MT2 // Type of the foreign matrix
499  , bool SO2 > // Storage order of the foreign matrix
500 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( const Matrix<MT2,SO2>& m )
501  : matrix_( ~m ) // The adapted sparse matrix
502 {
503  if( IsUniTriangular<MT2>::value ||
504  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( matrix_ ) ) ) {
505  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly upper matrix" );
506  }
507 
508  if( !IsStrictlyUpper<MT2>::value )
509  resetLower();
510 
511  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
512  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
513 }
515 //*************************************************************************************************
516 
517 
518 
519 
520 //=================================================================================================
521 //
522 // DATA ACCESS FUNCTIONS
523 //
524 //=================================================================================================
525 
526 //*************************************************************************************************
542 template< typename MT // Type of the adapted sparse matrix
543  , bool SO > // Storage order of the adapted sparse matrix
545  StrictlyUpperMatrix<MT,SO,false>::operator()( size_t i, size_t j )
546 {
547  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
548  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
549 
550  return Reference( matrix_, i, j );
551 }
553 //*************************************************************************************************
554 
555 
556 //*************************************************************************************************
572 template< typename MT // Type of the adapted sparse matrix
573  , bool SO > // Storage order of the adapted sparse matrix
575  StrictlyUpperMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
576 {
577  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
578  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
579 
580  return matrix_(i,j);
581 }
583 //*************************************************************************************************
584 
585 
586 //*************************************************************************************************
603 template< typename MT // Type of the adapted sparse matrix
604  , bool SO > // Storage order of the adapted sparse matrix
606  StrictlyUpperMatrix<MT,SO,false>::at( size_t i, size_t j )
607 {
608  if( i >= rows() ) {
609  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
610  }
611  if( j >= columns() ) {
612  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
613  }
614  return (*this)(i,j);
615 }
617 //*************************************************************************************************
618 
619 
620 //*************************************************************************************************
637 template< typename MT // Type of the adapted sparse matrix
638  , bool SO > // Storage order of the adapted sparse matrix
640  StrictlyUpperMatrix<MT,SO,false>::at( size_t i, size_t j ) const
641 {
642  if( i >= rows() ) {
643  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
644  }
645  if( j >= columns() ) {
646  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
647  }
648  return (*this)(i,j);
649 }
651 //*************************************************************************************************
652 
653 
654 //*************************************************************************************************
666 template< typename MT // Type of the adapted sparse matrix
667  , bool SO > // Storage order of the adapted sparse matrix
670 {
671  return matrix_.begin(i);
672 }
674 //*************************************************************************************************
675 
676 
677 //*************************************************************************************************
689 template< typename MT // Type of the adapted sparse matrix
690  , bool SO > // Storage order of the adapted sparse matrix
693 {
694  return matrix_.begin(i);
695 }
697 //*************************************************************************************************
698 
699 
700 //*************************************************************************************************
712 template< typename MT // Type of the adapted sparse matrix
713  , bool SO > // Storage order of the adapted sparse matrix
716 {
717  return matrix_.cbegin(i);
718 }
720 //*************************************************************************************************
721 
722 
723 //*************************************************************************************************
735 template< typename MT // Type of the adapted sparse matrix
736  , bool SO > // Storage order of the adapted sparse matrix
739 {
740  return matrix_.end(i);
741 }
743 //*************************************************************************************************
744 
745 
746 //*************************************************************************************************
758 template< typename MT // Type of the adapted sparse matrix
759  , bool SO > // Storage order of the adapted sparse matrix
761  StrictlyUpperMatrix<MT,SO,false>::end( size_t i ) const
762 {
763  return matrix_.end(i);
764 }
766 //*************************************************************************************************
767 
768 
769 //*************************************************************************************************
781 template< typename MT // Type of the adapted sparse matrix
782  , bool SO > // Storage order of the adapted sparse matrix
785 {
786  return matrix_.cend(i);
787 }
789 //*************************************************************************************************
790 
791 
792 
793 
794 //=================================================================================================
795 //
796 // ASSIGNMENT OPERATORS
797 //
798 //=================================================================================================
799 
800 //*************************************************************************************************
810 template< typename MT // Type of the adapted sparse matrix
811  , bool SO > // Storage order of the adapted sparse matrix
812 inline StrictlyUpperMatrix<MT,SO,false>&
813  StrictlyUpperMatrix<MT,SO,false>::operator=( const StrictlyUpperMatrix& rhs )
814 {
815  matrix_ = rhs.matrix_;
816 
817  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
818  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
819 
820  return *this;
821 }
823 //*************************************************************************************************
824 
825 
826 //*************************************************************************************************
833 template< typename MT // Type of the adapted sparse matrix
834  , bool SO > // Storage order of the adapted sparse matrix
835 inline StrictlyUpperMatrix<MT,SO,false>&
836  StrictlyUpperMatrix<MT,SO,false>::operator=( StrictlyUpperMatrix&& rhs ) noexcept
837 {
838  matrix_ = std::move( rhs.matrix_ );
839 
840  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
841  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
842 
843  return *this;
844 }
846 //*************************************************************************************************
847 
848 
849 //*************************************************************************************************
862 template< typename MT // Type of the adapted sparse matrix
863  , bool SO > // Storage order of the adapted sparse matrix
864 template< typename MT2 // Type of the right-hand side matrix
865  , bool SO2 > // Storage order of the right-hand side matrix
866 inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
867  StrictlyUpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
868 {
869  if( IsUniTriangular<MT2>::value ||
870  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
871  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
872  }
873 
874  matrix_ = ~rhs;
875 
876  if( !IsStrictlyUpper<MT2>::value )
877  resetLower();
878 
879  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
880  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
881 
882  return *this;
883 }
885 //*************************************************************************************************
886 
887 
888 //*************************************************************************************************
901 template< typename MT // Type of the adapted sparse matrix
902  , bool SO > // Storage order of the adapted sparse matrix
903 template< typename MT2 // Type of the right-hand side matrix
904  , bool SO2 > // Storage order of the right-hand side matrix
905 inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
906  StrictlyUpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
907 {
908  if( IsUniTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
909  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
910  }
911 
912  if( IsStrictlyUpper<MT2>::value ) {
913  matrix_ = ~rhs;
914  }
915  else {
916  MT tmp( ~rhs );
917 
918  if( !isStrictlyUpper( tmp ) ) {
919  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
920  }
921 
922  matrix_ = std::move( tmp );
923  }
924 
925  if( !IsStrictlyUpper<MT2>::value )
926  resetLower();
927 
928  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
929  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
930 
931  return *this;
932 }
934 //*************************************************************************************************
935 
936 
937 //*************************************************************************************************
950 template< typename MT // Type of the adapted sparse matrix
951  , bool SO > // Storage order of the adapted sparse matrix
952 template< typename MT2 // Type of the right-hand side matrix
953  , bool SO2 > // Storage order of the right-hand side matrix
954 inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
955  StrictlyUpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
956 {
957  if( IsUniTriangular<MT2>::value ||
958  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
959  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
960  }
961 
962  matrix_ += ~rhs;
963 
964  if( !IsStrictlyUpper<MT2>::value )
965  resetLower();
966 
967  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
968  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
969 
970  return *this;
971 }
973 //*************************************************************************************************
974 
975 
976 //*************************************************************************************************
989 template< typename MT // Type of the adapted sparse matrix
990  , bool SO > // Storage order of the adapted sparse matrix
991 template< typename MT2 // Type of the right-hand side matrix
992  , bool SO2 > // Storage order of the right-hand side matrix
993 inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
994  StrictlyUpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
995 {
996  if( IsUniTriangular<MT2>::value || ( IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
997  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
998  }
999 
1000  if( IsStrictlyUpper<MT2>::value ) {
1001  matrix_ += ~rhs;
1002  }
1003  else {
1004  const ResultType_<MT2> tmp( ~rhs );
1005 
1006  if( !isStrictlyUpper( tmp ) ) {
1007  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1008  }
1009 
1010  matrix_ += tmp;
1011  }
1012 
1013  if( !IsStrictlyUpper<MT2>::value )
1014  resetLower();
1015 
1016  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1017  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1018 
1019  return *this;
1020 }
1022 //*************************************************************************************************
1023 
1024 
1025 //*************************************************************************************************
1038 template< typename MT // Type of the adapted sparse matrix
1039  , bool SO > // Storage order of the adapted sparse matrix
1040 template< typename MT2 // Type of the right-hand side matrix
1041  , bool SO2 > // Storage order of the right-hand side matrix
1042 inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
1043  StrictlyUpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1044 {
1045  if( IsUniTriangular<MT2>::value ||
1046  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
1047  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1048  }
1049 
1050  matrix_ -= ~rhs;
1051 
1052  if( !IsStrictlyUpper<MT2>::value )
1053  resetLower();
1054 
1055  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1056  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1057 
1058  return *this;
1059 }
1061 //*************************************************************************************************
1062 
1063 
1064 //*************************************************************************************************
1077 template< typename MT // Type of the adapted sparse matrix
1078  , bool SO > // Storage order of the adapted sparse matrix
1079 template< typename MT2 // Type of the right-hand side matrix
1080  , bool SO2 > // Storage order of the right-hand side matrix
1081 inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
1082  StrictlyUpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1083 {
1084  if( IsUniTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1085  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1086  }
1087 
1088  if( IsStrictlyUpper<MT2>::value ) {
1089  matrix_ -= ~rhs;
1090  }
1091  else {
1092  const ResultType_<MT2> tmp( ~rhs );
1093 
1094  if( !isStrictlyUpper( tmp ) ) {
1095  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1096  }
1097 
1098  matrix_ -= tmp;
1099  }
1100 
1101  if( !IsStrictlyUpper<MT2>::value )
1102  resetLower();
1103 
1104  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1105  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1106 
1107  return *this;
1108 }
1110 //*************************************************************************************************
1111 
1112 
1113 //*************************************************************************************************
1125 template< typename MT // Type of the adapted sparse matrix
1126  , bool SO > // Storage order of the adapted sparse matrix
1127 template< typename MT2 // Type of the right-hand side matrix
1128  , bool SO2 > // Storage order of the right-hand side matrix
1129 inline StrictlyUpperMatrix<MT,SO,false>&
1130  StrictlyUpperMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1131 {
1132  if( matrix_.rows() != (~rhs).columns() ) {
1133  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1134  }
1135 
1136  MT tmp( matrix_ * ~rhs );
1137 
1138  if( !isStrictlyUpper( tmp ) ) {
1139  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1140  }
1141 
1142  matrix_ = std::move( tmp );
1143 
1144  if( !IsStrictlyUpper<MT2>::value )
1145  resetLower();
1146 
1147  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1148  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1149 
1150  return *this;
1151 }
1153 //*************************************************************************************************
1154 
1155 
1156 //*************************************************************************************************
1164 template< typename MT // Type of the adapted sparse matrix
1165  , bool SO > // Storage order of the adapted sparse matrix
1166 template< typename Other > // Data type of the right-hand side scalar
1167 inline EnableIf_< IsNumeric<Other>, StrictlyUpperMatrix<MT,SO,false> >&
1169 {
1170  matrix_ *= rhs;
1171  return *this;
1172 }
1173 //*************************************************************************************************
1174 
1175 
1176 //*************************************************************************************************
1184 template< typename MT // Type of the adapted sparse matrix
1185  , bool SO > // Storage order of the adapted sparse matrix
1186 template< typename Other > // Data type of the right-hand side scalar
1187 inline EnableIf_< IsNumeric<Other>, StrictlyUpperMatrix<MT,SO,false> >&
1189 {
1190  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1191 
1192  matrix_ /= rhs;
1193  return *this;
1194 }
1196 //*************************************************************************************************
1197 
1198 
1199 
1200 
1201 //=================================================================================================
1202 //
1203 // UTILITY FUNCTIONS
1204 //
1205 //=================================================================================================
1206 
1207 //*************************************************************************************************
1213 template< typename MT // Type of the adapted sparse matrix
1214  , bool SO > // Storage order of the adapted sparse matrix
1215 inline size_t StrictlyUpperMatrix<MT,SO,false>::rows() const noexcept
1216 {
1217  return matrix_.rows();
1218 }
1220 //*************************************************************************************************
1221 
1222 
1223 //*************************************************************************************************
1229 template< typename MT // Type of the adapted sparse matrix
1230  , bool SO > // Storage order of the adapted sparse matrix
1231 inline size_t StrictlyUpperMatrix<MT,SO,false>::columns() const noexcept
1232 {
1233  return matrix_.columns();
1234 }
1236 //*************************************************************************************************
1237 
1238 
1239 //*************************************************************************************************
1245 template< typename MT // Type of the adapted sparse matrix
1246  , bool SO > // Storage order of the adapted sparse matrix
1247 inline size_t StrictlyUpperMatrix<MT,SO,false>::capacity() const noexcept
1248 {
1249  return matrix_.capacity();
1250 }
1252 //*************************************************************************************************
1253 
1254 
1255 //*************************************************************************************************
1267 template< typename MT // Type of the adapted sparse matrix
1268  , bool SO > // Storage order of the adapted sparse matrix
1269 inline size_t StrictlyUpperMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1270 {
1271  return matrix_.capacity(i);
1272 }
1274 //*************************************************************************************************
1275 
1276 
1277 //*************************************************************************************************
1283 template< typename MT // Type of the adapted sparse matrix
1284  , bool SO > // Storage order of the adapted sparse matrix
1285 inline size_t StrictlyUpperMatrix<MT,SO,false>::nonZeros() const
1286 {
1287  return matrix_.nonZeros();
1288 }
1290 //*************************************************************************************************
1291 
1292 
1293 //*************************************************************************************************
1305 template< typename MT // Type of the adapted sparse matrix
1306  , bool SO > // Storage order of the adapted sparse matrix
1307 inline size_t StrictlyUpperMatrix<MT,SO,false>::nonZeros( size_t i ) const
1308 {
1309  return matrix_.nonZeros(i);
1310 }
1312 //*************************************************************************************************
1313 
1314 
1315 //*************************************************************************************************
1321 template< typename MT // Type of the adapted sparse matrix
1322  , bool SO > // Storage order of the adapted sparse matrix
1324 {
1325  if( SO ) {
1326  for( size_t j=1UL; j<columns(); ++j ) {
1327  matrix_.erase( j, matrix_.begin(j), matrix_.lowerBound(j,j) );
1328  }
1329  }
1330  else {
1331  for( size_t i=0UL; i<rows(); ++i ) {
1332  matrix_.erase( i, matrix_.lowerBound(i,i+1UL), matrix_.end(i) );
1333  }
1334  }
1335 }
1337 //*************************************************************************************************
1338 
1339 
1340 //*************************************************************************************************
1353 template< typename MT // Type of the adapted sparse matrix
1354  , bool SO > // Storage order of the adapted sparse matrix
1355 inline void StrictlyUpperMatrix<MT,SO,false>::reset( size_t i )
1356 {
1357  if( SO ) {
1358  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1359  }
1360  else {
1361  matrix_.erase( i, matrix_.lowerBound(i,i+1UL), matrix_.end(i) );
1362  }
1363 }
1365 //*************************************************************************************************
1366 
1367 
1368 //*************************************************************************************************
1376 template< typename MT // Type of the adapted sparse matrix
1377  , bool SO > // Storage order of the adapted sparse matrix
1379 {
1380  using blaze::clear;
1381 
1382  if( IsResizable<MT>::value ) {
1383  clear( matrix_ );
1384  }
1385  else {
1386  reset();
1387  }
1388 }
1390 //*************************************************************************************************
1391 
1392 
1393 //*************************************************************************************************
1408 template< typename MT // Type of the adapted sparse matrix
1409  , bool SO > // Storage order of the adapted sparse matrix
1410 void StrictlyUpperMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1411 {
1413 
1414  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1415 
1416  matrix_.resize( n, n, preserve );
1417 }
1419 //*************************************************************************************************
1420 
1421 
1422 //*************************************************************************************************
1433 template< typename MT // Type of the adapted sparse matrix
1434  , bool SO > // Storage order of the adapted sparse matrix
1435 inline void StrictlyUpperMatrix<MT,SO,false>::reserve( size_t nonzeros )
1436 {
1437  matrix_.reserve( nonzeros );
1438 }
1440 //*************************************************************************************************
1441 
1442 
1443 //*************************************************************************************************
1458 template< typename MT // Type of the adapted sparse matrix
1459  , bool SO > // Storage order of the adapted sparse matrix
1460 inline void StrictlyUpperMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1461 {
1462  matrix_.reserve( i, nonzeros );
1463 }
1465 //*************************************************************************************************
1466 
1467 
1468 //*************************************************************************************************
1479 template< typename MT // Type of the adapted sparse matrix
1480  , bool SO > // Storage order of the adapted sparse matrix
1481 inline void StrictlyUpperMatrix<MT,SO,false>::trim()
1482 {
1483  matrix_.trim();
1484 }
1486 //*************************************************************************************************
1487 
1488 
1489 //*************************************************************************************************
1501 template< typename MT // Type of the adapted sparse matrix
1502  , bool SO > // Storage order of the adapted sparse matrix
1503 inline void StrictlyUpperMatrix<MT,SO,false>::trim( size_t i )
1504 {
1505  matrix_.trim( i );
1506 }
1508 //*************************************************************************************************
1509 
1510 
1511 //*************************************************************************************************
1518 template< typename MT // Type of the adapted sparse matrix
1519  , bool SO > // Storage order of the adapted sparse matrix
1520 inline void StrictlyUpperMatrix<MT,SO,false>::swap( StrictlyUpperMatrix& m ) noexcept
1521 {
1522  using std::swap;
1523 
1524  swap( matrix_, m.matrix_ );
1525 }
1527 //*************************************************************************************************
1528 
1529 
1530 //*************************************************************************************************
1542 template< typename MT // Type of the adapted dense matrix
1543  , bool SO > // Storage order of the adapted dense matrix
1544 inline constexpr size_t StrictlyUpperMatrix<MT,SO,false>::maxNonZeros() noexcept
1545 {
1547 
1548  return maxNonZeros( Rows<MT>::value );
1549 }
1551 //*************************************************************************************************
1552 
1553 
1554 //*************************************************************************************************
1564 template< typename MT // Type of the adapted dense matrix
1565  , bool SO > // Storage order of the adapted dense matrix
1566 inline constexpr size_t StrictlyUpperMatrix<MT,SO,false>::maxNonZeros( size_t n ) noexcept
1567 {
1568  return ( ( n - 1UL ) * n ) / 2UL;
1569 }
1571 //*************************************************************************************************
1572 
1573 
1574 //*************************************************************************************************
1580 template< typename MT // Type of the adapted dense matrix
1581  , bool SO > // Storage order of the adapted dense matrix
1582 inline void StrictlyUpperMatrix<MT,SO,false>::resetLower()
1583 {
1584  if( SO ) {
1585  for( size_t j=0UL; j<columns(); ++j )
1586  matrix_.erase( j, matrix_.upperBound( j, j ), matrix_.end( j ) );
1587  }
1588  else {
1589  for( size_t i=1UL; i<rows(); ++i )
1590  matrix_.erase( i, matrix_.begin( i ), matrix_.lowerBound( i, i ) );
1591  }
1592 }
1594 //*************************************************************************************************
1595 
1596 
1597 
1598 
1599 //=================================================================================================
1600 //
1601 // INSERTION FUNCTIONS
1602 //
1603 //=================================================================================================
1604 
1605 //*************************************************************************************************
1621 template< typename MT // Type of the adapted sparse matrix
1622  , bool SO > // Storage order of the adapted sparse matrix
1624  StrictlyUpperMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1625 {
1626  if( i >= j ) {
1627  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1628  }
1629 
1630  return matrix_.set( i, j, value );
1631 }
1633 //*************************************************************************************************
1634 
1635 
1636 //*************************************************************************************************
1653 template< typename MT // Type of the adapted sparse matrix
1654  , bool SO > // Storage order of the adapted sparse matrix
1656  StrictlyUpperMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1657 {
1658  if( i >= j ) {
1659  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1660  }
1661 
1662  return matrix_.insert( i, j, value );
1663 }
1665 //*************************************************************************************************
1666 
1667 
1668 //*************************************************************************************************
1718 template< typename MT // Type of the adapted sparse matrix
1719  , bool SO > // Storage order of the adapted sparse matrix
1720 inline void StrictlyUpperMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1721 {
1722  if( i >= j ) {
1723  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1724  }
1725 
1726  matrix_.append( i, j, value, check );
1727 }
1729 //*************************************************************************************************
1730 
1731 
1732 //*************************************************************************************************
1746 template< typename MT // Type of the adapted sparse matrix
1747  , bool SO > // Storage order of the adapted sparse matrix
1748 inline void StrictlyUpperMatrix<MT,SO,false>::finalize( size_t i )
1749 {
1750  matrix_.finalize( i );
1751 }
1753 //*************************************************************************************************
1754 
1755 
1756 
1757 
1758 //=================================================================================================
1759 //
1760 // ERASE FUNCTIONS
1761 //
1762 //=================================================================================================
1763 
1764 //*************************************************************************************************
1774 template< typename MT // Type of the adapted sparse matrix
1775  , bool SO > // Storage order of the adapted sparse matrix
1776 inline void StrictlyUpperMatrix<MT,SO,false>::erase( size_t i, size_t j )
1777 {
1778  matrix_.erase( i, j );
1779 }
1781 //*************************************************************************************************
1782 
1783 
1784 //*************************************************************************************************
1796 template< typename MT // Type of the adapted sparse matrix
1797  , bool SO > // Storage order of the adapted sparse matrix
1799  StrictlyUpperMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1800 {
1801  return matrix_.erase( i, pos );
1802 }
1804 //*************************************************************************************************
1805 
1806 
1807 //*************************************************************************************************
1821 template< typename MT // Type of the adapted sparse matrix
1822  , bool SO > // Storage order of the adapted sparse matrix
1824  StrictlyUpperMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1825 {
1826  return matrix_.erase( i, first, last );
1827 }
1829 //*************************************************************************************************
1830 
1831 
1832 //*************************************************************************************************
1854 template< typename MT // Type of the adapted sparse matrix
1855  , bool SO > // Storage order of the adapted sparse matrix
1856 template< typename Pred > // Type of the unary predicate
1857 inline void StrictlyUpperMatrix<MT,SO,false>::erase( Pred predicate )
1858 {
1859  matrix_.erase( predicate );
1860 
1861  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1862 }
1864 //*************************************************************************************************
1865 
1866 
1867 //*************************************************************************************************
1895 template< typename MT // Type of the adapted sparse matrix
1896  , bool SO > // Storage order of the adapted sparse matrix
1897 template< typename Pred > // Type of the unary predicate
1898 inline void StrictlyUpperMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
1899 {
1900  matrix_.erase( i, first, last, predicate );
1901 
1902  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1903 }
1905 //*************************************************************************************************
1906 
1907 
1908 
1909 
1910 //=================================================================================================
1911 //
1912 // LOOKUP FUNCTIONS
1913 //
1914 //=================================================================================================
1915 
1916 //*************************************************************************************************
1932 template< typename MT // Type of the adapted sparse matrix
1933  , bool SO > // Storage order of the adapted sparse matrix
1935  StrictlyUpperMatrix<MT,SO,false>::find( size_t i, size_t j )
1936 {
1937  return matrix_.find( i, j );
1938 }
1940 //*************************************************************************************************
1941 
1942 
1943 //*************************************************************************************************
1959 template< typename MT // Type of the adapted sparse matrix
1960  , bool SO > // Storage order of the adapted sparse matrix
1962  StrictlyUpperMatrix<MT,SO,false>::find( size_t i, size_t j ) const
1963 {
1964  return matrix_.find( i, j );
1965 }
1967 //*************************************************************************************************
1968 
1969 
1970 //*************************************************************************************************
1986 template< typename MT // Type of the adapted sparse matrix
1987  , bool SO > // Storage order of the adapted sparse matrix
1989  StrictlyUpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
1990 {
1991  return matrix_.lowerBound( i, j );
1992 }
1994 //*************************************************************************************************
1995 
1996 
1997 //*************************************************************************************************
2013 template< typename MT // Type of the adapted sparse matrix
2014  , bool SO > // Storage order of the adapted sparse matrix
2016  StrictlyUpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
2017 {
2018  return matrix_.lowerBound( i, j );
2019 }
2021 //*************************************************************************************************
2022 
2023 
2024 //*************************************************************************************************
2040 template< typename MT // Type of the adapted sparse matrix
2041  , bool SO > // Storage order of the adapted sparse matrix
2043  StrictlyUpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
2044 {
2045  return matrix_.upperBound( i, j );
2046 }
2048 //*************************************************************************************************
2049 
2050 
2051 //*************************************************************************************************
2067 template< typename MT // Type of the adapted sparse matrix
2068  , bool SO > // Storage order of the adapted sparse matrix
2070  StrictlyUpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
2071 {
2072  return matrix_.upperBound( i, j );
2073 }
2075 //*************************************************************************************************
2076 
2077 
2078 
2079 
2080 //=================================================================================================
2081 //
2082 // NUMERIC FUNCTIONS
2083 //
2084 //=================================================================================================
2085 
2086 //*************************************************************************************************
2093 template< typename MT // Type of the adapted sparse matrix
2094  , bool SO > // Storage order of the adapted sparse matrix
2095 template< typename Other > // Data type of the scalar value
2096 inline StrictlyUpperMatrix<MT,SO,false>&
2097  StrictlyUpperMatrix<MT,SO,false>::scale( const Other& scalar )
2098 {
2099  matrix_.scale( scalar );
2100  return *this;
2101 }
2103 //*************************************************************************************************
2104 
2105 
2106 //*************************************************************************************************
2113 template< typename MT // Type of the adapted sparse matrix
2114  , bool SO > // Storage order of the adapted sparse matrix
2115 template< typename Other > // Data type of the scalar value
2116 inline StrictlyUpperMatrix<MT,SO,false>&
2117  StrictlyUpperMatrix<MT,SO,false>::scaleDiagonal( const Other& scalar )
2118 {
2119  matrix_.scaleDiagonal( scalar );
2120  return *this;
2121 }
2123 //*************************************************************************************************
2124 
2125 
2126 
2127 
2128 //=================================================================================================
2129 //
2130 // DEBUGGING FUNCTIONS
2131 //
2132 //=================================================================================================
2133 
2134 //*************************************************************************************************
2144 template< typename MT // Type of the adapted sparse matrix
2145  , bool SO > // Storage order of the adapted sparse matrix
2146 inline bool StrictlyUpperMatrix<MT,SO,false>::isIntact() const noexcept
2147 {
2148  using blaze::isIntact;
2149 
2150  return ( isIntact( matrix_ ) && isStrictlyUpper( matrix_ ) );
2151 }
2153 //*************************************************************************************************
2154 
2155 
2156 
2157 
2158 //=================================================================================================
2159 //
2160 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2161 //
2162 //=================================================================================================
2163 
2164 //*************************************************************************************************
2175 template< typename MT // Type of the adapted sparse matrix
2176  , bool SO > // Storage order of the adapted sparse matrix
2177 template< typename Other > // Data type of the foreign expression
2178 inline bool StrictlyUpperMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2179 {
2180  return matrix_.canAlias( alias );
2181 }
2183 //*************************************************************************************************
2184 
2185 
2186 //*************************************************************************************************
2197 template< typename MT // Type of the adapted sparse matrix
2198  , bool SO > // Storage order of the adapted sparse matrix
2199 template< typename Other > // Data type of the foreign expression
2200 inline bool StrictlyUpperMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2201 {
2202  return matrix_.isAliased( alias );
2203 }
2205 //*************************************************************************************************
2206 
2207 
2208 //*************************************************************************************************
2219 template< typename MT // Type of the adapted sparse matrix
2220  , bool SO > // Storage order of the adapted sparse matrix
2221 inline bool StrictlyUpperMatrix<MT,SO,false>::canSMPAssign() const noexcept
2222 {
2223  return matrix_.canSMPAssign();
2224 }
2226 //*************************************************************************************************
2227 
2228 } // namespace blaze
2229 
2230 #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:352
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: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:194
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:2935
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5556
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2928
#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:390
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.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1802
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2931
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:304
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:238
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:5635
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5618
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2939
#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:336
Header file for the IsUniTriangular type trait.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2932
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:544
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:260
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:2933
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2937
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
bool isStrictlyUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly upper triangular matrix.
Definition: DenseMatrix.h:1493
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2934
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:2938
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:267
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 &#39;resize&#39; member fu...
Definition: Resizable.h:81
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:320
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2929
#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 &#39;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:2930
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:249
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2936
#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:677
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