Dense.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_STRICTLYLOWERMATRIX_DENSE_H_
36 #define _BLAZE_MATH_ADAPTORS_STRICTLYLOWERMATRIX_DENSE_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
57 #include <blaze/math/Intrinsics.h>
58 #include <blaze/math/shims/Clear.h>
60 #include <blaze/math/shims/Move.h>
70 #include <blaze/system/Inline.h>
71 #include <blaze/util/Assert.h>
77 #include <blaze/util/DisableIf.h>
78 #include <blaze/util/EnableIf.h>
79 #include <blaze/util/Exception.h>
80 #include <blaze/util/FalseType.h>
82 #include <blaze/util/TrueType.h>
83 #include <blaze/util/Types.h>
84 #include <blaze/util/Unused.h>
85 
86 
87 namespace blaze {
88 
89 //=================================================================================================
90 //
91 // CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES
92 //
93 //=================================================================================================
94 
95 //*************************************************************************************************
103 template< typename MT // Type of the adapted dense matrix
104  , bool SO > // Storage order of the adapted dense matrix
105 class StrictlyLowerMatrix<MT,SO,true>
106  : public DenseMatrix< StrictlyLowerMatrix<MT,SO,true>, SO >
107 {
108  private:
109  //**Type definitions****************************************************************************
110  typedef typename MT::OppositeType OT;
111  typedef typename MT::TransposeType TT;
112  typedef typename MT::ElementType ET;
113  typedef IntrinsicTrait<ET> IT;
114  //**********************************************************************************************
115 
116  public:
117  //**Type definitions****************************************************************************
118  typedef StrictlyLowerMatrix<MT,SO,true> This;
119  typedef This ResultType;
120  typedef StrictlyLowerMatrix<OT,!SO,true> OppositeType;
121  typedef StrictlyUpperMatrix<TT,!SO,true> TransposeType;
122  typedef ET ElementType;
123  typedef typename MT::IntrinsicType IntrinsicType;
124  typedef typename MT::ReturnType ReturnType;
125  typedef const This& CompositeType;
126  typedef StrictlyLowerProxy<MT> Reference;
127  typedef typename MT::ConstReference ConstReference;
128  typedef typename MT::Pointer Pointer;
129  typedef typename MT::ConstPointer ConstPointer;
130  typedef typename MT::ConstIterator ConstIterator;
131  //**********************************************************************************************
132 
133  //**Rebind struct definition********************************************************************
136  template< typename ET > // Data type of the other matrix
137  struct Rebind {
139  typedef StrictlyLowerMatrix< typename MT::template Rebind<ET>::Other > Other;
140  };
141  //**********************************************************************************************
142 
143  //**Iterator class definition*******************************************************************
146  class Iterator
147  {
148  public:
149  //**Type definitions*************************************************************************
150  typedef std::random_access_iterator_tag IteratorCategory;
151  typedef typename MT::ElementType ValueType;
152  typedef StrictlyLowerProxy<MT> PointerType;
153  typedef StrictlyLowerProxy<MT> ReferenceType;
154  typedef ptrdiff_t DifferenceType;
155 
156  // STL iterator requirements
157  typedef IteratorCategory iterator_category;
158  typedef ValueType value_type;
159  typedef PointerType pointer;
160  typedef ReferenceType reference;
161  typedef DifferenceType difference_type;
162  //*******************************************************************************************
163 
164  //**Constructor******************************************************************************
167  inline Iterator()
168  : matrix_( NULL ) // Reference to the adapted dense matrix
169  , row_ ( 0UL ) // The current row index of the iterator
170  , column_( 0UL ) // The current column index of the iterator
171  {}
172  //*******************************************************************************************
173 
174  //**Constructor******************************************************************************
181  inline Iterator( MT& matrix, size_t row, size_t column )
182  : matrix_( &matrix ) // Reference to the adapted dense matrix
183  , row_ ( row ) // The current row-index of the iterator
184  , column_( column ) // The current column-index of the iterator
185  {}
186  //*******************************************************************************************
187 
188  //**Addition assignment operator*************************************************************
194  inline Iterator& operator+=( size_t inc ) {
195  ( SO )?( row_ += inc ):( column_ += inc );
196  return *this;
197  }
198  //*******************************************************************************************
199 
200  //**Subtraction assignment operator**********************************************************
206  inline Iterator& operator-=( size_t dec ) {
207  ( SO )?( row_ -= dec ):( column_ -= dec );
208  return *this;
209  }
210  //*******************************************************************************************
211 
212  //**Prefix increment operator****************************************************************
217  inline Iterator& operator++() {
218  ( SO )?( ++row_ ):( ++column_ );
219  return *this;
220  }
221  //*******************************************************************************************
222 
223  //**Postfix increment operator***************************************************************
228  inline const Iterator operator++( int ) {
229  const Iterator tmp( *this );
230  ++(*this);
231  return tmp;
232  }
233  //*******************************************************************************************
234 
235  //**Prefix decrement operator****************************************************************
240  inline Iterator& operator--() {
241  ( SO )?( --row_ ):( --column_ );
242  return *this;
243  }
244  //*******************************************************************************************
245 
246  //**Postfix decrement operator***************************************************************
251  inline const Iterator operator--( int ) {
252  const Iterator tmp( *this );
253  --(*this);
254  return tmp;
255  }
256  //*******************************************************************************************
257 
258  //**Element access operator******************************************************************
263  inline ReferenceType operator*() const {
264  return ReferenceType( *matrix_, row_, column_ );
265  }
266  //*******************************************************************************************
267 
268  //**Element access operator******************************************************************
273  inline PointerType operator->() const {
274  return PointerType( *matrix_, row_, column_ );
275  }
276  //*******************************************************************************************
277 
278  //**Conversion operator**********************************************************************
283  inline operator ConstIterator() const {
284  if( SO )
285  return matrix_->begin( column_ ) + row_;
286  else
287  return matrix_->begin( row_ ) + column_;
288  }
289  //*******************************************************************************************
290 
291  //**Equality operator************************************************************************
298  friend inline bool operator==( const Iterator& lhs, const Iterator& rhs ) {
299  return ( SO )?( lhs.row_ == rhs.row_ ):( lhs.column_ == rhs.column_ );
300  }
301  //*******************************************************************************************
302 
303  //**Equality operator************************************************************************
310  friend inline bool operator==( const Iterator& lhs, const ConstIterator& rhs ) {
311  return ( ConstIterator( lhs ) == rhs );
312  }
313  //*******************************************************************************************
314 
315  //**Equality operator************************************************************************
322  friend inline bool operator==( const ConstIterator& lhs, const Iterator& rhs ) {
323  return ( lhs == ConstIterator( rhs ) );
324  }
325  //*******************************************************************************************
326 
327  //**Inequality operator**********************************************************************
334  friend inline bool operator!=( const Iterator& lhs, const Iterator& rhs ) {
335  return ( SO )?( lhs.row_ != rhs.row_ ):( lhs.column_ != rhs.column_ );
336  }
337  //*******************************************************************************************
338 
339  //**Inequality operator**********************************************************************
346  friend inline bool operator!=( const Iterator& lhs, const ConstIterator& rhs ) {
347  return ( ConstIterator( lhs ) != rhs );
348  }
349  //*******************************************************************************************
350 
351  //**Inequality operator**********************************************************************
358  friend inline bool operator!=( const ConstIterator& lhs, const Iterator& rhs ) {
359  return ( lhs != ConstIterator( rhs ) );
360  }
361  //*******************************************************************************************
362 
363  //**Less-than operator***********************************************************************
370  friend inline bool operator<( const Iterator& lhs, const Iterator& rhs ) {
371  return ( SO )?( lhs.row_ < rhs.row_ ):( lhs.column_ < rhs.column_ );
372  }
373  //*******************************************************************************************
374 
375  //**Less-than operator***********************************************************************
382  friend inline bool operator<( const Iterator& lhs, const ConstIterator& rhs ) {
383  return ( ConstIterator( lhs ) < rhs );
384  }
385  //*******************************************************************************************
386 
387  //**Less-than operator***********************************************************************
394  friend inline bool operator<( const ConstIterator& lhs, const Iterator& rhs ) {
395  return ( lhs < ConstIterator( rhs ) );
396  }
397  //*******************************************************************************************
398 
399  //**Greater-than operator********************************************************************
406  friend inline bool operator>( const Iterator& lhs, const Iterator& rhs ) {
407  return ( SO )?( lhs.row_ > rhs.row_ ):( lhs.column_ > rhs.column_ );
408  }
409  //*******************************************************************************************
410 
411  //**Greater-than operator********************************************************************
418  friend inline bool operator>( const Iterator& lhs, const ConstIterator& rhs ) {
419  return ( ConstIterator( lhs ) > rhs );
420  }
421  //*******************************************************************************************
422 
423  //**Greater-than operator********************************************************************
430  friend inline bool operator>( const ConstIterator& lhs, const Iterator& rhs ) {
431  return ( lhs > ConstIterator( rhs ) );
432  }
433  //*******************************************************************************************
434 
435  //**Less-or-equal-than operator**************************************************************
442  friend inline bool operator<=( const Iterator& lhs, const Iterator& rhs ) {
443  return ( SO )?( lhs.row_ <= rhs.row_ ):( lhs.column_ <= rhs.column_ );
444  }
445  //*******************************************************************************************
446 
447  //**Less-or-equal-than operator**************************************************************
454  friend inline bool operator<=( const Iterator& lhs, const ConstIterator& rhs ) {
455  return ( ConstIterator( lhs ) <= rhs );
456  }
457  //*******************************************************************************************
458 
459  //**Less-or-equal-than operator**************************************************************
466  friend inline bool operator<=( const ConstIterator& lhs, const Iterator& rhs ) {
467  return ( lhs <= ConstIterator( rhs ) );
468  }
469  //*******************************************************************************************
470 
471  //**Greater-or-equal-than operator***********************************************************
478  friend inline bool operator>=( const Iterator& lhs, const Iterator& rhs ) {
479  return ( SO )?( lhs.row_ >= rhs.row_ ):( lhs.column_ >= rhs.column_ );
480  }
481  //*******************************************************************************************
482 
483  //**Greater-or-equal-than operator***********************************************************
490  friend inline bool operator>=( const Iterator& lhs, const ConstIterator& rhs ) {
491  return ( ConstIterator( lhs ) >= rhs );
492  }
493  //*******************************************************************************************
494 
495  //**Greater-or-equal-than operator***********************************************************
502  friend inline bool operator>=( const ConstIterator& lhs, const Iterator& rhs ) {
503  return ( lhs >= ConstIterator( rhs ) );
504  }
505  //*******************************************************************************************
506 
507  //**Subtraction operator*********************************************************************
513  inline DifferenceType operator-( const Iterator& rhs ) const {
514  return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
515  }
516  //*******************************************************************************************
517 
518  //**Addition operator************************************************************************
525  friend inline const Iterator operator+( const Iterator& it, size_t inc ) {
526  if( SO )
527  return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
528  else
529  return Iterator( *it.matrix_, it.row_, it.column_ + inc );
530  }
531  //*******************************************************************************************
532 
533  //**Addition operator************************************************************************
540  friend inline const Iterator operator+( size_t inc, const Iterator& it ) {
541  if( SO )
542  return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
543  else
544  return Iterator( *it.matrix_, it.row_, it.column_ + inc );
545  }
546  //*******************************************************************************************
547 
548  //**Subtraction operator*********************************************************************
555  friend inline const Iterator operator-( const Iterator& it, size_t dec ) {
556  if( SO )
557  return Iterator( *it.matrix_, it.row_ - dec, it.column_ );
558  else
559  return Iterator( *it.matrix_, it.row_, it.column_ - dec );
560  }
561  //*******************************************************************************************
562 
563  private:
564  //**Member variables*************************************************************************
565  MT* matrix_;
566  size_t row_;
567  size_t column_;
568  //*******************************************************************************************
569  };
570  //**********************************************************************************************
571 
572  //**Compilation flags***************************************************************************
574  enum { vectorizable = MT::vectorizable };
575 
577  enum { smpAssignable = MT::smpAssignable };
578  //**********************************************************************************************
579 
580  //**Constructors********************************************************************************
583  explicit inline StrictlyLowerMatrix();
584  template< typename A1 > explicit inline StrictlyLowerMatrix( const A1& a1 );
585  explicit inline StrictlyLowerMatrix( size_t n, const ElementType& init );
586 
587  explicit inline StrictlyLowerMatrix( ElementType* ptr, size_t n );
588  explicit inline StrictlyLowerMatrix( ElementType* ptr, size_t n, size_t nn );
589 
590  template< typename Deleter >
591  explicit inline StrictlyLowerMatrix( ElementType* ptr, size_t n, Deleter d );
592 
593  template< typename Deleter >
594  explicit inline StrictlyLowerMatrix( ElementType* ptr, size_t n, size_t nn, Deleter d );
595 
596  inline StrictlyLowerMatrix( const StrictlyLowerMatrix& m );
598  //**********************************************************************************************
599 
600  //**Destructor**********************************************************************************
601  // No explicitly declared destructor.
602  //**********************************************************************************************
603 
604  //**Data access functions***********************************************************************
607  inline Reference operator()( size_t i, size_t j );
608  inline ConstReference operator()( size_t i, size_t j ) const;
609  inline Reference at( size_t i, size_t j );
610  inline ConstReference at( size_t i, size_t j ) const;
611  inline ConstPointer data () const;
612  inline ConstPointer data ( size_t i ) const;
613  inline Iterator begin ( size_t i );
614  inline ConstIterator begin ( size_t i ) const;
615  inline ConstIterator cbegin( size_t i ) const;
616  inline Iterator end ( size_t i );
617  inline ConstIterator end ( size_t i ) const;
618  inline ConstIterator cend ( size_t i ) const;
620  //**********************************************************************************************
621 
622  //**Assignment operators************************************************************************
625  inline StrictlyLowerMatrix& operator=( const ElementType& rhs );
626  inline StrictlyLowerMatrix& operator=( const StrictlyLowerMatrix& rhs );
627 
628  template< typename MT2, bool SO2 >
629  inline typename DisableIf< IsComputation<MT2>, StrictlyLowerMatrix& >::Type
630  operator=( const Matrix<MT2,SO2>& rhs );
631 
632  template< typename MT2, bool SO2 >
633  inline typename EnableIf< IsComputation<MT2>, StrictlyLowerMatrix& >::Type
634  operator=( const Matrix<MT2,SO2>& rhs );
635 
636  template< typename MT2, bool SO2 >
637  inline typename DisableIf< IsComputation<MT2>, StrictlyLowerMatrix& >::Type
638  operator+=( const Matrix<MT2,SO2>& rhs );
639 
640  template< typename MT2, bool SO2 >
641  inline typename EnableIf< IsComputation<MT2>, StrictlyLowerMatrix& >::Type
642  operator+=( const Matrix<MT2,SO2>& rhs );
643 
644  template< typename MT2, bool SO2 >
645  inline typename DisableIf< IsComputation<MT2>, StrictlyLowerMatrix& >::Type
646  operator-=( const Matrix<MT2,SO2>& rhs );
647 
648  template< typename MT2, bool SO2 >
649  inline typename EnableIf< IsComputation<MT2>, StrictlyLowerMatrix& >::Type
650  operator-=( const Matrix<MT2,SO2>& rhs );
651 
652  template< typename MT2, bool SO2 >
653  inline StrictlyLowerMatrix& operator*=( const Matrix<MT2,SO2>& rhs );
654 
655  template< typename Other >
656  inline typename EnableIf< IsNumeric<Other>, StrictlyLowerMatrix >::Type&
657  operator*=( Other rhs );
658 
659  template< typename Other >
660  inline typename EnableIf< IsNumeric<Other>, StrictlyLowerMatrix >::Type&
661  operator/=( Other rhs );
663  //**********************************************************************************************
664 
665  //**Utility functions***************************************************************************
668  inline size_t rows() const;
669  inline size_t columns() const;
670  inline size_t spacing() const;
671  inline size_t capacity() const;
672  inline size_t capacity( size_t i ) const;
673  inline size_t nonZeros() const;
674  inline size_t nonZeros( size_t i ) const;
675  inline void reset();
676  inline void reset( size_t i );
677  inline void clear();
678  void resize ( size_t n, bool preserve=true );
679  inline void extend ( size_t n, bool preserve=true );
680  inline void reserve( size_t elements );
681 
682  template< typename Other > inline StrictlyLowerMatrix& scale( const Other& scalar );
683 
684  inline void swap( StrictlyLowerMatrix& m ) /* throw() */;
685 
686  static inline size_t maxNonZeros();
687  static inline size_t maxNonZeros( size_t n );
689  //**********************************************************************************************
690 
691  //**Debugging functions*************************************************************************
694  inline bool isIntact() const;
696  //**********************************************************************************************
697 
698  //**Expression template evaluation functions****************************************************
701  template< typename Other > inline bool canAlias ( const Other* alias ) const;
702  template< typename Other > inline bool isAliased( const Other* alias ) const;
703 
704  inline bool isAligned () const;
705  inline bool canSMPAssign() const;
706 
707  BLAZE_ALWAYS_INLINE IntrinsicType load ( size_t i, size_t j ) const;
708  BLAZE_ALWAYS_INLINE IntrinsicType loada( size_t i, size_t j ) const;
709  BLAZE_ALWAYS_INLINE IntrinsicType loadu( size_t i, size_t j ) const;
711  //**********************************************************************************************
712 
713  private:
714  //**Construction functions**********************************************************************
717  inline const MT construct( size_t n , TrueType );
718  inline const MT construct( const ElementType& value, FalseType );
719 
720  template< typename MT2, bool SO2, typename T >
721  inline const MT construct( const Matrix<MT2,SO2>& m, T );
723  //**********************************************************************************************
724 
725  //**Member variables****************************************************************************
728  MT matrix_;
729 
730  //**********************************************************************************************
731 
732  //**Friend declarations*************************************************************************
733  template< typename MT2, bool SO2, bool DF2 >
734  friend MT2& derestrict( StrictlyLowerMatrix<MT2,SO2,DF2>& m );
735  //**********************************************************************************************
736 
737  //**Compile time checks*************************************************************************
750  BLAZE_STATIC_ASSERT( Rows<MT>::value == Columns<MT>::value );
751  //**********************************************************************************************
752 };
754 //*************************************************************************************************
755 
756 
757 
758 
759 //=================================================================================================
760 //
761 // CONSTRUCTORS
762 //
763 //=================================================================================================
764 
765 //*************************************************************************************************
769 template< typename MT // Type of the adapted dense matrix
770  , bool SO > // Storage order of the adapted dense matrix
771 inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix()
772  : matrix_() // The adapted dense matrix
773 {
774  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
775  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
776 }
778 //*************************************************************************************************
779 
780 
781 //*************************************************************************************************
799 template< typename MT // Type of the adapted dense matrix
800  , bool SO > // Storage order of the adapted dense matrix
801 template< typename A1 > // Type of the constructor argument
802 inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( const A1& a1 )
803  : matrix_( construct( a1, typename IsResizable<MT>::Type() ) ) // The adapted dense matrix
804 {
805  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
806  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
807 }
809 //*************************************************************************************************
810 
811 
812 //*************************************************************************************************
819 template< typename MT // Type of the adapted dense matrix
820  , bool SO > // Storage order of the adapted dense matrix
821 inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( size_t n, const ElementType& init )
822  : matrix_( n, n, ElementType() ) // The adapted dense matrix
823 {
825 
826  if( SO ) {
827  for( size_t j=0UL; j<columns(); ++j ) {
828  for( size_t i=j+1UL; i<rows(); ++i )
829  matrix_(i,j) = init;
830  }
831  }
832  else {
833  for( size_t i=0UL; i<rows(); ++i ) {
834  for( size_t j=0UL; j<i; ++j )
835  matrix_(i,j) = init;
836  }
837  }
838 
839  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
840  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
841 }
843 //*************************************************************************************************
844 
845 
846 //*************************************************************************************************
868 template< typename MT // Type of the adapted dense matrix
869  , bool SO > // Storage order of the adapted dense matrix
870 inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( ElementType* ptr, size_t n )
871  : matrix_( ptr, n, n ) // The adapted dense matrix
872 {
873  if( !isStrictlyLower( matrix_ ) ) {
874  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly lower matrix" );
875  }
876 
877  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
878 }
880 //*************************************************************************************************
881 
882 
883 //*************************************************************************************************
906 template< typename MT // Type of the adapted dense matrix
907  , bool SO > // Storage order of the adapted dense matrix
908 inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( ElementType* ptr, size_t n, size_t nn )
909  : matrix_( ptr, n, n, nn ) // The adapted dense matrix
910 {
911  if( !isStrictlyLower( matrix_ ) ) {
912  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly lower matrix" );
913  }
914 
915  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
916 }
918 //*************************************************************************************************
919 
920 
921 //*************************************************************************************************
942 template< typename MT // Type of the adapted dense matrix
943  , bool SO > // Storage order of the adapted dense matrix
944 template< typename Deleter > // Type of the custom deleter
945 inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( ElementType* ptr, size_t n, Deleter d )
946  : matrix_( ptr, n, n, d ) // The adapted dense matrix
947 {
948  if( !isStrictlyLower( matrix_ ) ) {
949  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly lower matrix" );
950  }
951 
952  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
953 }
955 //*************************************************************************************************
956 
957 
958 //*************************************************************************************************
980 template< typename MT // Type of the adapted dense matrix
981  , bool SO > // Storage order of the adapted dense matrix
982 template< typename Deleter > // Type of the custom deleter
983 inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( ElementType* ptr, size_t n, size_t nn, Deleter d )
984  : matrix_( ptr, n, n, nn, d ) // The adapted dense matrix
985 {
986  if( !isStrictlyLower( matrix_ ) ) {
987  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly lower matrix" );
988  }
989 
990  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
991 }
993 //*************************************************************************************************
994 
995 
996 //*************************************************************************************************
1002 template< typename MT // Type of the adapted dense matrix
1003  , bool SO > // Storage order of the adapted dense matrix
1004 inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( const StrictlyLowerMatrix& m )
1005  : matrix_( m.matrix_ ) // The adapted dense matrix
1006 {
1007  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1008  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1009 }
1011 //*************************************************************************************************
1012 
1013 
1014 
1015 
1016 //=================================================================================================
1017 //
1018 // DATA ACCESS FUNCTIONS
1019 //
1020 //=================================================================================================
1021 
1022 //*************************************************************************************************
1038 template< typename MT // Type of the adapted dense matrix
1039  , bool SO > // Storage order of the adapted dense matrix
1041  StrictlyLowerMatrix<MT,SO,true>::operator()( size_t i, size_t j )
1042 {
1043  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1044  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1045 
1046  return Reference( matrix_, i, j );
1047 }
1049 //*************************************************************************************************
1050 
1051 
1052 //*************************************************************************************************
1068 template< typename MT // Type of the adapted dense matrix
1069  , bool SO > // Storage order of the adapted dense matrix
1071  StrictlyLowerMatrix<MT,SO,true>::operator()( size_t i, size_t j ) const
1072 {
1073  BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1074  BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1075 
1076  return matrix_(i,j);
1077 }
1079 //*************************************************************************************************
1080 
1081 
1082 //*************************************************************************************************
1099 template< typename MT // Type of the adapted dense matrix
1100  , bool SO > // Storage order of the adapted dense matrix
1102  StrictlyLowerMatrix<MT,SO,true>::at( size_t i, size_t j )
1103 {
1104  if( i >= rows() ) {
1105  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1106  }
1107  if( j >= columns() ) {
1108  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1109  }
1110  return (*this)(i,j);
1111 }
1113 //*************************************************************************************************
1114 
1115 
1116 //*************************************************************************************************
1133 template< typename MT // Type of the adapted dense matrix
1134  , bool SO > // Storage order of the adapted dense matrix
1136  StrictlyLowerMatrix<MT,SO,true>::at( size_t i, size_t j ) const
1137 {
1138  if( i >= rows() ) {
1139  BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1140  }
1141  if( j >= columns() ) {
1142  BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1143  }
1144  return (*this)(i,j);
1145 }
1147 //*************************************************************************************************
1148 
1149 
1150 //*************************************************************************************************
1163 template< typename MT // Type of the adapted dense matrix
1164  , bool SO > // Storage order of the adapted dense matrix
1165 inline typename StrictlyLowerMatrix<MT,SO,true>::ConstPointer
1166  StrictlyLowerMatrix<MT,SO,true>::data() const
1167 {
1168  return matrix_.data();
1169 }
1171 //*************************************************************************************************
1172 
1173 
1174 //*************************************************************************************************
1183 template< typename MT // Type of the adapted dense matrix
1184  , bool SO > // Storage order of the adapted dense matrix
1185 inline typename StrictlyLowerMatrix<MT,SO,true>::ConstPointer
1186  StrictlyLowerMatrix<MT,SO,true>::data( size_t i ) const
1187 {
1188  return matrix_.data(i);
1189 }
1191 //*************************************************************************************************
1192 
1193 
1194 //*************************************************************************************************
1206 template< typename MT // Type of the adapted dense matrix
1207  , bool SO > // Storage order of the adapted dense matrix
1210 {
1211  if( SO )
1212  return Iterator( matrix_, 0UL, i );
1213  else
1214  return Iterator( matrix_, i, 0UL );
1215 }
1217 //*************************************************************************************************
1218 
1219 
1220 //*************************************************************************************************
1232 template< typename MT // Type of the adapted dense matrix
1233  , bool SO > // Storage order of the adapted dense matrix
1235  StrictlyLowerMatrix<MT,SO,true>::begin( size_t i ) const
1236 {
1237  return matrix_.begin(i);
1238 }
1240 //*************************************************************************************************
1241 
1242 
1243 //*************************************************************************************************
1255 template< typename MT // Type of the adapted dense matrix
1256  , bool SO > // Storage order of the adapted dense matrix
1258  StrictlyLowerMatrix<MT,SO,true>::cbegin( size_t i ) const
1259 {
1260  return matrix_.cbegin(i);
1261 }
1263 //*************************************************************************************************
1264 
1265 
1266 //*************************************************************************************************
1278 template< typename MT // Type of the adapted dense matrix
1279  , bool SO > // Storage order of the adapted dense matrix
1282 {
1283  if( SO )
1284  return Iterator( matrix_, rows(), i );
1285  else
1286  return Iterator( matrix_, i, columns() );
1287 }
1289 //*************************************************************************************************
1290 
1291 
1292 //*************************************************************************************************
1304 template< typename MT // Type of the adapted dense matrix
1305  , bool SO > // Storage order of the adapted dense matrix
1307  StrictlyLowerMatrix<MT,SO,true>::end( size_t i ) const
1308 {
1309  return matrix_.end(i);
1310 }
1312 //*************************************************************************************************
1313 
1314 
1315 //*************************************************************************************************
1327 template< typename MT // Type of the adapted dense matrix
1328  , bool SO > // Storage order of the adapted dense matrix
1330  StrictlyLowerMatrix<MT,SO,true>::cend( size_t i ) const
1331 {
1332  return matrix_.cend(i);
1333 }
1335 //*************************************************************************************************
1336 
1337 
1338 
1339 
1340 //=================================================================================================
1341 //
1342 // ASSIGNMENT OPERATORS
1343 //
1344 //=================================================================================================
1345 
1346 //*************************************************************************************************
1353 template< typename MT // Type of the adapted dense matrix
1354  , bool SO > // Storage order of the adapted dense matrix
1355 inline StrictlyLowerMatrix<MT,SO,true>&
1356  StrictlyLowerMatrix<MT,SO,true>::operator=( const ElementType& rhs )
1357 {
1358  if( SO ) {
1359  for( size_t j=0UL; j<columns(); ++j )
1360  for( size_t i=j+1UL; i<rows(); ++i )
1361  matrix_(i,j) = rhs;
1362  }
1363  else {
1364  for( size_t i=1UL; i<rows(); ++i )
1365  for( size_t j=0UL; j<i; ++j )
1366  matrix_(i,j) = rhs;
1367  }
1368 
1369  return *this;
1370 }
1372 //*************************************************************************************************
1373 
1374 
1375 //*************************************************************************************************
1385 template< typename MT // Type of the adapted dense matrix
1386  , bool SO > // Storage order of the adapted dense matrix
1387 inline StrictlyLowerMatrix<MT,SO,true>&
1388  StrictlyLowerMatrix<MT,SO,true>::operator=( const StrictlyLowerMatrix& rhs )
1389 {
1390  matrix_ = rhs.matrix_;
1391 
1392  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1393  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1394 
1395  return *this;
1396 }
1398 //*************************************************************************************************
1399 
1400 
1401 //*************************************************************************************************
1414 template< typename MT // Type of the adapted dense matrix
1415  , bool SO > // Storage order of the adapted dense matrix
1416 template< typename MT2 // Type of the right-hand side matrix
1417  , bool SO2 > // Storage order of the right-hand side matrix
1418 inline typename DisableIf< IsComputation<MT2>, StrictlyLowerMatrix<MT,SO,true>& >::Type
1419  StrictlyLowerMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1420 {
1421  if( IsUniTriangular<MT2>::value ||
1422  ( !IsStrictlyLower<MT2>::value && !isStrictlyLower( ~rhs ) ) ) {
1423  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1424  }
1425 
1426  matrix_ = ~rhs;
1427 
1428  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1429  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1430 
1431  return *this;
1432 }
1434 //*************************************************************************************************
1435 
1436 
1437 //*************************************************************************************************
1450 template< typename MT // Type of the adapted dense matrix
1451  , bool SO > // Storage order of the adapted dense matrix
1452 template< typename MT2 // Type of the right-hand side matrix
1453  , bool SO2 > // Storage order of the right-hand side matrix
1454 inline typename EnableIf< IsComputation<MT2>, StrictlyLowerMatrix<MT,SO,true>& >::Type
1455  StrictlyLowerMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1456 {
1457  if( IsUniTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1458  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1459  }
1460 
1461  if( IsStrictlyLower<MT2>::value ) {
1462  matrix_ = ~rhs;
1463  }
1464  else {
1465  MT tmp( ~rhs );
1466 
1467  if( !isStrictlyLower( tmp ) ) {
1468  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1469  }
1470 
1471  move( matrix_, tmp );
1472  }
1473 
1474  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1475  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1476 
1477  return *this;
1478 }
1480 //*************************************************************************************************
1481 
1482 
1483 //*************************************************************************************************
1496 template< typename MT // Type of the adapted dense matrix
1497  , bool SO > // Storage order of the adapted dense matrix
1498 template< typename MT2 // Type of the right-hand side matrix
1499  , bool SO2 > // Storage order of the right-hand side matrix
1500 inline typename DisableIf< IsComputation<MT2>, StrictlyLowerMatrix<MT,SO,true>& >::Type
1501  StrictlyLowerMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1502 {
1503  if( IsUniTriangular<MT2>::value ||
1504  ( !IsStrictlyLower<MT2>::value && !isStrictlyLower( ~rhs ) ) ) {
1505  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1506  }
1507 
1508  matrix_ += ~rhs;
1509 
1510  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1511  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1512 
1513  return *this;
1514 }
1516 //*************************************************************************************************
1517 
1518 
1519 //*************************************************************************************************
1532 template< typename MT // Type of the adapted dense matrix
1533  , bool SO > // Storage order of the adapted dense matrix
1534 template< typename MT2 // Type of the right-hand side matrix
1535  , bool SO2 > // Storage order of the right-hand side matrix
1536 inline typename EnableIf< IsComputation<MT2>, StrictlyLowerMatrix<MT,SO,true>& >::Type
1537  StrictlyLowerMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1538 {
1539  if( IsUniTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1540  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1541  }
1542 
1543  if( IsStrictlyLower<MT2>::value ) {
1544  matrix_ += ~rhs;
1545  }
1546  else {
1547  typename MT2::ResultType tmp( ~rhs );
1548 
1549  if( !isStrictlyLower( tmp ) ) {
1550  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1551  }
1552 
1553  matrix_ += tmp;
1554  }
1555 
1556  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1557  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1558 
1559  return *this;
1560 }
1562 //*************************************************************************************************
1563 
1564 
1565 //*************************************************************************************************
1578 template< typename MT // Type of the adapted dense matrix
1579  , bool SO > // Storage order of the adapted dense matrix
1580 template< typename MT2 // Type of the right-hand side matrix
1581  , bool SO2 > // Storage order of the right-hand side matrix
1582 inline typename DisableIf< IsComputation<MT2>, StrictlyLowerMatrix<MT,SO,true>& >::Type
1583  StrictlyLowerMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1584 {
1585  if( IsUniTriangular<MT2>::value ||
1586  ( !IsStrictlyLower<MT2>::value && !isStrictlyLower( ~rhs ) ) ) {
1587  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1588  }
1589 
1590  matrix_ -= ~rhs;
1591 
1592  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1593  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1594 
1595  return *this;
1596 }
1598 //*************************************************************************************************
1599 
1600 
1601 //*************************************************************************************************
1614 template< typename MT // Type of the adapted dense matrix
1615  , bool SO > // Storage order of the adapted dense matrix
1616 template< typename MT2 // Type of the right-hand side matrix
1617  , bool SO2 > // Storage order of the right-hand side matrix
1618 inline typename EnableIf< IsComputation<MT2>, StrictlyLowerMatrix<MT,SO,true>& >::Type
1619  StrictlyLowerMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1620 {
1621  if( IsUniTriangular<MT2>::value || ( !IsSquare<MT2>::value && !isSquare( ~rhs ) ) ) {
1622  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1623  }
1624 
1625  if( IsStrictlyLower<MT2>::value ) {
1626  matrix_ -= ~rhs;
1627  }
1628  else {
1629  typename MT2::ResultType tmp( ~rhs );
1630 
1631  if( !isStrictlyLower( tmp ) ) {
1632  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1633  }
1634 
1635  matrix_ -= tmp;
1636  }
1637 
1638  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1639  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1640 
1641  return *this;
1642 }
1644 //*************************************************************************************************
1645 
1646 
1647 //*************************************************************************************************
1659 template< typename MT // Type of the adapted dense matrix
1660  , bool SO > // Storage order of the adapted dense matrix
1661 template< typename MT2 // Type of the right-hand side matrix
1662  , bool SO2 > // Storage order of the right-hand side matrix
1663 inline StrictlyLowerMatrix<MT,SO,true>&
1664  StrictlyLowerMatrix<MT,SO,true>::operator*=( const Matrix<MT2,SO2>& rhs )
1665 {
1666  if( matrix_.rows() != (~rhs).columns() ) {
1667  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1668  }
1669 
1670  MT tmp( matrix_ * ~rhs );
1671 
1672  if( !isStrictlyLower( tmp ) ) {
1673  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1674  }
1675 
1676  move( matrix_, tmp );
1677 
1678  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1679  BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1680 
1681  return *this;
1682 }
1684 //*************************************************************************************************
1685 
1686 
1687 //*************************************************************************************************
1695 template< typename MT // Type of the adapted dense matrix
1696  , bool SO > // Storage order of the adapted dense matrix
1697 template< typename Other > // Data type of the right-hand side scalar
1698 inline typename EnableIf< IsNumeric<Other>, StrictlyLowerMatrix<MT,SO,true> >::Type&
1699  StrictlyLowerMatrix<MT,SO,true>::operator*=( Other rhs )
1700 {
1701  matrix_ *= rhs;
1702  return *this;
1703 }
1704 //*************************************************************************************************
1705 
1706 
1707 //*************************************************************************************************
1715 template< typename MT // Type of the adapted dense matrix
1716  , bool SO > // Storage order of the adapted dense matrix
1717 template< typename Other > // Data type of the right-hand side scalar
1718 inline typename EnableIf< IsNumeric<Other>, StrictlyLowerMatrix<MT,SO,true> >::Type&
1719  StrictlyLowerMatrix<MT,SO,true>::operator/=( Other rhs )
1720 {
1721  BLAZE_USER_ASSERT( rhs != Other(0), "Division by zero detected" );
1722 
1723  matrix_ /= rhs;
1724  return *this;
1725 }
1727 //*************************************************************************************************
1728 
1729 
1730 
1731 
1732 //=================================================================================================
1733 //
1734 // UTILITY FUNCTIONS
1735 //
1736 //=================================================================================================
1737 
1738 //*************************************************************************************************
1744 template< typename MT // Type of the adapted dense matrix
1745  , bool SO > // Storage order of the adapted dense matrix
1746 inline size_t StrictlyLowerMatrix<MT,SO,true>::rows() const
1747 {
1748  return matrix_.rows();
1749 }
1751 //*************************************************************************************************
1752 
1753 
1754 //*************************************************************************************************
1760 template< typename MT // Type of the adapted dense matrix
1761  , bool SO > // Storage order of the adapted dense matrix
1762 inline size_t StrictlyLowerMatrix<MT,SO,true>::columns() const
1763 {
1764  return matrix_.columns();
1765 }
1767 //*************************************************************************************************
1768 
1769 
1770 //*************************************************************************************************
1781 template< typename MT // Type of the adapted dense matrix
1782  , bool SO > // Storage order of the adapted dense matrix
1783 inline size_t StrictlyLowerMatrix<MT,SO,true>::spacing() const
1784 {
1785  return matrix_.spacing();
1786 }
1788 //*************************************************************************************************
1789 
1790 
1791 //*************************************************************************************************
1797 template< typename MT // Type of the adapted dense matrix
1798  , bool SO > // Storage order of the adapted dense matrix
1799 inline size_t StrictlyLowerMatrix<MT,SO,true>::capacity() const
1800 {
1801  return matrix_.capacity();
1802 }
1804 //*************************************************************************************************
1805 
1806 
1807 //*************************************************************************************************
1819 template< typename MT // Type of the adapted dense matrix
1820  , bool SO > // Storage order of the adapted dense matrix
1821 inline size_t StrictlyLowerMatrix<MT,SO,true>::capacity( size_t i ) const
1822 {
1823  return matrix_.capacity(i);
1824 }
1826 //*************************************************************************************************
1827 
1828 
1829 //*************************************************************************************************
1835 template< typename MT // Type of the adapted dense matrix
1836  , bool SO > // Storage order of the adapted dense matrix
1837 inline size_t StrictlyLowerMatrix<MT,SO,true>::nonZeros() const
1838 {
1839  return matrix_.nonZeros();
1840 }
1842 //*************************************************************************************************
1843 
1844 
1845 //*************************************************************************************************
1857 template< typename MT // Type of the adapted dense matrix
1858  , bool SO > // Storage order of the adapted dense matrix
1859 inline size_t StrictlyLowerMatrix<MT,SO,true>::nonZeros( size_t i ) const
1860 {
1861  return matrix_.nonZeros(i);
1862 }
1864 //*************************************************************************************************
1865 
1866 
1867 //*************************************************************************************************
1873 template< typename MT // Type of the adapted dense matrix
1874  , bool SO > // Storage order of the adapted dense matrix
1876 {
1877  using blaze::clear;
1878 
1879  if( SO ) {
1880  for( size_t j=0UL; j<columns(); ++j )
1881  for( size_t i=j+1UL; i<rows(); ++i )
1882  clear( matrix_(i,j) );
1883  }
1884  else {
1885  for( size_t i=1UL; i<rows(); ++i )
1886  for( size_t j=0UL; j<i; ++j )
1887  clear( matrix_(i,j) );
1888  }
1889 }
1891 //*************************************************************************************************
1892 
1893 
1894 //*************************************************************************************************
1907 template< typename MT // Type of the adapted dense matrix
1908  , bool SO > // Storage order of the adapted dense matrix
1909 inline void StrictlyLowerMatrix<MT,SO,true>::reset( size_t i )
1910 {
1911  using blaze::clear;
1912 
1913  if( SO ) {
1914  for( size_t j=i+1UL; j<rows(); ++j )
1915  clear( matrix_(j,i) );
1916  }
1917  else {
1918  for( size_t j=0UL; j<i; ++j )
1919  clear( matrix_(i,j) );
1920  }
1921 }
1923 //*************************************************************************************************
1924 
1925 
1926 //*************************************************************************************************
1938 template< typename MT // Type of the adapted dense matrix
1939  , bool SO > // Storage order of the adapted dense matrix
1941 {
1942  using blaze::clear;
1943 
1944  if( IsResizable<MT>::value ) {
1945  clear( matrix_ );
1946  }
1947  else {
1948  reset();
1949  }
1950 }
1952 //*************************************************************************************************
1953 
1954 
1955 //*************************************************************************************************
1991 template< typename MT // Type of the adapted dense matrix
1992  , bool SO > // Storage order of the adapted dense matrix
1993 void StrictlyLowerMatrix<MT,SO,true>::resize( size_t n, bool preserve )
1994 {
1996 
1997  UNUSED_PARAMETER( preserve );
1998 
1999  BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
2000 
2001  const size_t oldsize( matrix_.rows() );
2002 
2003  matrix_.resize( n, n, true );
2004 
2005  if( n > oldsize )
2006  {
2007  const size_t increment( n - oldsize );
2008  submatrix( matrix_, 0UL, oldsize, n, increment ).reset();
2009  }
2010 }
2012 //*************************************************************************************************
2013 
2014 
2015 //*************************************************************************************************
2028 template< typename MT // Type of the adapted dense matrix
2029  , bool SO > // Storage order of the adapted dense matrix
2030 inline void StrictlyLowerMatrix<MT,SO,true>::extend( size_t n, bool preserve )
2031 {
2033 
2034  UNUSED_PARAMETER( preserve );
2035 
2036  resize( rows() + n, true );
2037 }
2038 //*************************************************************************************************
2039 
2040 
2041 //*************************************************************************************************
2051 template< typename MT // Type of the adapted dense matrix
2052  , bool SO > // Storage order of the adapted dense matrix
2053 inline void StrictlyLowerMatrix<MT,SO,true>::reserve( size_t elements )
2054 {
2055  matrix_.reserve( elements );
2056 }
2058 //*************************************************************************************************
2059 
2060 
2061 //*************************************************************************************************
2068 template< typename MT // Type of the adapted dense matrix
2069  , bool SO > // Storage order of the adapted dense matrix
2070 template< typename Other > // Data type of the scalar value
2071 inline StrictlyLowerMatrix<MT,SO,true>&
2072  StrictlyLowerMatrix<MT,SO,true>::scale( const Other& scalar )
2073 {
2074  matrix_.scale( scalar );
2075  return *this;
2076 }
2078 //*************************************************************************************************
2079 
2080 
2081 //*************************************************************************************************
2089 template< typename MT // Type of the adapted dense matrix
2090  , bool SO > // Storage order of the adapted dense matrix
2091 inline void StrictlyLowerMatrix<MT,SO,true>::swap( StrictlyLowerMatrix& m ) /* throw() */
2092 {
2093  using std::swap;
2094 
2095  swap( matrix_, m.matrix_ );
2096 }
2098 //*************************************************************************************************
2099 
2100 
2101 //*************************************************************************************************
2113 template< typename MT // Type of the adapted dense matrix
2114  , bool SO > // Storage order of the adapted dense matrix
2115 inline size_t StrictlyLowerMatrix<MT,SO,true>::maxNonZeros()
2116 {
2118 
2119  return maxNonZeros( Rows<MT>::value );
2120 }
2122 //*************************************************************************************************
2123 
2124 
2125 //*************************************************************************************************
2135 template< typename MT // Type of the adapted dense matrix
2136  , bool SO > // Storage order of the adapted dense matrix
2137 inline size_t StrictlyLowerMatrix<MT,SO,true>::maxNonZeros( size_t n )
2138 {
2139  return ( ( n - 1UL ) * n ) / 2UL;
2140 }
2142 //*************************************************************************************************
2143 
2144 
2145 
2146 
2147 //=================================================================================================
2148 //
2149 // DEBUGGING FUNCTIONS
2150 //
2151 //=================================================================================================
2152 
2153 //*************************************************************************************************
2163 template< typename MT // Type of the adapted dense matrix
2164  , bool SO > // Storage order of the adapted dense matrix
2166 {
2167  using blaze::isIntact;
2168 
2169  return ( isIntact( matrix_ ) && isStrictlyLower( matrix_ ) );
2170 }
2172 //*************************************************************************************************
2173 
2174 
2175 
2176 
2177 //=================================================================================================
2178 //
2179 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2180 //
2181 //=================================================================================================
2182 
2183 //*************************************************************************************************
2194 template< typename MT // Type of the adapted dense matrix
2195  , bool SO > // Storage order of the adapted dense matrix
2196 template< typename Other > // Data type of the foreign expression
2197 inline bool StrictlyLowerMatrix<MT,SO,true>::canAlias( const Other* alias ) const
2198 {
2199  return matrix_.canAlias( alias );
2200 }
2202 //*************************************************************************************************
2203 
2204 
2205 //*************************************************************************************************
2216 template< typename MT // Type of the adapted dense matrix
2217  , bool SO > // Storage order of the adapted dense matrix
2218 template< typename Other > // Data type of the foreign expression
2219 inline bool StrictlyLowerMatrix<MT,SO,true>::isAliased( const Other* alias ) const
2220 {
2221  return matrix_.isAliased( alias );
2222 }
2224 //*************************************************************************************************
2225 
2226 
2227 //*************************************************************************************************
2237 template< typename MT // Type of the adapted dense matrix
2238  , bool SO > // Storage order of the adapted dense matrix
2239 inline bool StrictlyLowerMatrix<MT,SO,true>::isAligned() const
2240 {
2241  return matrix_.isAligned();
2242 }
2244 //*************************************************************************************************
2245 
2246 
2247 //*************************************************************************************************
2258 template< typename MT // Type of the adapted dense matrix
2259  , bool SO > // Storage order of the adapted dense matrix
2260 inline bool StrictlyLowerMatrix<MT,SO,true>::canSMPAssign() const
2261 {
2262  return matrix_.canSMPAssign();
2263 }
2265 //*************************************************************************************************
2266 
2267 
2268 //*************************************************************************************************
2284 template< typename MT // Type of the adapted dense matrix
2285  , bool SO > // Storage order of the adapted dense matrix
2286 BLAZE_ALWAYS_INLINE typename StrictlyLowerMatrix<MT,SO,true>::IntrinsicType
2287  StrictlyLowerMatrix<MT,SO,true>::load( size_t i, size_t j ) const
2288 {
2289  return matrix_.load( i, j );
2290 }
2292 //*************************************************************************************************
2293 
2294 
2295 //*************************************************************************************************
2311 template< typename MT // Type of the adapted dense matrix
2312  , bool SO > // Storage order of the adapted dense matrix
2313 BLAZE_ALWAYS_INLINE typename StrictlyLowerMatrix<MT,SO,true>::IntrinsicType
2314  StrictlyLowerMatrix<MT,SO,true>::loada( size_t i, size_t j ) const
2315 {
2316  return matrix_.loada( i, j );
2317 }
2319 //*************************************************************************************************
2320 
2321 
2322 //*************************************************************************************************
2338 template< typename MT // Type of the adapted dense matrix
2339  , bool SO > // Storage order of the adapted dense matrix
2340 BLAZE_ALWAYS_INLINE typename StrictlyLowerMatrix<MT,SO,true>::IntrinsicType
2341  StrictlyLowerMatrix<MT,SO,true>::loadu( size_t i, size_t j ) const
2342 {
2343  return matrix_.loadu( i, j );
2344 }
2346 //*************************************************************************************************
2347 
2348 
2349 
2350 
2351 //=================================================================================================
2352 //
2353 // CONSTRUCTION FUNCTIONS
2354 //
2355 //=================================================================================================
2356 
2357 //*************************************************************************************************
2364 template< typename MT // Type of the adapted dense matrix
2365  , bool SO > // Storage order of the adapted dense matrix
2366 inline const MT StrictlyLowerMatrix<MT,SO,true>::construct( size_t n, TrueType )
2367 {
2369 
2370  return MT( n, n, ElementType() );
2371 }
2373 //*************************************************************************************************
2374 
2375 
2376 //*************************************************************************************************
2383 template< typename MT // Type of the adapted dense matrix
2384  , bool SO > // Storage order of the adapted dense matrix
2385 inline const MT StrictlyLowerMatrix<MT,SO,true>::construct( const ElementType& init, FalseType )
2386 {
2389 
2390  MT tmp;
2391 
2392  if( SO ) {
2393  for( size_t j=0UL; j<tmp.columns(); ++j ) {
2394  for( size_t i=j+1UL; i<tmp.rows(); ++i )
2395  tmp(i,j) = init;
2396  }
2397  }
2398  else {
2399  for( size_t i=0UL; i<tmp.rows(); ++i ) {
2400  for( size_t j=0UL; j<i; ++j )
2401  tmp(i,j) = init;
2402  }
2403  }
2404 
2405  return tmp;
2406 }
2408 //*************************************************************************************************
2409 
2410 
2411 //*************************************************************************************************
2422 template< typename MT // Type of the adapted dense matrix
2423  , bool SO > // Storage order of the adapted dense matrix
2424 template< typename MT2 // Type of the foreign matrix
2425  , bool SO2 // Storage order of the foreign matrix
2426  , typename T > // Type of the third argument
2427 inline const MT StrictlyLowerMatrix<MT,SO,true>::construct( const Matrix<MT2,SO2>& m, T )
2428 {
2429  const MT tmp( ~m );
2430 
2431  if( IsUniTriangular<MT2>::value ||
2432  ( !IsStrictlyLower<MT2>::value && !isStrictlyLower( tmp ) ) ) {
2433  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly lower matrix" );
2434  }
2435 
2436  return tmp;
2437 }
2439 //*************************************************************************************************
2440 
2441 } // namespace blaze
2442 
2443 #endif
Constraint on the data type.
Header file for all restructuring submatrix functions.
#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
#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 UNUSED_PARAMETER function template.
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:7820
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
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
bool operator<=(const NegativeAccuracy< A > &, const T &rhs)
Less-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:404
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 isStrictlyLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly lower triangular matrix.
Definition: DenseMatrix.h:1201
Header file for the FalseType type/value trait base class.
#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
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.In case the given data type T is not a dense, N-dimensional matrix type...
Definition: DenseMatrix.h:79
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
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename ColumnExprTrait< MT >::Type >::Type column(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific column of the given matrix.
Definition: Column.h:107
void UNUSED_PARAMETER(const T1 &)
Suppression of unused parameter warnings.
Definition: Unused.h:81
bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:366
CompressedMatrix< Type, true > This
Type of this CompressedMatrix instance.
Definition: CompressedMatrix.h:2582
bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value...
Definition: Accuracy.h:442
#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
#define BLAZE_CONSTRAINT_MUST_BE_SQUARE(T)
Constraint on the data type.In case the given data type T is not a square matrix type, a compilation error is created.
Definition: Square.h:78
void move(CustomMatrix< Type, AF, PF, SO > &dst, CustomMatrix< Type, AF, PF, SO > &src)
Moving the contents of one custom matrix to another.
Definition: CustomMatrix.h:6085
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 IsSquare type trait.
Constraint on the data type.
Constraint on the data type.
Header file for the DenseSubmatrix class template.
Header file for the DisableIf class template.
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type loadu(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loadu.h:74
Header file for the clear shim.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
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
const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:610
Header file for the DenseMatrix base class.
Header file for the Columns type trait.
Constraint on the data type.
const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc)
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:642
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.
Header file for the IsStrictlyLower type trait.
Header file for utility functions for dense matrices.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:527
Header file for all adaptor forward declarations.
const bool spacing
Adding an additional spacing line between two log messages.This setting gives the opportunity to add ...
Definition: Logging.h:70
DisableIf< Or< IsComputation< MT >, IsTransExpr< MT > >, typename RowExprTrait< MT >::Type >::Type row(Matrix< MT, SO > &matrix, size_t index)
Creating a view on a specific row of the given matrix.
Definition: Row.h:107
BLAZE_ALWAYS_INLINE EnableIf< And< IsIntegral< T >, HasSize< T, 2UL > >, simd_int16_t >::Type loada(const T *address)
Loads a vector of 2-byte integral values.
Definition: Loada.h:77
#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.
Header file for the StrictlyLowerProxy class.
#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 all intrinsic functionality.
Header file for the move shim.
SubmatrixExprTrait< MT, unaligned >::Type submatrix(Matrix< MT, SO > &matrix, size_t row, size_t column, size_t m, size_t n)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:146
bool operator<(const NegativeAccuracy< A > &lhs, const T &rhs)
Less-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:328
#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.
boost::false_type FalseType
Type/value traits base class.The FalseType class is used as base class for type traits and value trai...
Definition: FalseType.h:61
#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: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 operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:289
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.
boost::true_type TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
#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.
Header file for the implementation of the base template of the StrictlyLowerMatrix.
System settings for the inline keywords.
#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
Header file for the TrueType type/value trait base class.