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>
56 #include <blaze/math/Exception.h>
58 #include <blaze/math/shims/Clear.h>
66 #include <blaze/util/Assert.h>
71 #include <blaze/util/DisableIf.h>
72 #include <blaze/util/EnableIf.h>
75 #include <blaze/util/Types.h>
76 
77 
78 namespace blaze {
79 
80 //=================================================================================================
81 //
82 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
83 //
84 //=================================================================================================
85 
86 //*************************************************************************************************
94 template< typename MT // Type of the adapted sparse matrix
95  , bool SO > // Storage order of the adapted sparse matrix
96 class UpperMatrix<MT,SO,false>
97  : public SparseMatrix< UpperMatrix<MT,SO,false>, SO >
98 {
99  private:
100  //**Type definitions****************************************************************************
101  typedef OppositeType_<MT> OT;
102  typedef TransposeType_<MT> TT;
103  typedef ElementType_<MT> ET;
104  //**********************************************************************************************
105 
106  public:
107  //**Type definitions****************************************************************************
108  typedef UpperMatrix<MT,SO,false> This;
109  typedef SparseMatrix<This,SO> BaseType;
110  typedef This ResultType;
111  typedef UpperMatrix<OT,!SO,false> OppositeType;
112  typedef LowerMatrix<TT,!SO,false> TransposeType;
113  typedef ET ElementType;
114  typedef ReturnType_<MT> ReturnType;
115  typedef const This& CompositeType;
116  typedef UpperProxy<MT> Reference;
117  typedef ConstReference_<MT> ConstReference;
118  typedef Iterator_<MT> Iterator;
119  typedef ConstIterator_<MT> ConstIterator;
120  //**********************************************************************************************
121 
122  //**Rebind struct definition********************************************************************
125  template< typename ET > // Data type of the other matrix
126  struct Rebind {
128  typedef UpperMatrix< typename MT::template Rebind<ET>::Other > Other;
129  };
130  //**********************************************************************************************
131 
132  //**Compilation flags***************************************************************************
134  enum : bool { smpAssignable = false };
135  //**********************************************************************************************
136 
137  //**Constructors********************************************************************************
140  explicit inline UpperMatrix();
141  explicit inline UpperMatrix( size_t n );
142  explicit inline UpperMatrix( size_t n, size_t nonzeros );
143  explicit inline UpperMatrix( size_t n, const std::vector<size_t>& nonzeros );
144 
145  inline UpperMatrix( const UpperMatrix& m );
146  inline UpperMatrix( UpperMatrix&& m ) noexcept;
147 
148  template< typename MT2, bool SO2 >
149  inline UpperMatrix( const Matrix<MT2,SO2>& m );
151  //**********************************************************************************************
152 
153  //**Destructor**********************************************************************************
154  // No explicitly declared destructor.
155  //**********************************************************************************************
156 
157  //**Data access functions***********************************************************************
160  inline Reference operator()( size_t i, size_t j );
161  inline ConstReference operator()( size_t i, size_t j ) const;
162  inline Reference at( size_t i, size_t j );
163  inline ConstReference at( size_t i, size_t j ) const;
164  inline Iterator begin ( size_t i );
165  inline ConstIterator begin ( size_t i ) const;
166  inline ConstIterator cbegin( size_t i ) const;
167  inline Iterator end ( size_t i );
168  inline ConstIterator end ( size_t i ) const;
169  inline ConstIterator cend ( size_t i ) const;
171  //**********************************************************************************************
172 
173  //**Assignment operators************************************************************************
176  inline UpperMatrix& operator=( const UpperMatrix& rhs );
177  inline UpperMatrix& operator=( UpperMatrix&& rhs ) noexcept;
178 
179  template< typename MT2, bool SO2 >
180  inline DisableIf_< IsComputation<MT2>, UpperMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
181 
182  template< typename MT2, bool SO2 >
183  inline EnableIf_< IsComputation<MT2>, UpperMatrix& > operator=( const Matrix<MT2,SO2>& rhs );
184 
185  template< typename MT2, bool SO2 >
186  inline DisableIf_< IsComputation<MT2>, UpperMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
187 
188  template< typename MT2, bool SO2 >
189  inline EnableIf_< IsComputation<MT2>, UpperMatrix& > operator+=( const Matrix<MT2,SO2>& rhs );
190 
191  template< typename MT2, bool SO2 >
192  inline DisableIf_< IsComputation<MT2>, UpperMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
193 
194  template< typename MT2, bool SO2 >
195  inline EnableIf_< IsComputation<MT2>, UpperMatrix& > operator-=( const Matrix<MT2,SO2>& rhs );
196 
197  template< typename MT2, bool SO2 >
198  inline UpperMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
199 
200  template< typename Other >
201  inline EnableIf_< IsNumeric<Other>, UpperMatrix >& operator*=( Other rhs );
202 
203  template< typename Other >
204  inline EnableIf_< IsNumeric<Other>, UpperMatrix >& operator/=( Other rhs );
206  //**********************************************************************************************
207 
208  //**Utility functions***************************************************************************
211  inline size_t rows() const noexcept;
212  inline size_t columns() const noexcept;
213  inline size_t capacity() const noexcept;
214  inline size_t capacity( size_t i ) const noexcept;
215  inline size_t nonZeros() const;
216  inline size_t nonZeros( size_t i ) const;
217  inline void reset();
218  inline void reset( size_t i );
219  inline void clear();
220  inline Iterator set( size_t i, size_t j, const ElementType& value );
221  inline Iterator insert( size_t i, size_t j, const ElementType& value );
222  inline void erase( size_t i, size_t j );
223  inline Iterator erase( size_t i, Iterator pos );
224  inline Iterator erase( size_t i, Iterator first, Iterator last );
225  inline void resize ( size_t n, bool preserve=true );
226  inline void reserve( size_t nonzeros );
227  inline void reserve( size_t i, size_t nonzeros );
228  inline void trim();
229  inline void trim( size_t i );
230  template< typename Other > inline UpperMatrix& scale( const Other& scalar );
231  template< typename Other > inline UpperMatrix& scaleDiagonal( Other scale );
232  inline void swap( UpperMatrix& m ) noexcept;
233 
234  static inline constexpr size_t maxNonZeros() noexcept;
235  static inline constexpr size_t maxNonZeros( size_t n ) noexcept;
237  //**********************************************************************************************
238 
239  //**Lookup functions****************************************************************************
242  inline Iterator find ( size_t i, size_t j );
243  inline ConstIterator find ( size_t i, size_t j ) const;
244  inline Iterator lowerBound( size_t i, size_t j );
245  inline ConstIterator lowerBound( size_t i, size_t j ) const;
246  inline Iterator upperBound( size_t i, size_t j );
247  inline ConstIterator upperBound( size_t i, size_t j ) const;
249  //**********************************************************************************************
250 
251  //**Low-level utility functions*****************************************************************
254  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
255  inline void finalize( size_t i );
257  //**********************************************************************************************
258 
259  //**Debugging functions*************************************************************************
262  inline bool isIntact() const noexcept;
264  //**********************************************************************************************
265 
266  //**Expression template evaluation functions****************************************************
269  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
270  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
271 
272  inline bool canSMPAssign() const noexcept;
274  //**********************************************************************************************
275 
276  private:
277  //**Utility functions***************************************************************************
280  inline void resetLower();
282  //**********************************************************************************************
283 
284  //**Member variables****************************************************************************
287  MT matrix_;
288 
289  //**********************************************************************************************
290 
291  //**Friend declarations*************************************************************************
292  template< typename MT2, bool SO2, bool DF2 >
293  friend bool isDefault( const UpperMatrix<MT2,SO2,DF2>& m );
294 
295  template< typename MT2, bool SO2, bool DF2 >
296  friend MT2& derestrict( UpperMatrix<MT2,SO2,DF2>& m );
297  //**********************************************************************************************
298 
299  //**Compile time checks*************************************************************************
312  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
313  //**********************************************************************************************
314 };
316 //*************************************************************************************************
317 
318 
319 
320 
321 //=================================================================================================
322 //
323 // CONSTRUCTORS
324 //
325 //=================================================================================================
326 
327 //*************************************************************************************************
331 template< typename MT // Type of the adapted sparse matrix
332  , bool SO > // Storage order of the adapted sparse matrix
333 inline UpperMatrix<MT,SO,false>::UpperMatrix()
334  : matrix_() // The adapted sparse matrix
335 {
336  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
337 }
339 //*************************************************************************************************
340 
341 
342 //*************************************************************************************************
350 template< typename MT // Type of the adapted sparse matrix
351  , bool SO > // Storage order of the adapted sparse matrix
352 inline UpperMatrix<MT,SO,false>::UpperMatrix( size_t n )
353  : matrix_( n, n ) // The adapted sparse matrix
354 {
356 
357  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
358 }
360 //*************************************************************************************************
361 
362 
363 //*************************************************************************************************
372 template< typename MT // Type of the adapted sparse matrix
373  , bool SO > // Storage order of the adapted sparse matrix
374 inline UpperMatrix<MT,SO,false>::UpperMatrix( size_t n, size_t nonzeros )
375  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
376 {
378 
379  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
380 }
382 //*************************************************************************************************
383 
384 
385 //*************************************************************************************************
396 template< typename MT // Type of the adapted sparse matrix
397  , bool SO > // Storage order of the adapted sparse matrix
398 inline UpperMatrix<MT,SO,false>::UpperMatrix( size_t n, const std::vector<size_t>& nonzeros )
399  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
400 {
402 
403  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
404 }
406 //*************************************************************************************************
407 
408 
409 //*************************************************************************************************
415 template< typename MT // Type of the adapted sparse matrix
416  , bool SO > // Storage order of the adapted sparse matrix
417 inline UpperMatrix<MT,SO,false>::UpperMatrix( const UpperMatrix& m )
418  : matrix_( m.matrix_ ) // The adapted sparse matrix
419 {
420  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
421  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
422 }
424 //*************************************************************************************************
425 
426 
427 //*************************************************************************************************
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( UpperMatrix&& m ) noexcept
436  : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
437 {
438  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
439  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
440 }
442 //*************************************************************************************************
443 
444 
445 //*************************************************************************************************
455 template< typename MT // Type of the adapted sparse matrix
456  , bool SO > // Storage order of the adapted sparse matrix
457 template< typename MT2 // Type of the foreign matrix
458  , bool SO2 > // Storage order of the foreign matrix
459 inline UpperMatrix<MT,SO,false>::UpperMatrix( const Matrix<MT2,SO2>& m )
460  : matrix_( ~m ) // The adapted sparse matrix
461 {
462  if( !IsUpper<MT2>::value && !isUpper( matrix_ ) ) {
463  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of upper matrix" );
464  }
465 
466  if( !IsUpper<MT2>::value )
467  resetLower();
468 
469  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
470  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
471 }
473 //*************************************************************************************************
474 
475 
476 
477 
478 //=================================================================================================
479 //
480 // DATA ACCESS FUNCTIONS
481 //
482 //=================================================================================================
483 
484 //*************************************************************************************************
500 template< typename MT // Type of the adapted sparse matrix
501  , bool SO > // Storage order of the adapted sparse matrix
503  UpperMatrix<MT,SO,false>::operator()( size_t i, size_t j )
504 {
505  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
506  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
507 
508  return Reference( matrix_, i, j );
509 }
511 //*************************************************************************************************
512 
513 
514 //*************************************************************************************************
530 template< typename MT // Type of the adapted sparse matrix
531  , bool SO > // Storage order of the adapted sparse matrix
533  UpperMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
534 {
535  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
536  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
537 
538  return matrix_(i,j);
539 }
541 //*************************************************************************************************
542 
543 
544 //*************************************************************************************************
561 template< typename MT // Type of the adapted sparse matrix
562  , bool SO > // Storage order of the adapted sparse matrix
564  UpperMatrix<MT,SO,false>::at( size_t i, size_t j )
565 {
566  if( i >= rows() ) {
567  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
568  }
569  if( j >= columns() ) {
570  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
571  }
572  return (*this)(i,j);
573 }
575 //*************************************************************************************************
576 
577 
578 //*************************************************************************************************
595 template< typename MT // Type of the adapted sparse matrix
596  , bool SO > // Storage order of the adapted sparse matrix
598  UpperMatrix<MT,SO,false>::at( size_t i, size_t j ) const
599 {
600  if( i >= rows() ) {
601  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
602  }
603  if( j >= columns() ) {
604  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
605  }
606  return (*this)(i,j);
607 }
609 //*************************************************************************************************
610 
611 
612 //*************************************************************************************************
624 template< typename MT // Type of the adapted sparse matrix
625  , bool SO > // Storage order of the adapted sparse matrix
628 {
629  return matrix_.begin(i);
630 }
632 //*************************************************************************************************
633 
634 
635 //*************************************************************************************************
647 template< typename MT // Type of the adapted sparse matrix
648  , bool SO > // Storage order of the adapted sparse matrix
650  UpperMatrix<MT,SO,false>::begin( size_t i ) const
651 {
652  return matrix_.begin(i);
653 }
655 //*************************************************************************************************
656 
657 
658 //*************************************************************************************************
670 template< typename MT // Type of the adapted sparse matrix
671  , bool SO > // Storage order of the adapted sparse matrix
673  UpperMatrix<MT,SO,false>::cbegin( size_t i ) const
674 {
675  return matrix_.cbegin(i);
676 }
678 //*************************************************************************************************
679 
680 
681 //*************************************************************************************************
693 template< typename MT // Type of the adapted sparse matrix
694  , bool SO > // Storage order of the adapted sparse matrix
697 {
698  return matrix_.end(i);
699 }
701 //*************************************************************************************************
702 
703 
704 //*************************************************************************************************
716 template< typename MT // Type of the adapted sparse matrix
717  , bool SO > // Storage order of the adapted sparse matrix
719  UpperMatrix<MT,SO,false>::end( size_t i ) const
720 {
721  return matrix_.end(i);
722 }
724 //*************************************************************************************************
725 
726 
727 //*************************************************************************************************
739 template< typename MT // Type of the adapted sparse matrix
740  , bool SO > // Storage order of the adapted sparse matrix
742  UpperMatrix<MT,SO,false>::cend( size_t i ) const
743 {
744  return matrix_.cend(i);
745 }
747 //*************************************************************************************************
748 
749 
750 
751 
752 //=================================================================================================
753 //
754 // ASSIGNMENT OPERATORS
755 //
756 //=================================================================================================
757 
758 //*************************************************************************************************
768 template< typename MT // Type of the adapted sparse matrix
769  , bool SO > // Storage order of the adapted sparse matrix
770 inline UpperMatrix<MT,SO,false>&
771  UpperMatrix<MT,SO,false>::operator=( const UpperMatrix& rhs )
772 {
773  matrix_ = rhs.matrix_;
774 
775  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
776  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
777 
778  return *this;
779 }
781 //*************************************************************************************************
782 
783 
784 //*************************************************************************************************
791 template< typename MT // Type of the adapted sparse matrix
792  , bool SO > // Storage order of the adapted sparse matrix
793 inline UpperMatrix<MT,SO,false>&
794  UpperMatrix<MT,SO,false>::operator=( UpperMatrix&& rhs ) noexcept
795 {
796  matrix_ = std::move( rhs.matrix_ );
797 
798  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
799  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
800 
801  return *this;
802 }
804 //*************************************************************************************************
805 
806 
807 //*************************************************************************************************
820 template< typename MT // Type of the adapted sparse matrix
821  , bool SO > // Storage order of the adapted sparse matrix
822 template< typename MT2 // Type of the right-hand side matrix
823  , bool SO2 > // Storage order of the right-hand side matrix
824 inline DisableIf_< IsComputation<MT2>, UpperMatrix<MT,SO,false>& >
825  UpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
826 {
827  if( !IsUpper<MT2>::value && !isUpper( ~rhs ) ) {
828  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
829  }
830 
831  matrix_ = ~rhs;
832 
833  if( !IsUpper<MT2>::value )
834  resetLower();
835 
836  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
837  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
838 
839  return *this;
840 }
842 //*************************************************************************************************
843 
844 
845 //*************************************************************************************************
858 template< typename MT // Type of the adapted sparse matrix
859  , bool SO > // Storage order of the adapted sparse matrix
860 template< typename MT2 // Type of the right-hand side matrix
861  , bool SO2 > // Storage order of the right-hand side matrix
862 inline EnableIf_< IsComputation<MT2>, UpperMatrix<MT,SO,false>& >
863  UpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
864 {
865  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
866  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
867  }
868 
869  if( IsUpper<MT2>::value ) {
870  matrix_ = ~rhs;
871  }
872  else {
873  MT tmp( ~rhs );
874 
875  if( !isUpper( tmp ) ) {
876  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
877  }
878 
879  matrix_ = std::move( tmp );
880  }
881 
882  if( !IsUpper<MT2>::value )
883  resetLower();
884 
885  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
886  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
887 
888  return *this;
889 }
891 //*************************************************************************************************
892 
893 
894 //*************************************************************************************************
907 template< typename MT // Type of the adapted sparse matrix
908  , bool SO > // Storage order of the adapted sparse matrix
909 template< typename MT2 // Type of the right-hand side matrix
910  , bool SO2 > // Storage order of the right-hand side matrix
911 inline DisableIf_< IsComputation<MT2>, UpperMatrix<MT,SO,false>& >
912  UpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
913 {
914  if( !IsUpper<MT2>::value && !isUpper( ~rhs ) ) {
915  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
916  }
917 
918  matrix_ += ~rhs;
919 
920  if( !IsUpper<MT2>::value )
921  resetLower();
922 
923  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
924  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
925 
926  return *this;
927 }
929 //*************************************************************************************************
930 
931 
932 //*************************************************************************************************
945 template< typename MT // Type of the adapted sparse matrix
946  , bool SO > // Storage order of the adapted sparse matrix
947 template< typename MT2 // Type of the right-hand side matrix
948  , bool SO2 > // Storage order of the right-hand side matrix
949 inline EnableIf_< IsComputation<MT2>, UpperMatrix<MT,SO,false>& >
950  UpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
951 {
952  if( IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
953  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
954  }
955 
956  if( IsUpper<MT2>::value ) {
957  matrix_ += ~rhs;
958  }
959  else {
960  const ResultType_<MT2> tmp( ~rhs );
961 
962  if( !isUpper( tmp ) ) {
963  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
964  }
965 
966  matrix_ += tmp;
967  }
968 
969  if( !IsUpper<MT2>::value )
970  resetLower();
971 
972  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square 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 DisableIf_< IsComputation<MT2>, UpperMatrix<MT,SO,false>& >
999  UpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1000 {
1001  if( !IsUpper<MT2>::value && !isUpper( ~rhs ) ) {
1002  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
1003  }
1004 
1005  matrix_ -= ~rhs;
1006 
1007  if( !IsUpper<MT2>::value )
1008  resetLower();
1009 
1010  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
1011  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1012 
1013  return *this;
1014 }
1016 //*************************************************************************************************
1017 
1018 
1019 //*************************************************************************************************
1032 template< typename MT // Type of the adapted sparse matrix
1033  , bool SO > // Storage order of the adapted sparse matrix
1034 template< typename MT2 // Type of the right-hand side matrix
1035  , bool SO2 > // Storage order of the right-hand side matrix
1036 inline EnableIf_< IsComputation<MT2>, UpperMatrix<MT,SO,false>& >
1037  UpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1038 {
1039  if( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) {
1040  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
1041  }
1042 
1043  if( IsUpper<MT2>::value ) {
1044  matrix_ -= ~rhs;
1045  }
1046  else {
1047  const ResultType_<MT2> tmp( ~rhs );
1048 
1049  if( !isUpper( tmp ) ) {
1050  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
1051  }
1052 
1053  matrix_ -= tmp;
1054  }
1055 
1056  if( !IsUpper<MT2>::value )
1057  resetLower();
1058 
1059  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
1060  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1061 
1062  return *this;
1063 }
1065 //*************************************************************************************************
1066 
1067 
1068 //*************************************************************************************************
1080 template< typename MT // Type of the adapted sparse matrix
1081  , bool SO > // Storage order of the adapted sparse matrix
1082 template< typename MT2 // Type of the right-hand side matrix
1083  , bool SO2 > // Storage order of the right-hand side matrix
1084 inline UpperMatrix<MT,SO,false>&
1085  UpperMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1086 {
1087  if( matrix_.rows() != (~rhs).columns() ) {
1088  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
1089  }
1090 
1091  MT tmp( matrix_ * ~rhs );
1092 
1093  if( !isUpper( tmp ) ) {
1094  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to upper matrix" );
1095  }
1096 
1097  matrix_ = std::move( tmp );
1098 
1099  if( !IsUpper<MT2>::value )
1100  resetLower();
1101 
1102  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
1103  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1104 
1105  return *this;
1106 }
1108 //*************************************************************************************************
1109 
1110 
1111 //*************************************************************************************************
1119 template< typename MT // Type of the adapted sparse matrix
1120  , bool SO > // Storage order of the adapted sparse matrix
1121 template< typename Other > // Data type of the right-hand side scalar
1122 inline EnableIf_< IsNumeric<Other>, UpperMatrix<MT,SO,false> >&
1124 {
1125  matrix_ *= rhs;
1126  return *this;
1127 }
1128 //*************************************************************************************************
1129 
1130 
1131 //*************************************************************************************************
1139 template< typename MT // Type of the adapted sparse matrix
1140  , bool SO > // Storage order of the adapted sparse matrix
1141 template< typename Other > // Data type of the right-hand side scalar
1142 inline EnableIf_< IsNumeric<Other>, UpperMatrix<MT,SO,false> >&
1144 {
1145  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1146 
1147  matrix_ /= rhs;
1148  return *this;
1149 }
1151 //*************************************************************************************************
1152 
1153 
1154 
1155 
1156 //=================================================================================================
1157 //
1158 // UTILITY FUNCTIONS
1159 //
1160 //=================================================================================================
1161 
1162 //*************************************************************************************************
1168 template< typename MT // Type of the adapted sparse matrix
1169  , bool SO > // Storage order of the adapted sparse matrix
1170 inline size_t UpperMatrix<MT,SO,false>::rows() const noexcept
1171 {
1172  return matrix_.rows();
1173 }
1175 //*************************************************************************************************
1176 
1177 
1178 //*************************************************************************************************
1184 template< typename MT // Type of the adapted sparse matrix
1185  , bool SO > // Storage order of the adapted sparse matrix
1186 inline size_t UpperMatrix<MT,SO,false>::columns() const noexcept
1187 {
1188  return matrix_.columns();
1189 }
1191 //*************************************************************************************************
1192 
1193 
1194 //*************************************************************************************************
1200 template< typename MT // Type of the adapted sparse matrix
1201  , bool SO > // Storage order of the adapted sparse matrix
1202 inline size_t UpperMatrix<MT,SO,false>::capacity() const noexcept
1203 {
1204  return matrix_.capacity();
1205 }
1207 //*************************************************************************************************
1208 
1209 
1210 //*************************************************************************************************
1222 template< typename MT // Type of the adapted sparse matrix
1223  , bool SO > // Storage order of the adapted sparse matrix
1224 inline size_t UpperMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1225 {
1226  return matrix_.capacity(i);
1227 }
1229 //*************************************************************************************************
1230 
1231 
1232 //*************************************************************************************************
1238 template< typename MT // Type of the adapted sparse matrix
1239  , bool SO > // Storage order of the adapted sparse matrix
1240 inline size_t UpperMatrix<MT,SO,false>::nonZeros() const
1241 {
1242  return matrix_.nonZeros();
1243 }
1245 //*************************************************************************************************
1246 
1247 
1248 //*************************************************************************************************
1260 template< typename MT // Type of the adapted sparse matrix
1261  , bool SO > // Storage order of the adapted sparse matrix
1262 inline size_t UpperMatrix<MT,SO,false>::nonZeros( size_t i ) const
1263 {
1264  return matrix_.nonZeros(i);
1265 }
1267 //*************************************************************************************************
1268 
1269 
1270 //*************************************************************************************************
1276 template< typename MT // Type of the adapted sparse matrix
1277  , bool SO > // Storage order of the adapted sparse matrix
1278 inline void UpperMatrix<MT,SO,false>::reset()
1279 {
1280  matrix_.reset();
1281 }
1283 //*************************************************************************************************
1284 
1285 
1286 //*************************************************************************************************
1299 template< typename MT // Type of the adapted sparse matrix
1300  , bool SO > // Storage order of the adapted sparse matrix
1301 inline void UpperMatrix<MT,SO,false>::reset( size_t i )
1302 {
1303  matrix_.reset( i );
1304 }
1306 //*************************************************************************************************
1307 
1308 
1309 //*************************************************************************************************
1317 template< typename MT // Type of the adapted sparse matrix
1318  , bool SO > // Storage order of the adapted sparse matrix
1319 inline void UpperMatrix<MT,SO,false>::clear()
1320 {
1321  using blaze::clear;
1322 
1323  clear( matrix_ );
1324 }
1326 //*************************************************************************************************
1327 
1328 
1329 //*************************************************************************************************
1345 template< typename MT // Type of the adapted sparse matrix
1346  , bool SO > // Storage order of the adapted sparse matrix
1347 inline typename UpperMatrix<MT,SO,false>::Iterator
1348  UpperMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1349 {
1350  if( i > j ) {
1351  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to lower matrix element" );
1352  }
1353 
1354  return matrix_.set( i, j, value );
1355 }
1357 //*************************************************************************************************
1358 
1359 
1360 //*************************************************************************************************
1377 template< typename MT // Type of the adapted sparse matrix
1378  , bool SO > // Storage order of the adapted sparse matrix
1379 inline typename UpperMatrix<MT,SO,false>::Iterator
1380  UpperMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1381 {
1382  if( i > j ) {
1383  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to lower matrix element" );
1384  }
1385 
1386  return matrix_.insert( i, j, value );
1387 }
1389 //*************************************************************************************************
1390 
1391 
1392 //*************************************************************************************************
1402 template< typename MT // Type of the adapted sparse matrix
1403  , bool SO > // Storage order of the adapted sparse matrix
1404 inline void UpperMatrix<MT,SO,false>::erase( size_t i, size_t j )
1405 {
1406  matrix_.erase( i, j );
1407 }
1409 //*************************************************************************************************
1410 
1411 
1412 //*************************************************************************************************
1424 template< typename MT // Type of the adapted sparse matrix
1425  , bool SO > // Storage order of the adapted sparse matrix
1426 inline typename UpperMatrix<MT,SO,false>::Iterator
1427  UpperMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1428 {
1429  return matrix_.erase( i, pos );
1430 }
1432 //*************************************************************************************************
1433 
1434 
1435 //*************************************************************************************************
1448 template< typename MT // Type of the adapted sparse matrix
1449  , bool SO > // Storage order of the adapted sparse matrix
1450 inline typename UpperMatrix<MT,SO,false>::Iterator
1451  UpperMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1452 {
1453  return matrix_.erase( i, first, last );
1454 }
1456 //*************************************************************************************************
1457 
1458 
1459 //*************************************************************************************************
1474 template< typename MT // Type of the adapted sparse matrix
1475  , bool SO > // Storage order of the adapted sparse matrix
1476 void UpperMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1477 {
1479 
1480  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square upper matrix detected" );
1481 
1482  matrix_.resize( n, n, preserve );
1483 }
1485 //*************************************************************************************************
1486 
1487 
1488 //*************************************************************************************************
1499 template< typename MT // Type of the adapted sparse matrix
1500  , bool SO > // Storage order of the adapted sparse matrix
1501 inline void UpperMatrix<MT,SO,false>::reserve( size_t nonzeros )
1502 {
1503  matrix_.reserve( nonzeros );
1504 }
1506 //*************************************************************************************************
1507 
1508 
1509 //*************************************************************************************************
1523 template< typename MT // Type of the adapted sparse matrix
1524  , bool SO > // Storage order of the adapted sparse matrix
1525 inline void UpperMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1526 {
1527  matrix_.reserve( i, nonzeros );
1528 }
1530 //*************************************************************************************************
1531 
1532 
1533 //*************************************************************************************************
1544 template< typename MT // Type of the adapted sparse matrix
1545  , bool SO > // Storage order of the adapted sparse matrix
1546 inline void UpperMatrix<MT,SO,false>::trim()
1547 {
1548  matrix_.trim();
1549 }
1551 //*************************************************************************************************
1552 
1553 
1554 //*************************************************************************************************
1566 template< typename MT // Type of the adapted sparse matrix
1567  , bool SO > // Storage order of the adapted sparse matrix
1568 inline void UpperMatrix<MT,SO,false>::trim( size_t i )
1569 {
1570  matrix_.trim( i );
1571 }
1573 //*************************************************************************************************
1574 
1575 
1576 //*************************************************************************************************
1583 template< typename MT // Type of the adapted sparse matrix
1584  , bool SO > // Storage order of the adapted sparse matrix
1585 template< typename Other > // Data type of the scalar value
1586 inline UpperMatrix<MT,SO,false>&
1587  UpperMatrix<MT,SO,false>::scale( const Other& scalar )
1588 {
1589  matrix_.scale( scalar );
1590  return *this;
1591 }
1593 //*************************************************************************************************
1594 
1595 
1596 //*************************************************************************************************
1603 template< typename MT // Type of the adapted sparse matrix
1604  , bool SO > // Storage order of the adapted sparse matrix
1605 template< typename Other > // Data type of the scalar value
1606 inline UpperMatrix<MT,SO,false>&
1607  UpperMatrix<MT,SO,false>::scaleDiagonal( Other scalar )
1608 {
1609  matrix_.scaleDiagonal( scalar );
1610  return *this;
1611 }
1613 //*************************************************************************************************
1614 
1615 
1616 //*************************************************************************************************
1623 template< typename MT // Type of the adapted sparse matrix
1624  , bool SO > // Storage order of the adapted sparse matrix
1625 inline void UpperMatrix<MT,SO,false>::swap( UpperMatrix& m ) noexcept
1626 {
1627  using std::swap;
1628 
1629  swap( matrix_, m.matrix_ );
1630 }
1632 //*************************************************************************************************
1633 
1634 
1635 //*************************************************************************************************
1646 template< typename MT // Type of the adapted dense matrix
1647  , bool SO > // Storage order of the adapted dense matrix
1648 inline constexpr size_t UpperMatrix<MT,SO,false>::maxNonZeros() noexcept
1649 {
1651 
1652  return maxNonZeros( Rows<MT>::value );
1653 }
1655 //*************************************************************************************************
1656 
1657 
1658 //*************************************************************************************************
1668 template< typename MT // Type of the adapted dense matrix
1669  , bool SO > // Storage order of the adapted dense matrix
1670 inline constexpr size_t UpperMatrix<MT,SO,false>::maxNonZeros( size_t n ) noexcept
1671 {
1672  return ( ( n + 1UL ) * n ) / 2UL;
1673 }
1675 //*************************************************************************************************
1676 
1677 
1678 //*************************************************************************************************
1684 template< typename MT // Type of the adapted dense matrix
1685  , bool SO > // Storage order of the adapted dense matrix
1686 inline void UpperMatrix<MT,SO,false>::resetLower()
1687 {
1688  if( SO ) {
1689  for( size_t j=0UL; j<columns(); ++j )
1690  matrix_.erase( j, matrix_.upperBound( j, j ), matrix_.end( j ) );
1691  }
1692  else {
1693  for( size_t i=1UL; i<rows(); ++i )
1694  matrix_.erase( i, matrix_.begin( i ), matrix_.lowerBound( i, i ) );
1695  }
1696 }
1698 //*************************************************************************************************
1699 
1700 
1701 
1702 
1703 //=================================================================================================
1704 //
1705 // LOOKUP FUNCTIONS
1706 //
1707 //=================================================================================================
1708 
1709 //*************************************************************************************************
1725 template< typename MT // Type of the adapted sparse matrix
1726  , bool SO > // Storage order of the adapted sparse matrix
1727 inline typename UpperMatrix<MT,SO,false>::Iterator
1728  UpperMatrix<MT,SO,false>::find( size_t i, size_t j )
1729 {
1730  return matrix_.find( i, j );
1731 }
1733 //*************************************************************************************************
1734 
1735 
1736 //*************************************************************************************************
1752 template< typename MT // Type of the adapted sparse matrix
1753  , bool SO > // Storage order of the adapted sparse matrix
1755  UpperMatrix<MT,SO,false>::find( size_t i, size_t j ) const
1756 {
1757  return matrix_.find( i, j );
1758 }
1760 //*************************************************************************************************
1761 
1762 
1763 //*************************************************************************************************
1779 template< typename MT // Type of the adapted sparse matrix
1780  , bool SO > // Storage order of the adapted sparse matrix
1781 inline typename UpperMatrix<MT,SO,false>::Iterator
1782  UpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
1783 {
1784  return matrix_.lowerBound( i, j );
1785 }
1787 //*************************************************************************************************
1788 
1789 
1790 //*************************************************************************************************
1806 template< typename MT // Type of the adapted sparse matrix
1807  , bool SO > // Storage order of the adapted sparse matrix
1809  UpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
1810 {
1811  return matrix_.lowerBound( i, j );
1812 }
1814 //*************************************************************************************************
1815 
1816 
1817 //*************************************************************************************************
1833 template< typename MT // Type of the adapted sparse matrix
1834  , bool SO > // Storage order of the adapted sparse matrix
1835 inline typename UpperMatrix<MT,SO,false>::Iterator
1836  UpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
1837 {
1838  return matrix_.upperBound( i, j );
1839 }
1841 //*************************************************************************************************
1842 
1843 
1844 //*************************************************************************************************
1860 template< typename MT // Type of the adapted sparse matrix
1861  , bool SO > // Storage order of the adapted sparse matrix
1863  UpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
1864 {
1865  return matrix_.upperBound( i, j );
1866 }
1868 //*************************************************************************************************
1869 
1870 
1871 
1872 
1873 //=================================================================================================
1874 //
1875 // LOW-LEVEL UTILITY FUNCTIONS
1876 //
1877 //=================================================================================================
1878 
1879 //*************************************************************************************************
1929 template< typename MT // Type of the adapted sparse matrix
1930  , bool SO > // Storage order of the adapted sparse matrix
1931 inline void UpperMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1932 {
1933  if( i > j ) {
1934  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to lower matrix element" );
1935  }
1936 
1937  matrix_.append( i, j, value, check );
1938 }
1940 //*************************************************************************************************
1941 
1942 
1943 //*************************************************************************************************
1957 template< typename MT // Type of the adapted sparse matrix
1958  , bool SO > // Storage order of the adapted sparse matrix
1959 inline void UpperMatrix<MT,SO,false>::finalize( size_t i )
1960 {
1961  matrix_.finalize( i );
1962 }
1964 //*************************************************************************************************
1965 
1966 
1967 
1968 
1969 //=================================================================================================
1970 //
1971 // DEBUGGING FUNCTIONS
1972 //
1973 //=================================================================================================
1974 
1975 //*************************************************************************************************
1985 template< typename MT // Type of the adapted sparse matrix
1986  , bool SO > // Storage order of the adapted sparse matrix
1987 inline bool UpperMatrix<MT,SO,false>::isIntact() const noexcept
1988 {
1989  using blaze::isIntact;
1990 
1991  return ( isIntact( matrix_ ) && isUpper( matrix_ ) );
1992 }
1994 //*************************************************************************************************
1995 
1996 
1997 
1998 
1999 //=================================================================================================
2000 //
2001 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2002 //
2003 //=================================================================================================
2004 
2005 //*************************************************************************************************
2016 template< typename MT // Type of the adapted sparse matrix
2017  , bool SO > // Storage order of the adapted sparse matrix
2018 template< typename Other > // Data type of the foreign expression
2019 inline bool UpperMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2020 {
2021  return matrix_.canAlias( alias );
2022 }
2024 //*************************************************************************************************
2025 
2026 
2027 //*************************************************************************************************
2038 template< typename MT // Type of the adapted sparse matrix
2039  , bool SO > // Storage order of the adapted sparse matrix
2040 template< typename Other > // Data type of the foreign expression
2041 inline bool UpperMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2042 {
2043  return matrix_.isAliased( alias );
2044 }
2046 //*************************************************************************************************
2047 
2048 
2049 //*************************************************************************************************
2060 template< typename MT // Type of the adapted sparse matrix
2061  , bool SO > // Storage order of the adapted sparse matrix
2062 inline bool UpperMatrix<MT,SO,false>::canSMPAssign() const noexcept
2063 {
2064  return matrix_.canSMPAssign();
2065 }
2067 //*************************************************************************************************
2068 
2069 } // namespace blaze
2070 
2071 #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
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the Rows type trait.
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:346
Header file for basic type definitions.
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.In case the given data type T is not a dense or sparse matrix type and in...
Definition: StorageOrder.h:63
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
Constraint on the data type.
BLAZE_ALWAYS_INLINE MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:188
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2643
typename DisableIf< Condition, T >::Type DisableIf_
Auxiliary type for the DisableIf class template.The DisableIf_ alias declaration provides a convenien...
Definition: DisableIf.h:223
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:5077
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2636
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
Definition: Volatile.h:79
BLAZE_ALWAYS_INLINE size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:384
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
Constraint on the data type.
STL namespace.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2639
BLAZE_ALWAYS_INLINE MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:298
BLAZE_ALWAYS_INLINE MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:232
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
Header file for utility functions for sparse matrices.
Header file for the IsSquare type trait.
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b) noexcept
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:5148
Compile time assertion.
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:5131
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
Header file for the Columns type trait.
Constraint on the data type.
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:330
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2640
bool isUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper triangular matrix.
Definition: DenseMatrix.h:1267
Constraints on the storage order of matrix types.
Header file for the exception macros of the math module.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a upper triangular matrix type...
Definition: Upper.h:81
BLAZE_ALWAYS_INLINE void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:538
BLAZE_ALWAYS_INLINE MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:254
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2641
Header file for the UpperProxy class.
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2645
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the IsNumeric type trait.
BLAZE_ALWAYS_INLINE const EnableIf_< And< IsIntegral< T >, HasSize< T, 1UL > >, If_< IsSigned< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:76
Header file for all adaptor forward declarations.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a symmetric matrix type, a compilation error is created.
Definition: Symmetric.h:79
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2642
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is a lower triangular matrix type...
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type, a compilation error is created.
Definition: Reference.h:79
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2646
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:258
Constraint on the data type.
Constraint on the data type.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_RESIZABLE(T)
Constraint on the data type.In case the given data type T is resizable, i.e. has a 'resize' member fu...
Definition: Resizable.h:81
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:314
SparseMatrix< This, true > BaseType
Base type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2637
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE(T)
Constraint on the data type.In case the given data type T is not resizable, i.e. does not have a 'res...
Definition: Resizable.h:61
Header file for the IsComputation type trait class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_EXPRESSION_TYPE(T)
Constraint on the data type.In case the given data type T is an expression (i.e. a type derived from ...
Definition: Expression.h:81
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2638
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2644
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is an Hermitian matrix type, a compilation error is created.
Definition: Hermitian.h:79
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
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.
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:609
#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