Sparse.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_UNIUPPERMATRIX_SPARSE_H_
36 #define _BLAZE_MATH_ADAPTORS_UNIUPPERMATRIX_SPARSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <algorithm>
44 #include <stdexcept>
45 #include <vector>
57 #include <blaze/math/Functions.h>
58 #include <blaze/math/shims/Clear.h>
60 #include <blaze/math/shims/Move.h>
71 #include <blaze/util/Assert.h>
77 #include <blaze/util/DisableIf.h>
78 #include <blaze/util/EnableIf.h>
80 #include <blaze/util/Types.h>
81 
82 
83 namespace blaze {
84 
85 //=================================================================================================
86 //
87 // CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
88 //
89 //=================================================================================================
90 
91 //*************************************************************************************************
99 template< typename MT // Type of the adapted sparse matrix
100  , bool SO > // Storage order of the adapted sparse matrix
101 class UniUpperMatrix<MT,SO,false>
102  : public SparseMatrix< UniUpperMatrix<MT,SO,false>, SO >
103 {
104  private:
105  //**Type definitions****************************************************************************
106  typedef typename MT::OppositeType OT;
107  typedef typename MT::TransposeType TT;
108  typedef typename MT::ElementType ET;
109  //**********************************************************************************************
110 
111  public:
112  //**Type definitions****************************************************************************
113  typedef UniUpperMatrix<MT,SO,false> This;
114  typedef This ResultType;
115  typedef UniUpperMatrix<OT,!SO,false> OppositeType;
116  typedef UniLowerMatrix<TT,!SO,false> TransposeType;
117  typedef ET ElementType;
118  typedef typename MT::ReturnType ReturnType;
119  typedef const This& CompositeType;
120  typedef UniUpperProxy<MT> Reference;
121  typedef typename MT::ConstReference ConstReference;
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 UniUpperMatrix< typename MT::template Rebind<ET>::Other > Other;
132  };
133  //**********************************************************************************************
134 
135  //**UniUpperValue class definition*************************************************************
138  class UniUpperValue
139  {
140  private:
141  //**struct BuiltinType***********************************************************************
144  template< typename T >
145  struct BuiltinType { typedef INVALID_TYPE Type; };
146  //*******************************************************************************************
147 
148  //**struct ComplexType***********************************************************************
151  template< typename T >
152  struct ComplexType { typedef typename T::value_type Type; };
153  //*******************************************************************************************
154 
155  public:
156  //**Type definitions*************************************************************************
158  typedef typename If< IsComplex<ElementType>
159  , ComplexType<ElementType>
160  , BuiltinType<ElementType> >::Type::Type ValueType;
161 
162  typedef ValueType value_type;
163  //*******************************************************************************************
164 
165  //**Constructor******************************************************************************
171  inline UniUpperValue( ElementType& value, bool diagonal )
172  : value_ ( &value ) // The represented value.
173  , diagonal_( diagonal ) // true in case the element is on the diagonal, false if not
174  {}
175  //*******************************************************************************************
176 
177  //*******************************************************************************************
184  inline UniUpperValue& operator=( const UniUpperValue& uv ) {
185  if( diagonal_ )
186  throw std::invalid_argument( "Invalid assignment to diagonal matrix element" );
187  *value_ = *uv.value;
188  return *this;
189  }
190  //*******************************************************************************************
191 
192  //*******************************************************************************************
199  template< typename T > inline UniUpperValue& operator=( const T& v ) {
200  if( diagonal_ )
201  throw std::invalid_argument( "Invalid assignment to diagonal matrix element" );
202  *value_ = v;
203  return *this;
204  }
205  //*******************************************************************************************
206 
207  //*******************************************************************************************
214  template< typename T > inline UniUpperValue& operator+=( const T& v ) {
215  if( diagonal_ )
216  throw std::invalid_argument( "Invalid assignment to diagonal matrix element" );
217  *value_ += v;
218  return *this;
219  }
220  //*******************************************************************************************
221 
222  //*******************************************************************************************
229  template< typename T > inline UniUpperValue& operator-=( const T& v ) {
230  if( diagonal_ )
231  throw std::invalid_argument( "Invalid assignment to diagonal matrix element" );
232  *value_ -= v;
233  return *this;
234  }
235  //*******************************************************************************************
236 
237  //*******************************************************************************************
244  template< typename T > inline UniUpperValue& operator*=( const T& v ) {
245  if( diagonal_ )
246  throw std::invalid_argument( "Invalid assignment to diagonal matrix element" );
247  *value_ *= v;
248  return *this;
249  }
250  //*******************************************************************************************
251 
252  //*******************************************************************************************
259  template< typename T > inline UniUpperValue& operator/=( const T& v ) {
260  if( diagonal_ )
261  throw std::invalid_argument( "Invalid assignment to diagonal matrix element" );
262  *value_ /= v;
263  return *this;
264  }
265  //*******************************************************************************************
266 
267  //*******************************************************************************************
272  inline operator ElementType() const {
273  return *value_;
274  }
275  //*******************************************************************************************
276 
277  //*******************************************************************************************
285  inline ValueType real() const {
286  return value_->real();
287  }
288  //*******************************************************************************************
289 
290  //*******************************************************************************************
300  inline void real( ValueType value ) const {
301  if( diagonal_ )
302  throw std::invalid_argument( "Invalid assignment to diagonal matrix element" );
303  value_->real( value );
304  }
305  //*******************************************************************************************
306 
307  //*******************************************************************************************
315  inline ValueType imag() const {
316  return value_->imag();
317  }
318  //*******************************************************************************************
319 
320  //*******************************************************************************************
330  inline void imag( ValueType value ) const {
331  if( diagonal_ )
332  throw std::invalid_argument( "Invalid assignment to diagonal matrix element" );
333  value_->imag( value );
334  }
335  //*******************************************************************************************
336 
337  private:
338  //**Member variables*************************************************************************
339  ElementType* value_;
340  bool diagonal_;
341  //*******************************************************************************************
342  };
343  //**********************************************************************************************
344 
345  //**UniUpperElement class definition************************************************************
348  class UniUpperElement : private SparseElement
349  {
350  private:
351  //**Type definitions*************************************************************************
352  typedef typename MT::Iterator IteratorType;
353  //*******************************************************************************************
354 
355  public:
356  //**Type definitions*************************************************************************
357  typedef UniUpperValue ValueType;
358  typedef size_t IndexType;
359  typedef UniUpperValue Reference;
360  typedef const UniUpperValue ConstReference;
361  typedef UniUpperElement* Pointer;
362  //*******************************************************************************************
363 
364  //**Constructor******************************************************************************
370  inline UniUpperElement( IteratorType pos, bool diagonal )
371  : pos_ ( pos ) // Iterator to the current upper unitriangular matrix element
372  , diagonal_( diagonal ) // true in case the element is on the diagonal, false if not
373  {}
374  //*******************************************************************************************
375 
376  //**Assignment operator**********************************************************************
383  template< typename T > inline UniUpperElement& operator=( const T& v ) {
384  if( diagonal_ )
385  throw std::invalid_argument( "Invalid assignment to diagonal matrix element" );
386  *pos_ = v;
387  return *this;
388  }
389  //*******************************************************************************************
390 
391  //**Addition assignment operator*************************************************************
398  template< typename T > inline UniUpperElement& operator+=( const T& v ) {
399  if( diagonal_ )
400  throw std::invalid_argument( "Invalid assignment to diagonal matrix element" );
401  *pos_ += v;
402  return *this;
403  }
404  //*******************************************************************************************
405 
406  //**Subtraction assignment operator**********************************************************
413  template< typename T > inline UniUpperElement& operator-=( const T& v ) {
414  if( diagonal_ )
415  throw std::invalid_argument( "Invalid assignment to diagonal matrix element" );
416  *pos_ -= v;
417  return *this;
418  }
419  //*******************************************************************************************
420 
421  //**Multiplication assignment operator*******************************************************
428  template< typename T > inline UniUpperElement& operator*=( const T& v ) {
429  if( diagonal_ )
430  throw std::invalid_argument( "Invalid assignment to diagonal matrix element" );
431  *pos_ *= v;
432  return *this;
433  }
434  //*******************************************************************************************
435 
436  //**Division assignment operator*************************************************************
443  template< typename T > inline UniUpperElement& operator/=( const T& v ) {
444  if( diagonal_ )
445  throw std::invalid_argument( "Invalid assignment to diagonal matrix element" );
446  *pos_ /= v;
447  return *this;
448  }
449  //*******************************************************************************************
450 
451  //**Element access operator******************************************************************
456  inline Pointer operator->() {
457  return this;
458  }
459  //*******************************************************************************************
460 
461  //**Value function***************************************************************************
466  inline Reference value() const {
467  return Reference( pos_->value(), diagonal_ );
468  }
469  //*******************************************************************************************
470 
471  //**Index function***************************************************************************
476  inline IndexType index() const {
477  return pos_->index();
478  }
479  //*******************************************************************************************
480 
481  private:
482  //**Member variables*************************************************************************
483  IteratorType pos_;
484  bool diagonal_;
485  //*******************************************************************************************
486  };
487  //**********************************************************************************************
488 
489  //**Iterator class definition*******************************************************************
492  class Iterator
493  {
494  public:
495  //**Type definitions*************************************************************************
496  typedef typename MT::Iterator IteratorType;
497 
498  typedef std::forward_iterator_tag IteratorCategory;
499  typedef UniUpperElement ValueType;
500  typedef ValueType PointerType;
501  typedef ValueType ReferenceType;
502  typedef ptrdiff_t DifferenceType;
503 
504  // STL iterator requirements
505  typedef IteratorCategory iterator_category;
506  typedef ValueType value_type;
507  typedef PointerType pointer;
508  typedef ReferenceType reference;
509  typedef DifferenceType difference_type;
510  //*******************************************************************************************
511 
512  //**Default constructor**********************************************************************
515  inline Iterator()
516  : pos_ ( ) // Iterator to the current upper unitriangular matrix element
517  , index_ ( 0UL ) // The row/column index of the iterator
518  {}
519  //*******************************************************************************************
520 
521  //**Constructor******************************************************************************
527  inline Iterator( IteratorType pos, size_t index )
528  : pos_ ( pos ) // Iterator to the current upper unitriangular matrix element
529  , index_( index ) // The row/column index of the iterator
530  {}
531  //*******************************************************************************************
532 
533  //**Prefix increment operator****************************************************************
538  inline Iterator& operator++() {
539  ++pos_;
540  return *this;
541  }
542  //*******************************************************************************************
543 
544  //**Postfix increment operator***************************************************************
549  inline const Iterator operator++( int ) {
550  const Iterator tmp( *this );
551  ++(*this);
552  return tmp;
553  }
554  //*******************************************************************************************
555 
556  //**Element access operator******************************************************************
561  inline ReferenceType operator*() const {
562  return ReferenceType( pos_, pos_->index() == index_ );
563  }
564  //*******************************************************************************************
565 
566  //**Element access operator******************************************************************
571  inline PointerType operator->() const {
572  return PointerType( pos_, pos_->index() == index_ );
573  }
574  //*******************************************************************************************
575 
576  //**Conversion operator**********************************************************************
581  inline operator ConstIterator() const {
582  return pos_;
583  }
584  //*******************************************************************************************
585 
586  //**Equality operator************************************************************************
592  inline bool operator==( const Iterator& rhs ) const {
593  return pos_ == rhs.pos_;
594  }
595  //*******************************************************************************************
596 
597  //**Inequality operator**********************************************************************
603  inline bool operator!=( const Iterator& rhs ) const {
604  return !( *this == rhs );
605  }
606  //*******************************************************************************************
607 
608  //**Subtraction operator*********************************************************************
614  inline DifferenceType operator-( const Iterator& rhs ) const {
615  return pos_ - rhs.pos_;
616  }
617  //*******************************************************************************************
618 
619  //**Base function****************************************************************************
624  inline IteratorType base() const {
625  return pos_;
626  }
627  //*******************************************************************************************
628 
629  private:
630  //**Member variables*************************************************************************
631  IteratorType pos_;
632  size_t index_;
633  //*******************************************************************************************
634  };
635  //**********************************************************************************************
636 
637  //**Compilation flags***************************************************************************
639  enum { smpAssignable = 0 };
640  //**********************************************************************************************
641 
642  //**Constructors********************************************************************************
645  explicit inline UniUpperMatrix();
646  explicit inline UniUpperMatrix( size_t n );
647  explicit inline UniUpperMatrix( size_t n, size_t nonzeros );
648  explicit inline UniUpperMatrix( size_t n, const std::vector<size_t>& nonzeros );
649 
650  inline UniUpperMatrix( const UniUpperMatrix& m );
651  template< typename MT2, bool SO2 > inline UniUpperMatrix( const Matrix<MT2,SO2>& m );
653  //**********************************************************************************************
654 
655  //**Destructor**********************************************************************************
656  // No explicitly declared destructor.
657  //**********************************************************************************************
658 
659  //**Data access functions***********************************************************************
662  inline Reference operator()( size_t i, size_t j );
663  inline ConstReference operator()( size_t i, size_t j ) const;
664  inline Iterator begin ( size_t i );
665  inline ConstIterator begin ( size_t i ) const;
666  inline ConstIterator cbegin( size_t i ) const;
667  inline Iterator end ( size_t i );
668  inline ConstIterator end ( size_t i ) const;
669  inline ConstIterator cend ( size_t i ) const;
671  //**********************************************************************************************
672 
673  //**Assignment operators************************************************************************
676  inline UniUpperMatrix& operator=( const UniUpperMatrix& rhs );
677 
678  template< typename MT2, bool SO2 >
679  inline typename DisableIf< IsComputation<MT2>, UniUpperMatrix& >::Type
680  operator=( const Matrix<MT2,SO2>& rhs );
681 
682  template< typename MT2, bool SO2 >
683  inline typename EnableIf< IsComputation<MT2>, UniUpperMatrix& >::Type
684  operator=( const Matrix<MT2,SO2>& rhs );
685 
686  template< typename MT2, bool SO2 >
687  inline typename DisableIf< IsComputation<MT2>, UniUpperMatrix& >::Type
688  operator+=( const Matrix<MT2,SO2>& rhs );
689 
690  template< typename MT2, bool SO2 >
691  inline typename EnableIf< IsComputation<MT2>, UniUpperMatrix& >::Type
692  operator+=( const Matrix<MT2,SO2>& rhs );
693 
694  template< typename MT2, bool SO2 >
695  inline typename DisableIf< IsComputation<MT2>, UniUpperMatrix& >::Type
696  operator-=( const Matrix<MT2,SO2>& rhs );
697 
698  template< typename MT2, bool SO2 >
699  inline typename EnableIf< IsComputation<MT2>, UniUpperMatrix& >::Type
700  operator-=( const Matrix<MT2,SO2>& rhs );
701 
702  template< typename MT2, bool SO2 >
703  inline UniUpperMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
705  //**********************************************************************************************
706 
707  //**Utility functions***************************************************************************
710  inline size_t rows() const;
711  inline size_t columns() const;
712  inline size_t capacity() const;
713  inline size_t capacity( size_t i ) const;
714  inline size_t nonZeros() const;
715  inline size_t nonZeros( size_t i ) const;
716  inline void reset();
717  inline void reset( size_t i );
718  inline void clear();
719  inline Iterator set( size_t i, size_t j, const ElementType& value );
720  inline Iterator insert( size_t i, size_t j, const ElementType& value );
721  inline void erase( size_t i, size_t j );
722  inline Iterator erase( size_t i, Iterator pos );
723  inline Iterator erase( size_t i, Iterator first, Iterator last );
724  inline void resize ( size_t n, bool preserve=true );
725  inline void reserve( size_t nonzeros );
726  inline void reserve( size_t i, size_t nonzeros );
727  inline void trim();
728  inline void trim( size_t i );
729  inline void swap( UniUpperMatrix& m ) /* throw() */;
730 
731  static inline size_t maxNonZeros();
732  static inline size_t maxNonZeros( size_t n );
734  //**********************************************************************************************
735 
736  //**Lookup functions****************************************************************************
739  inline Iterator find ( size_t i, size_t j );
740  inline ConstIterator find ( size_t i, size_t j ) const;
741  inline Iterator lowerBound( size_t i, size_t j );
742  inline ConstIterator lowerBound( size_t i, size_t j ) const;
743  inline Iterator upperBound( size_t i, size_t j );
744  inline ConstIterator upperBound( size_t i, size_t j ) const;
746  //**********************************************************************************************
747 
748  //**Low-level utility functions*****************************************************************
751  inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
752  inline void finalize( size_t i );
754  //**********************************************************************************************
755 
756  //**Expression template evaluation functions****************************************************
759  template< typename Other > inline bool canAlias ( const Other* alias ) const;
760  template< typename Other > inline bool isAliased( const Other* alias ) const;
761 
762  inline bool canSMPAssign() const;
764  //**********************************************************************************************
765 
766  private:
767  //**Utility functions***************************************************************************
770  inline void resetLower();
772  //**********************************************************************************************
773 
774  //**Member variables****************************************************************************
777  MT matrix_;
778 
779  //**********************************************************************************************
780 
781  //**Friend declarations*************************************************************************
782  template< typename MT2, bool SO2, bool DF2 >
783  friend MT2& derestrict( UniUpperMatrix<MT2,SO2,DF2>& m );
784  //**********************************************************************************************
785 
786  //**Compile time checks*************************************************************************
799  BLAZE_STATIC_ASSERT( IsResizable<MT>::value || IsSquare<MT>::value );
800  //**********************************************************************************************
801 };
803 //*************************************************************************************************
804 
805 
806 
807 
808 //=================================================================================================
809 //
810 // CONSTRUCTORS
811 //
812 //=================================================================================================
813 
814 //*************************************************************************************************
818 template< typename MT // Type of the adapted sparse matrix
819  , bool SO > // Storage order of the adapted sparse matrix
820 inline UniUpperMatrix<MT,SO,false>::UniUpperMatrix()
821  : matrix_() // The adapted sparse matrix
822 {
823  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
824 }
826 //*************************************************************************************************
827 
828 
829 //*************************************************************************************************
837 template< typename MT // Type of the adapted sparse matrix
838  , bool SO > // Storage order of the adapted sparse matrix
839 inline UniUpperMatrix<MT,SO,false>::UniUpperMatrix( size_t n )
840  : matrix_( n, n, n ) // The adapted sparse matrix
841 {
843 
844  for( size_t i=0UL; i<n; ++i ) {
845  matrix_.append( i, i, ElementType(1) );
846  matrix_.finalize( i );
847  }
848 
849  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
850 }
852 //*************************************************************************************************
853 
854 
855 //*************************************************************************************************
865 template< typename MT // Type of the adapted sparse matrix
866  , bool SO > // Storage order of the adapted sparse matrix
867 inline UniUpperMatrix<MT,SO,false>::UniUpperMatrix( size_t n, size_t nonzeros )
868  : matrix_( n, n, max( nonzeros, n ) ) // The adapted sparse matrix
869 {
871 
872  for( size_t i=0UL; i<n; ++i ) {
873  matrix_.append( i, i, ElementType(1) );
874  matrix_.finalize( i );
875  }
876 
877  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
878 }
880 //*************************************************************************************************
881 
882 
883 //*************************************************************************************************
897 template< typename MT // Type of the adapted sparse matrix
898  , bool SO > // Storage order of the adapted sparse matrix
899 inline UniUpperMatrix<MT,SO,false>::UniUpperMatrix( size_t n, const std::vector<size_t>& nonzeros )
900  : matrix_( n, n, nonzeros ) // The adapted sparse matrix
901 {
903 
904  for( size_t i=0UL; i<n; ++i )
905  {
906  if( nonzeros[i] == 0UL )
907  throw std::invalid_argument( "Invalid capacity specification" );
908 
909  matrix_.append( i, i, ElementType(1) );
910  matrix_.finalize( i );
911  }
912 
913  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
914 }
916 //*************************************************************************************************
917 
918 
919 //*************************************************************************************************
925 template< typename MT // Type of the adapted sparse matrix
926  , bool SO > // Storage order of the adapted sparse matrix
927 inline UniUpperMatrix<MT,SO,false>::UniUpperMatrix( const UniUpperMatrix& m )
928  : matrix_( m.matrix_ ) // The adapted sparse matrix
929 {
930  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
931 }
933 //*************************************************************************************************
934 
935 
936 //*************************************************************************************************
946 template< typename MT // Type of the adapted sparse matrix
947  , bool SO > // Storage order of the adapted sparse matrix
948 template< typename MT2 // Type of the foreign matrix
949  , bool SO2 > // Storage order of the foreign matrix
950 inline UniUpperMatrix<MT,SO,false>::UniUpperMatrix( const Matrix<MT2,SO2>& m )
951  : matrix_( ~m ) // The adapted sparse matrix
952 {
953  if( !IsUniUpper<MT2>::value && !isUniUpper( matrix_ ) )
954  throw std::invalid_argument( "Invalid setup of uniupper matrix" );
955 
956  if( !IsUniUpper<MT2>::value )
957  resetLower();
958 
959  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
960 }
962 //*************************************************************************************************
963 
964 
965 
966 
967 //=================================================================================================
968 //
969 // DATA ACCESS FUNCTIONS
970 //
971 //=================================================================================================
972 
973 //*************************************************************************************************
985 template< typename MT // Type of the adapted sparse matrix
986  , bool SO > // Storage order of the adapted sparse matrix
988  UniUpperMatrix<MT,SO,false>::operator()( size_t i, size_t j )
989 {
990  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
991  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
992 
993  return Reference( matrix_, i, j );
994 }
996 //*************************************************************************************************
997 
998 
999 //*************************************************************************************************
1011 template< typename MT // Type of the adapted sparse matrix
1012  , bool SO > // Storage order of the adapted sparse matrix
1014  UniUpperMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
1015 {
1016  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1017  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1018 
1019  return matrix_(i,j);
1020 }
1022 //*************************************************************************************************
1023 
1024 
1025 //*************************************************************************************************
1037 template< typename MT // Type of the adapted sparse matrix
1038  , bool SO > // Storage order of the adapted sparse matrix
1041 {
1042  return Iterator( matrix_.begin(i), i );
1043 }
1045 //*************************************************************************************************
1046 
1047 
1048 //*************************************************************************************************
1060 template< typename MT // Type of the adapted sparse matrix
1061  , bool SO > // Storage order of the adapted sparse matrix
1063  UniUpperMatrix<MT,SO,false>::begin( size_t i ) const
1064 {
1065  return matrix_.begin(i);
1066 }
1068 //*************************************************************************************************
1069 
1070 
1071 //*************************************************************************************************
1083 template< typename MT // Type of the adapted sparse matrix
1084  , bool SO > // Storage order of the adapted sparse matrix
1086  UniUpperMatrix<MT,SO,false>::cbegin( size_t i ) const
1087 {
1088  return matrix_.cbegin(i);
1089 }
1091 //*************************************************************************************************
1092 
1093 
1094 //*************************************************************************************************
1106 template< typename MT // Type of the adapted sparse matrix
1107  , bool SO > // Storage order of the adapted sparse matrix
1110 {
1111  return Iterator( matrix_.end(i), i );
1112 }
1114 //*************************************************************************************************
1115 
1116 
1117 //*************************************************************************************************
1129 template< typename MT // Type of the adapted sparse matrix
1130  , bool SO > // Storage order of the adapted sparse matrix
1132  UniUpperMatrix<MT,SO,false>::end( size_t i ) const
1133 {
1134  return matrix_.end(i);
1135 }
1137 //*************************************************************************************************
1138 
1139 
1140 //*************************************************************************************************
1152 template< typename MT // Type of the adapted sparse matrix
1153  , bool SO > // Storage order of the adapted sparse matrix
1155  UniUpperMatrix<MT,SO,false>::cend( size_t i ) const
1156 {
1157  return matrix_.cend(i);
1158 }
1160 //*************************************************************************************************
1161 
1162 
1163 
1164 
1165 //=================================================================================================
1166 //
1167 // ASSIGNMENT OPERATORS
1168 //
1169 //=================================================================================================
1170 
1171 //*************************************************************************************************
1181 template< typename MT // Type of the adapted sparse matrix
1182  , bool SO > // Storage order of the adapted sparse matrix
1183 inline UniUpperMatrix<MT,SO,false>&
1184  UniUpperMatrix<MT,SO,false>::operator=( const UniUpperMatrix& rhs )
1185 {
1186  matrix_ = rhs.matrix_;
1187 
1188  return *this;
1189 }
1191 //*************************************************************************************************
1192 
1193 
1194 //*************************************************************************************************
1207 template< typename MT // Type of the adapted sparse matrix
1208  , bool SO > // Storage order of the adapted sparse matrix
1209 template< typename MT2 // Type of the right-hand side matrix
1210  , bool SO2 > // Storage order of the right-hand side matrix
1211 inline typename DisableIf< IsComputation<MT2>, UniUpperMatrix<MT,SO,false>& >::Type
1212  UniUpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
1213 {
1214  if( IsStrictlyTriangular<MT2>::value || ( !IsUniUpper<MT2>::value && !isUniUpper( ~rhs ) ) )
1215  throw std::invalid_argument( "Invalid assignment to uniupper matrix" );
1216 
1217  matrix_ = ~rhs;
1218 
1219  if( !IsUniUpper<MT2>::value )
1220  resetLower();
1221 
1222  return *this;
1223 }
1225 //*************************************************************************************************
1226 
1227 
1228 //*************************************************************************************************
1241 template< typename MT // Type of the adapted sparse matrix
1242  , bool SO > // Storage order of the adapted sparse matrix
1243 template< typename MT2 // Type of the right-hand side matrix
1244  , bool SO2 > // Storage order of the right-hand side matrix
1245 inline typename EnableIf< IsComputation<MT2>, UniUpperMatrix<MT,SO,false>& >::Type
1246  UniUpperMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
1247 {
1248  if( IsStrictlyTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) )
1249  throw std::invalid_argument( "Invalid assignment to uniupper matrix" );
1250 
1251  if( IsUniUpper<MT2>::value ) {
1252  matrix_ = ~rhs;
1253  }
1254  else {
1255  MT tmp( ~rhs );
1256 
1257  if( !isUniUpper( tmp ) )
1258  throw std::invalid_argument( "Invalid assignment to uniupper matrix" );
1259 
1260  move( matrix_, tmp );
1261  }
1262 
1263  if( !IsUniUpper<MT2>::value )
1264  resetLower();
1265 
1266  return *this;
1267 }
1269 //*************************************************************************************************
1270 
1271 
1272 //*************************************************************************************************
1285 template< typename MT // Type of the adapted sparse matrix
1286  , bool SO > // Storage order of the adapted sparse matrix
1287 template< typename MT2 // Type of the right-hand side matrix
1288  , bool SO2 > // Storage order of the right-hand side matrix
1289 inline typename DisableIf< IsComputation<MT2>, UniUpperMatrix<MT,SO,false>& >::Type
1290  UniUpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1291 {
1292  if( IsLower<MT2>::value || IsUniTriangular<MT2>::value ||
1293  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) )
1294  throw std::invalid_argument( "Invalid assignment to uniupper matrix" );
1295 
1296  matrix_ += ~rhs;
1297 
1298  if( !IsStrictlyUpper<MT2>::value )
1299  resetLower();
1300 
1301  return *this;
1302 }
1304 //*************************************************************************************************
1305 
1306 
1307 //*************************************************************************************************
1320 template< typename MT // Type of the adapted sparse matrix
1321  , bool SO > // Storage order of the adapted sparse matrix
1322 template< typename MT2 // Type of the right-hand side matrix
1323  , bool SO2 > // Storage order of the right-hand side matrix
1324 inline typename EnableIf< IsComputation<MT2>, UniUpperMatrix<MT,SO,false>& >::Type
1325  UniUpperMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1326 {
1327  if( IsLower<MT2>::value || IsUniTriangular<MT2>::value ||
1328  ( IsSquare<MT2>::value && !isSquare( ~rhs ) ) )
1329  throw std::invalid_argument( "Invalid assignment to uniupper matrix" );
1330 
1331  if( IsStrictlyUpper<MT2>::value ) {
1332  matrix_ += ~rhs;
1333  }
1334  else {
1335  typename MT2::ResultType tmp( ~rhs );
1336 
1337  if( !isStrictlyUpper( tmp ) )
1338  throw std::invalid_argument( "Invalid assignment to uniupper matrix" );
1339 
1340  matrix_ += tmp;
1341  }
1342 
1343  if( !IsStrictlyUpper<MT2>::value )
1344  resetLower();
1345 
1346  return *this;
1347 }
1349 //*************************************************************************************************
1350 
1351 
1352 //*************************************************************************************************
1365 template< typename MT // Type of the adapted sparse matrix
1366  , bool SO > // Storage order of the adapted sparse matrix
1367 template< typename MT2 // Type of the right-hand side matrix
1368  , bool SO2 > // Storage order of the right-hand side matrix
1369 inline typename DisableIf< IsComputation<MT2>, UniUpperMatrix<MT,SO,false>& >::Type
1370  UniUpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1371 {
1372  if( IsLower<MT2>::value || IsUniTriangular<MT2>::value ||
1373  ( !IsStrictlyUpper<MT2>::value && !isStrictlyUpper( ~rhs ) ) )
1374  throw std::invalid_argument( "Invalid assignment to uniupper matrix" );
1375 
1376  matrix_ -= ~rhs;
1377 
1378  if( !IsStrictlyUpper<MT2>::value )
1379  resetLower();
1380 
1381  return *this;
1382 }
1384 //*************************************************************************************************
1385 
1386 
1387 //*************************************************************************************************
1400 template< typename MT // Type of the adapted sparse matrix
1401  , bool SO > // Storage order of the adapted sparse matrix
1402 template< typename MT2 // Type of the right-hand side matrix
1403  , bool SO2 > // Storage order of the right-hand side matrix
1404 inline typename EnableIf< IsComputation<MT2>, UniUpperMatrix<MT,SO,false>& >::Type
1405  UniUpperMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1406 {
1407  if( IsLower<MT2>::value || IsUniTriangular<MT2>::value ||
1408  ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) )
1409  throw std::invalid_argument( "Invalid assignment to uniupper matrix" );
1410 
1411  if( IsStrictlyUpper<MT2>::value ) {
1412  matrix_ -= ~rhs;
1413  }
1414  else {
1415  typename MT2::ResultType tmp( ~rhs );
1416 
1417  if( !isStrictlyUpper( tmp ) )
1418  throw std::invalid_argument( "Invalid assignment to uniupper matrix" );
1419 
1420  matrix_ -= tmp;
1421  }
1422 
1423  if( !IsStrictlyUpper<MT2>::value )
1424  resetLower();
1425 
1426  return *this;
1427 }
1429 //*************************************************************************************************
1430 
1431 
1432 //*************************************************************************************************
1444 template< typename MT // Type of the adapted sparse matrix
1445  , bool SO > // Storage order of the adapted sparse matrix
1446 template< typename MT2 // Type of the right-hand side matrix
1447  , bool SO2 > // Storage order of the right-hand side matrix
1448 inline UniUpperMatrix<MT,SO,false>&
1449  UniUpperMatrix<MT,SO,false>::operator*=( const Matrix<MT2,SO2>& rhs )
1450 {
1451  if( matrix_.rows() != (~rhs).columns() )
1452  throw std::invalid_argument( "Invalid assignment to uniupper matrix" );
1453 
1454  MT tmp( matrix_ * ~rhs );
1455 
1456  if( !isUniUpper( tmp ) )
1457  throw std::invalid_argument( "Invalid assignment to uniupper matrix" );
1458 
1459  move( matrix_, tmp );
1460 
1461  if( !IsUniUpper<MT2>::value )
1462  resetLower();
1463 
1464  return *this;
1465 }
1467 //*************************************************************************************************
1468 
1469 
1470 
1471 
1472 //=================================================================================================
1473 //
1474 // UTILITY FUNCTIONS
1475 //
1476 //=================================================================================================
1477 
1478 //*************************************************************************************************
1484 template< typename MT // Type of the adapted sparse matrix
1485  , bool SO > // Storage order of the adapted sparse matrix
1486 inline size_t UniUpperMatrix<MT,SO,false>::rows() const
1487 {
1488  return matrix_.rows();
1489 }
1491 //*************************************************************************************************
1492 
1493 
1494 //*************************************************************************************************
1500 template< typename MT // Type of the adapted sparse matrix
1501  , bool SO > // Storage order of the adapted sparse matrix
1502 inline size_t UniUpperMatrix<MT,SO,false>::columns() const
1503 {
1504  return matrix_.columns();
1505 }
1507 //*************************************************************************************************
1508 
1509 
1510 //*************************************************************************************************
1516 template< typename MT // Type of the adapted sparse matrix
1517  , bool SO > // Storage order of the adapted sparse matrix
1518 inline size_t UniUpperMatrix<MT,SO,false>::capacity() const
1519 {
1520  return matrix_.capacity();
1521 }
1523 //*************************************************************************************************
1524 
1525 
1526 //*************************************************************************************************
1538 template< typename MT // Type of the adapted sparse matrix
1539  , bool SO > // Storage order of the adapted sparse matrix
1540 inline size_t UniUpperMatrix<MT,SO,false>::capacity( size_t i ) const
1541 {
1542  return matrix_.capacity(i);
1543 }
1545 //*************************************************************************************************
1546 
1547 
1548 //*************************************************************************************************
1554 template< typename MT // Type of the adapted sparse matrix
1555  , bool SO > // Storage order of the adapted sparse matrix
1556 inline size_t UniUpperMatrix<MT,SO,false>::nonZeros() const
1557 {
1558  return matrix_.nonZeros();
1559 }
1561 //*************************************************************************************************
1562 
1563 
1564 //*************************************************************************************************
1576 template< typename MT // Type of the adapted sparse matrix
1577  , bool SO > // Storage order of the adapted sparse matrix
1578 inline size_t UniUpperMatrix<MT,SO,false>::nonZeros( size_t i ) const
1579 {
1580  return matrix_.nonZeros(i);
1581 }
1583 //*************************************************************************************************
1584 
1585 
1586 //*************************************************************************************************
1592 template< typename MT // Type of the adapted sparse matrix
1593  , bool SO > // Storage order of the adapted sparse matrix
1595 {
1596  if( SO ) {
1597  for( size_t j=1UL; j<columns(); ++j ) {
1598  matrix_.erase( j, matrix_.begin(j), matrix_.lowerBound(j,j) );
1599  }
1600  }
1601  else {
1602  for( size_t i=0UL; i<rows(); ++i ) {
1603  matrix_.erase( i, matrix_.lowerBound(i,i+1UL), matrix_.end(i) );
1604  }
1605  }
1606 }
1608 //*************************************************************************************************
1609 
1610 
1611 //*************************************************************************************************
1624 template< typename MT // Type of the adapted sparse matrix
1625  , bool SO > // Storage order of the adapted sparse matrix
1626 inline void UniUpperMatrix<MT,SO,false>::reset( size_t i )
1627 {
1628  if( SO ) {
1629  matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1630  }
1631  else {
1632  matrix_.erase( i, matrix_.lowerBound(i,i+1UL), matrix_.end(i) );
1633  }
1634 }
1636 //*************************************************************************************************
1637 
1638 
1639 //*************************************************************************************************
1647 template< typename MT // Type of the adapted sparse matrix
1648  , bool SO > // Storage order of the adapted sparse matrix
1650 {
1651  using blaze::clear;
1652 
1653  if( IsResizable<MT>::value ) {
1654  clear( matrix_ );
1655  }
1656  else {
1657  reset();
1658  }
1659 }
1661 //*************************************************************************************************
1662 
1663 
1664 //*************************************************************************************************
1680 template< typename MT // Type of the adapted sparse matrix
1681  , bool SO > // Storage order of the adapted sparse matrix
1683  UniUpperMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1684 {
1685  if( i >= j )
1686  throw std::invalid_argument( "Invalid access to diagonal or lower matrix element" );
1687 
1688  return Iterator( matrix_.set( i, j, value ), ( SO ? j : i ) );
1689 }
1691 //*************************************************************************************************
1692 
1693 
1694 //*************************************************************************************************
1711 template< typename MT // Type of the adapted sparse matrix
1712  , bool SO > // Storage order of the adapted sparse matrix
1714  UniUpperMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1715 {
1716  if( i >= j )
1717  throw std::invalid_argument( "Invalid access to diagonal or lower matrix element" );
1718 
1719  return Iterator( matrix_.insert( i, j, value ), ( SO ? j : i ) );
1720 }
1722 //*************************************************************************************************
1723 
1724 
1725 //*************************************************************************************************
1737 template< typename MT // Type of the adapted sparse matrix
1738  , bool SO > // Storage order of the adapted sparse matrix
1739 inline void UniUpperMatrix<MT,SO,false>::erase( size_t i, size_t j )
1740 {
1741  if( i == j )
1742  throw std::invalid_argument( "Invalid access to diagonal matrix element" );
1743 
1744  matrix_.erase( i, j );
1745 }
1747 //*************************************************************************************************
1748 
1749 
1750 //*************************************************************************************************
1764 template< typename MT // Type of the adapted sparse matrix
1765  , bool SO > // Storage order of the adapted sparse matrix
1767  UniUpperMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1768 {
1769  if( pos != matrix_.end(i) && pos->index() == i )
1770  throw std::invalid_argument( "Invalid access to diagonal matrix element" );
1771 
1772  return Iterator( matrix_.erase( i, pos.base() ), i );
1773 }
1775 //*************************************************************************************************
1776 
1777 
1778 //*************************************************************************************************
1793 template< typename MT // Type of the adapted sparse matrix
1794  , bool SO > // Storage order of the adapted sparse matrix
1796  UniUpperMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1797 {
1798  for( Iterator element=first; element!=last; ++element ) {
1799  if( element->index() == i ) {
1800  throw std::invalid_argument( "Invalid access to diagonal matrix element" );
1801  }
1802  }
1803 
1804  return Iterator( matrix_.erase( i, first.base(), last.base() ), i );
1805 }
1807 //*************************************************************************************************
1808 
1809 
1810 //*************************************************************************************************
1825 template< typename MT // Type of the adapted sparse matrix
1826  , bool SO > // Storage order of the adapted sparse matrix
1827 void UniUpperMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1828 {
1830 
1831  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square uniupper matrix detected" );
1832 
1833  const size_t oldsize( matrix_.rows() );
1834 
1835  matrix_.resize( n, n, preserve );
1836 
1837  if( n > oldsize ) {
1838  for( size_t i=oldsize; i<n; ++i )
1839  matrix_.insert( i, i, ElementType(1) );
1840  }
1841 }
1843 //*************************************************************************************************
1844 
1845 
1846 //*************************************************************************************************
1857 template< typename MT // Type of the adapted sparse matrix
1858  , bool SO > // Storage order of the adapted sparse matrix
1859 inline void UniUpperMatrix<MT,SO,false>::reserve( size_t nonzeros )
1860 {
1861  matrix_.reserve( nonzeros );
1862 }
1864 //*************************************************************************************************
1865 
1866 
1867 //*************************************************************************************************
1881 template< typename MT // Type of the adapted sparse matrix
1882  , bool SO > // Storage order of the adapted sparse matrix
1883 inline void UniUpperMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1884 {
1885  matrix_.reserve( i, nonzeros );
1886 }
1888 //*************************************************************************************************
1889 
1890 
1891 //*************************************************************************************************
1902 template< typename MT // Type of the adapted sparse matrix
1903  , bool SO > // Storage order of the adapted sparse matrix
1904 inline void UniUpperMatrix<MT,SO,false>::trim()
1905 {
1906  matrix_.trim();
1907 }
1909 //*************************************************************************************************
1910 
1911 
1912 //*************************************************************************************************
1924 template< typename MT // Type of the adapted sparse matrix
1925  , bool SO > // Storage order of the adapted sparse matrix
1926 inline void UniUpperMatrix<MT,SO,false>::trim( size_t i )
1927 {
1928  matrix_.trim( i );
1929 }
1931 //*************************************************************************************************
1932 
1933 
1934 //*************************************************************************************************
1942 template< typename MT // Type of the adapted sparse matrix
1943  , bool SO > // Storage order of the adapted sparse matrix
1944 inline void UniUpperMatrix<MT,SO,false>::swap( UniUpperMatrix& m ) /* throw() */
1945 {
1946  using std::swap;
1947 
1948  swap( matrix_, m.matrix_ );
1949 }
1951 //*************************************************************************************************
1952 
1953 
1954 //*************************************************************************************************
1965 template< typename MT // Type of the adapted dense matrix
1966  , bool SO > // Storage order of the adapted dense matrix
1967 inline size_t UniUpperMatrix<MT,SO,false>::maxNonZeros()
1968 {
1970 
1971  return maxNonZeros( Rows<MT>::value );
1972 }
1974 //*************************************************************************************************
1975 
1976 
1977 //*************************************************************************************************
1987 template< typename MT // Type of the adapted dense matrix
1988  , bool SO > // Storage order of the adapted dense matrix
1989 inline size_t UniUpperMatrix<MT,SO,false>::maxNonZeros( size_t n )
1990 {
1991  return ( ( n + 1UL ) * n ) / 2UL;
1992 }
1994 //*************************************************************************************************
1995 
1996 
1997 //*************************************************************************************************
2003 template< typename MT // Type of the adapted dense matrix
2004  , bool SO > // Storage order of the adapted dense matrix
2005 inline void UniUpperMatrix<MT,SO,false>::resetLower()
2006 {
2007  if( SO ) {
2008  for( size_t j=0UL; j<columns(); ++j )
2009  matrix_.erase( j, matrix_.upperBound( j, j ), matrix_.end( j ) );
2010  }
2011  else {
2012  for( size_t i=1UL; i<rows(); ++i )
2013  matrix_.erase( i, matrix_.begin( i ), matrix_.lowerBound( i, i ) );
2014  }
2015 }
2017 //*************************************************************************************************
2018 
2019 
2020 
2021 
2022 //=================================================================================================
2023 //
2024 // LOOKUP FUNCTIONS
2025 //
2026 //=================================================================================================
2027 
2028 //*************************************************************************************************
2044 template< typename MT // Type of the adapted sparse matrix
2045  , bool SO > // Storage order of the adapted sparse matrix
2047  UniUpperMatrix<MT,SO,false>::find( size_t i, size_t j )
2048 {
2049  return Iterator( matrix_.find( i, j ), ( SO ? j : i ) );
2050 }
2052 //*************************************************************************************************
2053 
2054 
2055 //*************************************************************************************************
2071 template< typename MT // Type of the adapted sparse matrix
2072  , bool SO > // Storage order of the adapted sparse matrix
2074  UniUpperMatrix<MT,SO,false>::find( size_t i, size_t j ) const
2075 {
2076  return matrix_.find( i, j );
2077 }
2079 //*************************************************************************************************
2080 
2081 
2082 //*************************************************************************************************
2098 template< typename MT // Type of the adapted sparse matrix
2099  , bool SO > // Storage order of the adapted sparse matrix
2101  UniUpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
2102 {
2103  return Iterator( matrix_.lowerBound( i, j ), ( SO ? j : i ) );
2104 }
2106 //*************************************************************************************************
2107 
2108 
2109 //*************************************************************************************************
2125 template< typename MT // Type of the adapted sparse matrix
2126  , bool SO > // Storage order of the adapted sparse matrix
2128  UniUpperMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
2129 {
2130  return matrix_.lowerBound( i, j );
2131 }
2133 //*************************************************************************************************
2134 
2135 
2136 //*************************************************************************************************
2152 template< typename MT // Type of the adapted sparse matrix
2153  , bool SO > // Storage order of the adapted sparse matrix
2155  UniUpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
2156 {
2157  return Iterator( matrix_.upperBound( i, j ), ( SO ? j : i ) );
2158 }
2160 //*************************************************************************************************
2161 
2162 
2163 //*************************************************************************************************
2179 template< typename MT // Type of the adapted sparse matrix
2180  , bool SO > // Storage order of the adapted sparse matrix
2182  UniUpperMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
2183 {
2184  return matrix_.upperBound( i, j );
2185 }
2187 //*************************************************************************************************
2188 
2189 
2190 
2191 
2192 //=================================================================================================
2193 //
2194 // LOW-LEVEL UTILITY FUNCTIONS
2195 //
2196 //=================================================================================================
2197 
2198 //*************************************************************************************************
2248 template< typename MT // Type of the adapted sparse matrix
2249  , bool SO > // Storage order of the adapted sparse matrix
2250 inline void UniUpperMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
2251 {
2252  if( i >= j )
2253  throw std::invalid_argument( "Invalid access to diagonal or lower matrix element" );
2254 
2255  if( !check || !isDefault( value ) )
2256  matrix_.insert( i, j, value );
2257 }
2259 //*************************************************************************************************
2260 
2261 
2262 //*************************************************************************************************
2276 template< typename MT // Type of the adapted sparse matrix
2277  , bool SO > // Storage order of the adapted sparse matrix
2278 inline void UniUpperMatrix<MT,SO,false>::finalize( size_t i )
2279 {
2280  matrix_.trim( i );
2281 }
2283 //*************************************************************************************************
2284 
2285 
2286 
2287 
2288 //=================================================================================================
2289 //
2290 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2291 //
2292 //=================================================================================================
2293 
2294 //*************************************************************************************************
2305 template< typename MT // Type of the adapted sparse matrix
2306  , bool SO > // Storage order of the adapted sparse matrix
2307 template< typename Other > // Data type of the foreign expression
2308 inline bool UniUpperMatrix<MT,SO,false>::canAlias( const Other* alias ) const
2309 {
2310  return matrix_.canAlias( alias );
2311 }
2313 //*************************************************************************************************
2314 
2315 
2316 //*************************************************************************************************
2327 template< typename MT // Type of the adapted sparse matrix
2328  , bool SO > // Storage order of the adapted sparse matrix
2329 template< typename Other > // Data type of the foreign expression
2330 inline bool UniUpperMatrix<MT,SO,false>::isAliased( const Other* alias ) const
2331 {
2332  return matrix_.isAliased( alias );
2333 }
2335 //*************************************************************************************************
2336 
2337 
2338 //*************************************************************************************************
2349 template< typename MT // Type of the adapted sparse matrix
2350  , bool SO > // Storage order of the adapted sparse matrix
2351 inline bool UniUpperMatrix<MT,SO,false>::canSMPAssign() const
2352 {
2353  return matrix_.canSMPAssign();
2354 }
2356 //*************************************************************************************************
2357 
2358 } // namespace blaze
2359 
2360 #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:116
const MT::ElementType max(const DenseMatrix< MT, SO > &dm)
Returns the largest element of the dense matrix.
Definition: DenseMatrix.h:1649
Constraint on the data type.
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 the IsUniUpper type trait.
const DMatDMatMultExpr< T1, T2 > operator*(const DenseMatrix< T1, false > &lhs, const DenseMatrix< T2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:8247
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:902
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:237
void move(CompressedMatrix< Type, SO > &dst, CompressedMatrix< Type, SO > &src)
Moving the contents of one compressed matrix to another.
Definition: CompressedMatrix.h:4825
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:300
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:258
bool isStrictlyUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly upper triangular matrix.
Definition: DenseMatrix.h:1354
#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:242
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:821
const This & CompositeType
Data type for composite expression templates.
Definition: CompressedMatrix.h:2507
BLAZE_ALWAYS_INLINE size_t capacity(const Matrix< MT, SO > &matrix)
Returns the maximum capacity of the matrix.
Definition: Matrix.h:348
BLAZE_ALWAYS_INLINE size_t rows(const Matrix< MT, SO > &matrix)
Returns the current number of rows of the matrix.
Definition: Matrix.h:316
void clear(CompressedMatrix< Type, SO > &m)
Clearing the given compressed matrix.
Definition: CompressedMatrix.h:4762
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2501
#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
Header file for the implementation of the base template of the UniUpperMatrix.
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:386
Constraint on the data type.
CompressedMatrix< Type, false > OppositeType
Result type with opposite storage order for expression template evaluations.
Definition: CompressedMatrix.h:2503
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.
bool isDefault(const CompressedMatrix< Type, SO > &m)
Returns whether the given compressed matrix is in default state.
Definition: CompressedMatrix.h:4789
Header file for the DisableIf class template.
Header file for the IsStrictlyUpper type trait.
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
void swap(CompressedMatrix< Type, SO > &a, CompressedMatrix< Type, SO > &b)
Swapping the contents of two compressed matrices.
Definition: CompressedMatrix.h:4807
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2511
#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
Constraint on the data type.
Header file for the IsLower type trait.
Header file for the UniUpperProxy class.
Header file for the IsUniTriangular type trait.
Header file for the IsStrictlyTriangular type trait.
CompressedMatrix< Type, false > TransposeType
Transpose type for expression template evaluations.
Definition: CompressedMatrix.h:2504
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:195
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:535
Type ElementType
Type of the sparse matrix elements.
Definition: CompressedMatrix.h:2505
const Type & ConstReference
Reference to a constant matrix value.
Definition: CompressedMatrix.h:2509
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:841
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:2506
Header file for run time assertion macros.
Constraint on the data type.
Constraint on the data type.
const DenseIterator< Type > operator-(const DenseIterator< Type > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:585
#define BLAZE_CONSTRAINT_MUST_BE_NUMERIC_TYPE(T)
Constraint on the data type.In case the given data type T is not a numeric (integral or floating poin...
Definition: Numeric.h:79
#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:2510
Header file for the isDefault shim.
Constraint on the data type.
Constraint on the data type.
double real
Floating point data type of the Blaze library.This type definition offers the possibility to switch t...
Definition: Precision.h:47
#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:200
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, sse_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 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
bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value. ...
Definition: Accuracy.h:249
This ResultType
Result type for expression template evaluations.
Definition: CompressedMatrix.h:2502
BLAZE_ALWAYS_INLINE size_t columns(const Matrix< MT, SO > &matrix)
Returns the current number of columns of the matrix.
Definition: Matrix.h:332
bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
bool isUniUpper(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an upper unitriangular matrix.
Definition: DenseMatrix.h:1274
MatrixAccessProxy< This > Reference
Reference to a non-constant matrix value.
Definition: CompressedMatrix.h:2508
#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