Blaze 3.9
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
43#include <iterator>
44#include <utility>
48#include <blaze/math/Aliases.h>
77#include <blaze/system/Inline.h>
78#include <blaze/util/Assert.h>
84#include <blaze/util/EnableIf.h>
88#include <blaze/util/Types.h>
89
90
91namespace blaze {
92
93//=================================================================================================
94//
95// CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES
96//
97//=================================================================================================
98
99//*************************************************************************************************
107template< typename MT // Type of the adapted dense matrix
108 , bool SO > // Storage order of the adapted dense matrix
109class StrictlyLowerMatrix<MT,SO,true>
110 : public DenseMatrix< StrictlyLowerMatrix<MT,SO,true>, SO >
111{
112 private:
113 //**Type definitions****************************************************************************
114 using OT = OppositeType_t<MT>;
115 using TT = TransposeType_t<MT>;
116 using ET = ElementType_t<MT>;
117 //**********************************************************************************************
118
119 public:
120 //**Type definitions****************************************************************************
121 using This = StrictlyLowerMatrix<MT,SO,true>;
122 using BaseType = DenseMatrix<This,SO>;
123 using ResultType = This;
124 using OppositeType = StrictlyLowerMatrix<OT,!SO,true>;
125 using TransposeType = StrictlyUpperMatrix<TT,!SO,true>;
126 using ElementType = ET;
127 using SIMDType = SIMDType_t<MT>;
128 using TagType = TagType_t<MT>;
129 using ReturnType = ReturnType_t<MT>;
130 using CompositeType = const This&;
131 using Reference = StrictlyLowerProxy<MT>;
132 using ConstReference = ConstReference_t<MT>;
133 using Pointer = Pointer_t<MT>;
134 using ConstPointer = ConstPointer_t<MT>;
135 using ConstIterator = ConstIterator_t<MT>;
136 //**********************************************************************************************
137
138 //**Rebind struct definition********************************************************************
141 template< typename NewType > // Data type of the other matrix
142 struct Rebind {
144 using Other = StrictlyLowerMatrix< typename MT::template Rebind<NewType>::Other >;
145 };
146 //**********************************************************************************************
147
148 //**Resize struct definition********************************************************************
151 template< size_t NewM // Number of rows of the other matrix
152 , size_t NewN > // Number of columns of the other matrix
153 struct Resize {
155 using Other = StrictlyLowerMatrix< typename MT::template Resize<NewM,NewN>::Other >;
156 };
157 //**********************************************************************************************
158
159 //**Iterator class definition*******************************************************************
162 class Iterator
163 {
164 public:
165 //**Type definitions*************************************************************************
166 using IteratorCategory = std::random_access_iterator_tag;
167 using ValueType = ElementType_t<MT>;
168 using PointerType = StrictlyLowerProxy<MT>;
169 using ReferenceType = StrictlyLowerProxy<MT>;
170 using DifferenceType = ptrdiff_t;
171
172 // STL iterator requirements
173 using iterator_category = IteratorCategory;
174 using value_type = ValueType;
175 using pointer = PointerType;
176 using reference = ReferenceType;
177 using difference_type = DifferenceType;
178 //*******************************************************************************************
179
180 //**Constructor******************************************************************************
183 inline Iterator() noexcept
184 : matrix_( nullptr ) // Reference to the adapted dense matrix
185 , row_ ( 0UL ) // The current row index of the iterator
186 , column_( 0UL ) // The current column index of the iterator
187 {}
188 //*******************************************************************************************
189
190 //**Constructor******************************************************************************
197 inline Iterator( MT& matrix, size_t row, size_t column ) noexcept
198 : matrix_( &matrix ) // Reference to the adapted dense matrix
199 , row_ ( row ) // The current row-index of the iterator
200 , column_( column ) // The current column-index of the iterator
201 {}
202 //*******************************************************************************************
203
204 //**Addition assignment operator*************************************************************
210 inline Iterator& operator+=( size_t inc ) noexcept {
211 ( SO )?( row_ += inc ):( column_ += inc );
212 return *this;
213 }
214 //*******************************************************************************************
215
216 //**Subtraction assignment operator**********************************************************
222 inline Iterator& operator-=( size_t dec ) noexcept {
223 ( SO )?( row_ -= dec ):( column_ -= dec );
224 return *this;
225 }
226 //*******************************************************************************************
227
228 //**Prefix increment operator****************************************************************
233 inline Iterator& operator++() noexcept {
234 ( SO )?( ++row_ ):( ++column_ );
235 return *this;
236 }
237 //*******************************************************************************************
238
239 //**Postfix increment operator***************************************************************
244 inline const Iterator operator++( int ) noexcept {
245 const Iterator tmp( *this );
246 ++(*this);
247 return tmp;
248 }
249 //*******************************************************************************************
250
251 //**Prefix decrement operator****************************************************************
256 inline Iterator& operator--() noexcept {
257 ( SO )?( --row_ ):( --column_ );
258 return *this;
259 }
260 //*******************************************************************************************
261
262 //**Postfix decrement operator***************************************************************
267 inline const Iterator operator--( int ) noexcept {
268 const Iterator tmp( *this );
269 --(*this);
270 return tmp;
271 }
272 //*******************************************************************************************
273
274 //**Element access operator******************************************************************
279 inline ReferenceType operator*() const {
280 return ReferenceType( *matrix_, row_, column_ );
281 }
282 //*******************************************************************************************
283
284 //**Element access operator******************************************************************
289 inline PointerType operator->() const {
290 return PointerType( *matrix_, row_, column_ );
291 }
292 //*******************************************************************************************
293
294 //**Load function****************************************************************************
304 inline SIMDType load() const {
305 return (*matrix_).load(row_,column_);
306 }
307 //*******************************************************************************************
308
309 //**Loada function***************************************************************************
319 inline SIMDType loada() const {
320 return (*matrix_).loada(row_,column_);
321 }
322 //*******************************************************************************************
323
324 //**Loadu function***************************************************************************
334 inline SIMDType loadu() const {
335 return (*matrix_).loadu(row_,column_);
336 }
337 //*******************************************************************************************
338
339 //**Conversion operator**********************************************************************
344 inline operator ConstIterator() const {
345 if( SO )
346 return matrix_->begin( column_ ) + row_;
347 else
348 return matrix_->begin( row_ ) + column_;
349 }
350 //*******************************************************************************************
351
352 //**Equality operator************************************************************************
359 friend inline bool operator==( const Iterator& lhs, const Iterator& rhs ) noexcept {
360 return ( SO )?( lhs.row_ == rhs.row_ ):( lhs.column_ == rhs.column_ );
361 }
362 //*******************************************************************************************
363
364 //**Equality operator************************************************************************
371 friend inline bool operator==( const Iterator& lhs, const ConstIterator& rhs ) {
372 return ( ConstIterator( lhs ) == rhs );
373 }
374 //*******************************************************************************************
375
376 //**Equality operator************************************************************************
383 friend inline bool operator==( const ConstIterator& lhs, const Iterator& rhs ) {
384 return ( lhs == ConstIterator( rhs ) );
385 }
386 //*******************************************************************************************
387
388 //**Inequality operator**********************************************************************
395 friend inline bool operator!=( const Iterator& lhs, const Iterator& rhs ) noexcept {
396 return ( SO )?( lhs.row_ != rhs.row_ ):( lhs.column_ != rhs.column_ );
397 }
398 //*******************************************************************************************
399
400 //**Inequality operator**********************************************************************
407 friend inline bool operator!=( const Iterator& lhs, const ConstIterator& rhs ) {
408 return ( ConstIterator( lhs ) != rhs );
409 }
410 //*******************************************************************************************
411
412 //**Inequality operator**********************************************************************
419 friend inline bool operator!=( const ConstIterator& lhs, const Iterator& rhs ) {
420 return ( lhs != ConstIterator( rhs ) );
421 }
422 //*******************************************************************************************
423
424 //**Less-than operator***********************************************************************
431 friend inline bool operator<( const Iterator& lhs, const Iterator& rhs ) noexcept {
432 return ( SO )?( lhs.row_ < rhs.row_ ):( lhs.column_ < rhs.column_ );
433 }
434 //*******************************************************************************************
435
436 //**Less-than operator***********************************************************************
443 friend inline bool operator<( const Iterator& lhs, const ConstIterator& rhs ) {
444 return ( ConstIterator( lhs ) < rhs );
445 }
446 //*******************************************************************************************
447
448 //**Less-than operator***********************************************************************
455 friend inline bool operator<( const ConstIterator& lhs, const Iterator& rhs ) {
456 return ( lhs < ConstIterator( rhs ) );
457 }
458 //*******************************************************************************************
459
460 //**Greater-than operator********************************************************************
467 friend inline bool operator>( const Iterator& lhs, const Iterator& rhs ) noexcept {
468 return ( SO )?( lhs.row_ > rhs.row_ ):( lhs.column_ > rhs.column_ );
469 }
470 //*******************************************************************************************
471
472 //**Greater-than operator********************************************************************
479 friend inline bool operator>( const Iterator& lhs, const ConstIterator& rhs ) {
480 return ( ConstIterator( lhs ) > rhs );
481 }
482 //*******************************************************************************************
483
484 //**Greater-than operator********************************************************************
491 friend inline bool operator>( const ConstIterator& lhs, const Iterator& rhs ) {
492 return ( lhs > ConstIterator( rhs ) );
493 }
494 //*******************************************************************************************
495
496 //**Less-or-equal-than operator**************************************************************
503 friend inline bool operator<=( const Iterator& lhs, const Iterator& rhs ) noexcept {
504 return ( SO )?( lhs.row_ <= rhs.row_ ):( lhs.column_ <= rhs.column_ );
505 }
506 //*******************************************************************************************
507
508 //**Less-or-equal-than operator**************************************************************
515 friend inline bool operator<=( const Iterator& lhs, const ConstIterator& rhs ) {
516 return ( ConstIterator( lhs ) <= rhs );
517 }
518 //*******************************************************************************************
519
520 //**Less-or-equal-than operator**************************************************************
527 friend inline bool operator<=( const ConstIterator& lhs, const Iterator& rhs ) {
528 return ( lhs <= ConstIterator( rhs ) );
529 }
530 //*******************************************************************************************
531
532 //**Greater-or-equal-than operator***********************************************************
539 friend inline bool operator>=( const Iterator& lhs, const Iterator& rhs ) noexcept {
540 return ( SO )?( lhs.row_ >= rhs.row_ ):( lhs.column_ >= rhs.column_ );
541 }
542 //*******************************************************************************************
543
544 //**Greater-or-equal-than operator***********************************************************
551 friend inline bool operator>=( const Iterator& lhs, const ConstIterator& rhs ) {
552 return ( ConstIterator( lhs ) >= rhs );
553 }
554 //*******************************************************************************************
555
556 //**Greater-or-equal-than operator***********************************************************
563 friend inline bool operator>=( const ConstIterator& lhs, const Iterator& rhs ) {
564 return ( lhs >= ConstIterator( rhs ) );
565 }
566 //*******************************************************************************************
567
568 //**Subtraction operator*********************************************************************
574 inline DifferenceType operator-( const Iterator& rhs ) const noexcept {
575 return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
576 }
577 //*******************************************************************************************
578
579 //**Addition operator************************************************************************
586 friend inline const Iterator operator+( const Iterator& it, size_t inc ) noexcept {
587 if( SO )
588 return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
589 else
590 return Iterator( *it.matrix_, it.row_, it.column_ + inc );
591 }
592 //*******************************************************************************************
593
594 //**Addition operator************************************************************************
601 friend inline const Iterator operator+( size_t inc, const Iterator& it ) noexcept {
602 if( SO )
603 return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
604 else
605 return Iterator( *it.matrix_, it.row_, it.column_ + inc );
606 }
607 //*******************************************************************************************
608
609 //**Subtraction operator*********************************************************************
616 friend inline const Iterator operator-( const Iterator& it, size_t dec ) noexcept {
617 if( SO )
618 return Iterator( *it.matrix_, it.row_ - dec, it.column_ );
619 else
620 return Iterator( *it.matrix_, it.row_, it.column_ - dec );
621 }
622 //*******************************************************************************************
623
624 private:
625 //**Member variables*************************************************************************
626 MT* matrix_;
627 size_t row_;
628 size_t column_;
629 //*******************************************************************************************
630 };
631 //**********************************************************************************************
632
633 //**Compilation flags***************************************************************************
635 static constexpr bool simdEnabled = MT::simdEnabled;
636
638 static constexpr bool smpAssignable = MT::smpAssignable;
639 //**********************************************************************************************
640
641 //**Constructors********************************************************************************
644 inline StrictlyLowerMatrix();
645 template< typename A1 > explicit inline StrictlyLowerMatrix( const A1& a1 );
646 inline StrictlyLowerMatrix( size_t n, const ElementType& init );
647
648 inline StrictlyLowerMatrix( initializer_list< initializer_list<ElementType> > list );
649
650 template< typename Other >
651 inline StrictlyLowerMatrix( size_t n, const Other* array );
652
653 template< typename Other, size_t N >
654 inline StrictlyLowerMatrix( const Other (&array)[N][N] );
655
656 inline StrictlyLowerMatrix( ElementType* ptr, size_t n );
657 inline StrictlyLowerMatrix( ElementType* ptr, size_t n, size_t nn );
658
659 inline StrictlyLowerMatrix( const StrictlyLowerMatrix& m );
660 inline StrictlyLowerMatrix( StrictlyLowerMatrix&& m ) noexcept;
662 //**********************************************************************************************
663
664 //**Destructor**********************************************************************************
667 ~StrictlyLowerMatrix() = default;
669 //**********************************************************************************************
670
671 //**Data access functions***********************************************************************
674 inline Reference operator()( size_t i, size_t j );
675 inline ConstReference operator()( size_t i, size_t j ) const;
676 inline Reference at( size_t i, size_t j );
677 inline ConstReference at( size_t i, size_t j ) const;
678 inline ConstPointer data () const noexcept;
679 inline ConstPointer data ( size_t i ) const noexcept;
680 inline Iterator begin ( size_t i );
681 inline ConstIterator begin ( size_t i ) const;
682 inline ConstIterator cbegin( size_t i ) const;
683 inline Iterator end ( size_t i );
684 inline ConstIterator end ( size_t i ) const;
685 inline ConstIterator cend ( size_t i ) const;
687 //**********************************************************************************************
688
689 //**Assignment operators************************************************************************
692 inline StrictlyLowerMatrix& operator=( const ElementType& rhs );
693 inline StrictlyLowerMatrix& operator=( initializer_list< initializer_list<ElementType> > list );
694
695 template< typename Other, size_t N >
696 inline StrictlyLowerMatrix& operator=( const Other (&array)[N][N] );
697
698 inline StrictlyLowerMatrix& operator=( const StrictlyLowerMatrix& rhs );
699 inline StrictlyLowerMatrix& operator=( StrictlyLowerMatrix&& rhs ) noexcept;
700
701 template< typename MT2, bool SO2 >
702 inline auto operator=( const Matrix<MT2,SO2>& rhs )
703 -> DisableIf_t< IsComputation_v<MT2>, StrictlyLowerMatrix& >;
704
705 template< typename MT2, bool SO2 >
706 inline auto operator=( const Matrix<MT2,SO2>& rhs )
707 -> EnableIf_t< IsComputation_v<MT2>, StrictlyLowerMatrix& >;
708
709 template< typename MT2, bool SO2 >
710 inline auto operator+=( const Matrix<MT2,SO2>& rhs )
711 -> DisableIf_t< IsComputation_v<MT2>, StrictlyLowerMatrix& >;
712
713 template< typename MT2, bool SO2 >
714 inline auto operator+=( const Matrix<MT2,SO2>& rhs )
715 -> EnableIf_t< IsComputation_v<MT2>, StrictlyLowerMatrix& >;
716
717 template< typename MT2, bool SO2 >
718 inline auto operator-=( const Matrix<MT2,SO2>& rhs )
719 -> DisableIf_t< IsComputation_v<MT2>, StrictlyLowerMatrix& >;
720
721 template< typename MT2, bool SO2 >
722 inline auto operator-=( const Matrix<MT2,SO2>& rhs )
723 -> EnableIf_t< IsComputation_v<MT2>, StrictlyLowerMatrix& >;
724
725 template< typename MT2, bool SO2 >
726 inline auto operator%=( const Matrix<MT2,SO2>& rhs ) -> StrictlyLowerMatrix&;
727
728 template< typename ST >
729 inline auto operator*=( ST rhs ) -> EnableIf_t< IsScalar_v<ST>, StrictlyLowerMatrix& >;
730
731 template< typename ST >
732 inline auto operator/=( ST rhs ) -> EnableIf_t< IsScalar_v<ST>, StrictlyLowerMatrix& >;
734 //**********************************************************************************************
735
736 //**Utility functions***************************************************************************
739 inline size_t rows() const noexcept;
740 inline size_t columns() const noexcept;
741 inline size_t spacing() const noexcept;
742 inline size_t capacity() const noexcept;
743 inline size_t capacity( size_t i ) const noexcept;
744 inline size_t nonZeros() const;
745 inline size_t nonZeros( size_t i ) const;
746 inline void reset();
747 inline void reset( size_t i );
748 inline void clear();
749 void resize ( size_t n, bool preserve=true );
750 inline void extend ( size_t n, bool preserve=true );
751 inline void reserve( size_t elements );
752 inline void shrinkToFit();
753 inline void swap( StrictlyLowerMatrix& m ) noexcept;
754
755 static constexpr size_t maxNonZeros() noexcept;
756 static constexpr size_t maxNonZeros( size_t n ) noexcept;
758 //**********************************************************************************************
759
760 //**Numeric functions***************************************************************************
763 template< typename Other > inline StrictlyLowerMatrix& scale( const Other& scalar );
765 //**********************************************************************************************
766
767 //**Debugging functions*************************************************************************
770 inline bool isIntact() const noexcept;
772 //**********************************************************************************************
773
774 //**Expression template evaluation functions****************************************************
777 template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
778 template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
779
780 inline bool isAligned () const noexcept;
781 inline bool canSMPAssign() const noexcept;
782
783 BLAZE_ALWAYS_INLINE SIMDType load ( size_t i, size_t j ) const noexcept;
784 BLAZE_ALWAYS_INLINE SIMDType loada( size_t i, size_t j ) const noexcept;
785 BLAZE_ALWAYS_INLINE SIMDType loadu( size_t i, size_t j ) const noexcept;
787 //**********************************************************************************************
788
789 private:
790 //**Construction functions**********************************************************************
793 inline const MT construct( size_t n , TrueType );
794 inline const MT construct( const ElementType& value, FalseType );
795
796 template< typename MT2, bool SO2, typename T >
797 inline const MT construct( const Matrix<MT2,SO2>& m, T );
799 //**********************************************************************************************
800
801 //**Member variables****************************************************************************
804 MT matrix_;
806 //**********************************************************************************************
807
808 //**Friend declarations*************************************************************************
809 template< typename MT2, bool SO2, bool DF2 >
810 friend MT2& derestrict( StrictlyLowerMatrix<MT2,SO2,DF2>& m );
811 //**********************************************************************************************
812
813 //**Compile time checks*************************************************************************
828 BLAZE_STATIC_ASSERT( ( Size_v<MT,0UL> == Size_v<MT,1UL> ) );
829 //**********************************************************************************************
830};
832//*************************************************************************************************
833
834
835
836
837//=================================================================================================
838//
839// CONSTRUCTORS
840//
841//=================================================================================================
842
843//*************************************************************************************************
847template< typename MT // Type of the adapted dense matrix
848 , bool SO > // Storage order of the adapted dense matrix
849inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix()
850 : matrix_() // The adapted dense matrix
851{
852 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
853 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
854}
856//*************************************************************************************************
857
858
859//*************************************************************************************************
877template< typename MT // Type of the adapted dense matrix
878 , bool SO > // Storage order of the adapted dense matrix
879template< typename A1 > // Type of the constructor argument
880inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( const A1& a1 )
881 : matrix_( construct( a1, IsResizable<MT>() ) ) // The adapted dense matrix
882{
883 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
884 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
885}
887//*************************************************************************************************
888
889
890//*************************************************************************************************
897template< typename MT // Type of the adapted dense matrix
898 , bool SO > // Storage order of the adapted dense matrix
899inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( size_t n, const ElementType& init )
900 : matrix_( n, n, ElementType() ) // The adapted dense matrix
901{
903
904 if( SO ) {
905 for( size_t j=0UL; j<columns(); ++j ) {
906 for( size_t i=j+1UL; i<rows(); ++i )
907 matrix_(i,j) = init;
908 }
909 }
910 else {
911 for( size_t i=0UL; i<rows(); ++i ) {
912 for( size_t j=0UL; j<i; ++j )
913 matrix_(i,j) = init;
914 }
915 }
916
917 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
918 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
919}
921//*************************************************************************************************
922
923
924//*************************************************************************************************
948template< typename MT // Type of the adapted dense matrix
949 , bool SO > // Storage order of the adapted dense matrix
950inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( initializer_list< initializer_list<ElementType> > list )
951 : matrix_( list ) // The adapted dense matrix
952{
953 if( !isStrictlyLower( matrix_ ) ) {
954 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly lower matrix" );
955 }
956
957 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
958}
960//*************************************************************************************************
961
962
963//*************************************************************************************************
989template< typename MT // Type of the adapted dense matrix
990 , bool SO > // Storage order of the adapted dense matrix
991template< typename Other > // Data type of the initialization array
992inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( size_t n, const Other* array )
993 : matrix_( n, n, array ) // The adapted dense matrix
994{
995 if( !isStrictlyLower( matrix_ ) ) {
996 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly lower matrix" );
997 }
998
999 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1000}
1002//*************************************************************************************************
1003
1004
1005//*************************************************************************************************
1028template< typename MT // Type of the adapted dense matrix
1029 , bool SO > // Storage order of the adapted dense matrix
1030template< typename Other // Data type of the initialization array
1031 , size_t N > // Number of rows and columns of the initialization array
1032inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( const Other (&array)[N][N] )
1033 : matrix_( array ) // The adapted dense matrix
1034{
1035 if( !isStrictlyLower( matrix_ ) ) {
1036 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly lower matrix" );
1037 }
1038
1039 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1040}
1042//*************************************************************************************************
1043
1044
1045//*************************************************************************************************
1078template< typename MT // Type of the adapted dense matrix
1079 , bool SO > // Storage order of the adapted dense matrix
1080inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( ElementType* ptr, size_t n )
1081 : matrix_( ptr, n, n ) // The adapted dense matrix
1082{
1083 if( !isStrictlyLower( matrix_ ) ) {
1084 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly lower matrix" );
1085 }
1086
1087 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1088}
1090//*************************************************************************************************
1091
1092
1093//*************************************************************************************************
1127template< typename MT // Type of the adapted dense matrix
1128 , bool SO > // Storage order of the adapted dense matrix
1129inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( ElementType* ptr, size_t n, size_t nn )
1130 : matrix_( ptr, n, n, nn ) // The adapted dense matrix
1131{
1132 if( !isStrictlyLower( matrix_ ) ) {
1133 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly lower matrix" );
1134 }
1135
1136 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1137}
1139//*************************************************************************************************
1140
1141
1142//*************************************************************************************************
1148template< typename MT // Type of the adapted dense matrix
1149 , bool SO > // Storage order of the adapted dense matrix
1150inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( const StrictlyLowerMatrix& m )
1151 : matrix_( m.matrix_ ) // The adapted dense matrix
1152{
1153 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1154 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1155}
1157//*************************************************************************************************
1158
1159
1160//*************************************************************************************************
1166template< typename MT // Type of the adapted dense matrix
1167 , bool SO > // Storage order of the adapted dense matrix
1168inline StrictlyLowerMatrix<MT,SO,true>::StrictlyLowerMatrix( StrictlyLowerMatrix&& m ) noexcept
1169 : matrix_( std::move( m.matrix_ ) ) // The adapted dense matrix
1170{
1171 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1172 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1173}
1175//*************************************************************************************************
1176
1177
1178
1179
1180//=================================================================================================
1181//
1182// DATA ACCESS FUNCTIONS
1183//
1184//=================================================================================================
1185
1186//*************************************************************************************************
1202template< typename MT // Type of the adapted dense matrix
1203 , bool SO > // Storage order of the adapted dense matrix
1204inline typename StrictlyLowerMatrix<MT,SO,true>::Reference
1205 StrictlyLowerMatrix<MT,SO,true>::operator()( size_t i, size_t j )
1206{
1207 BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1208 BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1209
1210 return Reference( matrix_, i, j );
1211}
1213//*************************************************************************************************
1214
1215
1216//*************************************************************************************************
1232template< typename MT // Type of the adapted dense matrix
1233 , bool SO > // Storage order of the adapted dense matrix
1234inline typename StrictlyLowerMatrix<MT,SO,true>::ConstReference
1235 StrictlyLowerMatrix<MT,SO,true>::operator()( size_t i, size_t j ) const
1236{
1237 BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1238 BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1239
1240 return matrix_(i,j);
1241}
1243//*************************************************************************************************
1244
1245
1246//*************************************************************************************************
1263template< typename MT // Type of the adapted dense matrix
1264 , bool SO > // Storage order of the adapted dense matrix
1265inline typename StrictlyLowerMatrix<MT,SO,true>::Reference
1266 StrictlyLowerMatrix<MT,SO,true>::at( size_t i, size_t j )
1267{
1268 if( i >= rows() ) {
1269 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1270 }
1271 if( j >= columns() ) {
1272 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1273 }
1274 return (*this)(i,j);
1275}
1277//*************************************************************************************************
1278
1279
1280//*************************************************************************************************
1297template< typename MT // Type of the adapted dense matrix
1298 , bool SO > // Storage order of the adapted dense matrix
1299inline typename StrictlyLowerMatrix<MT,SO,true>::ConstReference
1300 StrictlyLowerMatrix<MT,SO,true>::at( size_t i, size_t j ) const
1301{
1302 if( i >= rows() ) {
1303 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1304 }
1305 if( j >= columns() ) {
1306 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1307 }
1308 return (*this)(i,j);
1309}
1311//*************************************************************************************************
1312
1313
1314//*************************************************************************************************
1327template< typename MT // Type of the adapted dense matrix
1328 , bool SO > // Storage order of the adapted dense matrix
1329inline typename StrictlyLowerMatrix<MT,SO,true>::ConstPointer
1331{
1332 return matrix_.data();
1333}
1335//*************************************************************************************************
1336
1337
1338//*************************************************************************************************
1347template< typename MT // Type of the adapted dense matrix
1348 , bool SO > // Storage order of the adapted dense matrix
1349inline typename StrictlyLowerMatrix<MT,SO,true>::ConstPointer
1350 StrictlyLowerMatrix<MT,SO,true>::data( size_t i ) const noexcept
1351{
1352 return matrix_.data(i);
1353}
1355//*************************************************************************************************
1356
1357
1358//*************************************************************************************************
1370template< typename MT // Type of the adapted dense matrix
1371 , bool SO > // Storage order of the adapted dense matrix
1372inline typename StrictlyLowerMatrix<MT,SO,true>::Iterator
1374{
1375 if( SO )
1376 return Iterator( matrix_, 0UL, i );
1377 else
1378 return Iterator( matrix_, i, 0UL );
1379}
1381//*************************************************************************************************
1382
1383
1384//*************************************************************************************************
1396template< typename MT // Type of the adapted dense matrix
1397 , bool SO > // Storage order of the adapted dense matrix
1398inline typename StrictlyLowerMatrix<MT,SO,true>::ConstIterator
1400{
1401 return matrix_.begin(i);
1402}
1404//*************************************************************************************************
1405
1406
1407//*************************************************************************************************
1419template< typename MT // Type of the adapted dense matrix
1420 , bool SO > // Storage order of the adapted dense matrix
1421inline typename StrictlyLowerMatrix<MT,SO,true>::ConstIterator
1423{
1424 return matrix_.cbegin(i);
1425}
1427//*************************************************************************************************
1428
1429
1430//*************************************************************************************************
1442template< typename MT // Type of the adapted dense matrix
1443 , bool SO > // Storage order of the adapted dense matrix
1444inline typename StrictlyLowerMatrix<MT,SO,true>::Iterator
1446{
1447 if( SO )
1448 return Iterator( matrix_, rows(), i );
1449 else
1450 return Iterator( matrix_, i, columns() );
1451}
1453//*************************************************************************************************
1454
1455
1456//*************************************************************************************************
1468template< typename MT // Type of the adapted dense matrix
1469 , bool SO > // Storage order of the adapted dense matrix
1470inline typename StrictlyLowerMatrix<MT,SO,true>::ConstIterator
1471 StrictlyLowerMatrix<MT,SO,true>::end( size_t i ) const
1472{
1473 return matrix_.end(i);
1474}
1476//*************************************************************************************************
1477
1478
1479//*************************************************************************************************
1491template< typename MT // Type of the adapted dense matrix
1492 , bool SO > // Storage order of the adapted dense matrix
1493inline typename StrictlyLowerMatrix<MT,SO,true>::ConstIterator
1495{
1496 return matrix_.cend(i);
1497}
1499//*************************************************************************************************
1500
1501
1502
1503
1504//=================================================================================================
1505//
1506// ASSIGNMENT OPERATORS
1507//
1508//=================================================================================================
1509
1510//*************************************************************************************************
1517template< typename MT // Type of the adapted dense matrix
1518 , bool SO > // Storage order of the adapted dense matrix
1519inline StrictlyLowerMatrix<MT,SO,true>&
1520 StrictlyLowerMatrix<MT,SO,true>::operator=( const ElementType& rhs )
1521{
1522 if( SO ) {
1523 for( size_t j=0UL; j<columns(); ++j )
1524 for( size_t i=j+1UL; i<rows(); ++i )
1525 matrix_(i,j) = rhs;
1526 }
1527 else {
1528 for( size_t i=1UL; i<rows(); ++i )
1529 for( size_t j=0UL; j<i; ++j )
1530 matrix_(i,j) = rhs;
1531 }
1532
1533 return *this;
1534}
1536//*************************************************************************************************
1537
1538
1539//*************************************************************************************************
1564template< typename MT // Type of the adapted dense matrix
1565 , bool SO > // Storage order of the adapted dense matrix
1566inline StrictlyLowerMatrix<MT,SO,true>&
1567 StrictlyLowerMatrix<MT,SO,true>::operator=( initializer_list< initializer_list<ElementType> > list )
1568{
1569 const InitializerMatrix<ElementType> tmp( list, list.size() );
1570
1571 if( !isStrictlyLower( tmp ) ) {
1572 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1573 }
1574
1575 matrix_ = list;
1576
1577 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1578 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1579
1580 return *this;
1581}
1583//*************************************************************************************************
1584
1585
1586//*************************************************************************************************
1611template< typename MT // Type of the adapted dense matrix
1612 , bool SO > // Storage order of the adapted dense matrix
1613template< typename Other // Data type of the initialization array
1614 , size_t N > // Number of rows and columns of the initialization array
1615inline StrictlyLowerMatrix<MT,SO,true>&
1616 StrictlyLowerMatrix<MT,SO,true>::operator=( const Other (&array)[N][N] )
1617{
1618 MT tmp( array );
1619
1620 if( !isStrictlyLower( tmp ) ) {
1621 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1622 }
1623
1624 matrix_ = std::move( tmp );
1625
1626 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1627 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1628
1629 return *this;
1630}
1632//*************************************************************************************************
1633
1634
1635//*************************************************************************************************
1645template< typename MT // Type of the adapted dense matrix
1646 , bool SO > // Storage order of the adapted dense matrix
1647inline StrictlyLowerMatrix<MT,SO,true>&
1648 StrictlyLowerMatrix<MT,SO,true>::operator=( const StrictlyLowerMatrix& rhs )
1649{
1650 matrix_ = rhs.matrix_;
1651
1652 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1653 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1654
1655 return *this;
1656}
1658//*************************************************************************************************
1659
1660
1661//*************************************************************************************************
1668template< typename MT // Type of the adapted dense matrix
1669 , bool SO > // Storage order of the adapted dense matrix
1670inline StrictlyLowerMatrix<MT,SO,true>&
1671 StrictlyLowerMatrix<MT,SO,true>::operator=( StrictlyLowerMatrix&& rhs ) noexcept
1672{
1673 matrix_ = std::move( rhs.matrix_ );
1674
1675 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1676 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1677
1678 return *this;
1679}
1681//*************************************************************************************************
1682
1683
1684//*************************************************************************************************
1697template< typename MT // Type of the adapted dense matrix
1698 , bool SO > // Storage order of the adapted dense matrix
1699template< typename MT2 // Type of the right-hand side matrix
1700 , bool SO2 > // Storage order of the right-hand side matrix
1701inline auto StrictlyLowerMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1702 -> DisableIf_t< IsComputation_v<MT2>, StrictlyLowerMatrix& >
1703{
1704 if( IsUniTriangular_v<MT2> ||
1705 ( !IsStrictlyLower_v<MT2> && !isStrictlyLower( *rhs ) ) ) {
1706 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1707 }
1708
1709 matrix_ = decllow( *rhs );
1710
1711 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1712 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1713
1714 return *this;
1715}
1717//*************************************************************************************************
1718
1719
1720//*************************************************************************************************
1733template< typename MT // Type of the adapted dense matrix
1734 , bool SO > // Storage order of the adapted dense matrix
1735template< typename MT2 // Type of the right-hand side matrix
1736 , bool SO2 > // Storage order of the right-hand side matrix
1737inline auto StrictlyLowerMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1738 -> EnableIf_t< IsComputation_v<MT2>, StrictlyLowerMatrix& >
1739{
1740 if( IsUniTriangular_v<MT2> || ( !IsSquare_v<MT2> && !isSquare( *rhs ) ) ) {
1741 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1742 }
1743
1744 if( IsStrictlyLower_v<MT2> ) {
1745 matrix_ = *rhs;
1746 }
1747 else {
1748 MT tmp( *rhs );
1749
1750 if( !isStrictlyLower( tmp ) ) {
1751 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1752 }
1753
1754 matrix_ = std::move( tmp );
1755 }
1756
1757 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1758 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1759
1760 return *this;
1761}
1763//*************************************************************************************************
1764
1765
1766//*************************************************************************************************
1779template< typename MT // Type of the adapted dense matrix
1780 , bool SO > // Storage order of the adapted dense matrix
1781template< typename MT2 // Type of the right-hand side matrix
1782 , bool SO2 > // Storage order of the right-hand side matrix
1783inline auto StrictlyLowerMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1784 -> DisableIf_t< IsComputation_v<MT2>, StrictlyLowerMatrix& >
1785{
1786 if( IsUniTriangular_v<MT2> ||
1787 ( !IsStrictlyLower_v<MT2> && !isStrictlyLower( *rhs ) ) ) {
1788 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1789 }
1790
1791 matrix_ += decllow( *rhs );
1792
1793 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1794 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1795
1796 return *this;
1797}
1799//*************************************************************************************************
1800
1801
1802//*************************************************************************************************
1815template< typename MT // Type of the adapted dense matrix
1816 , bool SO > // Storage order of the adapted dense matrix
1817template< typename MT2 // Type of the right-hand side matrix
1818 , bool SO2 > // Storage order of the right-hand side matrix
1819inline auto StrictlyLowerMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1820 -> EnableIf_t< IsComputation_v<MT2>, StrictlyLowerMatrix& >
1821{
1822 if( IsUniTriangular_v<MT2> || ( !IsSquare_v<MT2> && !isSquare( *rhs ) ) ) {
1823 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1824 }
1825
1826 if( IsStrictlyLower_v<MT2> ) {
1827 matrix_ += *rhs;
1828 }
1829 else {
1830 const ResultType_t<MT2> tmp( *rhs );
1831
1832 if( !isStrictlyLower( tmp ) ) {
1833 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1834 }
1835
1836 matrix_ += decllow( tmp );
1837 }
1838
1839 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1840 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1841
1842 return *this;
1843}
1845//*************************************************************************************************
1846
1847
1848//*************************************************************************************************
1861template< typename MT // Type of the adapted dense matrix
1862 , bool SO > // Storage order of the adapted dense matrix
1863template< typename MT2 // Type of the right-hand side matrix
1864 , bool SO2 > // Storage order of the right-hand side matrix
1865inline auto StrictlyLowerMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1866 -> DisableIf_t< IsComputation_v<MT2>, StrictlyLowerMatrix& >
1867{
1868 if( IsUniTriangular_v<MT2> ||
1869 ( !IsStrictlyLower_v<MT2> && !isStrictlyLower( *rhs ) ) ) {
1870 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1871 }
1872
1873 matrix_ -= decllow( *rhs );
1874
1875 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1876 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1877
1878 return *this;
1879}
1881//*************************************************************************************************
1882
1883
1884//*************************************************************************************************
1897template< typename MT // Type of the adapted dense matrix
1898 , bool SO > // Storage order of the adapted dense matrix
1899template< typename MT2 // Type of the right-hand side matrix
1900 , bool SO2 > // Storage order of the right-hand side matrix
1901inline auto StrictlyLowerMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1902 -> EnableIf_t< IsComputation_v<MT2>, StrictlyLowerMatrix& >
1903{
1904 if( IsUniTriangular_v<MT2> || ( !IsSquare_v<MT2> && !isSquare( *rhs ) ) ) {
1905 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1906 }
1907
1908 if( IsStrictlyLower_v<MT2> ) {
1909 matrix_ -= *rhs;
1910 }
1911 else {
1912 const ResultType_t<MT2> tmp( *rhs );
1913
1914 if( !isStrictlyLower( tmp ) ) {
1915 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1916 }
1917
1918 matrix_ -= decllow( tmp );
1919 }
1920
1921 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1922 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1923
1924 return *this;
1925}
1927//*************************************************************************************************
1928
1929
1930//*************************************************************************************************
1941template< typename MT // Type of the adapted dense matrix
1942 , bool SO > // Storage order of the adapted dense matrix
1943template< typename MT2 // Type of the right-hand side matrix
1944 , bool SO2 > // Storage order of the right-hand side matrix
1945inline auto StrictlyLowerMatrix<MT,SO,true>::operator%=( const Matrix<MT2,SO2>& rhs )
1946 -> StrictlyLowerMatrix&
1947{
1948 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
1949 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to strictly lower matrix" );
1950 }
1951
1952 matrix_ %= *rhs;
1953
1954 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
1955 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1956
1957 return *this;
1958}
1960//*************************************************************************************************
1961
1962
1963//*************************************************************************************************
1971template< typename MT // Type of the adapted dense matrix
1972 , bool SO > // Storage order of the adapted dense matrix
1973template< typename ST > // Data type of the right-hand side scalar
1975 -> EnableIf_t< IsScalar_v<ST>, StrictlyLowerMatrix& >
1976{
1977 matrix_ *= rhs;
1978 return *this;
1979}
1980//*************************************************************************************************
1981
1982
1983//*************************************************************************************************
1991template< typename MT // Type of the adapted dense matrix
1992 , bool SO > // Storage order of the adapted dense matrix
1993template< typename ST > // Data type of the right-hand side scalar
1995 -> EnableIf_t< IsScalar_v<ST>, StrictlyLowerMatrix& >
1996{
1997 BLAZE_USER_ASSERT( !isZero( rhs ), "Division by zero detected" );
1998
1999 matrix_ /= rhs;
2000 return *this;
2001}
2003//*************************************************************************************************
2004
2005
2006
2007
2008//=================================================================================================
2009//
2010// UTILITY FUNCTIONS
2011//
2012//=================================================================================================
2013
2014//*************************************************************************************************
2020template< typename MT // Type of the adapted dense matrix
2021 , bool SO > // Storage order of the adapted dense matrix
2022inline size_t StrictlyLowerMatrix<MT,SO,true>::rows() const noexcept
2023{
2024 return matrix_.rows();
2025}
2027//*************************************************************************************************
2028
2029
2030//*************************************************************************************************
2036template< typename MT // Type of the adapted dense matrix
2037 , bool SO > // Storage order of the adapted dense matrix
2038inline size_t StrictlyLowerMatrix<MT,SO,true>::columns() const noexcept
2039{
2040 return matrix_.columns();
2041}
2043//*************************************************************************************************
2044
2045
2046//*************************************************************************************************
2057template< typename MT // Type of the adapted dense matrix
2058 , bool SO > // Storage order of the adapted dense matrix
2059inline size_t StrictlyLowerMatrix<MT,SO,true>::spacing() const noexcept
2060{
2061 return matrix_.spacing();
2062}
2064//*************************************************************************************************
2065
2066
2067//*************************************************************************************************
2073template< typename MT // Type of the adapted dense matrix
2074 , bool SO > // Storage order of the adapted dense matrix
2075inline size_t StrictlyLowerMatrix<MT,SO,true>::capacity() const noexcept
2076{
2077 return matrix_.capacity();
2078}
2080//*************************************************************************************************
2081
2082
2083//*************************************************************************************************
2095template< typename MT // Type of the adapted dense matrix
2096 , bool SO > // Storage order of the adapted dense matrix
2097inline size_t StrictlyLowerMatrix<MT,SO,true>::capacity( size_t i ) const noexcept
2098{
2099 return matrix_.capacity(i);
2100}
2102//*************************************************************************************************
2103
2104
2105//*************************************************************************************************
2111template< typename MT // Type of the adapted dense matrix
2112 , bool SO > // Storage order of the adapted dense matrix
2114{
2115 return matrix_.nonZeros();
2116}
2118//*************************************************************************************************
2119
2120
2121//*************************************************************************************************
2133template< typename MT // Type of the adapted dense matrix
2134 , bool SO > // Storage order of the adapted dense matrix
2135inline size_t StrictlyLowerMatrix<MT,SO,true>::nonZeros( size_t i ) const
2136{
2137 return matrix_.nonZeros(i);
2138}
2140//*************************************************************************************************
2141
2142
2143//*************************************************************************************************
2149template< typename MT // Type of the adapted dense matrix
2150 , bool SO > // Storage order of the adapted dense matrix
2152{
2153 using blaze::clear;
2154
2155 if( SO ) {
2156 for( size_t j=0UL; j<columns(); ++j )
2157 for( size_t i=j+1UL; i<rows(); ++i )
2158 clear( matrix_(i,j) );
2159 }
2160 else {
2161 for( size_t i=1UL; i<rows(); ++i )
2162 for( size_t j=0UL; j<i; ++j )
2163 clear( matrix_(i,j) );
2164 }
2165}
2167//*************************************************************************************************
2168
2169
2170//*************************************************************************************************
2183template< typename MT // Type of the adapted dense matrix
2184 , bool SO > // Storage order of the adapted dense matrix
2185inline void StrictlyLowerMatrix<MT,SO,true>::reset( size_t i )
2186{
2187 using blaze::clear;
2188
2189 if( SO ) {
2190 for( size_t j=i+1UL; j<rows(); ++j )
2191 clear( matrix_(j,i) );
2192 }
2193 else {
2194 for( size_t j=0UL; j<i; ++j )
2195 clear( matrix_(i,j) );
2196 }
2197}
2199//*************************************************************************************************
2200
2201
2202//*************************************************************************************************
2214template< typename MT // Type of the adapted dense matrix
2215 , bool SO > // Storage order of the adapted dense matrix
2217{
2218 matrix_.clear();
2219
2220 BLAZE_INTERNAL_ASSERT( matrix_.rows() == 0UL, "Invalid number of rows" );
2221 BLAZE_INTERNAL_ASSERT( matrix_.columns() == 0UL, "Invalid number of columns" );
2222}
2224//*************************************************************************************************
2225
2226
2227//*************************************************************************************************
2263template< typename MT // Type of the adapted dense matrix
2264 , bool SO > // Storage order of the adapted dense matrix
2265void StrictlyLowerMatrix<MT,SO,true>::resize( size_t n, bool preserve )
2266{
2268
2269 MAYBE_UNUSED( preserve );
2270
2271 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square strictly lower matrix detected" );
2272
2273 const size_t oldsize( matrix_.rows() );
2274
2275 matrix_.resize( n, n, true );
2276
2277 if( n > oldsize )
2278 {
2279 const size_t increment( n - oldsize );
2280 submatrix( matrix_, 0UL, oldsize, n, increment ).reset();
2281 }
2282}
2284//*************************************************************************************************
2285
2286
2287//*************************************************************************************************
2300template< typename MT // Type of the adapted dense matrix
2301 , bool SO > // Storage order of the adapted dense matrix
2302inline void StrictlyLowerMatrix<MT,SO,true>::extend( size_t n, bool preserve )
2303{
2305
2306 MAYBE_UNUSED( preserve );
2307
2308 resize( rows() + n, true );
2309}
2310//*************************************************************************************************
2311
2312
2313//*************************************************************************************************
2323template< typename MT // Type of the adapted dense matrix
2324 , bool SO > // Storage order of the adapted dense matrix
2325inline void StrictlyLowerMatrix<MT,SO,true>::reserve( size_t elements )
2326{
2327 matrix_.reserve( elements );
2328}
2330//*************************************************************************************************
2331
2332
2333//*************************************************************************************************
2343template< typename MT // Type of the adapted dense matrix
2344 , bool SO > // Storage order of the adapted dense matrix
2346{
2347 matrix_.shrinkToFit();
2348}
2350//*************************************************************************************************
2351
2352
2353//*************************************************************************************************
2360template< typename MT // Type of the adapted dense matrix
2361 , bool SO > // Storage order of the adapted dense matrix
2362inline void StrictlyLowerMatrix<MT,SO,true>::swap( StrictlyLowerMatrix& m ) noexcept
2363{
2364 using std::swap;
2365
2366 swap( matrix_, m.matrix_ );
2367}
2369//*************************************************************************************************
2370
2371
2372//*************************************************************************************************
2384template< typename MT // Type of the adapted dense matrix
2385 , bool SO > // Storage order of the adapted dense matrix
2386constexpr size_t StrictlyLowerMatrix<MT,SO,true>::maxNonZeros() noexcept
2387{
2389
2390 return maxNonZeros( Size_v<MT,0UL> );
2391}
2393//*************************************************************************************************
2394
2395
2396//*************************************************************************************************
2406template< typename MT // Type of the adapted dense matrix
2407 , bool SO > // Storage order of the adapted dense matrix
2408constexpr size_t StrictlyLowerMatrix<MT,SO,true>::maxNonZeros( size_t n ) noexcept
2409{
2410 return ( ( n - 1UL ) * n ) / 2UL;
2411}
2413//*************************************************************************************************
2414
2415
2416
2417
2418//=================================================================================================
2419//
2420// NUMERIC FUNCTIONS
2421//
2422//=================================================================================================
2423
2424//*************************************************************************************************
2442template< typename MT // Type of the adapted dense matrix
2443 , bool SO > // Storage order of the adapted dense matrix
2444template< typename Other > // Data type of the scalar value
2445inline StrictlyLowerMatrix<MT,SO,true>&
2446 StrictlyLowerMatrix<MT,SO,true>::scale( const Other& scalar )
2447{
2448 matrix_.scale( scalar );
2449 return *this;
2450}
2452//*************************************************************************************************
2453
2454
2455
2456
2457//=================================================================================================
2458//
2459// DEBUGGING FUNCTIONS
2460//
2461//=================================================================================================
2462
2463//*************************************************************************************************
2473template< typename MT // Type of the adapted dense matrix
2474 , bool SO > // Storage order of the adapted dense matrix
2475inline bool StrictlyLowerMatrix<MT,SO,true>::isIntact() const noexcept
2476{
2477 using blaze::isIntact;
2478
2479 return ( isIntact( matrix_ ) && isStrictlyLower( matrix_ ) );
2480}
2482//*************************************************************************************************
2483
2484
2485
2486
2487//=================================================================================================
2488//
2489// EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2490//
2491//=================================================================================================
2492
2493//*************************************************************************************************
2504template< typename MT // Type of the adapted dense matrix
2505 , bool SO > // Storage order of the adapted dense matrix
2506template< typename Other > // Data type of the foreign expression
2507inline bool StrictlyLowerMatrix<MT,SO,true>::canAlias( const Other* alias ) const noexcept
2508{
2509 return matrix_.canAlias( alias );
2510}
2512//*************************************************************************************************
2513
2514
2515//*************************************************************************************************
2526template< typename MT // Type of the adapted dense matrix
2527 , bool SO > // Storage order of the adapted dense matrix
2528template< typename Other > // Data type of the foreign expression
2529inline bool StrictlyLowerMatrix<MT,SO,true>::isAliased( const Other* alias ) const noexcept
2530{
2531 return matrix_.isAliased( alias );
2532}
2534//*************************************************************************************************
2535
2536
2537//*************************************************************************************************
2547template< typename MT // Type of the adapted dense matrix
2548 , bool SO > // Storage order of the adapted dense matrix
2549inline bool StrictlyLowerMatrix<MT,SO,true>::isAligned() const noexcept
2550{
2551 return matrix_.isAligned();
2552}
2554//*************************************************************************************************
2555
2556
2557//*************************************************************************************************
2568template< typename MT // Type of the adapted dense matrix
2569 , bool SO > // Storage order of the adapted dense matrix
2570inline bool StrictlyLowerMatrix<MT,SO,true>::canSMPAssign() const noexcept
2571{
2572 return matrix_.canSMPAssign();
2573}
2575//*************************************************************************************************
2576
2577
2578//*************************************************************************************************
2594template< typename MT // Type of the adapted dense matrix
2595 , bool SO > // Storage order of the adapted dense matrix
2596BLAZE_ALWAYS_INLINE typename StrictlyLowerMatrix<MT,SO,true>::SIMDType
2597 StrictlyLowerMatrix<MT,SO,true>::load( size_t i, size_t j ) const noexcept
2598{
2599 return matrix_.load( i, j );
2600}
2602//*************************************************************************************************
2603
2604
2605//*************************************************************************************************
2621template< typename MT // Type of the adapted dense matrix
2622 , bool SO > // Storage order of the adapted dense matrix
2623BLAZE_ALWAYS_INLINE typename StrictlyLowerMatrix<MT,SO,true>::SIMDType
2624 StrictlyLowerMatrix<MT,SO,true>::loada( size_t i, size_t j ) const noexcept
2625{
2626 return matrix_.loada( i, j );
2627}
2629//*************************************************************************************************
2630
2631
2632//*************************************************************************************************
2648template< typename MT // Type of the adapted dense matrix
2649 , bool SO > // Storage order of the adapted dense matrix
2650BLAZE_ALWAYS_INLINE typename StrictlyLowerMatrix<MT,SO,true>::SIMDType
2651 StrictlyLowerMatrix<MT,SO,true>::loadu( size_t i, size_t j ) const noexcept
2652{
2653 return matrix_.loadu( i, j );
2654}
2656//*************************************************************************************************
2657
2658
2659
2660
2661//=================================================================================================
2662//
2663// CONSTRUCTION FUNCTIONS
2664//
2665//=================================================================================================
2666
2667//*************************************************************************************************
2674template< typename MT // Type of the adapted dense matrix
2675 , bool SO > // Storage order of the adapted dense matrix
2676inline const MT StrictlyLowerMatrix<MT,SO,true>::construct( size_t n, TrueType )
2677{
2679
2680 return MT( n, n, ElementType() );
2681}
2683//*************************************************************************************************
2684
2685
2686//*************************************************************************************************
2693template< typename MT // Type of the adapted dense matrix
2694 , bool SO > // Storage order of the adapted dense matrix
2695inline const MT StrictlyLowerMatrix<MT,SO,true>::construct( const ElementType& init, FalseType )
2696{
2699
2700 MT tmp;
2701
2702 if( SO ) {
2703 for( size_t j=0UL; j<tmp.columns(); ++j ) {
2704 for( size_t i=j+1UL; i<tmp.rows(); ++i )
2705 tmp(i,j) = init;
2706 }
2707 }
2708 else {
2709 for( size_t i=0UL; i<tmp.rows(); ++i ) {
2710 for( size_t j=0UL; j<i; ++j )
2711 tmp(i,j) = init;
2712 }
2713 }
2714
2715 return tmp;
2716}
2718//*************************************************************************************************
2719
2720
2721//*************************************************************************************************
2732template< typename MT // Type of the adapted dense matrix
2733 , bool SO > // Storage order of the adapted dense matrix
2734template< typename MT2 // Type of the foreign matrix
2735 , bool SO2 // Storage order of the foreign matrix
2736 , typename T > // Type of the third argument
2737inline const MT StrictlyLowerMatrix<MT,SO,true>::construct( const Matrix<MT2,SO2>& m, T )
2738{
2739 const MT tmp( *m );
2740
2741 if( IsUniTriangular_v<MT2> ||
2742 ( !IsStrictlyLower_v<MT2> && !isStrictlyLower( tmp ) ) ) {
2743 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of strictly lower matrix" );
2744 }
2745
2746 return tmp;
2747}
2749//*************************************************************************************************
2750
2751} // namespace blaze
2752
2753#endif
Header file for auxiliary alias declarations.
Header file for run time assertion macros.
Constraint on the data type.
constexpr const DenseIterator< Type, AF > operator-(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Subtraction between a DenseIterator and an integral value.
Definition: DenseIterator.h:751
constexpr const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:719
Header file for the EnableIf class template.
Constraint on the data type.
Header file for the IntegralConstant class template.
Header file for the IsComputation type trait class.
Header file for the isDefault shim.
Header file for the IsResizable type trait.
Header file for the IsScalar type trait.
Header file for the IsSquare type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsUniTriangular type trait.
Constraint on the data type.
Header file for the MAYBE_UNUSED function template.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Compile time assertion.
Constraint on the data type.
Header file for the StrictlyLowerProxy class.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the implementation of the base template of the StrictlyLowerMatrix.
Initializer list type of the Blaze library.
Pointer difference type of the Blaze library.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for utility functions for dense matrices.
Header file for the implementation of a matrix representation of an initializer list.
Header file for the DenseMatrix base class.
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:137
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.
Definition: Volatile.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.
Definition: Pointer.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.
Definition: Const.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.
Definition: Reference.h:79
auto operator/=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Division assignment operator for the division of a dense matrix by a scalar value ( ).
Definition: DenseMatrix.h:574
bool isStrictlyLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a strictly lower triangular matrix.
Definition: DenseMatrix.h:2096
MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:182
auto operator+=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Addition assignment operator for the addition of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:386
auto operator*=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:510
size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:265
decltype(auto) decllow(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as lower.
Definition: DMatDeclLowExpr.h:1004
decltype(auto) operator*(const DenseMatrix< MT1, false > &lhs, const DenseMatrix< MT2, false > &rhs)
Multiplication operator for the multiplication of two row-major dense matrices ( ).
Definition: DMatDMatMultExpr.h:9640
auto operator-=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Subtraction assignment operator for the subtraction of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:448
bool isZero(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a zero matrix.
Definition: DenseMatrix.h:1819
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:207
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:225
decltype(auto) elements(Vector< VT, TF > &vector, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:143
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VIEW_TYPE(T)
Constraint on the data type.
Definition: View.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Hermitian.h:79
#define BLAZE_CONSTRAINT_MUST_BE_SQUARE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Square.h:60
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Upper.h:81
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_RESIZABLE_TYPE(T)
Constraint on the data type.
Definition: Resizable.h:81
#define BLAZE_CONSTRAINT_MUST_BE_STATIC_TYPE(T)
Constraint on the data type.
Definition: Static.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(T)
Constraint on the data type.
Definition: Resizable.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T)
Constraint on the data type.
Definition: Transformation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.
Definition: StorageOrder.h:63
constexpr bool IsScalar_v
Auxiliary variable template for the IsScalar type trait.
Definition: IsScalar.h:104
constexpr ptrdiff_t Size_v
Auxiliary variable template for the Size type trait.
Definition: Size.h:176
constexpr bool IsComputation_v
Auxiliary variable template for the IsComputation type trait.
Definition: IsComputation.h:90
constexpr bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:370
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:253
constexpr bool operator<(const NegativeAccuracy< A > &lhs, const T &rhs)
Less-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:332
constexpr 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:446
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
constexpr 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:408
constexpr void clear(Matrix< MT, SO > &matrix)
Clearing the given matrix.
Definition: Matrix.h:960
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:628
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:644
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:730
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:562
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:692
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:660
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:1108
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:584
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:518
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:1169
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:1383
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:137
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition: Assert.h:117
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loadu(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loadu.h:76
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > loada(const T *address) noexcept
Loads a vector of 1-byte integral values.
Definition: Loada.h:79
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.
Definition: StaticAssert.h:112
decltype(auto) submatrix(Matrix< MT, SO > &, RSAs...)
Creating a view on a specific submatrix of the given matrix.
Definition: Submatrix.h:181
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
BoolConstant< true > TrueType
Type traits base class.
Definition: IntegralConstant.h:132
BoolConstant< false > FalseType
Type/value traits base class.
Definition: IntegralConstant.h:121
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
typename EnableIf<!Condition, T >::Type DisableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:175
Header file for the exception macros of the math module.
Header file for the extended initializer_list functionality.
Header file for all adaptor forward declarations.
Constraints on the storage order of matrix types.
Header file for the Size type trait.
Header file for the clear shim.
Header file for the isZero shim.
System settings for the inline keywords.
Header file for basic type definitions.
Header file for the implementation of the Submatrix view.