Sparse.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_UPPERMATRIX_SPARSE_H_
36 #define _BLAZE_MATH_ADAPTORS_UPPERMATRIX_SPARSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <utility>
44 #include <vector>
48 #include <blaze/math/Aliases.h>
59 #include <blaze/math/Exception.h>
62 #include <blaze/math/shims/Clear.h>
69 #include <blaze/util/Assert.h>
74 #include <blaze/util/DisableIf.h>
75 #include <blaze/util/EnableIf.h>
77 #include <blaze/util/Types.h>
78 
79 
80 namespace blaze {
81 
82 //=================================================================================================
83 //
84 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
85 //
86 //=================================================================================================
87 
88 //*************************************************************************************************
96 template< typename MT // Type of the adapted sparse matrix
97  , bool SO > // Storage order of the adapted sparse matrix
98 class UpperMatrix<MT,SO,false>
99  : public SparseMatrix< UpperMatrix<MT,SO,false>, SO >
100 {
101  private:
102  //**Type definitions****************************************************************************
103  using OT = OppositeType_t<MT>;
104  using TT = TransposeType_t<MT>;
105  using ET = ElementType_t<MT>;
106  //**********************************************************************************************
107 
108  public:
109  //**Type definitions****************************************************************************
110  using This = UpperMatrix<MT,SO,false>;
111  using BaseType = SparseMatrix<This,SO>;
112  using ResultType = This;
113  using OppositeType = UpperMatrix<OT,!SO,false>;
114  using TransposeType = LowerMatrix<TT,!SO,false>;
115  using ElementType = ET;
116  using ReturnType = ReturnType_t<MT>;
117  using CompositeType = const This&;
118  using Reference = UpperProxy<MT>;
119  using ConstReference = ConstReference_t<MT>;
120  using Iterator = Iterator_t<MT>;
121  using ConstIterator = ConstIterator_t<MT>;
122  //**********************************************************************************************
123 
124  //**Rebind struct definition********************************************************************
127  template< typename NewType > // Data type of the other matrix
128  struct Rebind {
130  using Other = UpperMatrix< typename MT::template Rebind<NewType>::Other >;
131  };
132  //**********************************************************************************************
133 
134  //**Resize struct definition********************************************************************
137  template< size_t NewM // Number of rows of the other matrix
138  , size_t NewN > // Number of columns of the other matrix
139  struct Resize {
141  using Other = UpperMatrix< typename MT::template Resize<NewM,NewN>::Other >;
142  };
143  //**********************************************************************************************
144 
145  //**Compilation flags***************************************************************************
147  static constexpr bool smpAssignable = false;
148  //**********************************************************************************************
149 
150  //**Constructors********************************************************************************
153  explicit inline UpperMatrix();
154  explicit inline UpperMatrix( size_t n );
155  explicit inline UpperMatrix( size_t n, size_t nonzeros );
156  explicit inline UpperMatrix( size_t n, const std::vector<size_t>& nonzeros );
157  explicit inline UpperMatrix( initializer_list< initializer_list<ElementType> > list );
158 
159  inline UpperMatrix( const UpperMatrix& m );
160  inline UpperMatrix( UpperMatrix&& m ) noexcept;
161 
162  template< typename MT2, bool SO2 >
163  inline UpperMatrix( const Matrix<MT2,SO2>& m );
165  //**********************************************************************************************
166 
167  //**Destructor**********************************************************************************
170  ~UpperMatrix() = default;
172  //**********************************************************************************************
173 
174  //**Data access functions***********************************************************************
177  inline Reference operator()( size_t i, size_t j );
178  inline ConstReference operator()( size_t i, size_t j ) const;
179  inline Reference at( size_t i, size_t j );
180  inline ConstReference at( size_t i, size_t j ) const;
181  inline Iterator begin ( size_t i );
182  inline ConstIterator begin ( size_t i ) const;
183  inline ConstIterator cbegin( size_t i ) const;
184  inline Iterator end ( size_t i );
185  inline ConstIterator end ( size_t i ) const;
186  inline ConstIterator cend ( size_t i ) const;
188  //**********************************************************************************************
189 
190  //**Assignment operators************************************************************************
193  inline UpperMatrix& operator=( initializer_list< initializer_list<ElementType> > list );
194 
195  inline UpperMatrix& operator=( const UpperMatrix& rhs );
196  inline UpperMatrix& operator=( UpperMatrix&& rhs ) noexcept;
197 
198  template< typename MT2, bool SO2 >
199  inline auto operator=( const Matrix<MT2,SO2>& rhs )
200  -> DisableIf_t< IsComputation_v<MT2>, UpperMatrix& >;
201 
202  template< typename MT2, bool SO2 >
203  inline auto operator=( const Matrix<MT2,SO2>& rhs )
204  -> EnableIf_t< IsComputation_v<MT2>, UpperMatrix& >;
205 
206  template< typename MT2, bool SO2 >
207  inline auto operator+=( const Matrix<MT2,SO2>& rhs )
208  -> DisableIf_t< IsComputation_v<MT2>, UpperMatrix& >;
209 
210  template< typename MT2, bool SO2 >
211  inline auto operator+=( const Matrix<MT2,SO2>& rhs )
212  -> EnableIf_t< IsComputation_v<MT2>, UpperMatrix& >;
213 
214  template< typename MT2, bool SO2 >
215  inline auto operator-=( const Matrix<MT2,SO2>& rhs )
216  -> DisableIf_t< IsComputation_v<MT2>, UpperMatrix& >;
217 
218  template< typename MT2, bool SO2 >
219  inline auto operator-=( const Matrix<MT2,SO2>& rhs )
220  -> EnableIf_t< IsComputation_v<MT2>, UpperMatrix& >;
221 
222  template< typename MT2, bool SO2 >
223  inline auto operator%=( const Matrix<MT2,SO2>& rhs ) -> UpperMatrix&;
225  //**********************************************************************************************
226 
227  //**Utility functions***************************************************************************
230  inline size_t rows() const noexcept;
231  inline size_t columns() const noexcept;
232  inline size_t capacity() const noexcept;
233  inline size_t capacity( size_t i ) const noexcept;
234  inline size_t nonZeros() const;
235  inline size_t nonZeros( size_t i ) const;
236  inline void reset();
237  inline void reset( size_t i );
238  inline void clear();
239  inline void resize ( size_t n, bool preserve=true );
240  inline void reserve( size_t nonzeros );
241  inline void reserve( size_t i, size_t nonzeros );
242  inline void trim();
243  inline void trim( size_t i );
244  inline void shrinkToFit();
245  inline void swap( UpperMatrix& m ) noexcept;
246 
247  static inline constexpr size_t maxNonZeros() noexcept;
248  static inline constexpr size_t maxNonZeros( size_t n ) noexcept;
250  //**********************************************************************************************
251 
252  //**Insertion functions*************************************************************************
255  inline Iterator set( size_t i, size_t j, const ElementType& value );
256  inline Iterator insert( size_t i, size_t j, const ElementType& value );
257  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
258  inline void finalize( size_t i );
260  //**********************************************************************************************
261 
262  //**Erase functions*****************************************************************************
265  inline void erase( size_t i, size_t j );
266  inline Iterator erase( size_t i, Iterator pos );
267  inline Iterator erase( size_t i, Iterator first, Iterator last );
268 
269  template< typename Pred >
270  inline void erase( Pred predicate );
271 
272  template< typename Pred >
273  inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
275  //**********************************************************************************************
276 
277  //**Lookup functions****************************************************************************
280  inline Iterator find ( size_t i, size_t j );
281  inline ConstIterator find ( size_t i, size_t j ) const;
282  inline Iterator lowerBound( size_t i, size_t j );
283  inline ConstIterator lowerBound( size_t i, size_t j ) const;
284  inline Iterator upperBound( size_t i, size_t j );
285  inline ConstIterator upperBound( size_t i, size_t j ) const;
287  //**********************************************************************************************
288 
289  //**Numeric functions***************************************************************************
292  template< typename Other > inline UpperMatrix& scale( const Other& scalar );
294  //**********************************************************************************************
295 
296  //**Debugging functions*************************************************************************
299  inline bool isIntact() const noexcept;
301  //**********************************************************************************************
302 
303  //**Expression template evaluation functions****************************************************
306  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
307  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
308 
309  inline bool canSMPAssign() const noexcept;
311  //**********************************************************************************************
312 
313  private:
314  //**Utility functions***************************************************************************
317  inline void resetLower();
319  //**********************************************************************************************
320 
321  //**Member variables****************************************************************************
324  MT matrix_;
325 
326  //**********************************************************************************************
327 
328  //**Friend declarations*************************************************************************
329  template< bool RF, typename MT2, bool SO2, bool DF2 >
330  friend bool isDefault( const UpperMatrix<MT2,SO2,DF2>& m );
331 
332  template< typename MT2, bool SO2, bool DF2 >
333  friend MT2& derestrict( UpperMatrix<MT2,SO2,DF2>& m );
334  //**********************************************************************************************
335 
336  //**Compile time checks*************************************************************************
349  BLAZE_STATIC_ASSERT( ( Size_v<MT,0UL> == Size_v<MT,1UL> ) );
350  //**********************************************************************************************
351 };
353 //*************************************************************************************************
354 
355 
356 
357 
358 //=================================================================================================
359 //
360 // CONSTRUCTORS
361 //
362 //=================================================================================================
363 
364 //*************************************************************************************************
368 template< typename MT // Type of the adapted sparse matrix
369  , bool SO > // Storage order of the adapted sparse matrix
370 inline UpperMatrix<MT,SO,false>::UpperMatrix()
371  : matrix_() // The adapted sparse matrix
372 {
373  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
374 }
376 //*************************************************************************************************
377 
378 
379 //*************************************************************************************************
387 template< typename MT // Type of the adapted sparse matrix
388  , bool SO > // Storage order of the adapted sparse matrix
389 inline UpperMatrix<MT,SO,false>::UpperMatrix( size_t n )
390  : matrix_( n, n ) // The adapted sparse matrix
391 {
393 
394  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
395 }
397 //*************************************************************************************************
398 
399 
400 //*************************************************************************************************
409 template< typename MT // Type of the adapted sparse matrix
410  , bool SO > // Storage order of the adapted sparse matrix
411 inline UpperMatrix<MT,SO,false>::UpperMatrix( size_t n, size_t nonzeros )
412  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
413 {
415 
416  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
417 }
419 //*************************************************************************************************
420 
421 
422 //*************************************************************************************************
433 template< typename MT // Type of the adapted sparse matrix
434  , bool SO > // Storage order of the adapted sparse matrix
435 inline UpperMatrix<MT,SO,false>::UpperMatrix( size_t n, const std::vector<size_t>& nonzeros )
436  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
437 {
439 
440  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
441 }
443 //*************************************************************************************************
444 
445 
446 //*************************************************************************************************
470 template< typename MT // Type of the adapted sparse matrix
471  , bool SO > // Storage order of the adapted sparse matrix
472 inline UpperMatrix<MT,SO,false>::UpperMatrix( initializer_list< initializer_list<ElementType> > list )
473  : matrix_( list ) // The adapted sparse matrix
474 {
475  if( !isUpper( matrix_ ) ) {
476  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of upper matrix" );
477  }
478 
479  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
480 }
482 //*************************************************************************************************
483 
484 
485 //*************************************************************************************************
491 template< typename MT // Type of the adapted sparse matrix
492  , bool SO > // Storage order of the adapted sparse matrix
493 inline UpperMatrix<MT,SO,false>::UpperMatrix( const UpperMatrix& m )
494  : matrix_( m.matrix_ ) // The adapted sparse matrix
495 {
496  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
497  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
498 }
500 //*************************************************************************************************
501 
502 
503 //*************************************************************************************************
509 template< typename MT // Type of the adapted sparse matrix
510  , bool SO > // Storage order of the adapted sparse matrix
511 inline UpperMatrix<MT,SO,false>::UpperMatrix( UpperMatrix&& m ) noexcept
512  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
513 {
514  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
515  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
516 }
518 //*************************************************************************************************
519 
520 
521 //*************************************************************************************************
531 template< typename MT // Type of the adapted sparse matrix
532  , bool SO > // Storage order of the adapted sparse matrix
533 template< typename MT2 // Type of the foreign matrix
534  , bool SO2 > // Storage order of the foreign matrix
535 inline UpperMatrix<MT,SO,false>::UpperMatrix( const Matrix<MT2,SO2>& m )
536  : matrix_( ~m ) // The adapted sparse matrix
537 {
538  if( !IsUpper_v<MT2> && !isUpper( matrix_ ) ) {
539  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of upper matrix" );
540  }
541 
542  if( !IsUpper_v<MT2> )
543  resetLower();
544 
545  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
546  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
547 }
549 //*************************************************************************************************
550 
551 
552 
553 
554 //=================================================================================================
555 //
556 // DATA ACCESS FUNCTIONS
557 //
558 //=================================================================================================
559 
560 //*************************************************************************************************
576 template< typename MT // Type of the adapted sparse matrix
577  , bool SO > // Storage order of the adapted sparse matrix
579  UpperMatrix<MT,SO,false>::operator()( size_t i, size_t j )
580 {
581  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
582  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
583 
584  return Reference( matrix_, i, j );
585 }
587 //*************************************************************************************************
588 
589 
590 //*************************************************************************************************
606 template< typename MT // Type of the adapted sparse matrix
607  , bool SO > // Storage order of the adapted sparse matrix
609  UpperMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
610 {
611  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
612  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
613 
614  return matrix_(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  UpperMatrix<MT,SO,false>::at( size_t i, size_t j )
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 //*************************************************************************************************
671 template< typename MT // Type of the adapted sparse matrix
672  , bool SO > // Storage order of the adapted sparse matrix
674  UpperMatrix<MT,SO,false>::at( size_t i, size_t j ) const
675 {
676  if( i >= rows() ) {
677  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
678  }
679  if( j >= columns() ) {
680  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
681  }
682  return (*this)(i,j);
683 }
685 //*************************************************************************************************
686 
687 
688 //*************************************************************************************************
700 template< typename MT // Type of the adapted sparse matrix
701  , bool SO > // Storage order of the adapted sparse matrix
704 {
705  return matrix_.begin(i);
706 }
708 //*************************************************************************************************
709 
710 
711 //*************************************************************************************************
723 template< typename MT // Type of the adapted sparse matrix
724  , bool SO > // Storage order of the adapted sparse matrix
726  UpperMatrix<MT,SO,false>::begin( size_t i ) const
727 {
728  return matrix_.begin(i);
729 }
731 //*************************************************************************************************
732 
733 
734 //*************************************************************************************************
746 template< typename MT // Type of the adapted sparse matrix
747  , bool SO > // Storage order of the adapted sparse matrix
749  UpperMatrix<MT,SO,false>::cbegin( size_t i ) const
750 {
751  return matrix_.cbegin(i);
752 }
754 //*************************************************************************************************
755 
756 
757 //*************************************************************************************************
769 template< typename MT // Type of the adapted sparse matrix
770  , bool SO > // Storage order of the adapted sparse matrix
773 {
774  return matrix_.end(i);
775 }
777 //*************************************************************************************************
778 
779 
780 //*************************************************************************************************
792 template< typename MT // Type of the adapted sparse matrix
793  , bool SO > // Storage order of the adapted sparse matrix
795  UpperMatrix<MT,SO,false>::end( size_t i ) const
796 {
797  return matrix_.end(i);
798 }
800 //*************************************************************************************************
801 
802 
803 //*************************************************************************************************
815 template< typename MT // Type of the adapted sparse matrix
816  , bool SO > // Storage order of the adapted sparse matrix
818  UpperMatrix<MT,SO,false>::cend( size_t i ) const
819 {
820  return matrix_.cend(i);
821 }
823 //*************************************************************************************************
824 
825 
826 
827 
828 //=================================================================================================
829 //
830 // ASSIGNMENT OPERATORS
831 //
832 //=================================================================================================
833 
834 //*************************************************************************************************
859 template< typename MT // Type of the adapted sparse matrix
860  , bool SO > // Storage order of the adapted sparse matrix
861 inline UpperMatrix<MT,SO,false>&
862  UpperMatrix<MT,SO,false>::operator=( initializer_list< initializer_list<ElementType> > list )
863 {
864  const InitializerMatrix<ElementType> tmp( list, list.size() );
865 
866  if( !isUpper( tmp ) ) {
867  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
868  }
869 
870  matrix_ = list;
871 
872  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
873  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
874 
875  return *this;
876 }
878 //*************************************************************************************************
879 
880 
881 //*************************************************************************************************
891 template< typename MT // Type of the adapted sparse matrix
892  , bool SO > // Storage order of the adapted sparse matrix
893 inline UpperMatrix<MT,SO,false>&
894  UpperMatrix<MT,SO,false>::operator=( const UpperMatrix& rhs )
895 {
896  matrix_ = rhs.matrix_;
897 
898  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
899  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
900 
901  return *this;
902 }
904 //*************************************************************************************************
905 
906 
907 //*************************************************************************************************
914 template< typename MT // Type of the adapted sparse matrix
915  , bool SO > // Storage order of the adapted sparse matrix
916 inline UpperMatrix<MT,SO,false>&
917  UpperMatrix<MT,SO,false>::operator=( UpperMatrix&& rhs ) noexcept
918 {
919  matrix_ = std::move( rhs.matrix_ );
920 
921  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
922  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
923 
924  return *this;
925 }
927 //*************************************************************************************************
928 
929 
930 //*************************************************************************************************
943 template< typename MT // Type of the adapted sparse matrix
944  , bool SO > // Storage order of the adapted sparse matrix
945 template< typename MT2 // Type of the right-hand side matrix
946  , bool SO2 > // Storage order of the right-hand side matrix
947 inline auto UpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
948  -> DisableIf_t< IsComputation_v<MT2>, UpperMatrix& >
949 {
950  if( !IsUpper_v<MT2> && !isUpper( ~rhs ) ) {
951  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
952  }
953 
954  matrix_ = declupp( ~rhs );
955 
956  if( !IsUpper_v<MT2> )
957  resetLower();
958 
959  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
960  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
961 
962  return *this;
963 }
965 //*************************************************************************************************
966 
967 
968 //*************************************************************************************************
981 template< typename MT // Type of the adapted sparse matrix
982  , bool SO > // Storage order of the adapted sparse matrix
983 template< typename MT2 // Type of the right-hand side matrix
984  , bool SO2 > // Storage order of the right-hand side matrix
985 inline auto UpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
986  -> EnableIf_t< IsComputation_v<MT2>, UpperMatrix& >
987 {
988  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
989  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
990  }
991 
992  if( IsUpper_v<MT2> ) {
993  matrix_ = ~rhs;
994  }
995  else {
996  MT tmp( ~rhs );
997 
998  if( !isUpper( tmp ) ) {
999  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
1000  }
1001 
1002  matrix_ = std::move( tmp );
1003  }
1004 
1005  if( !IsUpper_v<MT2> )
1006  resetLower();
1007 
1008  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
1009  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1010 
1011  return *this;
1012 }
1014 //*************************************************************************************************
1015 
1016 
1017 //*************************************************************************************************
1030 template< typename MT // Type of the adapted sparse matrix
1031  , bool SO > // Storage order of the adapted sparse matrix
1032 template< typename MT2 // Type of the right-hand side matrix
1033  , bool SO2 > // Storage order of the right-hand side matrix
1034 inline auto UpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1035  -> DisableIf_t< IsComputation_v<MT2>, UpperMatrix& >
1036 {
1037  if( !IsUpper_v<MT2> && !isUpper( ~rhs ) ) {
1038  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
1039  }
1040 
1041  matrix_ += declupp( ~rhs );
1042 
1043  if( !IsUpper_v<MT2> )
1044  resetLower();
1045 
1046  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
1047  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1048 
1049  return *this;
1050 }
1052 //*************************************************************************************************
1053 
1054 
1055 //*************************************************************************************************
1068 template< typename MT // Type of the adapted sparse matrix
1069  , bool SO > // Storage order of the adapted sparse matrix
1070 template< typename MT2 // Type of the right-hand side matrix
1071  , bool SO2 > // Storage order of the right-hand side matrix
1072 inline auto UpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1073  -> EnableIf_t< IsComputation_v<MT2>, UpperMatrix& >
1074 {
1075  if( IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1076  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
1077  }
1078 
1079  if( IsUpper_v<MT2> ) {
1080  matrix_ += ~rhs;
1081  }
1082  else {
1083  const ResultType_t<MT2> tmp( ~rhs );
1084 
1085  if( !isUpper( tmp ) ) {
1086  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
1087  }
1088 
1089  matrix_ += declupp( tmp );
1090  }
1091 
1092  if( !IsUpper_v<MT2> )
1093  resetLower();
1094 
1095  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
1096  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1097 
1098  return *this;
1099 }
1101 //*************************************************************************************************
1102 
1103 
1104 //*************************************************************************************************
1117 template< typename MT // Type of the adapted sparse matrix
1118  , bool SO > // Storage order of the adapted sparse matrix
1119 template< typename MT2 // Type of the right-hand side matrix
1120  , bool SO2 > // Storage order of the right-hand side matrix
1121 inline auto UpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1122  -> DisableIf_t< IsComputation_v<MT2>, UpperMatrix& >
1123 {
1124  if( !IsUpper_v<MT2> && !isUpper( ~rhs ) ) {
1125  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
1126  }
1127 
1128  matrix_ -= declupp( ~rhs );
1129 
1130  if( !IsUpper_v<MT2> )
1131  resetLower();
1132 
1133  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
1134  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1135 
1136  return *this;
1137 }
1139 //*************************************************************************************************
1140 
1141 
1142 //*************************************************************************************************
1155 template< typename MT // Type of the adapted sparse matrix
1156  , bool SO > // Storage order of the adapted sparse matrix
1157 template< typename MT2 // Type of the right-hand side matrix
1158  , bool SO2 > // Storage order of the right-hand side matrix
1159 inline auto UpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1160  -> EnableIf_t< IsComputation_v<MT2>, UpperMatrix& >
1161 {
1162  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1163  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
1164  }
1165 
1166  if( IsUpper_v<MT2> ) {
1167  matrix_ -= ~rhs;
1168  }
1169  else {
1170  const ResultType_t<MT2> tmp( ~rhs );
1171 
1172  if( !isUpper( tmp ) ) {
1173  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
1174  }
1175 
1176  matrix_ -= declupp( tmp );
1177  }
1178 
1179  if( !IsUpper_v<MT2> )
1180  resetLower();
1181 
1182  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
1183  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1184 
1185  return *this;
1186 }
1188 //*************************************************************************************************
1189 
1190 
1191 //*************************************************************************************************
1202 template< typename MT // Type of the adapted sparse matrix
1203  , bool SO > // Storage order of the adapted sparse matrix
1204 template< typename MT2 // Type of the right-hand side matrix
1205  , bool SO2 > // Storage order of the right-hand side matrix
1206 inline auto UpperMatrix<MT,SO,false>::operator%=( const Matrix<MT2,SO2>& rhs )
1207  -> UpperMatrix&
1208 {
1209  if( !IsSquare_v<MT2> && !isSquare( ~rhs ) ) {
1210  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
1211  }
1212 
1213  matrix_ %= ~rhs;
1214 
1215  if( !IsUpper_v<MT2> )
1216  resetLower();
1217 
1218  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
1219  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1220 
1221  return *this;
1222 }
1224 //*************************************************************************************************
1225 
1226 
1227 
1228 
1229 //=================================================================================================
1230 //
1231 // UTILITY FUNCTIONS
1232 //
1233 //=================================================================================================
1234 
1235 //*************************************************************************************************
1241 template< typename MT // Type of the adapted sparse matrix
1242  , bool SO > // Storage order of the adapted sparse matrix
1243 inline size_t UpperMatrix<MT,SO,false>::rows() const noexcept
1244 {
1245  return matrix_.rows();
1246 }
1248 //*************************************************************************************************
1249 
1250 
1251 //*************************************************************************************************
1257 template< typename MT // Type of the adapted sparse matrix
1258  , bool SO > // Storage order of the adapted sparse matrix
1259 inline size_t UpperMatrix<MT,SO,false>::columns() const noexcept
1260 {
1261  return matrix_.columns();
1262 }
1264 //*************************************************************************************************
1265 
1266 
1267 //*************************************************************************************************
1273 template< typename MT // Type of the adapted sparse matrix
1274  , bool SO > // Storage order of the adapted sparse matrix
1275 inline size_t UpperMatrix<MT,SO,false>::capacity() const noexcept
1276 {
1277  return matrix_.capacity();
1278 }
1280 //*************************************************************************************************
1281 
1282 
1283 //*************************************************************************************************
1295 template< typename MT // Type of the adapted sparse matrix
1296  , bool SO > // Storage order of the adapted sparse matrix
1297 inline size_t UpperMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1298 {
1299  return matrix_.capacity(i);
1300 }
1302 //*************************************************************************************************
1303 
1304 
1305 //*************************************************************************************************
1311 template< typename MT // Type of the adapted sparse matrix
1312  , bool SO > // Storage order of the adapted sparse matrix
1313 inline size_t UpperMatrix<MT,SO,false>::nonZeros() const
1314 {
1315  return matrix_.nonZeros();
1316 }
1318 //*************************************************************************************************
1319 
1320 
1321 //*************************************************************************************************
1333 template< typename MT // Type of the adapted sparse matrix
1334  , bool SO > // Storage order of the adapted sparse matrix
1335 inline size_t UpperMatrix<MT,SO,false>::nonZeros( size_t i ) const
1336 {
1337  return matrix_.nonZeros(i);
1338 }
1340 //*************************************************************************************************
1341 
1342 
1343 //*************************************************************************************************
1349 template< typename MT // Type of the adapted sparse matrix
1350  , bool SO > // Storage order of the adapted sparse matrix
1351 inline void UpperMatrix<MT,SO,false>::reset()
1352 {
1353  matrix_.reset();
1354 }
1356 //*************************************************************************************************
1357 
1358 
1359 //*************************************************************************************************
1372 template< typename MT // Type of the adapted sparse matrix
1373  , bool SO > // Storage order of the adapted sparse matrix
1374 inline void UpperMatrix<MT,SO,false>::reset( size_t i )
1375 {
1376  matrix_.reset( i );
1377 }
1379 //*************************************************************************************************
1380 
1381 
1382 //*************************************************************************************************
1390 template< typename MT // Type of the adapted sparse matrix
1391  , bool SO > // Storage order of the adapted sparse matrix
1392 inline void UpperMatrix<MT,SO,false>::clear()
1393 {
1394  using blaze::clear;
1395 
1396  clear( matrix_ );
1397 }
1399 //*************************************************************************************************
1400 
1401 
1402 //*************************************************************************************************
1417 template< typename MT // Type of the adapted sparse matrix
1418  , bool SO > // Storage order of the adapted sparse matrix
1419 void UpperMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1420 {
1422 
1423  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
1424 
1425  matrix_.resize( n, n, preserve );
1426 }
1428 //*************************************************************************************************
1429 
1430 
1431 //*************************************************************************************************
1442 template< typename MT // Type of the adapted sparse matrix
1443  , bool SO > // Storage order of the adapted sparse matrix
1444 inline void UpperMatrix<MT,SO,false>::reserve( size_t nonzeros )
1445 {
1446  matrix_.reserve( nonzeros );
1447 }
1449 //*************************************************************************************************
1450 
1451 
1452 //*************************************************************************************************
1466 template< typename MT // Type of the adapted sparse matrix
1467  , bool SO > // Storage order of the adapted sparse matrix
1468 inline void UpperMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1469 {
1470  matrix_.reserve( i, nonzeros );
1471 }
1473 //*************************************************************************************************
1474 
1475 
1476 //*************************************************************************************************
1487 template< typename MT // Type of the adapted sparse matrix
1488  , bool SO > // Storage order of the adapted sparse matrix
1489 inline void UpperMatrix<MT,SO,false>::trim()
1490 {
1491  matrix_.trim();
1492 }
1494 //*************************************************************************************************
1495 
1496 
1497 //*************************************************************************************************
1509 template< typename MT // Type of the adapted sparse matrix
1510  , bool SO > // Storage order of the adapted sparse matrix
1511 inline void UpperMatrix<MT,SO,false>::trim( size_t i )
1512 {
1513  matrix_.trim( i );
1514 }
1516 //*************************************************************************************************
1517 
1518 
1519 //*************************************************************************************************
1529 template< typename MT // Type of the adapted sparse matrix
1530  , bool SO > // Storage order of the adapted sparse matrix
1532 {
1533  matrix_.shrinkToFit();
1534 }
1536 //*************************************************************************************************
1537 
1538 
1539 //*************************************************************************************************
1546 template< typename MT // Type of the adapted sparse matrix
1547  , bool SO > // Storage order of the adapted sparse matrix
1548 inline void UpperMatrix<MT,SO,false>::swap( UpperMatrix& m ) noexcept
1549 {
1550  using std::swap;
1551 
1552  swap( matrix_, m.matrix_ );
1553 }
1555 //*************************************************************************************************
1556 
1557 
1558 //*************************************************************************************************
1569 template< typename MT // Type of the adapted dense matrix
1570  , bool SO > // Storage order of the adapted dense matrix
1571 inline constexpr size_t UpperMatrix<MT,SO,false>::maxNonZeros() noexcept
1572 {
1574 
1575  return maxNonZeros( Size_v<MT,0UL> );
1576 }
1578 //*************************************************************************************************
1579 
1580 
1581 //*************************************************************************************************
1591 template< typename MT // Type of the adapted dense matrix
1592  , bool SO > // Storage order of the adapted dense matrix
1593 inline constexpr size_t UpperMatrix<MT,SO,false>::maxNonZeros( size_t n ) noexcept
1594 {
1595  return ( ( n + 1UL ) * n ) / 2UL;
1596 }
1598 //*************************************************************************************************
1599 
1600 
1601 //*************************************************************************************************
1607 template< typename MT // Type of the adapted dense matrix
1608  , bool SO > // Storage order of the adapted dense matrix
1609 inline void UpperMatrix<MT,SO,false>::resetLower()
1610 {
1611  using blaze::erase;
1612 
1613  if( SO ) {
1614  for( size_t j=0UL; j<columns(); ++j )
1615  erase( matrix_, j, matrix_.upperBound( j, j ), matrix_.end( j ) );
1616  }
1617  else {
1618  for( size_t i=1UL; i<rows(); ++i )
1619  erase( matrix_, i, matrix_.begin( i ), matrix_.lowerBound( i, i ) );
1620  }
1621 }
1623 //*************************************************************************************************
1624 
1625 
1626 
1627 
1628 //=================================================================================================
1629 //
1630 // INSERTION FUNCTIONS
1631 //
1632 //=================================================================================================
1633 
1634 //*************************************************************************************************
1650 template< typename MT // Type of the adapted sparse matrix
1651  , bool SO > // Storage order of the adapted sparse matrix
1652 inline typename UpperMatrix<MT,SO,false>::Iterator
1653  UpperMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1654 {
1655  if( i > j ) {
1656  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to lower matrix element" );
1657  }
1658 
1659  return matrix_.set( i, j, value );
1660 }
1662 //*************************************************************************************************
1663 
1664 
1665 //*************************************************************************************************
1682 template< typename MT // Type of the adapted sparse matrix
1683  , bool SO > // Storage order of the adapted sparse matrix
1684 inline typename UpperMatrix<MT,SO,false>::Iterator
1685  UpperMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1686 {
1687  if( i > j ) {
1688  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to lower matrix element" );
1689  }
1690 
1691  return matrix_.insert( i, j, value );
1692 }
1694 //*************************************************************************************************
1695 
1696 
1697 //*************************************************************************************************
1747 template< typename MT // Type of the adapted sparse matrix
1748  , bool SO > // Storage order of the adapted sparse matrix
1749 inline void UpperMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1750 {
1751  if( i > j ) {
1752  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to lower matrix element" );
1753  }
1754 
1755  matrix_.append( i, j, value, check );
1756 }
1758 //*************************************************************************************************
1759 
1760 
1761 //*************************************************************************************************
1775 template< typename MT // Type of the adapted sparse matrix
1776  , bool SO > // Storage order of the adapted sparse matrix
1777 inline void UpperMatrix<MT,SO,false>::finalize( size_t i )
1778 {
1779  matrix_.finalize( i );
1780 }
1782 //*************************************************************************************************
1783 
1784 
1785 
1786 
1787 //=================================================================================================
1788 //
1789 // ERASE FUNCTIONS
1790 //
1791 //=================================================================================================
1792 
1793 //*************************************************************************************************
1803 template< typename MT // Type of the adapted sparse matrix
1804  , bool SO > // Storage order of the adapted sparse matrix
1805 inline void UpperMatrix<MT,SO,false>::erase( size_t i, size_t j )
1806 {
1807  using blaze::erase;
1808 
1809  erase( matrix_, i, j );
1810 }
1812 //*************************************************************************************************
1813 
1814 
1815 //*************************************************************************************************
1827 template< typename MT // Type of the adapted sparse matrix
1828  , bool SO > // Storage order of the adapted sparse matrix
1829 inline typename UpperMatrix<MT,SO,false>::Iterator
1830  UpperMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1831 {
1832  using blaze::erase;
1833 
1834  return erase( matrix_, i, pos );
1835 }
1837 //*************************************************************************************************
1838 
1839 
1840 //*************************************************************************************************
1853 template< typename MT // Type of the adapted sparse matrix
1854  , bool SO > // Storage order of the adapted sparse matrix
1855 inline typename UpperMatrix<MT,SO,false>::Iterator
1856  UpperMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1857 {
1858  using blaze::erase;
1859 
1860  return erase( matrix_, i, first, last );
1861 }
1863 //*************************************************************************************************
1864 
1865 
1866 //*************************************************************************************************
1888 template< typename MT // Type of the adapted sparse matrix
1889  , bool SO > // Storage order of the adapted sparse matrix
1890 template< typename Pred > // Type of the unary predicate
1891 inline void UpperMatrix<MT,SO,false>::erase( Pred predicate )
1892 {
1893  using blaze::erase;
1894 
1895  erase( matrix_, predicate );
1896 
1897  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1898 }
1900 //*************************************************************************************************
1901 
1902 
1903 //*************************************************************************************************
1931 template< typename MT // Type of the adapted sparse matrix
1932  , bool SO > // Storage order of the adapted sparse matrix
1933 template< typename Pred > // Type of the unary predicate
1934 inline void UpperMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
1935 {
1936  using blaze::erase;
1937 
1938  erase( matrix_, i, first, last, predicate );
1939 
1940  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1941 }
1943 //*************************************************************************************************
1944 
1945 
1946 
1947 
1948 //=================================================================================================
1949 //
1950 // LOOKUP FUNCTIONS
1951 //
1952 //=================================================================================================
1953 
1954 //*************************************************************************************************
1970 template< typename MT // Type of the adapted sparse matrix
1971  , bool SO > // Storage order of the adapted sparse matrix
1972 inline typename UpperMatrix<MT,SO,false>::Iterator
1973  UpperMatrix<MT,SO,false>::find( size_t i, size_t j )
1974 {
1975  return matrix_.find( i, j );
1976 }
1978 //*************************************************************************************************
1979 
1980 
1981 //*************************************************************************************************
1997 template< typename MT // Type of the adapted sparse matrix
1998  , bool SO > // Storage order of the adapted sparse matrix
2000  UpperMatrix<MT,SO,false>::find( size_t i, size_t j ) const
2001 {
2002  return matrix_.find( i, j );
2003 }
2005 //*************************************************************************************************
2006 
2007 
2008 //*************************************************************************************************
2024 template< typename MT // Type of the adapted sparse matrix
2025  , bool SO > // Storage order of the adapted sparse matrix
2026 inline typename UpperMatrix<MT,SO,false>::Iterator
2027  UpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
2028 {
2029  return matrix_.lowerBound( i, j );
2030 }
2032 //*************************************************************************************************
2033 
2034 
2035 //*************************************************************************************************
2051 template< typename MT // Type of the adapted sparse matrix
2052  , bool SO > // Storage order of the adapted sparse matrix
2054  UpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
2055 {
2056  return matrix_.lowerBound( i, j );
2057 }
2059 //*************************************************************************************************
2060 
2061 
2062 //*************************************************************************************************
2078 template< typename MT // Type of the adapted sparse matrix
2079  , bool SO > // Storage order of the adapted sparse matrix
2080 inline typename UpperMatrix<MT,SO,false>::Iterator
2081  UpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
2082 {
2083  return matrix_.upperBound( i, j );
2084 }
2086 //*************************************************************************************************
2087 
2088 
2089 //*************************************************************************************************
2105 template< typename MT // Type of the adapted sparse matrix
2106  , bool SO > // Storage order of the adapted sparse matrix
2108  UpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
2109 {
2110  return matrix_.upperBound( i, j );
2111 }
2113 //*************************************************************************************************
2114 
2115 
2116 
2117 
2118 //=================================================================================================
2119 //
2120 // NUMERIC FUNCTIONS
2121 //
2122 //=================================================================================================
2123 
2124 //*************************************************************************************************
2142 template< typename MT // Type of the adapted sparse matrix
2143  , bool SO > // Storage order of the adapted sparse matrix
2144 template< typename Other > // Data type of the scalar value
2145 inline UpperMatrix<MT,SO,false>&
2146  UpperMatrix<MT,SO,false>::scale( const Other& scalar )
2147 {
2148  matrix_.scale( scalar );
2149  return *this;
2150 }
2152 //*************************************************************************************************
2153 
2154 
2155 
2156 
2157 //=================================================================================================
2158 //
2159 // DEBUGGING FUNCTIONS
2160 //
2161 //=================================================================================================
2162 
2163 //*************************************************************************************************
2173 template< typename MT // Type of the adapted sparse matrix
2174  , bool SO > // Storage order of the adapted sparse matrix
2175 inline bool UpperMatrix<MT,SO,false>::isIntact() const noexcept
2176 {
2177  using blaze::isIntact;
2178 
2179  return ( isIntact( matrix_ ) && isUpper( matrix_ ) );
2180 }
2182 //*************************************************************************************************
2183 
2184 
2185 
2186 
2187 //=================================================================================================
2188 //
2189 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2190 //
2191 //=================================================================================================
2192 
2193 //*************************************************************************************************
2204 template< typename MT // Type of the adapted sparse matrix
2205  , bool SO > // Storage order of the adapted sparse matrix
2206 template< typename Other > // Data type of the foreign expression
2207 inline bool UpperMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2208 {
2209  return matrix_.canAlias( alias );
2210 }
2212 //*************************************************************************************************
2213 
2214 
2215 //*************************************************************************************************
2226 template< typename MT // Type of the adapted sparse matrix
2227  , bool SO > // Storage order of the adapted sparse matrix
2228 template< typename Other > // Data type of the foreign expression
2229 inline bool UpperMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2230 {
2231  return matrix_.isAliased( alias );
2232 }
2234 //*************************************************************************************************
2235 
2236 
2237 //*************************************************************************************************
2248 template< typename MT // Type of the adapted sparse matrix
2249  , bool SO > // Storage order of the adapted sparse matrix
2250 inline bool UpperMatrix<MT,SO,false>::canSMPAssign() const noexcept
2251 {
2252  return matrix_.canSMPAssign();
2253 }
2255 //*************************************************************************************************
2256 
2257 } // namespace blaze
2258 
2259 #endif
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:79
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:3078
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1271
#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
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:546
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
Constraint on the data type.
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:3077
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3075
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: CompressedMatrix.h:3113
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:799
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5828
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:3079
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:3084
decltype(auto) declupp(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as upper.
Definition: DMatDeclUppExpr.h:1002
#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
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:584
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
Header file for the extended initializer_list functionality.
Constraint on the data type.
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
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:482
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:416
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
Header file for utility functions for sparse matrices.
Header file for the IsSquare type trait.
Constraint on the data type.
Header file for the implementation of a matrix representation of an initializer list.
Header file for the DisableIf class template.
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:3083
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#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:5907
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5890
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:3076
#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:3080
#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
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:3086
Constraint on the data type.
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
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:738
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:438
Header file for the UpperProxy class.
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
Header file for all adaptor forward declarations.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1357
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:281
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
Constraint on the data type.
Constraint on the data type.
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:3081
#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:3082
#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:263
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
#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
Header file for the IsUpper type trait.
#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
Header file for the implementation of the base template of the UpperMatrix.
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:951
Header file for the Size 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
constexpr ptrdiff_t Size_v
Auxiliary variable template for the Size type trait.The Size_v variable template provides a convenien...
Definition: Size.h:176
Header file for the clear shim.