Sparse.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_STRICTLYUPPERMATRIX_SPARSE_H_
36 #define _BLAZE_MATH_ADAPTORS_STRICTLYUPPERMATRIX_SPARSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <vector>
57 #include <blaze/math/Functions.h>
58 #include <blaze/math/shims/Clear.h>
60 #include <blaze/math/shims/Move.h>
69 #include <blaze/util/Assert.h>
74 #include <blaze/util/DisableIf.h>
75 #include <blaze/util/EnableIf.h>
76 #include <blaze/util/Exception.h>
79 #include <blaze/util/Types.h>
80 
81 
82 namespace blaze {
83 
84 //=================================================================================================
85 //
86 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
87 //
88 //=================================================================================================
89 
90 //*************************************************************************************************
98 template< typename MT // Type of the adapted sparse matrix
99  , bool SO > // Storage order of the adapted sparse matrix
100 class StrictlyUpperMatrix<MT,SO,false>
101  : public SparseMatrix< StrictlyUpperMatrix<MT,SO,false>, SO >
102 {
103  private:
104  //**Type definitions****************************************************************************
105  typedef typename MT::OppositeType OT;
106  typedef typename MT::TransposeType TT;
107  typedef typename MT::ElementType ET;
108  //**********************************************************************************************
109 
110  public:
111  //**Type definitions****************************************************************************
112  typedef StrictlyUpperMatrix<MT,SO,false> This;
113  typedef This ResultType;
114  typedef StrictlyUpperMatrix<OT,!SO,false> OppositeType;
115  typedef StrictlyLowerMatrix<TT,!SO,false> TransposeType;
116  typedef ET ElementType;
117  typedef typename MT::ReturnType ReturnType;
118  typedef const This& CompositeType;
119  typedef StrictlyUpperProxy<MT> Reference;
120  typedef typename MT::ConstReference ConstReference;
121  typedef typename MT::Iterator Iterator;
122  typedef typename MT::ConstIterator ConstIterator;
123  //**********************************************************************************************
124 
125  //**Rebind struct definition********************************************************************
128  template< typename ET > // Data type of the other matrix
129  struct Rebind {
131  typedef StrictlyUpperMatrix< typename MT::template Rebind<ET>::Other > Other;
132  };
133  //**********************************************************************************************
134 
135  //**Compilation flags***************************************************************************
137  enum { smpAssignable = 0 };
138  //**********************************************************************************************
139 
140  //**Constructors********************************************************************************
143  explicit inline StrictlyUpperMatrix();
144  explicit inline StrictlyUpperMatrix( size_t n );
145  explicit inline StrictlyUpperMatrix( size_t n, size_t nonzeros );
146  explicit inline StrictlyUpperMatrix( size_t n, const std::vector<size_t>& nonzeros );
147 
148  inline StrictlyUpperMatrix( const StrictlyUpperMatrix& m );
149  template< typename MT2, bool SO2 > inline StrictlyUpperMatrix( 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 StrictlyUpperMatrix& operator=( const StrictlyUpperMatrix& rhs );
177 
178  template< typename MT2, bool SO2 >
179  inline typename DisableIf< IsComputation<MT2>, StrictlyUpperMatrix& >::Type
180  operator=( const Matrix<MT2,SO2>& rhs );
181 
182  template< typename MT2, bool SO2 >
183  inline typename EnableIf< IsComputation<MT2>, StrictlyUpperMatrix& >::Type
184  operator=( const Matrix<MT2,SO2>& rhs );
185 
186  template< typename MT2, bool SO2 >
187  inline typename DisableIf< IsComputation<MT2>, StrictlyUpperMatrix& >::Type
188  operator+=( const Matrix<MT2,SO2>& rhs );
189 
190  template< typename MT2, bool SO2 >
191  inline typename EnableIf< IsComputation<MT2>, StrictlyUpperMatrix& >::Type
192  operator+=( const Matrix<MT2,SO2>& rhs );
193 
194  template< typename MT2, bool SO2 >
195  inline typename DisableIf< IsComputation<MT2>, StrictlyUpperMatrix& >::Type
196  operator-=( const Matrix<MT2,SO2>& rhs );
197 
198  template< typename MT2, bool SO2 >
199  inline typename EnableIf< IsComputation<MT2>, StrictlyUpperMatrix& >::Type
200  operator-=( const Matrix<MT2,SO2>& rhs );
201 
202  template< typename MT2, bool SO2 >
203  inline StrictlyUpperMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
204 
205  template< typename Other >
206  inline typename EnableIf< IsNumeric<Other>, StrictlyUpperMatrix >::Type&
207  operator*=( Other rhs );
208 
209  template< typename Other >
210  inline typename EnableIf< IsNumeric<Other>, StrictlyUpperMatrix >::Type&
211  operator/=( Other rhs );
213  //**********************************************************************************************
214 
215  //**Utility functions***************************************************************************
218  inline size_t rows() const;
219  inline size_t columns() const;
220  inline size_t capacity() const;
221  inline size_t capacity( size_t i ) const;
222  inline size_t nonZeros() const;
223  inline size_t nonZeros( size_t i ) const;
224  inline void reset();
225  inline void reset( size_t i );
226  inline void clear();
227  inline Iterator set( size_t i, size_t j, const ElementType& value );
228  inline Iterator insert( size_t i, size_t j, const ElementType& value );
229  inline void erase( size_t i, size_t j );
230  inline Iterator erase( size_t i, Iterator pos );
231  inline Iterator erase( size_t i, Iterator first, Iterator last );
232  inline void resize ( size_t n, bool preserve=true );
233  inline void reserve( size_t nonzeros );
234  inline void reserve( size_t i, size_t nonzeros );
235  inline void trim();
236  inline void trim( size_t i );
237 
238  template< typename Other > inline StrictlyUpperMatrix& scale( const Other& scalar );
239  template< typename Other > inline StrictlyUpperMatrix& scaleDiagonal( Other scale );
240 
241  inline void swap( StrictlyUpperMatrix& m ) /* throw() */;
242 
243  static inline size_t maxNonZeros();
244  static inline size_t maxNonZeros( size_t n );
246  //**********************************************************************************************
247 
248  //**Lookup functions****************************************************************************
251  inline Iterator find ( size_t i, size_t j );
252  inline ConstIterator find ( size_t i, size_t j ) const;
253  inline Iterator lowerBound( size_t i, size_t j );
254  inline ConstIterator lowerBound( size_t i, size_t j ) const;
255  inline Iterator upperBound( size_t i, size_t j );
256  inline ConstIterator upperBound( size_t i, size_t j ) const;
258  //**********************************************************************************************
259 
260  //**Low-level utility functions*****************************************************************
263  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
264  inline void finalize( size_t i );
266  //**********************************************************************************************
267 
268  //**Debugging functions*************************************************************************
271  inline bool isIntact() const;
273  //**********************************************************************************************
274 
275  //**Expression template evaluation functions****************************************************
278  template< typename Other > inline bool canAlias ( const Other* alias ) const;
279  template< typename Other > inline bool isAliased( const Other* alias ) const;
280 
281  inline bool canSMPAssign() const;
283  //**********************************************************************************************
284 
285  private:
286  //**Utility functions***************************************************************************
289  inline void resetLower();
291  //**********************************************************************************************
292 
293  //**Member variables****************************************************************************
296  MT matrix_;
297 
298  //**********************************************************************************************
299 
300  //**Friend declarations*************************************************************************
301  template< typename MT2, bool SO2, bool DF2 >
302  friend MT2& derestrict( StrictlyUpperMatrix<MT2,SO2,DF2>& m );
303  //**********************************************************************************************
304 
305  //**Compile time checks*************************************************************************
318  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
319  //**********************************************************************************************
320 };
322 //*************************************************************************************************
323 
324 
325 
326 
327 //=================================================================================================
328 //
329 // CONSTRUCTORS
330 //
331 //=================================================================================================
332 
333 //*************************************************************************************************
337 template< typename MT // Type of the adapted sparse matrix
338  , bool SO > // Storage order of the adapted sparse matrix
339 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix()
340  : matrix_() // The adapted sparse matrix
341 {
342  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
343 }
345 //*************************************************************************************************
346 
347 
348 //*************************************************************************************************
356 template< typename MT // Type of the adapted sparse matrix
357  , bool SO > // Storage order of the adapted sparse matrix
358 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( size_t n )
359  : matrix_( n, n, n ) // The adapted sparse matrix
360 {
362 
363  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
364 }
366 //*************************************************************************************************
367 
368 
369 //*************************************************************************************************
379 template< typename MT // Type of the adapted sparse matrix
380  , bool SO > // Storage order of the adapted sparse matrix
381 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( size_t n, size_t nonzeros )
382  : matrix_( n, n, max( nonzeros, n ) ) // The adapted sparse matrix
383 {
385 
386  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
387 }
389 //*************************************************************************************************
390 
391 
392 //*************************************************************************************************
406 template< typename MT // Type of the adapted sparse matrix
407  , bool SO > // Storage order of the adapted sparse matrix
408 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( size_t n, const std::vector<size_t>& nonzeros )
409  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
410 {
412 
413  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
414 }
416 //*************************************************************************************************
417 
418 
419 //*************************************************************************************************
425 template< typename MT // Type of the adapted sparse matrix
426  , bool SO > // Storage order of the adapted sparse matrix
427 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( const StrictlyUpperMatrix& m )
428  : matrix_( m.matrix_ ) // The adapted sparse matrix
429 {
430  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
431  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
432 }
434 //*************************************************************************************************
435 
436 
437 //*************************************************************************************************
448 template< typename MT // Type of the adapted sparse matrix
449  , bool SO > // Storage order of the adapted sparse matrix
450 template< typename MT2 // Type of the foreign matrix
451  , bool SO2 > // Storage order of the foreign matrix
452 inline StrictlyUpperMatrix<MT,SO,false>::StrictlyUpperMatrix( const Matrix<MT2,SO2>& m )
453  : matrix_( ~m ) // The adapted sparse matrix
454 {
455  if( IsUniTriangular<MT2>::value ||
456  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( matrix_ ) ) ) {
457  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly upper matrix" );
458  }
459 
460  if( !IsStrictlyUpper<MT2>::value )
461  resetLower();
462 
463  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
464  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
465 }
467 //*************************************************************************************************
468 
469 
470 
471 
472 //=================================================================================================
473 //
474 // DATA ACCESS FUNCTIONS
475 //
476 //=================================================================================================
477 
478 //*************************************************************************************************
494 template< typename MT // Type of the adapted sparse matrix
495  , bool SO > // Storage order of the adapted sparse matrix
497  StrictlyUpperMatrix<MT,SO,false>::operator()( size_t i, size_t j )
498 {
499  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
500  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
501 
502  return Reference( matrix_, i, j );
503 }
505 //*************************************************************************************************
506 
507 
508 //*************************************************************************************************
524 template< typename MT // Type of the adapted sparse matrix
525  , bool SO > // Storage order of the adapted sparse matrix
527  StrictlyUpperMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
528 {
529  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
530  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
531 
532  return matrix_(i,j);
533 }
535 //*************************************************************************************************
536 
537 
538 //*************************************************************************************************
555 template< typename MT // Type of the adapted sparse matrix
556  , bool SO > // Storage order of the adapted sparse matrix
558  StrictlyUpperMatrix<MT,SO,false>::at( size_t i, size_t j )
559 {
560  if( i >= rows() ) {
561  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
562  }
563  if( j >= columns() ) {
564  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
565  }
566  return (*this)(i,j);
567 }
569 //*************************************************************************************************
570 
571 
572 //*************************************************************************************************
589 template< typename MT // Type of the adapted sparse matrix
590  , bool SO > // Storage order of the adapted sparse matrix
592  StrictlyUpperMatrix<MT,SO,false>::at( size_t i, size_t j ) const
593 {
594  if( i >= rows() ) {
595  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
596  }
597  if( j >= columns() ) {
598  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
599  }
600  return (*this)(i,j);
601 }
603 //*************************************************************************************************
604 
605 
606 //*************************************************************************************************
618 template< typename MT // Type of the adapted sparse matrix
619  , bool SO > // Storage order of the adapted sparse matrix
622 {
623  return matrix_.begin(i);
624 }
626 //*************************************************************************************************
627 
628 
629 //*************************************************************************************************
641 template< typename MT // Type of the adapted sparse matrix
642  , bool SO > // Storage order of the adapted sparse matrix
645 {
646  return matrix_.begin(i);
647 }
649 //*************************************************************************************************
650 
651 
652 //*************************************************************************************************
664 template< typename MT // Type of the adapted sparse matrix
665  , bool SO > // Storage order of the adapted sparse matrix
668 {
669  return matrix_.cbegin(i);
670 }
672 //*************************************************************************************************
673 
674 
675 //*************************************************************************************************
687 template< typename MT // Type of the adapted sparse matrix
688  , bool SO > // Storage order of the adapted sparse matrix
691 {
692  return matrix_.end(i);
693 }
695 //*************************************************************************************************
696 
697 
698 //*************************************************************************************************
710 template< typename MT // Type of the adapted sparse matrix
711  , bool SO > // Storage order of the adapted sparse matrix
713  StrictlyUpperMatrix<MT,SO,false>::end( size_t i ) const
714 {
715  return matrix_.end(i);
716 }
718 //*************************************************************************************************
719 
720 
721 //*************************************************************************************************
733 template< typename MT // Type of the adapted sparse matrix
734  , bool SO > // Storage order of the adapted sparse matrix
737 {
738  return matrix_.cend(i);
739 }
741 //*************************************************************************************************
742 
743 
744 
745 
746 //=================================================================================================
747 //
748 // ASSIGNMENT OPERATORS
749 //
750 //=================================================================================================
751 
752 //*************************************************************************************************
762 template< typename MT // Type of the adapted sparse matrix
763  , bool SO > // Storage order of the adapted sparse matrix
764 inline StrictlyUpperMatrix<MT,SO,false>&
765  StrictlyUpperMatrix<MT,SO,false>::operator=( const StrictlyUpperMatrix& rhs )
766 {
767  matrix_ = rhs.matrix_;
768 
769  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
770  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
771 
772  return *this;
773 }
775 //*************************************************************************************************
776 
777 
778 //*************************************************************************************************
791 template< typename MT // Type of the adapted sparse matrix
792  , bool SO > // Storage order of the adapted sparse matrix
793 template< typename MT2 // Type of the right-hand side matrix
794  , bool SO2 > // Storage order of the right-hand side matrix
795 inline typename DisableIf< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >::Type
796  StrictlyUpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
797 {
798  if( IsUniTriangular<MT2>::value ||
799  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
800  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
801  }
802 
803  matrix_ = ~rhs;
804 
805  if( !IsStrictlyUpper<MT2>::value )
806  resetLower();
807 
808  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
809  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
810 
811  return *this;
812 }
814 //*************************************************************************************************
815 
816 
817 //*************************************************************************************************
830 template< typename MT // Type of the adapted sparse matrix
831  , bool SO > // Storage order of the adapted sparse matrix
832 template< typename MT2 // Type of the right-hand side matrix
833  , bool SO2 > // Storage order of the right-hand side matrix
834 inline typename EnableIf< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >::Type
835  StrictlyUpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
836 {
837  if( IsUniTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
838  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
839  }
840 
841  if( IsStrictlyUpper<MT2>::value ) {
842  matrix_ = ~rhs;
843  }
844  else {
845  MT tmp( ~rhs );
846 
847  if( !isStrictlyUpper( tmp ) ) {
848  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
849  }
850 
851  move( matrix_, tmp );
852  }
853 
854  if( !IsStrictlyUpper<MT2>::value )
855  resetLower();
856 
857  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
858  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
859 
860  return *this;
861 }
863 //*************************************************************************************************
864 
865 
866 //*************************************************************************************************
879 template< typename MT // Type of the adapted sparse matrix
880  , bool SO > // Storage order of the adapted sparse matrix
881 template< typename MT2 // Type of the right-hand side matrix
882  , bool SO2 > // Storage order of the right-hand side matrix
883 inline typename DisableIf< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >::Type
884  StrictlyUpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
885 {
886  if( IsUniTriangular<MT2>::value ||
887  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
888  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
889  }
890 
891  matrix_ += ~rhs;
892 
893  if( !IsStrictlyUpper<MT2>::value )
894  resetLower();
895 
896  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
897  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
898 
899  return *this;
900 }
902 //*************************************************************************************************
903 
904 
905 //*************************************************************************************************
918 template< typename MT // Type of the adapted sparse matrix
919  , bool SO > // Storage order of the adapted sparse matrix
920 template< typename MT2 // Type of the right-hand side matrix
921  , bool SO2 > // Storage order of the right-hand side matrix
922 inline typename EnableIf< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >::Type
923  StrictlyUpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
924 {
925  if( IsUniTriangular<MT2>::value || ( IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
926  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
927  }
928 
929  if( IsStrictlyUpper<MT2>::value ) {
930  matrix_ += ~rhs;
931  }
932  else {
933  typename MT2::ResultType tmp( ~rhs );
934 
935  if( !isStrictlyUpper( tmp ) ) {
936  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
937  }
938 
939  matrix_ += tmp;
940  }
941 
942  if( !IsStrictlyUpper<MT2>::value )
943  resetLower();
944 
945  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
946  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
947 
948  return *this;
949 }
951 //*************************************************************************************************
952 
953 
954 //*************************************************************************************************
967 template< typename MT // Type of the adapted sparse matrix
968  , bool SO > // Storage order of the adapted sparse matrix
969 template< typename MT2 // Type of the right-hand side matrix
970  , bool SO2 > // Storage order of the right-hand side matrix
971 inline typename DisableIf< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >::Type
972  StrictlyUpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
973 {
974  if( IsUniTriangular<MT2>::value ||
975  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) ) {
976  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
977  }
978 
979  matrix_ -= ~rhs;
980 
981  if( !IsStrictlyUpper<MT2>::value )
982  resetLower();
983 
984  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
985  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
986 
987  return *this;
988 }
990 //*************************************************************************************************
991 
992 
993 //*************************************************************************************************
1006 template< typename MT // Type of the adapted sparse matrix
1007  , bool SO > // Storage order of the adapted sparse matrix
1008 template< typename MT2 // Type of the right-hand side matrix
1009  , bool SO2 > // Storage order of the right-hand side matrix
1010 inline typename EnableIf< IsComputation<MT2>, StrictlyUpperMatrix<MT,SO,false>& >::Type
1011  StrictlyUpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1012 {
1013  if( IsUniTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1014  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1015  }
1016 
1017  if( IsStrictlyUpper<MT2>::value ) {
1018  matrix_ -= ~rhs;
1019  }
1020  else {
1021  typename MT2::ResultType tmp( ~rhs );
1022 
1023  if( !isStrictlyUpper( tmp ) ) {
1024  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1025  }
1026 
1027  matrix_ -= tmp;
1028  }
1029 
1030  if( !IsStrictlyUpper<MT2>::value )
1031  resetLower();
1032 
1033  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1034  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1035 
1036  return *this;
1037 }
1039 //*************************************************************************************************
1040 
1041 
1042 //*************************************************************************************************
1054 template< typename MT // Type of the adapted sparse matrix
1055  , bool SO > // Storage order of the adapted sparse matrix
1056 template< typename MT2 // Type of the right-hand side matrix
1057  , bool SO2 > // Storage order of the right-hand side matrix
1058 inline StrictlyUpperMatrix<MT,SO,false>&
1059  StrictlyUpperMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1060 {
1061  if( matrix_.rows() != (~rhs).columns() ) {
1062  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1063  }
1064 
1065  MT tmp( matrix_ * ~rhs );
1066 
1067  if( !isStrictlyUpper( tmp ) ) {
1068  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly upper matrix" );
1069  }
1070 
1071  move( matrix_, tmp );
1072 
1073  if( !IsStrictlyUpper<MT2>::value )
1074  resetLower();
1075 
1076  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1077  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1078 
1079  return *this;
1080 }
1082 //*************************************************************************************************
1083 
1084 
1085 //*************************************************************************************************
1093 template< typename MT // Type of the adapted sparse matrix
1094  , bool SO > // Storage order of the adapted sparse matrix
1095 template< typename Other > // Data type of the right-hand side scalar
1096 inline typename EnableIf< IsNumeric<Other>, StrictlyUpperMatrix<MT,SO,false> >::Type&
1097  StrictlyUpperMatrix<MT,SO,false>::operator*=( Other rhs )
1098 {
1099  matrix_ *= rhs;
1100  return *this;
1101 }
1102 //*************************************************************************************************
1103 
1104 
1105 //*************************************************************************************************
1113 template< typename MT // Type of the adapted sparse matrix
1114  , bool SO > // Storage order of the adapted sparse matrix
1115 template< typename Other > // Data type of the right-hand side scalar
1116 inline typename EnableIf< IsNumeric<Other>, StrictlyUpperMatrix<MT,SO,false> >::Type&
1117  StrictlyUpperMatrix<MT,SO,false>::operator/=( Other rhs )
1118 {
1119  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1120 
1121  matrix_ /= rhs;
1122  return *this;
1123 }
1125 //*************************************************************************************************
1126 
1127 
1128 
1129 
1130 //=================================================================================================
1131 //
1132 // UTILITY FUNCTIONS
1133 //
1134 //=================================================================================================
1135 
1136 //*************************************************************************************************
1142 template< typename MT // Type of the adapted sparse matrix
1143  , bool SO > // Storage order of the adapted sparse matrix
1144 inline size_t StrictlyUpperMatrix<MT,SO,false>::rows() const
1145 {
1146  return matrix_.rows();
1147 }
1149 //*************************************************************************************************
1150 
1151 
1152 //*************************************************************************************************
1158 template< typename MT // Type of the adapted sparse matrix
1159  , bool SO > // Storage order of the adapted sparse matrix
1160 inline size_t StrictlyUpperMatrix<MT,SO,false>::columns() const
1161 {
1162  return matrix_.columns();
1163 }
1165 //*************************************************************************************************
1166 
1167 
1168 //*************************************************************************************************
1174 template< typename MT // Type of the adapted sparse matrix
1175  , bool SO > // Storage order of the adapted sparse matrix
1176 inline size_t StrictlyUpperMatrix<MT,SO,false>::capacity() const
1177 {
1178  return matrix_.capacity();
1179 }
1181 //*************************************************************************************************
1182 
1183 
1184 //*************************************************************************************************
1196 template< typename MT // Type of the adapted sparse matrix
1197  , bool SO > // Storage order of the adapted sparse matrix
1198 inline size_t StrictlyUpperMatrix<MT,SO,false>::capacity( size_t i ) const
1199 {
1200  return matrix_.capacity(i);
1201 }
1203 //*************************************************************************************************
1204 
1205 
1206 //*************************************************************************************************
1212 template< typename MT // Type of the adapted sparse matrix
1213  , bool SO > // Storage order of the adapted sparse matrix
1214 inline size_t StrictlyUpperMatrix<MT,SO,false>::nonZeros() const
1215 {
1216  return matrix_.nonZeros();
1217 }
1219 //*************************************************************************************************
1220 
1221 
1222 //*************************************************************************************************
1234 template< typename MT // Type of the adapted sparse matrix
1235  , bool SO > // Storage order of the adapted sparse matrix
1236 inline size_t StrictlyUpperMatrix<MT,SO,false>::nonZeros( size_t i ) const
1237 {
1238  return matrix_.nonZeros(i);
1239 }
1241 //*************************************************************************************************
1242 
1243 
1244 //*************************************************************************************************
1250 template< typename MT // Type of the adapted sparse matrix
1251  , bool SO > // Storage order of the adapted sparse matrix
1253 {
1254  if( SO ) {
1255  for( size_t j=1UL; j<columns(); ++j ) {
1256  matrix_.erase( j, matrix_.begin(j), matrix_.lowerBound(j,j) );
1257  }
1258  }
1259  else {
1260  for( size_t i=0UL; i<rows(); ++i ) {
1261  matrix_.erase( i, matrix_.lowerBound(i,i+1UL), matrix_.end(i) );
1262  }
1263  }
1264 }
1266 //*************************************************************************************************
1267 
1268 
1269 //*************************************************************************************************
1282 template< typename MT // Type of the adapted sparse matrix
1283  , bool SO > // Storage order of the adapted sparse matrix
1284 inline void StrictlyUpperMatrix<MT,SO,false>::reset( size_t i )
1285 {
1286  if( SO ) {
1287  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1288  }
1289  else {
1290  matrix_.erase( i, matrix_.lowerBound(i,i+1UL), matrix_.end(i) );
1291  }
1292 }
1294 //*************************************************************************************************
1295 
1296 
1297 //*************************************************************************************************
1305 template< typename MT // Type of the adapted sparse matrix
1306  , bool SO > // Storage order of the adapted sparse matrix
1308 {
1309  using blaze::clear;
1310 
1311  if( IsResizable<MT>::value ) {
1312  clear( matrix_ );
1313  }
1314  else {
1315  reset();
1316  }
1317 }
1319 //*************************************************************************************************
1320 
1321 
1322 //*************************************************************************************************
1338 template< typename MT // Type of the adapted sparse matrix
1339  , bool SO > // Storage order of the adapted sparse matrix
1341  StrictlyUpperMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1342 {
1343  if( i >= j ) {
1344  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1345  }
1346 
1347  return matrix_.set( i, j, value );
1348 }
1350 //*************************************************************************************************
1351 
1352 
1353 //*************************************************************************************************
1370 template< typename MT // Type of the adapted sparse matrix
1371  , bool SO > // Storage order of the adapted sparse matrix
1373  StrictlyUpperMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1374 {
1375  if( i >= j ) {
1376  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1377  }
1378 
1379  return matrix_.insert( i, j, value );
1380 }
1382 //*************************************************************************************************
1383 
1384 
1385 //*************************************************************************************************
1395 template< typename MT // Type of the adapted sparse matrix
1396  , bool SO > // Storage order of the adapted sparse matrix
1397 inline void StrictlyUpperMatrix<MT,SO,false>::erase( size_t i, size_t j )
1398 {
1399  matrix_.erase( i, j );
1400 }
1402 //*************************************************************************************************
1403 
1404 
1405 //*************************************************************************************************
1417 template< typename MT // Type of the adapted sparse matrix
1418  , bool SO > // Storage order of the adapted sparse matrix
1420  StrictlyUpperMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1421 {
1422  return matrix_.erase( i, pos );
1423 }
1425 //*************************************************************************************************
1426 
1427 
1428 //*************************************************************************************************
1442 template< typename MT // Type of the adapted sparse matrix
1443  , bool SO > // Storage order of the adapted sparse matrix
1445  StrictlyUpperMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1446 {
1447  return matrix_.erase( i, first, last );
1448 }
1450 //*************************************************************************************************
1451 
1452 
1453 //*************************************************************************************************
1468 template< typename MT // Type of the adapted sparse matrix
1469  , bool SO > // Storage order of the adapted sparse matrix
1470 void StrictlyUpperMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1471 {
1473 
1474  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly upper matrix detected" );
1475 
1476  matrix_.resize( n, n, preserve );
1477 }
1479 //*************************************************************************************************
1480 
1481 
1482 //*************************************************************************************************
1493 template< typename MT // Type of the adapted sparse matrix
1494  , bool SO > // Storage order of the adapted sparse matrix
1495 inline void StrictlyUpperMatrix<MT,SO,false>::reserve( size_t nonzeros )
1496 {
1497  matrix_.reserve( nonzeros );
1498 }
1500 //*************************************************************************************************
1501 
1502 
1503 //*************************************************************************************************
1518 template< typename MT // Type of the adapted sparse matrix
1519  , bool SO > // Storage order of the adapted sparse matrix
1520 inline void StrictlyUpperMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1521 {
1522  matrix_.reserve( i, nonzeros );
1523 }
1525 //*************************************************************************************************
1526 
1527 
1528 //*************************************************************************************************
1539 template< typename MT // Type of the adapted sparse matrix
1540  , bool SO > // Storage order of the adapted sparse matrix
1541 inline void StrictlyUpperMatrix<MT,SO,false>::trim()
1542 {
1543  matrix_.trim();
1544 }
1546 //*************************************************************************************************
1547 
1548 
1549 //*************************************************************************************************
1561 template< typename MT // Type of the adapted sparse matrix
1562  , bool SO > // Storage order of the adapted sparse matrix
1563 inline void StrictlyUpperMatrix<MT,SO,false>::trim( size_t i )
1564 {
1565  matrix_.trim( i );
1566 }
1568 //*************************************************************************************************
1569 
1570 
1571 //*************************************************************************************************
1578 template< typename MT // Type of the adapted sparse matrix
1579  , bool SO > // Storage order of the adapted sparse matrix
1580 template< typename Other > // Data type of the scalar value
1581 inline StrictlyUpperMatrix<MT,SO,false>&
1582  StrictlyUpperMatrix<MT,SO,false>::scale( const Other& scalar )
1583 {
1584  matrix_.scale( scalar );
1585  return *this;
1586 }
1588 //*************************************************************************************************
1589 
1590 
1591 //*************************************************************************************************
1598 template< typename MT // Type of the adapted sparse matrix
1599  , bool SO > // Storage order of the adapted sparse matrix
1600 template< typename Other > // Data type of the scalar value
1601 inline StrictlyUpperMatrix<MT,SO,false>&
1602  StrictlyUpperMatrix<MT,SO,false>::scaleDiagonal( Other scalar )
1603 {
1604  matrix_.scaleDiagonal( scalar );
1605  return *this;
1606 }
1608 //*************************************************************************************************
1609 
1610 
1611 //*************************************************************************************************
1619 template< typename MT // Type of the adapted sparse matrix
1620  , bool SO > // Storage order of the adapted sparse matrix
1621 inline void StrictlyUpperMatrix<MT,SO,false>::swap( StrictlyUpperMatrix& m ) /* throw() */
1622 {
1623  using std::swap;
1624 
1625  swap( matrix_, m.matrix_ );
1626 }
1628 //*************************************************************************************************
1629 
1630 
1631 //*************************************************************************************************
1643 template< typename MT // Type of the adapted dense matrix
1644  , bool SO > // Storage order of the adapted dense matrix
1645 inline size_t StrictlyUpperMatrix<MT,SO,false>::maxNonZeros()
1646 {
1648 
1649  return maxNonZeros( Rows<MT>::value );
1650 }
1652 //*************************************************************************************************
1653 
1654 
1655 //*************************************************************************************************
1665 template< typename MT // Type of the adapted dense matrix
1666  , bool SO > // Storage order of the adapted dense matrix
1667 inline size_t StrictlyUpperMatrix<MT,SO,false>::maxNonZeros( size_t n )
1668 {
1669  return ( ( n - 1UL ) * n ) / 2UL;
1670 }
1672 //*************************************************************************************************
1673 
1674 
1675 //*************************************************************************************************
1681 template< typename MT // Type of the adapted dense matrix
1682  , bool SO > // Storage order of the adapted dense matrix
1683 inline void StrictlyUpperMatrix<MT,SO,false>::resetLower()
1684 {
1685  if( SO ) {
1686  for( size_t j=0UL; j<columns(); ++j )
1687  matrix_.erase( j, matrix_.upperBound( j, j ), matrix_.end( j ) );
1688  }
1689  else {
1690  for( size_t i=1UL; i<rows(); ++i )
1691  matrix_.erase( i, matrix_.begin( i ), matrix_.lowerBound( i, i ) );
1692  }
1693 }
1695 //*************************************************************************************************
1696 
1697 
1698 
1699 
1700 //=================================================================================================
1701 //
1702 // LOOKUP FUNCTIONS
1703 //
1704 //=================================================================================================
1705 
1706 //*************************************************************************************************
1722 template< typename MT // Type of the adapted sparse matrix
1723  , bool SO > // Storage order of the adapted sparse matrix
1725  StrictlyUpperMatrix<MT,SO,false>::find( size_t i, size_t j )
1726 {
1727  return matrix_.find( i, j );
1728 }
1730 //*************************************************************************************************
1731 
1732 
1733 //*************************************************************************************************
1749 template< typename MT // Type of the adapted sparse matrix
1750  , bool SO > // Storage order of the adapted sparse matrix
1752  StrictlyUpperMatrix<MT,SO,false>::find( size_t i, size_t j ) const
1753 {
1754  return matrix_.find( i, j );
1755 }
1757 //*************************************************************************************************
1758 
1759 
1760 //*************************************************************************************************
1776 template< typename MT // Type of the adapted sparse matrix
1777  , bool SO > // Storage order of the adapted sparse matrix
1779  StrictlyUpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
1780 {
1781  return matrix_.lowerBound( i, j );
1782 }
1784 //*************************************************************************************************
1785 
1786 
1787 //*************************************************************************************************
1803 template< typename MT // Type of the adapted sparse matrix
1804  , bool SO > // Storage order of the adapted sparse matrix
1806  StrictlyUpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
1807 {
1808  return matrix_.lowerBound( i, j );
1809 }
1811 //*************************************************************************************************
1812 
1813 
1814 //*************************************************************************************************
1830 template< typename MT // Type of the adapted sparse matrix
1831  , bool SO > // Storage order of the adapted sparse matrix
1833  StrictlyUpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
1834 {
1835  return matrix_.upperBound( i, j );
1836 }
1838 //*************************************************************************************************
1839 
1840 
1841 //*************************************************************************************************
1857 template< typename MT // Type of the adapted sparse matrix
1858  , bool SO > // Storage order of the adapted sparse matrix
1860  StrictlyUpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
1861 {
1862  return matrix_.upperBound( i, j );
1863 }
1865 //*************************************************************************************************
1866 
1867 
1868 
1869 
1870 //=================================================================================================
1871 //
1872 // LOW-LEVEL UTILITY FUNCTIONS
1873 //
1874 //=================================================================================================
1875 
1876 //*************************************************************************************************
1926 template< typename MT // Type of the adapted sparse matrix
1927  , bool SO > // Storage order of the adapted sparse matrix
1928 inline void StrictlyUpperMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1929 {
1930  if( i >= j ) {
1931  BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or lower matrix element" );
1932  }
1933 
1934  matrix_.append( i, j, value, check );
1935 }
1937 //*************************************************************************************************
1938 
1939 
1940 //*************************************************************************************************
1954 template< typename MT // Type of the adapted sparse matrix
1955  , bool SO > // Storage order of the adapted sparse matrix
1956 inline void StrictlyUpperMatrix<MT,SO,false>::finalize( size_t i )
1957 {
1958  matrix_.finalize( i );
1959 }
1961 //*************************************************************************************************
1962 
1963 
1964 
1965 
1966 //=================================================================================================
1967 //
1968 // DEBUGGING FUNCTIONS
1969 //
1970 //=================================================================================================
1971 
1972 //*************************************************************************************************
1982 template< typename MT // Type of the adapted sparse matrix
1983  , bool SO > // Storage order of the adapted sparse matrix
1985 {
1986  using blaze::isIntact;
1987 
1988  return ( isIntact( matrix_ ) && isStrictlyUpper( matrix_ ) );
1989 }
1991 //*************************************************************************************************
1992 
1993 
1994 
1995 
1996 //=================================================================================================
1997 //
1998 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1999 //
2000 //=================================================================================================
2001 
2002 //*************************************************************************************************
2013 template< typename MT // Type of the adapted sparse matrix
2014  , bool SO > // Storage order of the adapted sparse matrix
2015 template< typename Other > // Data type of the foreign expression
2016 inline bool StrictlyUpperMatrix<MT,SO,false>::canAlias( const Other* alias ) const
2017 {
2018  return matrix_.canAlias( alias );
2019 }
2021 //*************************************************************************************************
2022 
2023 
2024 //*************************************************************************************************
2035 template< typename MT // Type of the adapted sparse matrix
2036  , bool SO > // Storage order of the adapted sparse matrix
2037 template< typename Other > // Data type of the foreign expression
2038 inline bool StrictlyUpperMatrix<MT,SO,false>::isAliased( const Other* alias ) const
2039 {
2040  return matrix_.isAliased( alias );
2041 }
2043 //*************************************************************************************************
2044 
2045 
2046 //*************************************************************************************************
2057 template< typename MT // Type of the adapted sparse matrix
2058  , bool SO > // Storage order of the adapted sparse matrix
2059 inline bool StrictlyUpperMatrix<MT,SO,false>::canSMPAssign() const
2060 {
2061  return matrix_.canSMPAssign();
2062 }
2064 //*************************************************************************************************
2065 
2066 } // namespace blaze
2067 
2068 #endif
Header file for the StrictlyUpperProxy class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type, a compilation error is created.
Definition: Const.h:116
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exceptionThis macro encapsulates the default way of...
Definition: Exception.h:187
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1729
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type set(T value)
Sets all values in the vector to the given 2-byte integral value.
Definition: Set.h:73
Header file for mathematical functions.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the Rows type trait.
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE bool isSquare(const Matrix< MT, SO > &matrix)
Checks if the given matrix is a square matrix.
Definition: Matrix.h:603
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:229
void move(CompressedMatrix< Type, SO > &dst, CompressedMatrix< Type, SO > &src)
Moving the contents of one compressed matrix to another.
Definition: CompressedMatrix.h:5016
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:292
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:250
bool isStrictlyUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly upper triangular matrix.
Definition: DenseMatrix.h:1434
#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:81
Constraint on the data type.
Constraint on the data type.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:507
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2588
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:340
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:308
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:4926
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2582
#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:116
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:378
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2584
Constraint on the data type.
Constraint on the data type.
Header file for the SparseMatrix base class.
Header file for utility functions for sparse matrices.
Header file for the IsSquare type trait.
Constraint on the data type.
Header file for the DisableIf class template.
Header file for the IsStrictlyUpper type trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
Compile time assertion.
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4998
bool isIntact(const CompressedMatrix< Type, SO > &m)
Returns whether the invariants of the given compressed matrix are intact.
Definition: CompressedMatrix.h:4980
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2592
#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:116
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exceptionThis macro encapsulates the default way of Bla...
Definition: Exception.h:331
Header file for the Columns type trait.
Constraint on the data type.
Header file for the IsUniTriangular type trait.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2585
Constraints on the storage order of matrix types.
#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:118
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:187
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:532
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2586
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2590
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:527
Header file for the implementation of the base template of the StrictlyUpperMatrix.
Header file for the IsNumeric type trait.
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:116
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2587
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:118
#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:116
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:2591
Header file for the isDefault shim.
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:118
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b)
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:256
Header file for the move shim.
#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:79
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:118
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2583
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:324
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:237
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2589
#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:116
Header file for exception macros.
#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:143
Header file for the IsResizable type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a sparse, N-dimensional matrix type...
Definition: SparseMatrix.h:79