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>
58 #include <blaze/math/Exception.h>
60 #include <blaze/math/shims/Clear.h>
71 #include <blaze/util/Assert.h>
76 #include <blaze/util/DisableIf.h>
77 #include <blaze/util/EnableIf.h>
80 #include <blaze/util/Types.h>
81 
82 
83 namespace blaze {
84 
85 //=================================================================================================
86 //
87 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
88 //
89 //=================================================================================================
90 
91 //*************************************************************************************************
99 template< typename MT // Type of the adapted sparse matrix
100  , bool SO > // Storage order of the adapted sparse matrix
101 class StrictlyUpperMatrix<MT,SO,false>
102  : public SparseMatrix< StrictlyUpperMatrix<MT,SO,false>, SO >
103 {
104  private:
105  //**Type definitions****************************************************************************
106  using OT = OppositeType_<MT>;
107  using TT = TransposeType_<MT>;
108  using ET = ElementType_<MT>;
109  //**********************************************************************************************
110 
111  public:
112  //**Type definitions****************************************************************************
113  using This = StrictlyUpperMatrix<MT,SO,false>;
114  using BaseType = SparseMatrix<This,SO>;
115  using ResultType = This;
116  using OppositeType = StrictlyUpperMatrix<OT,!SO,false>;
117  using TransposeType = StrictlyLowerMatrix<TT,!SO,false>;
118  using ElementType = ET;
119  using ReturnType = ReturnType_<MT>;
120  using CompositeType = const This&;
121  using Reference = StrictlyUpperProxy<MT>;
122  using ConstReference = ConstReference_<MT>;
123  using Iterator = Iterator_<MT>;
124  using ConstIterator = ConstIterator_<MT>;
125  //**********************************************************************************************
126 
127  //**Rebind struct definition********************************************************************
130  template< typename NewType > // Data type of the other matrix
131  struct Rebind {
133  using Other = StrictlyUpperMatrix< typename MT::template Rebind<NewType>::Other >;
134  };
135  //**********************************************************************************************
136 
137  //**Resize struct definition********************************************************************
140  template< size_t NewM // Number of rows of the other matrix
141  , size_t NewN > // Number of columns of the other matrix
142  struct Resize {
144  using Other = StrictlyUpperMatrix< typename MT::template Resize<NewM,NewN>::Other >;
145  };
146  //**********************************************************************************************
147 
148  //**Compilation flags***************************************************************************
150  enum : bool { smpAssignable = false };
151  //**********************************************************************************************
152 
153  //**Constructors********************************************************************************
156  explicit inline StrictlyUpperMatrix();
157  explicit inline StrictlyUpperMatrix( size_t n );
158  explicit inline StrictlyUpperMatrix( size_t n, size_t nonzeros );
159  explicit inline StrictlyUpperMatrix( size_t n, const std::vector<size_t>& nonzeros );
160 
161  inline StrictlyUpperMatrix( const StrictlyUpperMatrix& m );
162  inline StrictlyUpperMatrix( StrictlyUpperMatrix&& m ) noexcept;
163 
164  template< typename MT2, bool SO2 >
165  inline StrictlyUpperMatrix( const Matrix<MT2,SO2>& m );
167  //**********************************************************************************************
168 
169  //**Destructor**********************************************************************************
170  // No explicitly declared destructor.
171  //**********************************************************************************************
172 
173  //**Data access functions***********************************************************************
176  inline Reference operator()( size_t i, size_t j );
177  inline ConstReference operator()( size_t i, size_t j ) const;
178  inline Reference at( size_t i, size_t j );
179  inline ConstReference at( size_t i, size_t j ) const;
180  inline Iterator begin ( size_t i );
181  inline ConstIterator begin ( size_t i ) const;
182  inline ConstIterator cbegin( size_t i ) const;
183  inline Iterator end ( size_t i );
184  inline ConstIterator end ( size_t i ) const;
185  inline ConstIterator cend ( size_t i ) const;
187  //**********************************************************************************************
188 
189  //**Assignment operators************************************************************************
192  inline StrictlyUpperMatrix& operator=( const StrictlyUpperMatrix& rhs );
193  inline StrictlyUpperMatrix& operator=( StrictlyUpperMatrix&& rhs ) noexcept;
194 
195  template< typename MT2, bool SO2 >
196  inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
197  operator=( const Matrix<MT2,SO2>& rhs );
198 
199  template< typename MT2, bool SO2 >
200  inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
201  operator=( const Matrix<MT2,SO2>& rhs );
202 
203  template< typename MT2, bool SO2 >
204  inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
205  operator+=( const Matrix<MT2,SO2>& rhs );
206 
207  template< typename MT2, bool SO2 >
208  inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
209  operator+=( const Matrix<MT2,SO2>& rhs );
210 
211  template< typename MT2, bool SO2 >
212  inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
213  operator-=( const Matrix<MT2,SO2>& rhs );
214 
215  template< typename MT2, bool SO2 >
216  inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix& >
217  operator-=( const Matrix<MT2,SO2>& rhs );
218 
219  template< typename MT2, bool SO2 >
220  inline StrictlyUpperMatrix& operator%=( const Matrix<MT2,SO2>& rhs );
221 
222  template< typename MT2, bool SO2 >
223  inline StrictlyUpperMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
224 
225  template< typename Other >
226  inline EnableIf_< IsNumeric<Other>, StrictlyUpperMatrix >& operator*=( Other rhs );
227 
228  template< typename Other >
229  inline EnableIf_< IsNumeric<Other>, StrictlyUpperMatrix >& operator/=( Other rhs );
231  //**********************************************************************************************
232 
233  //**Utility functions***************************************************************************
236  inline size_t rows() const noexcept;
237  inline size_t columns() const noexcept;
238  inline size_t capacity() const noexcept;
239  inline size_t capacity( size_t i ) const noexcept;
240  inline size_t nonZeros() const;
241  inline size_t nonZeros( size_t i ) const;
242  inline void reset();
243  inline void reset( size_t i );
244  inline void clear();
245  inline void resize ( size_t n, bool preserve=true );
246  inline void reserve( size_t nonzeros );
247  inline void reserve( size_t i, size_t nonzeros );
248  inline void trim();
249  inline void trim( size_t i );
250  inline void shrinkToFit();
251  inline void swap( StrictlyUpperMatrix& m ) noexcept;
252 
253  static inline constexpr size_t maxNonZeros() noexcept;
254  static inline constexpr size_t maxNonZeros( size_t n ) noexcept;
256  //**********************************************************************************************
257 
258  //**Insertion functions*************************************************************************
261  inline Iterator set ( size_t i, size_t j, const ElementType& value );
262  inline Iterator insert ( size_t i, size_t j, const ElementType& value );
263  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
264  inline void finalize( size_t i );
266  //**********************************************************************************************
267 
268  //**Erase functions*****************************************************************************
271  inline void erase( size_t i, size_t j );
272  inline Iterator erase( size_t i, Iterator pos );
273  inline Iterator erase( size_t i, Iterator first, Iterator last );
274 
275  template< typename Pred >
276  inline void erase( Pred predicate );
277 
278  template< typename Pred >
279  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
281  //**********************************************************************************************
282 
283  //**Lookup functions****************************************************************************
286  inline Iterator find ( size_t i, size_t j );
287  inline ConstIterator find ( size_t i, size_t j ) const;
288  inline Iterator lowerBound( size_t i, size_t j );
289  inline ConstIterator lowerBound( size_t i, size_t j ) const;
290  inline Iterator upperBound( size_t i, size_t j );
291  inline ConstIterator upperBound( size_t i, size_t j ) const;
293  //**********************************************************************************************
294 
295  //**Numeric functions***************************************************************************
298  template< typename Other > inline StrictlyUpperMatrix& scale( const Other& scalar );
299  template< typename Other > inline StrictlyUpperMatrix& scaleDiagonal( const Other& scale );
301  //**********************************************************************************************
302 
303  //**Debugging functions*************************************************************************
306  inline bool isIntact() const noexcept;
308  //**********************************************************************************************
309 
310  //**Expression template evaluation functions****************************************************
313  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
314  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
315 
316  inline bool canSMPAssign() const noexcept;
318  //**********************************************************************************************
319 
320  private:
321  //**Utility functions***************************************************************************
324  inline void resetLower();
326  //**********************************************************************************************
327 
328  //**Member variables****************************************************************************
331  MT matrix_;
332 
333  //**********************************************************************************************
334 
335  //**Friend declarations*************************************************************************
336  template< typename MT2, bool SO2, bool DF2 >
337  friend MT2& derestrict( StrictlyUpperMatrix<MT2,SO2,DF2>& m );
338  //**********************************************************************************************
339 
340  //**Compile time checks*************************************************************************
353  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
354  //**********************************************************************************************
355 };
357 //*************************************************************************************************
358 
359 
360 
361 
362 //=================================================================================================
363 //
364 // CONSTRUCTORS
365 //
366 //=================================================================================================
367 
368 //*************************************************************************************************
372 template< typename MT // Type of the adapted sparse matrix
373  , bool SO > // Storage order of the adapted sparse matrix
374 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix()
375  : matrix_() // The adapted sparse matrix
376 {
377  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
378 }
380 //*************************************************************************************************
381 
382 
383 //*************************************************************************************************
391 template< typename MT // Type of the adapted sparse matrix
392  , bool SO > // Storage order of the adapted sparse matrix
393 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( size_t n )
394  : matrix_( n, n, n ) // The adapted sparse matrix
395 {
397 
398  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
399 }
401 //*************************************************************************************************
402 
403 
404 //*************************************************************************************************
414 template< typename MT // Type of the adapted sparse matrix
415  , bool SO > // Storage order of the adapted sparse matrix
416 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( size_t n, size_t nonzeros )
417  : matrix_( n, n, max( nonzeros, n ) ) // The adapted sparse matrix
418 {
420 
421  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
422 }
424 //*************************************************************************************************
425 
426 
427 //*************************************************************************************************
441 template< typename MT // Type of the adapted sparse matrix
442  , bool SO > // Storage order of the adapted sparse matrix
443 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( size_t n, const std::vector<size_t>& nonzeros )
444  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
445 {
447 
448  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
449 }
451 //*************************************************************************************************
452 
453 
454 //*************************************************************************************************
460 template< typename MT // Type of the adapted sparse matrix
461  , bool SO > // Storage order of the adapted sparse matrix
462 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( const StrictlyUpperMatrix& m )
463  : matrix_( m.matrix_ ) // The adapted sparse matrix
464 {
465  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
466  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
467 }
469 //*************************************************************************************************
470 
471 
472 //*************************************************************************************************
478 template< typename MT // Type of the adapted sparse matrix
479  , bool SO > // Storage order of the adapted sparse matrix
480 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( StrictlyUpperMatrix&& m ) noexcept
481  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
482 {
483  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
484  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
485 }
487 //*************************************************************************************************
488 
489 
490 //*************************************************************************************************
501 template< typename MT // Type of the adapted sparse matrix
502  , bool SO > // Storage order of the adapted sparse matrix
503 template< typename MT2 // Type of the foreign matrix
504  , bool SO2 > // Storage order of the foreign matrix
505 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( const Matrix<MT2,SO2>& m )
506  : matrix_( ~m ) // The adapted sparse matrix
507 {
508  if( IsUniTriangular<MT2>::value ||
509  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( matrix_ ) ) ) {
510  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly upper matrix" );
511  }
512 
513  if( !IsStrictlyUpper<MT2>::value )
514  resetLower();
515 
516  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
517  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
518 }
520 //*************************************************************************************************
521 
522 
523 
524 
525 //=================================================================================================
526 //
527 // DATA ACCESS FUNCTIONS
528 //
529 //=================================================================================================
530 
531 //*************************************************************************************************
547 template< typename MT // Type of the adapted sparse matrix
548  , bool SO > // Storage order of the adapted sparse matrix
550  StrictlyUpperMatrix<MT,SO,false>::operator()( size_t i, size_t j )
551 {
552  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
553  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
554 
555  return Reference( matrix_, i, j );
556 }
558 //*************************************************************************************************
559 
560 
561 //*************************************************************************************************
577 template< typename MT // Type of the adapted sparse matrix
578  , bool SO > // Storage order of the adapted sparse matrix
580  StrictlyUpperMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
581 {
582  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
583  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
584 
585  return matrix_(i,j);
586 }
588 //*************************************************************************************************
589 
590 
591 //*************************************************************************************************
608 template< typename MT // Type of the adapted sparse matrix
609  , bool SO > // Storage order of the adapted sparse matrix
611  StrictlyUpperMatrix<MT,SO,false>::at( size_t i, size_t j )
612 {
613  if( i >= rows() ) {
614  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
615  }
616  if( j >= columns() ) {
617  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
618  }
619  return (*this)(i,j);
620 }
622 //*************************************************************************************************
623 
624 
625 //*************************************************************************************************
642 template< typename MT // Type of the adapted sparse matrix
643  , bool SO > // Storage order of the adapted sparse matrix
645  StrictlyUpperMatrix<MT,SO,false>::at( size_t i, size_t j ) const
646 {
647  if( i >= rows() ) {
648  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
649  }
650  if( j >= columns() ) {
651  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
652  }
653  return (*this)(i,j);
654 }
656 //*************************************************************************************************
657 
658 
659 //*************************************************************************************************
671 template< typename MT // Type of the adapted sparse matrix
672  , bool SO > // Storage order of the adapted sparse matrix
675 {
676  return matrix_.begin(i);
677 }
679 //*************************************************************************************************
680 
681 
682 //*************************************************************************************************
694 template< typename MT // Type of the adapted sparse matrix
695  , bool SO > // Storage order of the adapted sparse matrix
698 {
699  return matrix_.begin(i);
700 }
702 //*************************************************************************************************
703 
704 
705 //*************************************************************************************************
717 template< typename MT // Type of the adapted sparse matrix
718  , bool SO > // Storage order of the adapted sparse matrix
721 {
722  return matrix_.cbegin(i);
723 }
725 //*************************************************************************************************
726 
727 
728 //*************************************************************************************************
740 template< typename MT // Type of the adapted sparse matrix
741  , bool SO > // Storage order of the adapted sparse matrix
744 {
745  return matrix_.end(i);
746 }
748 //*************************************************************************************************
749 
750 
751 //*************************************************************************************************
763 template< typename MT // Type of the adapted sparse matrix
764  , bool SO > // Storage order of the adapted sparse matrix
766  StrictlyUpperMatrix<MT,SO,false>::end( size_t i ) const
767 {
768  return matrix_.end(i);
769 }
771 //*************************************************************************************************
772 
773 
774 //*************************************************************************************************
786 template< typename MT // Type of the adapted sparse matrix
787  , bool SO > // Storage order of the adapted sparse matrix
790 {
791  return matrix_.cend(i);
792 }
794 //*************************************************************************************************
795 
796 
797 
798 
799 //=================================================================================================
800 //
801 // ASSIGNMENT OPERATORS
802 //
803 //=================================================================================================
804 
805 //*************************************************************************************************
815 template< typename MT // Type of the adapted sparse matrix
816  , bool SO > // Storage order of the adapted sparse matrix
817 inline StrictlyUpperMatrix<MT,SO,false>&
818  StrictlyUpperMatrix<MT,SO,false>::operator=( const StrictlyUpperMatrix& rhs )
819 {
820  matrix_ = rhs.matrix_;
821 
822  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
823  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
824 
825  return *this;
826 }
828 //*************************************************************************************************
829 
830 
831 //*************************************************************************************************
838 template< typename MT // Type of the adapted sparse matrix
839  , bool SO > // Storage order of the adapted sparse matrix
840 inline StrictlyUpperMatrix<MT,SO,false>&
841  StrictlyUpperMatrix<MT,SO,false>::operator=( StrictlyUpperMatrix&& rhs ) noexcept
842 {
843  matrix_ = std::move( rhs.matrix_ );
844 
845  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
846  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
847 
848  return *this;
849 }
851 //*************************************************************************************************
852 
853 
854 //*************************************************************************************************
867 template< typename MT // Type of the adapted sparse matrix
868  , bool SO > // Storage order of the adapted sparse matrix
869 template< typename MT2 // Type of the right-hand side matrix
870  , bool SO2 > // Storage order of the right-hand side matrix
871 inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
872  StrictlyUpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
873 {
874  if( IsUniTriangular<MT2>::value ||
875  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
876  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
877  }
878 
879  matrix_ = declupp( ~rhs );
880 
881  if( !IsStrictlyUpper<MT2>::value )
882  resetLower();
883 
884  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
885  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
886 
887  return *this;
888 }
890 //*************************************************************************************************
891 
892 
893 //*************************************************************************************************
906 template< typename MT // Type of the adapted sparse matrix
907  , bool SO > // Storage order of the adapted sparse matrix
908 template< typename MT2 // Type of the right-hand side matrix
909  , bool SO2 > // Storage order of the right-hand side matrix
910 inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
911  StrictlyUpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
912 {
913  if( IsUniTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
914  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
915  }
916 
917  if( IsStrictlyUpper<MT2>::value ) {
918  matrix_ = ~rhs;
919  }
920  else {
921  MT tmp( ~rhs );
922 
923  if( !isStrictlyUpper( tmp ) ) {
924  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
925  }
926 
927  matrix_ = std::move( tmp );
928  }
929 
930  if( !IsStrictlyUpper<MT2>::value )
931  resetLower();
932 
933  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
934  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
935 
936  return *this;
937 }
939 //*************************************************************************************************
940 
941 
942 //*************************************************************************************************
955 template< typename MT // Type of the adapted sparse matrix
956  , bool SO > // Storage order of the adapted sparse matrix
957 template< typename MT2 // Type of the right-hand side matrix
958  , bool SO2 > // Storage order of the right-hand side matrix
959 inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
960  StrictlyUpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
961 {
962  if( IsUniTriangular<MT2>::value ||
963  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
964  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
965  }
966 
967  matrix_ += declupp( ~rhs );
968 
969  if( !IsStrictlyUpper<MT2>::value )
970  resetLower();
971 
972  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
973  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
974 
975  return *this;
976 }
978 //*************************************************************************************************
979 
980 
981 //*************************************************************************************************
994 template< typename MT // Type of the adapted sparse matrix
995  , bool SO > // Storage order of the adapted sparse matrix
996 template< typename MT2 // Type of the right-hand side matrix
997  , bool SO2 > // Storage order of the right-hand side matrix
998 inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
999  StrictlyUpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1000 {
1001  if( IsUniTriangular<MT2>::value || ( IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1002  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1003  }
1004 
1005  if( IsStrictlyUpper<MT2>::value ) {
1006  matrix_ += ~rhs;
1007  }
1008  else {
1009  const ResultType_<MT2> tmp( ~rhs );
1010 
1011  if( !isStrictlyUpper( tmp ) ) {
1012  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1013  }
1014 
1015  matrix_ += declupp( tmp );
1016  }
1017 
1018  if( !IsStrictlyUpper<MT2>::value )
1019  resetLower();
1020 
1021  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1022  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1023 
1024  return *this;
1025 }
1027 //*************************************************************************************************
1028 
1029 
1030 //*************************************************************************************************
1043 template< typename MT // Type of the adapted sparse matrix
1044  , bool SO > // Storage order of the adapted sparse matrix
1045 template< typename MT2 // Type of the right-hand side matrix
1046  , bool SO2 > // Storage order of the right-hand side matrix
1047 inline DisableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
1048  StrictlyUpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1049 {
1050  if( IsUniTriangular<MT2>::value ||
1051  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
1052  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1053  }
1054 
1055  matrix_ -= declupp( ~rhs );
1056 
1057  if( !IsStrictlyUpper<MT2>::value )
1058  resetLower();
1059 
1060  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1061  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1062 
1063  return *this;
1064 }
1066 //*************************************************************************************************
1067 
1068 
1069 //*************************************************************************************************
1082 template< typename MT // Type of the adapted sparse matrix
1083  , bool SO > // Storage order of the adapted sparse matrix
1084 template< typename MT2 // Type of the right-hand side matrix
1085  , bool SO2 > // Storage order of the right-hand side matrix
1086 inline EnableIf_< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >
1087  StrictlyUpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1088 {
1089  if( IsUniTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1090  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1091  }
1092 
1093  if( IsStrictlyUpper<MT2>::value ) {
1094  matrix_ -= ~rhs;
1095  }
1096  else {
1097  const ResultType_<MT2> tmp( ~rhs );
1098 
1099  if( !isStrictlyUpper( tmp ) ) {
1100  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1101  }
1102 
1103  matrix_ -= declupp( tmp );
1104  }
1105 
1106  if( !IsStrictlyUpper<MT2>::value )
1107  resetLower();
1108 
1109  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1110  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1111 
1112  return *this;
1113 }
1115 //*************************************************************************************************
1116 
1117 
1118 //*************************************************************************************************
1129 template< typename MT // Type of the adapted sparse matrix
1130  , bool SO > // Storage order of the adapted sparse matrix
1131 template< typename MT2 // Type of the right-hand side matrix
1132  , bool SO2 > // Storage order of the right-hand side matrix
1133 inline StrictlyUpperMatrix<MT,SO,false>&
1134  StrictlyUpperMatrix<MT,SO,false>::operator%=( const Matrix<MT2,SO2>& rhs )
1135 {
1136  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1137  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1138  }
1139 
1140  matrix_ %= ~rhs;
1141 
1142  if( !IsStrictlyUpper<MT2>::value )
1143  resetLower();
1144 
1145  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1146  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1147 
1148  return *this;
1149 }
1151 //*************************************************************************************************
1152 
1153 
1154 //*************************************************************************************************
1166 template< typename MT // Type of the adapted sparse matrix
1167  , bool SO > // Storage order of the adapted sparse matrix
1168 template< typename MT2 // Type of the right-hand side matrix
1169  , bool SO2 > // Storage order of the right-hand side matrix
1170 inline StrictlyUpperMatrix<MT,SO,false>&
1171  StrictlyUpperMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1172 {
1173  if( matrix_.rows() != (~rhs).columns() ) {
1174  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1175  }
1176 
1177  MT tmp( matrix_ * ~rhs );
1178 
1179  if( !isStrictlyUpper( tmp ) ) {
1180  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1181  }
1182 
1183  matrix_ = std::move( tmp );
1184 
1185  if( !IsStrictlyUpper<MT2>::value )
1186  resetLower();
1187 
1188  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1189  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1190 
1191  return *this;
1192 }
1194 //*************************************************************************************************
1195 
1196 
1197 //*************************************************************************************************
1205 template< typename MT // Type of the adapted sparse matrix
1206  , bool SO > // Storage order of the adapted sparse matrix
1207 template< typename Other > // Data type of the right-hand side scalar
1208 inline EnableIf_< IsNumeric<Other>, StrictlyUpperMatrix<MT,SO,false> >&
1210 {
1211  matrix_ *= rhs;
1212  return *this;
1213 }
1214 //*************************************************************************************************
1215 
1216 
1217 //*************************************************************************************************
1225 template< typename MT // Type of the adapted sparse matrix
1226  , bool SO > // Storage order of the adapted sparse matrix
1227 template< typename Other > // Data type of the right-hand side scalar
1228 inline EnableIf_< IsNumeric<Other>, StrictlyUpperMatrix<MT,SO,false> >&
1230 {
1231  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1232 
1233  matrix_ /= rhs;
1234  return *this;
1235 }
1237 //*************************************************************************************************
1238 
1239 
1240 
1241 
1242 //=================================================================================================
1243 //
1244 // UTILITY FUNCTIONS
1245 //
1246 //=================================================================================================
1247 
1248 //*************************************************************************************************
1254 template< typename MT // Type of the adapted sparse matrix
1255  , bool SO > // Storage order of the adapted sparse matrix
1256 inline size_t StrictlyUpperMatrix<MT,SO,false>::rows() const noexcept
1257 {
1258  return matrix_.rows();
1259 }
1261 //*************************************************************************************************
1262 
1263 
1264 //*************************************************************************************************
1270 template< typename MT // Type of the adapted sparse matrix
1271  , bool SO > // Storage order of the adapted sparse matrix
1272 inline size_t StrictlyUpperMatrix<MT,SO,false>::columns() const noexcept
1273 {
1274  return matrix_.columns();
1275 }
1277 //*************************************************************************************************
1278 
1279 
1280 //*************************************************************************************************
1286 template< typename MT // Type of the adapted sparse matrix
1287  , bool SO > // Storage order of the adapted sparse matrix
1288 inline size_t StrictlyUpperMatrix<MT,SO,false>::capacity() const noexcept
1289 {
1290  return matrix_.capacity();
1291 }
1293 //*************************************************************************************************
1294 
1295 
1296 //*************************************************************************************************
1308 template< typename MT // Type of the adapted sparse matrix
1309  , bool SO > // Storage order of the adapted sparse matrix
1310 inline size_t StrictlyUpperMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1311 {
1312  return matrix_.capacity(i);
1313 }
1315 //*************************************************************************************************
1316 
1317 
1318 //*************************************************************************************************
1324 template< typename MT // Type of the adapted sparse matrix
1325  , bool SO > // Storage order of the adapted sparse matrix
1326 inline size_t StrictlyUpperMatrix<MT,SO,false>::nonZeros() const
1327 {
1328  return matrix_.nonZeros();
1329 }
1331 //*************************************************************************************************
1332 
1333 
1334 //*************************************************************************************************
1346 template< typename MT // Type of the adapted sparse matrix
1347  , bool SO > // Storage order of the adapted sparse matrix
1348 inline size_t StrictlyUpperMatrix<MT,SO,false>::nonZeros( size_t i ) const
1349 {
1350  return matrix_.nonZeros(i);
1351 }
1353 //*************************************************************************************************
1354 
1355 
1356 //*************************************************************************************************
1362 template< typename MT // Type of the adapted sparse matrix
1363  , bool SO > // Storage order of the adapted sparse matrix
1365 {
1366  if( SO ) {
1367  for( size_t j=1UL; j<columns(); ++j ) {
1368  matrix_.erase( j, matrix_.begin(j), matrix_.lowerBound(j,j) );
1369  }
1370  }
1371  else {
1372  for( size_t i=0UL; i<rows(); ++i ) {
1373  matrix_.erase( i, matrix_.lowerBound(i,i+1UL), matrix_.end(i) );
1374  }
1375  }
1376 }
1378 //*************************************************************************************************
1379 
1380 
1381 //*************************************************************************************************
1394 template< typename MT // Type of the adapted sparse matrix
1395  , bool SO > // Storage order of the adapted sparse matrix
1396 inline void StrictlyUpperMatrix<MT,SO,false>::reset( size_t i )
1397 {
1398  if( SO ) {
1399  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1400  }
1401  else {
1402  matrix_.erase( i, matrix_.lowerBound(i,i+1UL), matrix_.end(i) );
1403  }
1404 }
1406 //*************************************************************************************************
1407 
1408 
1409 //*************************************************************************************************
1417 template< typename MT // Type of the adapted sparse matrix
1418  , bool SO > // Storage order of the adapted sparse matrix
1420 {
1421  using blaze::clear;
1422 
1423  if( IsResizable<MT>::value ) {
1424  clear( matrix_ );
1425  }
1426  else {
1427  reset();
1428  }
1429 }
1431 //*************************************************************************************************
1432 
1433 
1434 //*************************************************************************************************
1449 template< typename MT // Type of the adapted sparse matrix
1450  , bool SO > // Storage order of the adapted sparse matrix
1451 void StrictlyUpperMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1452 {
1454 
1455  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1456 
1457  matrix_.resize( n, n, preserve );
1458 }
1460 //*************************************************************************************************
1461 
1462 
1463 //*************************************************************************************************
1474 template< typename MT // Type of the adapted sparse matrix
1475  , bool SO > // Storage order of the adapted sparse matrix
1476 inline void StrictlyUpperMatrix<MT,SO,false>::reserve( size_t nonzeros )
1477 {
1478  matrix_.reserve( nonzeros );
1479 }
1481 //*************************************************************************************************
1482 
1483 
1484 //*************************************************************************************************
1499 template< typename MT // Type of the adapted sparse matrix
1500  , bool SO > // Storage order of the adapted sparse matrix
1501 inline void StrictlyUpperMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1502 {
1503  matrix_.reserve( i, nonzeros );
1504 }
1506 //*************************************************************************************************
1507 
1508 
1509 //*************************************************************************************************
1520 template< typename MT // Type of the adapted sparse matrix
1521  , bool SO > // Storage order of the adapted sparse matrix
1522 inline void StrictlyUpperMatrix<MT,SO,false>::trim()
1523 {
1524  matrix_.trim();
1525 }
1527 //*************************************************************************************************
1528 
1529 
1530 //*************************************************************************************************
1542 template< typename MT // Type of the adapted sparse matrix
1543  , bool SO > // Storage order of the adapted sparse matrix
1544 inline void StrictlyUpperMatrix<MT,SO,false>::trim( size_t i )
1545 {
1546  matrix_.trim( i );
1547 }
1549 //*************************************************************************************************
1550 
1551 
1552 //*************************************************************************************************
1562 template< typename MT // Type of the adapted sparse matrix
1563  , bool SO > // Storage order of the adapted sparse matrix
1565 {
1566  matrix_.shrinkToFit();
1567 }
1569 //*************************************************************************************************
1570 
1571 
1572 //*************************************************************************************************
1579 template< typename MT // Type of the adapted sparse matrix
1580  , bool SO > // Storage order of the adapted sparse matrix
1581 inline void StrictlyUpperMatrix<MT,SO,false>::swap( StrictlyUpperMatrix& m ) noexcept
1582 {
1583  using std::swap;
1584 
1585  swap( matrix_, m.matrix_ );
1586 }
1588 //*************************************************************************************************
1589 
1590 
1591 //*************************************************************************************************
1603 template< typename MT // Type of the adapted dense matrix
1604  , bool SO > // Storage order of the adapted dense matrix
1605 inline constexpr size_t StrictlyUpperMatrix<MT,SO,false>::maxNonZeros() noexcept
1606 {
1608 
1609  return maxNonZeros( Rows<MT>::value );
1610 }
1612 //*************************************************************************************************
1613 
1614 
1615 //*************************************************************************************************
1625 template< typename MT // Type of the adapted dense matrix
1626  , bool SO > // Storage order of the adapted dense matrix
1627 inline constexpr size_t StrictlyUpperMatrix<MT,SO,false>::maxNonZeros( size_t n ) noexcept
1628 {
1629  return ( ( n - 1UL ) * n ) / 2UL;
1630 }
1632 //*************************************************************************************************
1633 
1634 
1635 //*************************************************************************************************
1641 template< typename MT // Type of the adapted dense matrix
1642  , bool SO > // Storage order of the adapted dense matrix
1643 inline void StrictlyUpperMatrix<MT,SO,false>::resetLower()
1644 {
1645  if( SO ) {
1646  for( size_t j=0UL; j<columns(); ++j )
1647  matrix_.erase( j, matrix_.upperBound( j, j ), matrix_.end( j ) );
1648  }
1649  else {
1650  for( size_t i=1UL; i<rows(); ++i )
1651  matrix_.erase( i, matrix_.begin( i ), matrix_.lowerBound( i, i ) );
1652  }
1653 }
1655 //*************************************************************************************************
1656 
1657 
1658 
1659 
1660 //=================================================================================================
1661 //
1662 // INSERTION FUNCTIONS
1663 //
1664 //=================================================================================================
1665 
1666 //*************************************************************************************************
1682 template< typename MT // Type of the adapted sparse matrix
1683  , bool SO > // Storage order of the adapted sparse matrix
1685  StrictlyUpperMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1686 {
1687  if( i >= j ) {
1688  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1689  }
1690 
1691  return matrix_.set( i, j, value );
1692 }
1694 //*************************************************************************************************
1695 
1696 
1697 //*************************************************************************************************
1714 template< typename MT // Type of the adapted sparse matrix
1715  , bool SO > // Storage order of the adapted sparse matrix
1717  StrictlyUpperMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1718 {
1719  if( i >= j ) {
1720  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1721  }
1722 
1723  return matrix_.insert( i, j, value );
1724 }
1726 //*************************************************************************************************
1727 
1728 
1729 //*************************************************************************************************
1779 template< typename MT // Type of the adapted sparse matrix
1780  , bool SO > // Storage order of the adapted sparse matrix
1781 inline void StrictlyUpperMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1782 {
1783  if( i >= j ) {
1784  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1785  }
1786 
1787  matrix_.append( i, j, value, check );
1788 }
1790 //*************************************************************************************************
1791 
1792 
1793 //*************************************************************************************************
1807 template< typename MT // Type of the adapted sparse matrix
1808  , bool SO > // Storage order of the adapted sparse matrix
1809 inline void StrictlyUpperMatrix<MT,SO,false>::finalize( size_t i )
1810 {
1811  matrix_.finalize( i );
1812 }
1814 //*************************************************************************************************
1815 
1816 
1817 
1818 
1819 //=================================================================================================
1820 //
1821 // ERASE FUNCTIONS
1822 //
1823 //=================================================================================================
1824 
1825 //*************************************************************************************************
1835 template< typename MT // Type of the adapted sparse matrix
1836  , bool SO > // Storage order of the adapted sparse matrix
1837 inline void StrictlyUpperMatrix<MT,SO,false>::erase( size_t i, size_t j )
1838 {
1839  matrix_.erase( i, j );
1840 }
1842 //*************************************************************************************************
1843 
1844 
1845 //*************************************************************************************************
1857 template< typename MT // Type of the adapted sparse matrix
1858  , bool SO > // Storage order of the adapted sparse matrix
1860  StrictlyUpperMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1861 {
1862  return matrix_.erase( i, pos );
1863 }
1865 //*************************************************************************************************
1866 
1867 
1868 //*************************************************************************************************
1882 template< typename MT // Type of the adapted sparse matrix
1883  , bool SO > // Storage order of the adapted sparse matrix
1885  StrictlyUpperMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1886 {
1887  return matrix_.erase( i, first, last );
1888 }
1890 //*************************************************************************************************
1891 
1892 
1893 //*************************************************************************************************
1915 template< typename MT // Type of the adapted sparse matrix
1916  , bool SO > // Storage order of the adapted sparse matrix
1917 template< typename Pred > // Type of the unary predicate
1918 inline void StrictlyUpperMatrix<MT,SO,false>::erase( Pred predicate )
1919 {
1920  matrix_.erase( predicate );
1921 
1922  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1923 }
1925 //*************************************************************************************************
1926 
1927 
1928 //*************************************************************************************************
1956 template< typename MT // Type of the adapted sparse matrix
1957  , bool SO > // Storage order of the adapted sparse matrix
1958 template< typename Pred > // Type of the unary predicate
1959 inline void StrictlyUpperMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
1960 {
1961  matrix_.erase( i, first, last, predicate );
1962 
1963  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1964 }
1966 //*************************************************************************************************
1967 
1968 
1969 
1970 
1971 //=================================================================================================
1972 //
1973 // LOOKUP FUNCTIONS
1974 //
1975 //=================================================================================================
1976 
1977 //*************************************************************************************************
1993 template< typename MT // Type of the adapted sparse matrix
1994  , bool SO > // Storage order of the adapted sparse matrix
1996  StrictlyUpperMatrix<MT,SO,false>::find( size_t i, size_t j )
1997 {
1998  return matrix_.find( i, j );
1999 }
2001 //*************************************************************************************************
2002 
2003 
2004 //*************************************************************************************************
2020 template< typename MT // Type of the adapted sparse matrix
2021  , bool SO > // Storage order of the adapted sparse matrix
2023  StrictlyUpperMatrix<MT,SO,false>::find( size_t i, size_t j ) const
2024 {
2025  return matrix_.find( i, j );
2026 }
2028 //*************************************************************************************************
2029 
2030 
2031 //*************************************************************************************************
2047 template< typename MT // Type of the adapted sparse matrix
2048  , bool SO > // Storage order of the adapted sparse matrix
2050  StrictlyUpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
2051 {
2052  return matrix_.lowerBound( i, j );
2053 }
2055 //*************************************************************************************************
2056 
2057 
2058 //*************************************************************************************************
2074 template< typename MT // Type of the adapted sparse matrix
2075  , bool SO > // Storage order of the adapted sparse matrix
2077  StrictlyUpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
2078 {
2079  return matrix_.lowerBound( i, j );
2080 }
2082 //*************************************************************************************************
2083 
2084 
2085 //*************************************************************************************************
2101 template< typename MT // Type of the adapted sparse matrix
2102  , bool SO > // Storage order of the adapted sparse matrix
2104  StrictlyUpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
2105 {
2106  return matrix_.upperBound( i, j );
2107 }
2109 //*************************************************************************************************
2110 
2111 
2112 //*************************************************************************************************
2128 template< typename MT // Type of the adapted sparse matrix
2129  , bool SO > // Storage order of the adapted sparse matrix
2131  StrictlyUpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
2132 {
2133  return matrix_.upperBound( i, j );
2134 }
2136 //*************************************************************************************************
2137 
2138 
2139 
2140 
2141 //=================================================================================================
2142 //
2143 // NUMERIC FUNCTIONS
2144 //
2145 //=================================================================================================
2146 
2147 //*************************************************************************************************
2165 template< typename MT // Type of the adapted sparse matrix
2166  , bool SO > // Storage order of the adapted sparse matrix
2167 template< typename Other > // Data type of the scalar value
2168 inline StrictlyUpperMatrix<MT,SO,false>&
2169  StrictlyUpperMatrix<MT,SO,false>::scale( const Other& scalar )
2170 {
2171  matrix_.scale( scalar );
2172  return *this;
2173 }
2175 //*************************************************************************************************
2176 
2177 
2178 //*************************************************************************************************
2188 template< typename MT // Type of the adapted sparse matrix
2189  , bool SO > // Storage order of the adapted sparse matrix
2190 template< typename Other > // Data type of the scalar value
2191 inline StrictlyUpperMatrix<MT,SO,false>&
2192  StrictlyUpperMatrix<MT,SO,false>::scaleDiagonal( const Other& scalar )
2193 {
2194  matrix_.scaleDiagonal( scalar );
2195  return *this;
2196 }
2198 //*************************************************************************************************
2199 
2200 
2201 
2202 
2203 //=================================================================================================
2204 //
2205 // DEBUGGING FUNCTIONS
2206 //
2207 //=================================================================================================
2208 
2209 //*************************************************************************************************
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>::isIntact() const noexcept
2222 {
2223  using blaze::isIntact;
2224 
2225  return ( isIntact( matrix_ ) && isStrictlyUpper( matrix_ ) );
2226 }
2228 //*************************************************************************************************
2229 
2230 
2231 
2232 
2233 //=================================================================================================
2234 //
2235 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2236 //
2237 //=================================================================================================
2238 
2239 //*************************************************************************************************
2250 template< typename MT // Type of the adapted sparse matrix
2251  , bool SO > // Storage order of the adapted sparse matrix
2252 template< typename Other > // Data type of the foreign expression
2253 inline bool StrictlyUpperMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2254 {
2255  return matrix_.canAlias( alias );
2256 }
2258 //*************************************************************************************************
2259 
2260 
2261 //*************************************************************************************************
2272 template< typename MT // Type of the adapted sparse matrix
2273  , bool SO > // Storage order of the adapted sparse matrix
2274 template< typename Other > // Data type of the foreign expression
2275 inline bool StrictlyUpperMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2276 {
2277  return matrix_.isAliased( alias );
2278 }
2280 //*************************************************************************************************
2281 
2282 
2283 //*************************************************************************************************
2294 template< typename MT // Type of the adapted sparse matrix
2295  , bool SO > // Storage order of the adapted sparse matrix
2296 inline bool StrictlyUpperMatrix<MT,SO,false>::canSMPAssign() const noexcept
2297 {
2298  return matrix_.canSMPAssign();
2299 }
2301 //*************************************************************************************************
2302 
2303 } // namespace blaze
2304 
2305 #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.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3079
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the Rows type trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:356
Header file for basic type definitions.
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:63
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1411
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3078
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:198
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:560
BLAZE_ALWAYS_INLINE void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:609
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5845
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3080
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3085
decltype(auto) declupp(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as upper.
Definition: DMatDeclUppExpr.h:1027
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:394
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3086
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1393
Constraint on the data type.
const ElementType_< MT > max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1809
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:308
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:242
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
Header file for utility functions for sparse matrices.
Header file for the IsSquare type trait.
Constraint on the data type.
Headerfile for the generic max algorithm.
Header file for the DisableIf class template.
Header file for the IsStrictlyUpper type trait.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3084
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_CONSTRAINT_MUST_BE_STATIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a static data type, i.e. a vector or matrix with dimensions fixed at compile time, a compilation error is created.
Definition: Static.h:61
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5924
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5907
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3077
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Type ElementType
Type of the compressed matrix elements.
Definition: CompressedMatrix.h:3081
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the Columns type trait.
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3087
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:340
Header file for the IsUniTriangular type trait.
Constraints on the storage order of matrix types.
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:81
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:548
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:264
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:580
Header file for the 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:1500
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:270
Constraint on the data type.
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:324
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3082
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a &#39;res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:3083
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:252
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1375
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.In case of an invalid compile time expression, a compilation error is cr...
Definition: StaticAssert.h:112
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:742
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