Blaze 3.9
Dense.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_ADAPTORS_UNILOWERMATRIX_DENSE_H_
36#define _BLAZE_MATH_ADAPTORS_UNILOWERMATRIX_DENSE_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <iterator>
44#include <utility>
48#include <blaze/math/Aliases.h>
81#include <blaze/system/Inline.h>
82#include <blaze/util/Assert.h>
88#include <blaze/util/EnableIf.h>
92#include <blaze/util/Types.h>
93
94
95namespace blaze {
96
97//=================================================================================================
98//
99// CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES
100//
101//=================================================================================================
102
103//*************************************************************************************************
111template< typename MT // Type of the adapted dense matrix
112 , bool SO > // Storage order of the adapted dense matrix
113class UniLowerMatrix<MT,SO,true>
114 : public DenseMatrix< UniLowerMatrix<MT,SO,true>, SO >
115{
116 private:
117 //**Type definitions****************************************************************************
118 using OT = OppositeType_t<MT>;
119 using TT = TransposeType_t<MT>;
120 using ET = ElementType_t<MT>;
121 //**********************************************************************************************
122
123 public:
124 //**Type definitions****************************************************************************
125 using This = UniLowerMatrix<MT,SO,true>;
126 using BaseType = DenseMatrix<This,SO>;
127 using ResultType = This;
128 using OppositeType = UniLowerMatrix<OT,!SO,true>;
129 using TransposeType = UniUpperMatrix<TT,!SO,true>;
130 using ElementType = ET;
131 using SIMDType = SIMDType_t<MT>;
132 using TagType = TagType_t<MT>;
133 using ReturnType = ReturnType_t<MT>;
134 using CompositeType = const This&;
135 using Reference = UniLowerProxy<MT>;
136 using ConstReference = ConstReference_t<MT>;
137 using Pointer = Pointer_t<MT>;
138 using ConstPointer = ConstPointer_t<MT>;
139 using ConstIterator = ConstIterator_t<MT>;
140 //**********************************************************************************************
141
142 //**Rebind struct definition********************************************************************
145 template< typename NewType > // Data type of the other matrix
146 struct Rebind {
148 using Other = UniLowerMatrix< typename MT::template Rebind<NewType>::Other >;
149 };
150 //**********************************************************************************************
151
152 //**Resize struct definition********************************************************************
155 template< size_t NewM // Number of rows of the other matrix
156 , size_t NewN > // Number of columns of the other matrix
157 struct Resize {
159 using Other = UniLowerMatrix< typename MT::template Resize<NewM,NewN>::Other >;
160 };
161 //**********************************************************************************************
162
163 //**Iterator class definition*******************************************************************
166 class Iterator
167 {
168 public:
169 //**Type definitions*************************************************************************
170 using IteratorCategory = std::random_access_iterator_tag;
171 using ValueType = ElementType_t<MT>;
172 using PointerType = UniLowerProxy<MT>;
173 using ReferenceType = UniLowerProxy<MT>;
174 using DifferenceType = ptrdiff_t;
175
176 // STL iterator requirements
177 using iterator_category = IteratorCategory;
178 using value_type = ValueType;
179 using pointer = PointerType;
180 using reference = ReferenceType;
181 using difference_type = DifferenceType;
182 //*******************************************************************************************
183
184 //**Constructor******************************************************************************
187 inline Iterator() noexcept
188 : matrix_( nullptr ) // Reference to the adapted dense matrix
189 , row_ ( 0UL ) // The current row index of the iterator
190 , column_( 0UL ) // The current column index of the iterator
191 {}
192 //*******************************************************************************************
193
194 //**Constructor******************************************************************************
201 inline Iterator( MT& matrix, size_t row, size_t column ) noexcept
202 : matrix_( &matrix ) // Reference to the adapted dense matrix
203 , row_ ( row ) // The current row-index of the iterator
204 , column_( column ) // The current column-index of the iterator
205 {}
206 //*******************************************************************************************
207
208 //**Addition assignment operator*************************************************************
214 inline Iterator& operator+=( size_t inc ) noexcept {
215 ( SO )?( row_ += inc ):( column_ += inc );
216 return *this;
217 }
218 //*******************************************************************************************
219
220 //**Subtraction assignment operator**********************************************************
226 inline Iterator& operator-=( size_t dec ) noexcept {
227 ( SO )?( row_ -= dec ):( column_ -= dec );
228 return *this;
229 }
230 //*******************************************************************************************
231
232 //**Prefix increment operator****************************************************************
237 inline Iterator& operator++() noexcept {
238 ( SO )?( ++row_ ):( ++column_ );
239 return *this;
240 }
241 //*******************************************************************************************
242
243 //**Postfix increment operator***************************************************************
248 inline const Iterator operator++( int ) noexcept {
249 const Iterator tmp( *this );
250 ++(*this);
251 return tmp;
252 }
253 //*******************************************************************************************
254
255 //**Prefix decrement operator****************************************************************
260 inline Iterator& operator--() noexcept {
261 ( SO )?( --row_ ):( --column_ );
262 return *this;
263 }
264 //*******************************************************************************************
265
266 //**Postfix decrement operator***************************************************************
271 inline const Iterator operator--( int ) noexcept {
272 const Iterator tmp( *this );
273 --(*this);
274 return tmp;
275 }
276 //*******************************************************************************************
277
278 //**Element access operator******************************************************************
283 inline ReferenceType operator*() const {
284 return ReferenceType( *matrix_, row_, column_ );
285 }
286 //*******************************************************************************************
287
288 //**Element access operator******************************************************************
293 inline PointerType operator->() const {
294 return PointerType( *matrix_, row_, column_ );
295 }
296 //*******************************************************************************************
297
298 //**Load function****************************************************************************
308 inline SIMDType load() const {
309 return (*matrix_).load(row_,column_);
310 }
311 //*******************************************************************************************
312
313 //**Loada function***************************************************************************
323 inline SIMDType loada() const {
324 return (*matrix_).loada(row_,column_);
325 }
326 //*******************************************************************************************
327
328 //**Loadu function***************************************************************************
338 inline SIMDType loadu() const {
339 return (*matrix_).loadu(row_,column_);
340 }
341 //*******************************************************************************************
342
343 //**Conversion operator**********************************************************************
348 inline operator ConstIterator() const {
349 if( SO )
350 return matrix_->begin( column_ ) + row_;
351 else
352 return matrix_->begin( row_ ) + column_;
353 }
354 //*******************************************************************************************
355
356 //**Equality operator************************************************************************
363 friend inline bool operator==( const Iterator& lhs, const Iterator& rhs ) noexcept {
364 return ( SO )?( lhs.row_ == rhs.row_ ):( lhs.column_ == rhs.column_ );
365 }
366 //*******************************************************************************************
367
368 //**Equality operator************************************************************************
375 friend inline bool operator==( const Iterator& lhs, const ConstIterator& rhs ) noexcept {
376 return ( ConstIterator( lhs ) == rhs );
377 }
378 //*******************************************************************************************
379
380 //**Equality operator************************************************************************
387 friend inline bool operator==( const ConstIterator& lhs, const Iterator& rhs ) noexcept {
388 return ( lhs == ConstIterator( rhs ) );
389 }
390 //*******************************************************************************************
391
392 //**Inequality operator**********************************************************************
399 friend inline bool operator!=( const Iterator& lhs, const Iterator& rhs ) noexcept {
400 return ( SO )?( lhs.row_ != rhs.row_ ):( lhs.column_ != rhs.column_ );
401 }
402 //*******************************************************************************************
403
404 //**Inequality operator**********************************************************************
411 friend inline bool operator!=( const Iterator& lhs, const ConstIterator& rhs ) {
412 return ( ConstIterator( lhs ) != rhs );
413 }
414 //*******************************************************************************************
415
416 //**Inequality operator**********************************************************************
423 friend inline bool operator!=( const ConstIterator& lhs, const Iterator& rhs ) {
424 return ( lhs != ConstIterator( rhs ) );
425 }
426 //*******************************************************************************************
427
428 //**Less-than operator***********************************************************************
435 friend inline bool operator<( const Iterator& lhs, const Iterator& rhs ) noexcept {
436 return ( SO )?( lhs.row_ < rhs.row_ ):( lhs.column_ < rhs.column_ );
437 }
438 //*******************************************************************************************
439
440 //**Less-than operator***********************************************************************
447 friend inline bool operator<( const Iterator& lhs, const ConstIterator& rhs ) {
448 return ( ConstIterator( lhs ) < rhs );
449 }
450 //*******************************************************************************************
451
452 //**Less-than operator***********************************************************************
459 friend inline bool operator<( const ConstIterator& lhs, const Iterator& rhs ) {
460 return ( lhs < ConstIterator( rhs ) );
461 }
462 //*******************************************************************************************
463
464 //**Greater-than operator********************************************************************
471 friend inline bool operator>( const Iterator& lhs, const Iterator& rhs ) noexcept {
472 return ( SO )?( lhs.row_ > rhs.row_ ):( lhs.column_ > rhs.column_ );
473 }
474 //*******************************************************************************************
475
476 //**Greater-than operator********************************************************************
483 friend inline bool operator>( const Iterator& lhs, const ConstIterator& rhs ) {
484 return ( ConstIterator( lhs ) > rhs );
485 }
486 //*******************************************************************************************
487
488 //**Greater-than operator********************************************************************
495 friend inline bool operator>( const ConstIterator& lhs, const Iterator& rhs ) {
496 return ( lhs > ConstIterator( rhs ) );
497 }
498 //*******************************************************************************************
499
500 //**Less-or-equal-than operator**************************************************************
507 friend inline bool operator<=( const Iterator& lhs, const Iterator& rhs ) noexcept {
508 return ( SO )?( lhs.row_ <= rhs.row_ ):( lhs.column_ <= rhs.column_ );
509 }
510 //*******************************************************************************************
511
512 //**Less-or-equal-than operator**************************************************************
519 friend inline bool operator<=( const Iterator& lhs, const ConstIterator& rhs ) {
520 return ( ConstIterator( lhs ) <= rhs );
521 }
522 //*******************************************************************************************
523
524 //**Less-or-equal-than operator**************************************************************
531 friend inline bool operator<=( const ConstIterator& lhs, const Iterator& rhs ) {
532 return ( lhs <= ConstIterator( rhs ) );
533 }
534 //*******************************************************************************************
535
536 //**Greater-or-equal-than operator***********************************************************
543 friend inline bool operator>=( const Iterator& lhs, const Iterator& rhs ) noexcept {
544 return ( SO )?( lhs.row_ >= rhs.row_ ):( lhs.column_ >= rhs.column_ );
545 }
546 //*******************************************************************************************
547
548 //**Greater-or-equal-than operator***********************************************************
555 friend inline bool operator>=( const Iterator& lhs, const ConstIterator& rhs ) {
556 return ( ConstIterator( lhs ) >= rhs );
557 }
558 //*******************************************************************************************
559
560 //**Greater-or-equal-than operator***********************************************************
567 friend inline bool operator>=( const ConstIterator& lhs, const Iterator& rhs ) {
568 return ( lhs >= ConstIterator( rhs ) );
569 }
570 //*******************************************************************************************
571
572 //**Subtraction operator*********************************************************************
578 inline DifferenceType operator-( const Iterator& rhs ) const noexcept {
579 return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
580 }
581 //*******************************************************************************************
582
583 //**Addition operator************************************************************************
590 friend inline const Iterator operator+( const Iterator& it, size_t inc ) noexcept {
591 if( SO )
592 return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
593 else
594 return Iterator( *it.matrix_, it.row_, it.column_ + inc );
595 }
596 //*******************************************************************************************
597
598 //**Addition operator************************************************************************
605 friend inline const Iterator operator+( size_t inc, const Iterator& it ) noexcept {
606 if( SO )
607 return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
608 else
609 return Iterator( *it.matrix_, it.row_, it.column_ + inc );
610 }
611 //*******************************************************************************************
612
613 //**Subtraction operator*********************************************************************
620 friend inline const Iterator operator-( const Iterator& it, size_t dec ) noexcept {
621 if( SO )
622 return Iterator( *it.matrix_, it.row_ - dec, it.column_ );
623 else
624 return Iterator( *it.matrix_, it.row_, it.column_ - dec );
625 }
626 //*******************************************************************************************
627
628 private:
629 //**Member variables*************************************************************************
630 MT* matrix_;
631 size_t row_;
632 size_t column_;
633 //*******************************************************************************************
634 };
635 //**********************************************************************************************
636
637 //**Compilation flags***************************************************************************
639 static constexpr bool simdEnabled = MT::simdEnabled;
640
642 static constexpr bool smpAssignable = MT::smpAssignable;
643 //**********************************************************************************************
644
645 //**Constructors********************************************************************************
648 inline UniLowerMatrix();
649 template< typename A1 > explicit inline UniLowerMatrix( const A1& a1 );
650 inline UniLowerMatrix( size_t n, const ElementType& init );
651
652 inline UniLowerMatrix( initializer_list< initializer_list<ElementType> > list );
653
654 template< typename Other >
655 inline UniLowerMatrix( size_t n, const Other* array );
656
657 template< typename Other, size_t N >
658 inline UniLowerMatrix( const Other (&array)[N][N] );
659
660 inline UniLowerMatrix( ElementType* ptr, size_t n );
661 inline UniLowerMatrix( ElementType* ptr, size_t n, size_t nn );
662
663 inline UniLowerMatrix( const UniLowerMatrix& m );
664 inline UniLowerMatrix( UniLowerMatrix&& m ) noexcept;
666 //**********************************************************************************************
667
668 //**Destructor**********************************************************************************
671 ~UniLowerMatrix() = default;
673 //**********************************************************************************************
674
675 //**Data access functions***********************************************************************
678 inline Reference operator()( size_t i, size_t j );
679 inline ConstReference operator()( size_t i, size_t j ) const;
680 inline Reference at( size_t i, size_t j );
681 inline ConstReference at( size_t i, size_t j ) const;
682 inline ConstPointer data () const noexcept;
683 inline ConstPointer data ( size_t i ) const noexcept;
684 inline Iterator begin ( size_t i );
685 inline ConstIterator begin ( size_t i ) const;
686 inline ConstIterator cbegin( size_t i ) const;
687 inline Iterator end ( size_t i );
688 inline ConstIterator end ( size_t i ) const;
689 inline ConstIterator cend ( size_t i ) const;
691 //**********************************************************************************************
692
693 //**Assignment operators************************************************************************
696 inline UniLowerMatrix& operator=( const ElementType& rhs );
697 inline UniLowerMatrix& operator=( initializer_list< initializer_list<ElementType> > list );
698
699 template< typename Other, size_t N >
700 inline UniLowerMatrix& operator=( const Other (&array)[N][N] );
701
702 inline UniLowerMatrix& operator=( const UniLowerMatrix& rhs );
703 inline UniLowerMatrix& operator=( UniLowerMatrix&& rhs ) noexcept;
704
705 template< typename MT2, bool SO2 >
706 inline auto operator=( const Matrix<MT2,SO2>& rhs )
707 -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
708
709 template< typename MT2, bool SO2 >
710 inline auto operator=( const Matrix<MT2,SO2>& rhs )
711 -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
712
713 template< typename MT2, bool SO2 >
714 inline auto operator+=( const Matrix<MT2,SO2>& rhs )
715 -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
716
717 template< typename MT2, bool SO2 >
718 inline auto operator+=( const Matrix<MT2,SO2>& rhs )
719 -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
720
721 template< typename MT2, bool SO2 >
722 inline auto operator-=( const Matrix<MT2,SO2>& rhs )
723 -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
724
725 template< typename MT2, bool SO2 >
726 inline auto operator-=( const Matrix<MT2,SO2>& rhs )
727 -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
728
729 template< typename MT2, bool SO2 >
730 inline auto operator%=( const Matrix<MT2,SO2>& rhs ) -> UniLowerMatrix&;
732 //**********************************************************************************************
733
734 //**Utility functions***************************************************************************
737 inline size_t rows() const noexcept;
738 inline size_t columns() const noexcept;
739 inline size_t spacing() const noexcept;
740 inline size_t capacity() const noexcept;
741 inline size_t capacity( size_t i ) const noexcept;
742 inline size_t nonZeros() const;
743 inline size_t nonZeros( size_t i ) const;
744 inline void reset();
745 inline void reset( size_t i );
746 inline void clear();
747 void resize ( size_t n, bool preserve=true );
748 inline void extend ( size_t n, bool preserve=true );
749 inline void reserve( size_t elements );
750 inline void shrinkToFit();
751 inline void swap( UniLowerMatrix& m ) noexcept;
752
753 static constexpr size_t maxNonZeros() noexcept;
754 static constexpr size_t maxNonZeros( size_t n ) noexcept;
756 //**********************************************************************************************
757
758 //**Debugging functions*************************************************************************
761 inline bool isIntact() const noexcept;
763 //**********************************************************************************************
764
765 //**Expression template evaluation functions****************************************************
768 template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
769 template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
770
771 inline bool isAligned () const noexcept;
772 inline bool canSMPAssign() const noexcept;
773
774 BLAZE_ALWAYS_INLINE SIMDType load ( size_t i, size_t j ) const noexcept;
775 BLAZE_ALWAYS_INLINE SIMDType loada( size_t i, size_t j ) const noexcept;
776 BLAZE_ALWAYS_INLINE SIMDType loadu( size_t i, size_t j ) const noexcept;
778 //**********************************************************************************************
779
780 private:
781 //**Construction functions**********************************************************************
784 inline const MT construct( size_t n , TrueType );
785 inline const MT construct( const ElementType& value, FalseType );
786
787 template< typename MT2, bool SO2, typename T >
788 inline const MT construct( const Matrix<MT2,SO2>& m, T );
790 //**********************************************************************************************
791
792 //**Member variables****************************************************************************
795 MT matrix_;
797 //**********************************************************************************************
798
799 //**Friend declarations*************************************************************************
800 template< typename MT2, bool SO2, bool DF2 >
801 friend MT2& derestrict( UniLowerMatrix<MT2,SO2,DF2>& m );
802 //**********************************************************************************************
803
804 //**Compile time checks*************************************************************************
821 BLAZE_STATIC_ASSERT( ( Size_v<MT,0UL> == Size_v<MT,1UL> ) );
822 //**********************************************************************************************
823};
825//*************************************************************************************************
826
827
828
829
830//=================================================================================================
831//
832// CONSTRUCTORS
833//
834//=================================================================================================
835
836//*************************************************************************************************
840template< typename MT // Type of the adapted dense matrix
841 , bool SO > // Storage order of the adapted dense matrix
842inline UniLowerMatrix<MT,SO,true>::UniLowerMatrix()
843 : matrix_() // The adapted dense matrix
844{
845 for( size_t i=0UL; i<rows(); ++i )
846 matrix_(i,i) = ElementType(1);
847
848 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
849 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
850}
852//*************************************************************************************************
853
854
855//*************************************************************************************************
873template< typename MT // Type of the adapted dense matrix
874 , bool SO > // Storage order of the adapted dense matrix
875template< typename A1 > // Type of the constructor argument
876inline UniLowerMatrix<MT,SO,true>::UniLowerMatrix( const A1& a1 )
877 : matrix_( construct( a1, IsResizable<MT>() ) ) // The adapted dense matrix
878{
879 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
880 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
881}
883//*************************************************************************************************
884
885
886//*************************************************************************************************
893template< typename MT // Type of the adapted dense matrix
894 , bool SO > // Storage order of the adapted dense matrix
895inline UniLowerMatrix<MT,SO,true>::UniLowerMatrix( size_t n, const ElementType& init )
896 : matrix_( n, n, ElementType() ) // The adapted dense matrix
897{
899
900 if( SO ) {
901 for( size_t j=0UL; j<columns(); ++j ) {
902 matrix_(j,j) = ElementType(1);
903 for( size_t i=j+1UL; i<rows(); ++i )
904 matrix_(i,j) = init;
905 }
906 }
907 else {
908 for( size_t i=0UL; i<rows(); ++i ) {
909 for( size_t j=0UL; j<i; ++j )
910 matrix_(i,j) = init;
911 matrix_(i,i) = ElementType(1);
912 }
913 }
914
915 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
916 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
917}
919//*************************************************************************************************
920
921
922//*************************************************************************************************
946template< typename MT // Type of the adapted dense matrix
947 , bool SO > // Storage order of the adapted dense matrix
948inline UniLowerMatrix<MT,SO,true>::UniLowerMatrix( initializer_list< initializer_list<ElementType> > list )
949 : matrix_( list ) // The adapted dense matrix
950{
951 if( !isUniLower( matrix_ ) ) {
952 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
953 }
954
955 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
956}
958//*************************************************************************************************
959
960
961//*************************************************************************************************
987template< typename MT // Type of the adapted dense matrix
988 , bool SO > // Storage order of the adapted dense matrix
989template< typename Other > // Data type of the initialization array
990inline UniLowerMatrix<MT,SO,true>::UniLowerMatrix( size_t n, const Other* array )
991 : matrix_( n, n, array ) // The adapted dense matrix
992{
993 if( !isUniLower( matrix_ ) ) {
994 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
995 }
996
997 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
998}
1000//*************************************************************************************************
1001
1002
1003//*************************************************************************************************
1026template< typename MT // Type of the adapted dense matrix
1027 , bool SO > // Storage order of the adapted dense matrix
1028template< typename Other // Data type of the initialization array
1029 , size_t N > // Number of rows and columns of the initialization array
1030inline UniLowerMatrix<MT,SO,true>::UniLowerMatrix( const Other (&array)[N][N] )
1031 : matrix_( array ) // The adapted dense matrix
1032{
1033 if( !isUniLower( matrix_ ) ) {
1034 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
1035 }
1036
1037 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1038}
1040//*************************************************************************************************
1041
1042
1043//*************************************************************************************************
1078template< typename MT // Type of the adapted dense matrix
1079 , bool SO > // Storage order of the adapted dense matrix
1080inline UniLowerMatrix<MT,SO,true>::UniLowerMatrix( ElementType* ptr, size_t n )
1081 : matrix_( ptr, n, n ) // The adapted dense matrix
1082{
1083 if( !isUniLower( matrix_ ) ) {
1084 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
1085 }
1086
1087 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1088}
1090//*************************************************************************************************
1091
1092
1093//*************************************************************************************************
1130template< typename MT // Type of the adapted dense matrix
1131 , bool SO > // Storage order of the adapted dense matrix
1132inline UniLowerMatrix<MT,SO,true>::UniLowerMatrix( ElementType* ptr, size_t n, size_t nn )
1133 : matrix_( ptr, n, n, nn ) // The adapted dense matrix
1134{
1135 if( !isUniLower( matrix_ ) ) {
1136 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
1137 }
1138
1139 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1140}
1142//*************************************************************************************************
1143
1144
1145//*************************************************************************************************
1151template< typename MT // Type of the adapted dense matrix
1152 , bool SO > // Storage order of the adapted dense matrix
1153inline UniLowerMatrix<MT,SO,true>::UniLowerMatrix( const UniLowerMatrix& m )
1154 : matrix_( m.matrix_ ) // The adapted dense matrix
1155{
1156 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1157 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1158}
1160//*************************************************************************************************
1161
1162
1163//*************************************************************************************************
1169template< typename MT // Type of the adapted dense matrix
1170 , bool SO > // Storage order of the adapted dense matrix
1171inline UniLowerMatrix<MT,SO,true>::UniLowerMatrix( UniLowerMatrix&& m ) noexcept
1172 : matrix_( std::move( m.matrix_ ) ) // The adapted dense matrix
1173{
1174 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1175 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1176}
1178//*************************************************************************************************
1179
1180
1181
1182
1183//=================================================================================================
1184//
1185// DATA ACCESS FUNCTIONS
1186//
1187//=================================================================================================
1188
1189//*************************************************************************************************
1205template< typename MT // Type of the adapted dense matrix
1206 , bool SO > // Storage order of the adapted dense matrix
1207inline typename UniLowerMatrix<MT,SO,true>::Reference
1208 UniLowerMatrix<MT,SO,true>::operator()( size_t i, size_t j )
1209{
1210 BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1211 BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1212
1213 return Reference( matrix_, i, j );
1214}
1216//*************************************************************************************************
1217
1218
1219//*************************************************************************************************
1235template< typename MT // Type of the adapted dense matrix
1236 , bool SO > // Storage order of the adapted dense matrix
1237inline typename UniLowerMatrix<MT,SO,true>::ConstReference
1238 UniLowerMatrix<MT,SO,true>::operator()( size_t i, size_t j ) const
1239{
1240 BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1241 BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1242
1243 return matrix_(i,j);
1244}
1246//*************************************************************************************************
1247
1248
1249//*************************************************************************************************
1266template< typename MT // Type of the adapted dense matrix
1267 , bool SO > // Storage order of the adapted dense matrix
1268inline typename UniLowerMatrix<MT,SO,true>::Reference
1269 UniLowerMatrix<MT,SO,true>::at( size_t i, size_t j )
1270{
1271 if( i >= rows() ) {
1272 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1273 }
1274 if( j >= columns() ) {
1275 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1276 }
1277 return (*this)(i,j);
1278}
1280//*************************************************************************************************
1281
1282
1283//*************************************************************************************************
1300template< typename MT // Type of the adapted dense matrix
1301 , bool SO > // Storage order of the adapted dense matrix
1302inline typename UniLowerMatrix<MT,SO,true>::ConstReference
1303 UniLowerMatrix<MT,SO,true>::at( size_t i, size_t j ) const
1304{
1305 if( i >= rows() ) {
1306 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1307 }
1308 if( j >= columns() ) {
1309 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1310 }
1311 return (*this)(i,j);
1312}
1314//*************************************************************************************************
1315
1316
1317//*************************************************************************************************
1330template< typename MT // Type of the adapted dense matrix
1331 , bool SO > // Storage order of the adapted dense matrix
1332inline typename UniLowerMatrix<MT,SO,true>::ConstPointer
1333 UniLowerMatrix<MT,SO,true>::data() const noexcept
1334{
1335 return matrix_.data();
1336}
1338//*************************************************************************************************
1339
1340
1341//*************************************************************************************************
1350template< typename MT // Type of the adapted dense matrix
1351 , bool SO > // Storage order of the adapted dense matrix
1352inline typename UniLowerMatrix<MT,SO,true>::ConstPointer
1353 UniLowerMatrix<MT,SO,true>::data( size_t i ) const noexcept
1354{
1355 return matrix_.data(i);
1356}
1358//*************************************************************************************************
1359
1360
1361//*************************************************************************************************
1373template< typename MT // Type of the adapted dense matrix
1374 , bool SO > // Storage order of the adapted dense matrix
1375inline typename UniLowerMatrix<MT,SO,true>::Iterator
1377{
1378 if( SO )
1379 return Iterator( matrix_, 0UL, i );
1380 else
1381 return Iterator( matrix_, i, 0UL );
1382}
1384//*************************************************************************************************
1385
1386
1387//*************************************************************************************************
1399template< typename MT // Type of the adapted dense matrix
1400 , bool SO > // Storage order of the adapted dense matrix
1401inline typename UniLowerMatrix<MT,SO,true>::ConstIterator
1402 UniLowerMatrix<MT,SO,true>::begin( size_t i ) const
1403{
1404 return matrix_.begin(i);
1405}
1407//*************************************************************************************************
1408
1409
1410//*************************************************************************************************
1422template< typename MT // Type of the adapted dense matrix
1423 , bool SO > // Storage order of the adapted dense matrix
1424inline typename UniLowerMatrix<MT,SO,true>::ConstIterator
1425 UniLowerMatrix<MT,SO,true>::cbegin( size_t i ) const
1426{
1427 return matrix_.cbegin(i);
1428}
1430//*************************************************************************************************
1431
1432
1433//*************************************************************************************************
1445template< typename MT // Type of the adapted dense matrix
1446 , bool SO > // Storage order of the adapted dense matrix
1447inline typename UniLowerMatrix<MT,SO,true>::Iterator
1449{
1450 if( SO )
1451 return Iterator( matrix_, rows(), i );
1452 else
1453 return Iterator( matrix_, i, columns() );
1454}
1456//*************************************************************************************************
1457
1458
1459//*************************************************************************************************
1471template< typename MT // Type of the adapted dense matrix
1472 , bool SO > // Storage order of the adapted dense matrix
1473inline typename UniLowerMatrix<MT,SO,true>::ConstIterator
1474 UniLowerMatrix<MT,SO,true>::end( size_t i ) const
1475{
1476 return matrix_.end(i);
1477}
1479//*************************************************************************************************
1480
1481
1482//*************************************************************************************************
1494template< typename MT // Type of the adapted dense matrix
1495 , bool SO > // Storage order of the adapted dense matrix
1496inline typename UniLowerMatrix<MT,SO,true>::ConstIterator
1497 UniLowerMatrix<MT,SO,true>::cend( size_t i ) const
1498{
1499 return matrix_.cend(i);
1500}
1502//*************************************************************************************************
1503
1504
1505
1506
1507//=================================================================================================
1508//
1509// ASSIGNMENT OPERATORS
1510//
1511//=================================================================================================
1512
1513//*************************************************************************************************
1520template< typename MT // Type of the adapted dense matrix
1521 , bool SO > // Storage order of the adapted dense matrix
1522inline UniLowerMatrix<MT,SO,true>&
1523 UniLowerMatrix<MT,SO,true>::operator=( const ElementType& rhs )
1524{
1525 if( SO ) {
1526 for( size_t j=0UL; j<columns(); ++j )
1527 for( size_t i=j+1UL; i<rows(); ++i )
1528 matrix_(i,j) = rhs;
1529 }
1530 else {
1531 for( size_t i=1UL; i<rows(); ++i )
1532 for( size_t j=0UL; j<i; ++j )
1533 matrix_(i,j) = rhs;
1534 }
1535
1536 return *this;
1537}
1539//*************************************************************************************************
1540
1541
1542//*************************************************************************************************
1567template< typename MT // Type of the adapted dense matrix
1568 , bool SO > // Storage order of the adapted dense matrix
1569inline UniLowerMatrix<MT,SO,true>&
1570 UniLowerMatrix<MT,SO,true>::operator=( initializer_list< initializer_list<ElementType> > list )
1571{
1572 const InitializerMatrix<ElementType> tmp( list, list.size() );
1573
1574 if( !isUniLower( tmp ) ) {
1575 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1576 }
1577
1578 matrix_ = list;
1579
1580 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1581 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1582
1583 return *this;
1584}
1586//*************************************************************************************************
1587
1588
1589//*************************************************************************************************
1613template< typename MT // Type of the adapted dense matrix
1614 , bool SO > // Storage order of the adapted dense matrix
1615template< typename Other // Data type of the initialization array
1616 , size_t N > // Number of rows and columns of the initialization array
1617inline UniLowerMatrix<MT,SO,true>&
1618 UniLowerMatrix<MT,SO,true>::operator=( const Other (&array)[N][N] )
1619{
1620 MT tmp( array );
1621
1622 if( !isUniLower( tmp ) ) {
1623 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1624 }
1625
1626 matrix_ = std::move( tmp );
1627
1628 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1629 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1630
1631 return *this;
1632}
1634//*************************************************************************************************
1635
1636
1637//*************************************************************************************************
1647template< typename MT // Type of the adapted dense matrix
1648 , bool SO > // Storage order of the adapted dense matrix
1649inline UniLowerMatrix<MT,SO,true>&
1650 UniLowerMatrix<MT,SO,true>::operator=( const UniLowerMatrix& rhs )
1651{
1652 matrix_ = rhs.matrix_;
1653
1654 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1655 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1656
1657 return *this;
1658}
1660//*************************************************************************************************
1661
1662
1663//*************************************************************************************************
1670template< typename MT // Type of the adapted dense matrix
1671 , bool SO > // Storage order of the adapted dense matrix
1672inline UniLowerMatrix<MT,SO,true>&
1673 UniLowerMatrix<MT,SO,true>::operator=( UniLowerMatrix&& rhs ) noexcept
1674{
1675 matrix_ = std::move( rhs.matrix_ );
1676
1677 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1678 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1679
1680 return *this;
1681}
1683//*************************************************************************************************
1684
1685
1686//*************************************************************************************************
1699template< typename MT // Type of the adapted dense matrix
1700 , bool SO > // Storage order of the adapted dense matrix
1701template< typename MT2 // Type of the right-hand side matrix
1702 , bool SO2 > // Storage order of the right-hand side matrix
1703inline auto UniLowerMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1704 -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1705{
1706 if( IsStrictlyTriangular_v<MT2> || ( !IsUniLower_v<MT2> && !isUniLower( *rhs ) ) ) {
1707 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1708 }
1709
1710 matrix_ = decllow( *rhs );
1711
1712 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1713 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1714
1715 return *this;
1716}
1718//*************************************************************************************************
1719
1720
1721//*************************************************************************************************
1734template< typename MT // Type of the adapted dense matrix
1735 , bool SO > // Storage order of the adapted dense matrix
1736template< typename MT2 // Type of the right-hand side matrix
1737 , bool SO2 > // Storage order of the right-hand side matrix
1738inline auto UniLowerMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1739 -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1740{
1741 if( IsStrictlyTriangular_v<MT2> || ( !IsSquare_v<MT2> && !isSquare( *rhs ) ) ) {
1742 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1743 }
1744
1745 if( IsUniLower_v<MT2> ) {
1746 matrix_ = *rhs;
1747 }
1748 else {
1749 MT tmp( *rhs );
1750
1751 if( !isUniLower( tmp ) ) {
1752 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1753 }
1754
1755 matrix_ = std::move( tmp );
1756 }
1757
1758 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1759 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1760
1761 return *this;
1762}
1764//*************************************************************************************************
1765
1766
1767//*************************************************************************************************
1780template< typename MT // Type of the adapted dense matrix
1781 , bool SO > // Storage order of the adapted dense matrix
1782template< typename MT2 // Type of the right-hand side matrix
1783 , bool SO2 > // Storage order of the right-hand side matrix
1784inline auto UniLowerMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1785 -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1786{
1787 if( IsUpper_v<MT2> || IsUniTriangular_v<MT2> ||
1788 ( !IsStrictlyLower_v<MT2> && !isStrictlyLower( *rhs ) ) ) {
1789 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1790 }
1791
1792 matrix_ += decllow( *rhs );
1793
1794 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1795 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1796
1797 return *this;
1798}
1800//*************************************************************************************************
1801
1802
1803//*************************************************************************************************
1816template< typename MT // Type of the adapted dense matrix
1817 , bool SO > // Storage order of the adapted dense matrix
1818template< typename MT2 // Type of the right-hand side matrix
1819 , bool SO2 > // Storage order of the right-hand side matrix
1820inline auto UniLowerMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1821 -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1822{
1823 if( IsUpper_v<MT2> || IsUniTriangular_v<MT2> ||
1824 ( !IsSquare_v<MT2> && !isSquare( *rhs ) ) ) {
1825 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1826 }
1827
1828 if( IsStrictlyLower_v<MT2> ) {
1829 matrix_ += *rhs;
1830 }
1831 else {
1832 const ResultType_t<MT2> tmp( *rhs );
1833
1834 if( !isStrictlyLower( tmp ) ) {
1835 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1836 }
1837
1838 matrix_ += decllow( tmp );
1839 }
1840
1841 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1842 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1843
1844 return *this;
1845}
1847//*************************************************************************************************
1848
1849
1850//*************************************************************************************************
1863template< typename MT // Type of the adapted dense matrix
1864 , bool SO > // Storage order of the adapted dense matrix
1865template< typename MT2 // Type of the right-hand side matrix
1866 , bool SO2 > // Storage order of the right-hand side matrix
1867inline auto UniLowerMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1868 -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1869{
1870 if( IsUpper_v<MT2> || IsUniTriangular_v<MT2> ||
1871 ( !IsStrictlyLower_v<MT2> && !isStrictlyLower( *rhs ) ) ) {
1872 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1873 }
1874
1875 matrix_ -= decllow( *rhs );
1876
1877 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1878 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1879
1880 return *this;
1881}
1883//*************************************************************************************************
1884
1885
1886//*************************************************************************************************
1899template< typename MT // Type of the adapted dense matrix
1900 , bool SO > // Storage order of the adapted dense matrix
1901template< typename MT2 // Type of the right-hand side matrix
1902 , bool SO2 > // Storage order of the right-hand side matrix
1903inline auto UniLowerMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1904 -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1905{
1906 if( IsUpper_v<MT2> || IsUniTriangular_v<MT2> ||
1907 ( !IsSquare_v<MT2> && !isSquare( *rhs ) ) ) {
1908 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1909 }
1910
1911 if( IsStrictlyLower_v<MT2> ) {
1912 matrix_ -= *rhs;
1913 }
1914 else {
1915 const ResultType_t<MT2> tmp( *rhs );
1916
1917 if( !isStrictlyLower( tmp ) ) {
1918 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1919 }
1920
1921 matrix_ -= decllow( tmp );
1922 }
1923
1924 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1925 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1926
1927 return *this;
1928}
1930//*************************************************************************************************
1931
1932
1933//*************************************************************************************************
1946template< typename MT // Type of the adapted dense matrix
1947 , bool SO > // Storage order of the adapted dense matrix
1948template< typename MT2 // Type of the right-hand side matrix
1949 , bool SO2 > // Storage order of the right-hand side matrix
1950inline auto UniLowerMatrix<MT,SO,true>::operator%=( const Matrix<MT2,SO2>& rhs )
1951 -> UniLowerMatrix&
1952{
1953 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
1954 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1955 }
1956
1957 If_t< IsComputation_v<MT2>, ResultType_t<MT2>, const MT2& > tmp( *rhs );
1958
1959 for( size_t i=0UL; i<(*rhs).rows(); ++i ) {
1960 if( !isOne( tmp(i,i) ) ) {
1961 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1962 }
1963 }
1964
1965 matrix_ %= tmp;
1966
1967 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1968 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1969
1970 return *this;
1971}
1973//*************************************************************************************************
1974
1975
1976
1977
1978//=================================================================================================
1979//
1980// UTILITY FUNCTIONS
1981//
1982//=================================================================================================
1983
1984//*************************************************************************************************
1990template< typename MT // Type of the adapted dense matrix
1991 , bool SO > // Storage order of the adapted dense matrix
1992inline size_t UniLowerMatrix<MT,SO,true>::rows() const noexcept
1993{
1994 return matrix_.rows();
1995}
1997//*************************************************************************************************
1998
1999
2000//*************************************************************************************************
2006template< typename MT // Type of the adapted dense matrix
2007 , bool SO > // Storage order of the adapted dense matrix
2008inline size_t UniLowerMatrix<MT,SO,true>::columns() const noexcept
2009{
2010 return matrix_.columns();
2011}
2013//*************************************************************************************************
2014
2015
2016//*************************************************************************************************
2027template< typename MT // Type of the adapted dense matrix
2028 , bool SO > // Storage order of the adapted dense matrix
2029inline size_t UniLowerMatrix<MT,SO,true>::spacing() const noexcept
2030{
2031 return matrix_.spacing();
2032}
2034//*************************************************************************************************
2035
2036
2037//*************************************************************************************************
2043template< typename MT // Type of the adapted dense matrix
2044 , bool SO > // Storage order of the adapted dense matrix
2045inline size_t UniLowerMatrix<MT,SO,true>::capacity() const noexcept
2046{
2047 return matrix_.capacity();
2048}
2050//*************************************************************************************************
2051
2052
2053//*************************************************************************************************
2065template< typename MT // Type of the adapted dense matrix
2066 , bool SO > // Storage order of the adapted dense matrix
2067inline size_t UniLowerMatrix<MT,SO,true>::capacity( size_t i ) const noexcept
2068{
2069 return matrix_.capacity(i);
2070}
2072//*************************************************************************************************
2073
2074
2075//*************************************************************************************************
2081template< typename MT // Type of the adapted dense matrix
2082 , bool SO > // Storage order of the adapted dense matrix
2083inline size_t UniLowerMatrix<MT,SO,true>::nonZeros() const
2084{
2085 return matrix_.nonZeros();
2086}
2088//*************************************************************************************************
2089
2090
2091//*************************************************************************************************
2103template< typename MT // Type of the adapted dense matrix
2104 , bool SO > // Storage order of the adapted dense matrix
2105inline size_t UniLowerMatrix<MT,SO,true>::nonZeros( size_t i ) const
2106{
2107 return matrix_.nonZeros(i);
2108}
2110//*************************************************************************************************
2111
2112
2113//*************************************************************************************************
2119template< typename MT // Type of the adapted dense matrix
2120 , bool SO > // Storage order of the adapted dense matrix
2122{
2123 using blaze::clear;
2124
2125 if( SO ) {
2126 for( size_t j=0UL; j<columns(); ++j )
2127 for( size_t i=j+1UL; i<rows(); ++i )
2128 clear( matrix_(i,j) );
2129 }
2130 else {
2131 for( size_t i=1UL; i<rows(); ++i )
2132 for( size_t j=0UL; j<i; ++j )
2133 clear( matrix_(i,j) );
2134 }
2135}
2137//*************************************************************************************************
2138
2139
2140//*************************************************************************************************
2153template< typename MT // Type of the adapted dense matrix
2154 , bool SO > // Storage order of the adapted dense matrix
2155inline void UniLowerMatrix<MT,SO,true>::reset( size_t i )
2156{
2157 using blaze::clear;
2158
2159 if( SO ) {
2160 for( size_t j=i+1UL; j<rows(); ++j )
2161 clear( matrix_(j,i) );
2162 }
2163 else {
2164 for( size_t j=0UL; j<i; ++j )
2165 clear( matrix_(i,j) );
2166 }
2167}
2169//*************************************************************************************************
2170
2171
2172//*************************************************************************************************
2184template< typename MT // Type of the adapted dense matrix
2185 , bool SO > // Storage order of the adapted dense matrix
2187{
2188 matrix_.clear();
2189
2190 BLAZE_INTERNAL_ASSERT( matrix_.rows() == 0UL, "Invalid number of rows" );
2191 BLAZE_INTERNAL_ASSERT( matrix_.columns() == 0UL, "Invalid number of columns" );
2192}
2194//*************************************************************************************************
2195
2196
2197//*************************************************************************************************
2233template< typename MT // Type of the adapted dense matrix
2234 , bool SO > // Storage order of the adapted dense matrix
2235void UniLowerMatrix<MT,SO,true>::resize( size_t n, bool preserve )
2236{
2238
2239 MAYBE_UNUSED( preserve );
2240
2241 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
2242
2243 const size_t oldsize( matrix_.rows() );
2244
2245 matrix_.resize( n, n, true );
2246
2247 if( n > oldsize )
2248 {
2249 const size_t increment( n - oldsize );
2250 submatrix( matrix_, 0UL, oldsize, n-1UL, increment ).reset();
2251
2252 for( size_t i=oldsize; i<n; ++i )
2253 matrix_(i,i) = ElementType(1);
2254 }
2255}
2257//*************************************************************************************************
2258
2259
2260//*************************************************************************************************
2273template< typename MT // Type of the adapted dense matrix
2274 , bool SO > // Storage order of the adapted dense matrix
2275inline void UniLowerMatrix<MT,SO,true>::extend( size_t n, bool preserve )
2276{
2278
2279 MAYBE_UNUSED( preserve );
2280
2281 resize( rows() + n, true );
2282}
2283//*************************************************************************************************
2284
2285
2286//*************************************************************************************************
2296template< typename MT // Type of the adapted dense matrix
2297 , bool SO > // Storage order of the adapted dense matrix
2298inline void UniLowerMatrix<MT,SO,true>::reserve( size_t elements )
2299{
2300 matrix_.reserve( elements );
2301}
2303//*************************************************************************************************
2304
2305
2306//*************************************************************************************************
2316template< typename MT // Type of the adapted dense matrix
2317 , bool SO > // Storage order of the adapted dense matrix
2319{
2320 matrix_.shrinkToFit();
2321}
2323//*************************************************************************************************
2324
2325
2326//*************************************************************************************************
2333template< typename MT // Type of the adapted dense matrix
2334 , bool SO > // Storage order of the adapted dense matrix
2335inline void UniLowerMatrix<MT,SO,true>::swap( UniLowerMatrix& m ) noexcept
2336{
2337 using std::swap;
2338
2339 swap( matrix_, m.matrix_ );
2340}
2342//*************************************************************************************************
2343
2344
2345//*************************************************************************************************
2357template< typename MT // Type of the adapted dense matrix
2358 , bool SO > // Storage order of the adapted dense matrix
2359constexpr size_t UniLowerMatrix<MT,SO,true>::maxNonZeros() noexcept
2360{
2362
2363 return maxNonZeros( Size_v<MT,0UL> );
2364}
2366//*************************************************************************************************
2367
2368
2369//*************************************************************************************************
2379template< typename MT // Type of the adapted dense matrix
2380 , bool SO > // Storage order of the adapted dense matrix
2381constexpr size_t UniLowerMatrix<MT,SO,true>::maxNonZeros( size_t n ) noexcept
2382{
2383 return ( ( n + 1UL ) * n ) / 2UL;
2384}
2386//*************************************************************************************************
2387
2388
2389
2390
2391//=================================================================================================
2392//
2393// DEBUGGING FUNCTIONS
2394//
2395//=================================================================================================
2396
2397//*************************************************************************************************
2407template< typename MT // Type of the adapted dense matrix
2408 , bool SO > // Storage order of the adapted dense matrix
2409inline bool UniLowerMatrix<MT,SO,true>::isIntact() const noexcept
2410{
2411 using blaze::isIntact;
2412
2413 return ( isIntact( matrix_ ) && isUniLower( matrix_ ) );
2414}
2416//*************************************************************************************************
2417
2418
2419
2420
2421//=================================================================================================
2422//
2423// EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2424//
2425//=================================================================================================
2426
2427//*************************************************************************************************
2438template< typename MT // Type of the adapted dense matrix
2439 , bool SO > // Storage order of the adapted dense matrix
2440template< typename Other > // Data type of the foreign expression
2441inline bool UniLowerMatrix<MT,SO,true>::canAlias( const Other* alias ) const noexcept
2442{
2443 return matrix_.canAlias( alias );
2444}
2446//*************************************************************************************************
2447
2448
2449//*************************************************************************************************
2460template< typename MT // Type of the adapted dense matrix
2461 , bool SO > // Storage order of the adapted dense matrix
2462template< typename Other > // Data type of the foreign expression
2463inline bool UniLowerMatrix<MT,SO,true>::isAliased( const Other* alias ) const noexcept
2464{
2465 return matrix_.isAliased( alias );
2466}
2468//*************************************************************************************************
2469
2470
2471//*************************************************************************************************
2481template< typename MT // Type of the adapted dense matrix
2482 , bool SO > // Storage order of the adapted dense matrix
2483inline bool UniLowerMatrix<MT,SO,true>::isAligned() const noexcept
2484{
2485 return matrix_.isAligned();
2486}
2488//*************************************************************************************************
2489
2490
2491//*************************************************************************************************
2502template< typename MT // Type of the adapted dense matrix
2503 , bool SO > // Storage order of the adapted dense matrix
2504inline bool UniLowerMatrix<MT,SO,true>::canSMPAssign() const noexcept
2505{
2506 return matrix_.canSMPAssign();
2507}
2509//*************************************************************************************************
2510
2511
2512//*************************************************************************************************
2528template< typename MT // Type of the adapted dense matrix
2529 , bool SO > // Storage order of the adapted dense matrix
2530BLAZE_ALWAYS_INLINE typename UniLowerMatrix<MT,SO,true>::SIMDType
2531 UniLowerMatrix<MT,SO,true>::load( size_t i, size_t j ) const noexcept
2532{
2533 return matrix_.load( i, j );
2534}
2536//*************************************************************************************************
2537
2538
2539//*************************************************************************************************
2555template< typename MT // Type of the adapted dense matrix
2556 , bool SO > // Storage order of the adapted dense matrix
2557BLAZE_ALWAYS_INLINE typename UniLowerMatrix<MT,SO,true>::SIMDType
2558 UniLowerMatrix<MT,SO,true>::loada( size_t i, size_t j ) const noexcept
2559{
2560 return matrix_.loada( i, j );
2561}
2563//*************************************************************************************************
2564
2565
2566//*************************************************************************************************
2582template< typename MT // Type of the adapted dense matrix
2583 , bool SO > // Storage order of the adapted dense matrix
2584BLAZE_ALWAYS_INLINE typename UniLowerMatrix<MT,SO,true>::SIMDType
2585 UniLowerMatrix<MT,SO,true>::loadu( size_t i, size_t j ) const noexcept
2586{
2587 return matrix_.loadu( i, j );
2588}
2590//*************************************************************************************************
2591
2592
2593
2594
2595//=================================================================================================
2596//
2597// CONSTRUCTION FUNCTIONS
2598//
2599//=================================================================================================
2600
2601//*************************************************************************************************
2608template< typename MT // Type of the adapted dense matrix
2609 , bool SO > // Storage order of the adapted dense matrix
2610inline const MT UniLowerMatrix<MT,SO,true>::construct( size_t n, TrueType )
2611{
2613
2614 MT tmp( n, n, ElementType() );
2615
2616 for( size_t i=0UL; i<n; ++i )
2617 tmp(i,i) = ElementType(1);
2618
2619 return tmp;
2620}
2622//*************************************************************************************************
2623
2624
2625//*************************************************************************************************
2632template< typename MT // Type of the adapted dense matrix
2633 , bool SO > // Storage order of the adapted dense matrix
2634inline const MT UniLowerMatrix<MT,SO,true>::construct( const ElementType& init, FalseType )
2635{
2638
2639 MT tmp;
2640
2641 if( SO ) {
2642 for( size_t j=0UL; j<tmp.columns(); ++j ) {
2643 tmp(j,j) = ElementType(1);
2644 for( size_t i=j+1UL; i<tmp.rows(); ++i )
2645 tmp(i,j) = init;
2646 }
2647 }
2648 else {
2649 for( size_t i=0UL; i<tmp.rows(); ++i ) {
2650 for( size_t j=0UL; j<i; ++j )
2651 tmp(i,j) = init;
2652 tmp(i,i) = ElementType(1);
2653 }
2654 }
2655
2656 return tmp;
2657}
2659//*************************************************************************************************
2660
2661
2662//*************************************************************************************************
2673template< typename MT // Type of the adapted dense matrix
2674 , bool SO > // Storage order of the adapted dense matrix
2675template< typename MT2 // Type of the foreign matrix
2676 , bool SO2 // Storage order of the foreign matrix
2677 , typename T > // Type of the third argument
2678inline const MT UniLowerMatrix<MT,SO,true>::construct( const Matrix<MT2,SO2>& m, T )
2679{
2680 const MT tmp( *m );
2681
2682 if( IsStrictlyTriangular_v<MT2> || ( !IsUniLower_v<MT2> && !isUniLower( tmp ) ) ) {
2683 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
2684 }
2685
2686 return tmp;
2687}
2689//*************************************************************************************************
2690
2691} // namespace blaze
2692
2693#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 isOne shim.
Header file for the IsResizable type trait.
Header file for the IsSquare type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyTriangular type trait.
Header file for the IsUniLower type trait.
Header file for the IsUniTriangular type trait.
Header file for the IsUpper 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.
Constraint on the data type.
Compile time assertion.
Constraint on the data type.
Constraint on the data type.
Header file for the UniLowerProxy 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 UniLowerMatrix.
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
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
bool isUniLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower unitriangular matrix.
Definition: DenseMatrix.h:2009
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 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_UNIFORM_TYPE(T)
Constraint on the data type.
Definition: Uniform.h:81
#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_BE_SCALAR_TYPE(T)
Constraint on the data type.
Definition: Scalar.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 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
bool isOne(const Proxy< PT, RT > &proxy)
Returns whether the represented element is 1.
Definition: Proxy.h:2337
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.
System settings for the inline keywords.
Header file for basic type definitions.
Header file for the implementation of the Submatrix view.