Blaze 3.9
Dense.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_ADAPTORS_LOWERMATRIX_DENSE_H_
36#define _BLAZE_MATH_ADAPTORS_LOWERMATRIX_DENSE_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <iterator>
44#include <utility>
48#include <blaze/math/Aliases.h>
76#include <blaze/system/Inline.h>
77#include <blaze/util/Assert.h>
83#include <blaze/util/EnableIf.h>
87#include <blaze/util/Types.h>
88
89
90namespace blaze {
91
92//=================================================================================================
93//
94// CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES
95//
96//=================================================================================================
97
98//*************************************************************************************************
106template< typename MT // Type of the adapted dense matrix
107 , bool SO > // Storage order of the adapted dense matrix
108class LowerMatrix<MT,SO,true>
109 : public DenseMatrix< LowerMatrix<MT,SO,true>, SO >
110{
111 private:
112 //**Type definitions****************************************************************************
113 using OT = OppositeType_t<MT>;
114 using TT = TransposeType_t<MT>;
115 using ET = ElementType_t<MT>;
116 //**********************************************************************************************
117
118 public:
119 //**Type definitions****************************************************************************
120 using This = LowerMatrix<MT,SO,true>;
121 using BaseType = DenseMatrix<This,SO>;
122 using ResultType = This;
123 using OppositeType = LowerMatrix<OT,!SO,true>;
124 using TransposeType = UpperMatrix<TT,!SO,true>;
125 using ElementType = ET;
126 using SIMDType = SIMDType_t<MT>;
127 using TagType = TagType_t<MT>;
128 using ReturnType = ReturnType_t<MT>;
129 using CompositeType = const This&;
130 using Reference = LowerProxy<MT>;
131 using ConstReference = ConstReference_t<MT>;
132 using Pointer = Pointer_t<MT>;
133 using ConstPointer = ConstPointer_t<MT>;
134 using ConstIterator = ConstIterator_t<MT>;
135 //**********************************************************************************************
136
137 //**Rebind struct definition********************************************************************
140 template< typename NewType > // Data type of the other matrix
141 struct Rebind {
143 using Other = LowerMatrix< typename MT::template Rebind<NewType>::Other >;
144 };
145 //**********************************************************************************************
146
147 //**Resize struct definition********************************************************************
150 template< size_t NewM // Number of rows of the other matrix
151 , size_t NewN > // Number of columns of the other matrix
152 struct Resize {
154 using Other = LowerMatrix< typename MT::template Resize<NewM,NewN>::Other >;
155 };
156 //**********************************************************************************************
157
158 //**Iterator class definition*******************************************************************
161 class Iterator
162 {
163 public:
164 //**Type definitions*************************************************************************
165 using IteratorCategory = std::random_access_iterator_tag;
166 using ValueType = ElementType_t<MT>;
167 using PointerType = LowerProxy<MT>;
168 using ReferenceType = LowerProxy<MT>;
169 using DifferenceType = ptrdiff_t;
170
171 // STL iterator requirements
172 using iterator_category = IteratorCategory;
173 using value_type = ValueType;
174 using pointer = PointerType;
175 using reference = ReferenceType;
176 using difference_type = DifferenceType;
177 //*******************************************************************************************
178
179 //**Constructor******************************************************************************
182 inline Iterator() noexcept
183 : matrix_( nullptr ) // Reference to the adapted dense matrix
184 , row_ ( 0UL ) // The current row index of the iterator
185 , column_( 0UL ) // The current column index of the iterator
186 {}
187 //*******************************************************************************************
188
189 //**Constructor******************************************************************************
196 inline Iterator( MT& matrix, size_t row, size_t column ) noexcept
197 : matrix_( &matrix ) // Reference to the adapted dense matrix
198 , row_ ( row ) // The current row-index of the iterator
199 , column_( column ) // The current column-index of the iterator
200 {}
201 //*******************************************************************************************
202
203 //**Addition assignment operator*************************************************************
209 inline Iterator& operator+=( size_t inc ) noexcept {
210 ( SO )?( row_ += inc ):( column_ += inc );
211 return *this;
212 }
213 //*******************************************************************************************
214
215 //**Subtraction assignment operator**********************************************************
221 inline Iterator& operator-=( size_t dec ) noexcept {
222 ( SO )?( row_ -= dec ):( column_ -= dec );
223 return *this;
224 }
225 //*******************************************************************************************
226
227 //**Prefix increment operator****************************************************************
232 inline Iterator& operator++() noexcept {
233 ( SO )?( ++row_ ):( ++column_ );
234 return *this;
235 }
236 //*******************************************************************************************
237
238 //**Postfix increment operator***************************************************************
243 inline const Iterator operator++( int ) noexcept {
244 const Iterator tmp( *this );
245 ++(*this);
246 return tmp;
247 }
248 //*******************************************************************************************
249
250 //**Prefix decrement operator****************************************************************
255 inline Iterator& operator--() noexcept {
256 ( SO )?( --row_ ):( --column_ );
257 return *this;
258 }
259 //*******************************************************************************************
260
261 //**Postfix decrement operator***************************************************************
266 inline const Iterator operator--( int ) noexcept {
267 const Iterator tmp( *this );
268 --(*this);
269 return tmp;
270 }
271 //*******************************************************************************************
272
273 //**Element access operator******************************************************************
278 inline ReferenceType operator*() const {
279 return ReferenceType( *matrix_, row_, column_ );
280 }
281 //*******************************************************************************************
282
283 //**Element access operator******************************************************************
288 inline PointerType operator->() const {
289 return PointerType( *matrix_, row_, column_ );
290 }
291 //*******************************************************************************************
292
293 //**Load function****************************************************************************
303 inline SIMDType load() const {
304 return (*matrix_).load(row_,column_);
305 }
306 //*******************************************************************************************
307
308 //**Loada function***************************************************************************
318 inline SIMDType loada() const {
319 return (*matrix_).loada(row_,column_);
320 }
321 //*******************************************************************************************
322
323 //**Loadu function***************************************************************************
333 inline SIMDType loadu() const {
334 return (*matrix_).loadu(row_,column_);
335 }
336 //*******************************************************************************************
337
338 //**Conversion operator**********************************************************************
343 inline operator ConstIterator() const {
344 if( SO )
345 return matrix_->begin( column_ ) + row_;
346 else
347 return matrix_->begin( row_ ) + column_;
348 }
349 //*******************************************************************************************
350
351 //**Equality operator************************************************************************
358 friend inline bool operator==( const Iterator& lhs, const Iterator& rhs ) noexcept {
359 return ( SO )?( lhs.row_ == rhs.row_ ):( lhs.column_ == rhs.column_ );
360 }
361 //*******************************************************************************************
362
363 //**Equality operator************************************************************************
370 friend inline bool operator==( const Iterator& lhs, const ConstIterator& rhs ) {
371 return ( ConstIterator( lhs ) == rhs );
372 }
373 //*******************************************************************************************
374
375 //**Equality operator************************************************************************
382 friend inline bool operator==( const ConstIterator& lhs, const Iterator& rhs ) {
383 return ( lhs == ConstIterator( rhs ) );
384 }
385 //*******************************************************************************************
386
387 //**Inequality operator**********************************************************************
394 friend inline bool operator!=( const Iterator& lhs, const Iterator& rhs ) noexcept {
395 return ( SO )?( lhs.row_ != rhs.row_ ):( lhs.column_ != rhs.column_ );
396 }
397 //*******************************************************************************************
398
399 //**Inequality operator**********************************************************************
406 friend inline bool operator!=( const Iterator& lhs, const ConstIterator& rhs ) {
407 return ( ConstIterator( lhs ) != rhs );
408 }
409 //*******************************************************************************************
410
411 //**Inequality operator**********************************************************************
418 friend inline bool operator!=( const ConstIterator& lhs, const Iterator& rhs ) {
419 return ( lhs != ConstIterator( rhs ) );
420 }
421 //*******************************************************************************************
422
423 //**Less-than operator***********************************************************************
430 friend inline bool operator<( const Iterator& lhs, const Iterator& rhs ) noexcept {
431 return ( SO )?( lhs.row_ < rhs.row_ ):( lhs.column_ < rhs.column_ );
432 }
433 //*******************************************************************************************
434
435 //**Less-than operator***********************************************************************
442 friend inline bool operator<( const Iterator& lhs, const ConstIterator& rhs ) {
443 return ( ConstIterator( lhs ) < rhs );
444 }
445 //*******************************************************************************************
446
447 //**Less-than operator***********************************************************************
454 friend inline bool operator<( const ConstIterator& lhs, const Iterator& rhs ) {
455 return ( lhs < ConstIterator( rhs ) );
456 }
457 //*******************************************************************************************
458
459 //**Greater-than operator********************************************************************
466 friend inline bool operator>( const Iterator& lhs, const Iterator& rhs ) noexcept {
467 return ( SO )?( lhs.row_ > rhs.row_ ):( lhs.column_ > rhs.column_ );
468 }
469 //*******************************************************************************************
470
471 //**Greater-than operator********************************************************************
478 friend inline bool operator>( const Iterator& lhs, const ConstIterator& rhs ) {
479 return ( ConstIterator( lhs ) > rhs );
480 }
481 //*******************************************************************************************
482
483 //**Greater-than operator********************************************************************
490 friend inline bool operator>( const ConstIterator& lhs, const Iterator& rhs ) {
491 return ( lhs > ConstIterator( rhs ) );
492 }
493 //*******************************************************************************************
494
495 //**Less-or-equal-than operator**************************************************************
502 friend inline bool operator<=( const Iterator& lhs, const Iterator& rhs ) noexcept {
503 return ( SO )?( lhs.row_ <= rhs.row_ ):( lhs.column_ <= rhs.column_ );
504 }
505 //*******************************************************************************************
506
507 //**Less-or-equal-than operator**************************************************************
514 friend inline bool operator<=( const Iterator& lhs, const ConstIterator& rhs ) {
515 return ( ConstIterator( lhs ) <= rhs );
516 }
517 //*******************************************************************************************
518
519 //**Less-or-equal-than operator**************************************************************
526 friend inline bool operator<=( const ConstIterator& lhs, const Iterator& rhs ) {
527 return ( lhs <= ConstIterator( rhs ) );
528 }
529 //*******************************************************************************************
530
531 //**Greater-or-equal-than operator***********************************************************
538 friend inline bool operator>=( const Iterator& lhs, const Iterator& rhs ) noexcept {
539 return ( SO )?( lhs.row_ >= rhs.row_ ):( lhs.column_ >= rhs.column_ );
540 }
541 //*******************************************************************************************
542
543 //**Greater-or-equal-than operator***********************************************************
550 friend inline bool operator>=( const Iterator& lhs, const ConstIterator& rhs ) {
551 return ( ConstIterator( lhs ) >= rhs );
552 }
553 //*******************************************************************************************
554
555 //**Greater-or-equal-than operator***********************************************************
562 friend inline bool operator>=( const ConstIterator& lhs, const Iterator& rhs ) {
563 return ( lhs >= ConstIterator( rhs ) );
564 }
565 //*******************************************************************************************
566
567 //**Subtraction operator*********************************************************************
573 inline DifferenceType operator-( const Iterator& rhs ) const noexcept {
574 return ( SO )?( row_ - rhs.row_ ):( column_ - rhs.column_ );
575 }
576 //*******************************************************************************************
577
578 //**Addition operator************************************************************************
585 friend inline const Iterator operator+( const Iterator& it, size_t inc ) noexcept {
586 if( SO )
587 return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
588 else
589 return Iterator( *it.matrix_, it.row_, it.column_ + inc );
590 }
591 //*******************************************************************************************
592
593 //**Addition operator************************************************************************
600 friend inline const Iterator operator+( size_t inc, const Iterator& it ) noexcept {
601 if( SO )
602 return Iterator( *it.matrix_, it.row_ + inc, it.column_ );
603 else
604 return Iterator( *it.matrix_, it.row_, it.column_ + inc );
605 }
606 //*******************************************************************************************
607
608 //**Subtraction operator*********************************************************************
615 friend inline const Iterator operator-( const Iterator& it, size_t dec ) noexcept {
616 if( SO )
617 return Iterator( *it.matrix_, it.row_ - dec, it.column_ );
618 else
619 return Iterator( *it.matrix_, it.row_, it.column_ - dec );
620 }
621 //*******************************************************************************************
622
623 private:
624 //**Member variables*************************************************************************
625 MT* matrix_;
626 size_t row_;
627 size_t column_;
628 //*******************************************************************************************
629 };
630 //**********************************************************************************************
631
632 //**Compilation flags***************************************************************************
634 static constexpr bool simdEnabled = MT::simdEnabled;
635
637 static constexpr bool smpAssignable = MT::smpAssignable;
638 //**********************************************************************************************
639
640 //**Constructors********************************************************************************
643 inline LowerMatrix();
644 template< typename A1 > explicit inline LowerMatrix( const A1& a1 );
645 inline LowerMatrix( size_t n, const ElementType& init );
646
647 inline LowerMatrix( initializer_list< initializer_list<ElementType> > list );
648
649 template< typename Other >
650 inline LowerMatrix( size_t n, const Other* array );
651
652 template< typename Other, size_t N >
653 inline LowerMatrix( const Other (&array)[N][N] );
654
655 inline LowerMatrix( ElementType* ptr, size_t n );
656 inline LowerMatrix( ElementType* ptr, size_t n, size_t nn );
657
658 inline LowerMatrix( const LowerMatrix& m );
659 inline LowerMatrix( LowerMatrix&& m ) noexcept;
661 //**********************************************************************************************
662
663 //**Destructor**********************************************************************************
666 ~LowerMatrix() = default;
668 //**********************************************************************************************
669
670 //**Data access functions***********************************************************************
673 inline Reference operator()( size_t i, size_t j );
674 inline ConstReference operator()( size_t i, size_t j ) const;
675 inline Reference at( size_t i, size_t j );
676 inline ConstReference at( size_t i, size_t j ) const;
677 inline ConstPointer data () const noexcept;
678 inline ConstPointer data ( size_t i ) const noexcept;
679 inline Iterator begin ( size_t i );
680 inline ConstIterator begin ( size_t i ) const;
681 inline ConstIterator cbegin( size_t i ) const;
682 inline Iterator end ( size_t i );
683 inline ConstIterator end ( size_t i ) const;
684 inline ConstIterator cend ( size_t i ) const;
686 //**********************************************************************************************
687
688 //**Assignment operators************************************************************************
691 inline LowerMatrix& operator=( const ElementType& rhs );
692 inline LowerMatrix& operator=( initializer_list< initializer_list<ElementType> > list );
693
694 template< typename Other, size_t N >
695 inline LowerMatrix& operator=( const Other (&array)[N][N] );
696
697 inline LowerMatrix& operator=( const LowerMatrix& rhs );
698 inline LowerMatrix& operator=( LowerMatrix&& rhs ) noexcept;
699
700 template< typename MT2, bool SO2 >
701 inline auto operator=( const Matrix<MT2,SO2>& rhs )
702 -> DisableIf_t< IsComputation_v<MT2>, LowerMatrix& >;
703
704 template< typename MT2, bool SO2 >
705 inline auto operator=( const Matrix<MT2,SO2>& rhs )
706 -> EnableIf_t< IsComputation_v<MT2>, LowerMatrix& >;
707
708 template< typename MT2, bool SO2 >
709 inline auto operator+=( const Matrix<MT2,SO2>& rhs )
710 -> DisableIf_t< IsComputation_v<MT2>, LowerMatrix& >;
711
712 template< typename MT2, bool SO2 >
713 inline auto operator+=( const Matrix<MT2,SO2>& rhs )
714 -> EnableIf_t< IsComputation_v<MT2>, LowerMatrix& >;
715
716 template< typename MT2, bool SO2 >
717 inline auto operator-=( const Matrix<MT2,SO2>& rhs )
718 -> DisableIf_t< IsComputation_v<MT2>, LowerMatrix& >;
719
720 template< typename MT2, bool SO2 >
721 inline auto operator-=( const Matrix<MT2,SO2>& rhs )
722 -> EnableIf_t< IsComputation_v<MT2>, LowerMatrix& >;
723
724 template< typename MT2, bool SO2 >
725 inline auto operator%=( const Matrix<MT2,SO2>& rhs ) -> LowerMatrix&;
726
727 template< typename ST >
728 inline auto operator*=( ST rhs ) -> EnableIf_t< IsScalar_v<ST>, LowerMatrix& >;
729
730 template< typename ST >
731 inline auto operator/=( ST rhs ) -> EnableIf_t< IsScalar_v<ST>, LowerMatrix& >;
733 //**********************************************************************************************
734
735 //**Utility functions***************************************************************************
738 inline size_t rows() const noexcept;
739 inline size_t columns() const noexcept;
740 inline size_t spacing() const noexcept;
741 inline size_t capacity() const noexcept;
742 inline size_t capacity( size_t i ) const noexcept;
743 inline size_t nonZeros() const;
744 inline size_t nonZeros( size_t i ) const;
745 inline void reset();
746 inline void reset( size_t i );
747 inline void clear();
748 void resize ( size_t n, bool preserve=true );
749 inline void extend ( size_t n, bool preserve=true );
750 inline void reserve( size_t elements );
751 inline void shrinkToFit();
752 inline void swap( LowerMatrix& m ) noexcept;
753
754 static constexpr size_t maxNonZeros() noexcept;
755 static constexpr size_t maxNonZeros( size_t n ) noexcept;
757 //**********************************************************************************************
758
759 //**Numeric functions***************************************************************************
762 template< typename Other > inline LowerMatrix& scale( const Other& scalar );
764 //**********************************************************************************************
765
766 //**Debugging functions*************************************************************************
769 inline bool isIntact() const noexcept;
771 //**********************************************************************************************
772
773 //**Expression template evaluation functions****************************************************
776 template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
777 template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
778
779 inline bool isAligned () const noexcept;
780 inline bool canSMPAssign() const noexcept;
781
782 BLAZE_ALWAYS_INLINE SIMDType load ( size_t i, size_t j ) const noexcept;
783 BLAZE_ALWAYS_INLINE SIMDType loada( size_t i, size_t j ) const noexcept;
784 BLAZE_ALWAYS_INLINE SIMDType loadu( size_t i, size_t j ) const noexcept;
786 //**********************************************************************************************
787
788 private:
789 //**Construction functions**********************************************************************
792 inline const MT construct( size_t n , TrueType );
793 inline const MT construct( const ElementType& value, FalseType );
794
795 template< typename MT2, bool SO2, typename T >
796 inline const MT construct( const Matrix<MT2,SO2>& m, T );
798 //**********************************************************************************************
799
800 //**Member variables****************************************************************************
803 MT matrix_;
805 //**********************************************************************************************
806
807 //**Friend declarations*************************************************************************
808 template< typename MT2, bool SO2, bool DF2 >
809 friend MT2& derestrict( LowerMatrix<MT2,SO2,DF2>& m );
810 //**********************************************************************************************
811
812 //**Compile time checks*************************************************************************
827 BLAZE_STATIC_ASSERT( ( Size_v<MT,0UL> == Size_v<MT,1UL> ) );
828 //**********************************************************************************************
829};
831//*************************************************************************************************
832
833
834
835
836//=================================================================================================
837//
838// CONSTRUCTORS
839//
840//=================================================================================================
841
842//*************************************************************************************************
846template< typename MT // Type of the adapted dense matrix
847 , bool SO > // Storage order of the adapted dense matrix
848inline LowerMatrix<MT,SO,true>::LowerMatrix()
849 : matrix_() // The adapted dense matrix
850{
851 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
852 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
853}
855//*************************************************************************************************
856
857
858//*************************************************************************************************
876template< typename MT // Type of the adapted dense matrix
877 , bool SO > // Storage order of the adapted dense matrix
878template< typename A1 > // Type of the constructor argument
879inline LowerMatrix<MT,SO,true>::LowerMatrix( const A1& a1 )
880 : matrix_( construct( a1, IsResizable<MT>() ) ) // The adapted dense matrix
881{
882 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
883 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
884}
886//*************************************************************************************************
887
888
889//*************************************************************************************************
896template< typename MT // Type of the adapted dense matrix
897 , bool SO > // Storage order of the adapted dense matrix
898inline LowerMatrix<MT,SO,true>::LowerMatrix( size_t n, const ElementType& init )
899 : matrix_( n, n, ElementType() ) // The adapted dense matrix
900{
902
903 if( SO ) {
904 for( size_t j=0UL; j<columns(); ++j )
905 for( size_t i=j; i<rows(); ++i )
906 matrix_(i,j) = init;
907 }
908 else {
909 for( size_t i=0UL; i<rows(); ++i )
910 for( size_t j=0UL; j<=i; ++j )
911 matrix_(i,j) = init;
912 }
913
914 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
915 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
916}
918//*************************************************************************************************
919
920
921//*************************************************************************************************
945template< typename MT // Type of the adapted dense matrix
946 , bool SO > // Storage order of the adapted dense matrix
947inline LowerMatrix<MT,SO,true>::LowerMatrix( initializer_list< initializer_list<ElementType> > list )
948 : matrix_( list ) // The adapted dense matrix
949{
950 if( !isLower( matrix_ ) ) {
951 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of lower matrix" );
952 }
953
954 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
955}
957//*************************************************************************************************
958
959
960//*************************************************************************************************
986template< typename MT // Type of the adapted dense matrix
987 , bool SO > // Storage order of the adapted dense matrix
988template< typename Other > // Data type of the initialization array
989inline LowerMatrix<MT,SO,true>::LowerMatrix( size_t n, const Other* array )
990 : matrix_( n, n, array ) // The adapted dense matrix
991{
992 if( !isLower( matrix_ ) ) {
993 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of lower matrix" );
994 }
995
996 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
997}
999//*************************************************************************************************
1000
1001
1002//*************************************************************************************************
1025template< typename MT // Type of the adapted dense matrix
1026 , bool SO > // Storage order of the adapted dense matrix
1027template< typename Other // Data type of the initialization array
1028 , size_t N > // Number of rows and columns of the initialization array
1029inline LowerMatrix<MT,SO,true>::LowerMatrix( const Other (&array)[N][N] )
1030 : matrix_( array ) // The adapted dense matrix
1031{
1032 if( !isLower( matrix_ ) ) {
1033 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of lower matrix" );
1034 }
1035
1036 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1037}
1039//*************************************************************************************************
1040
1041
1042//*************************************************************************************************
1074template< typename MT // Type of the adapted dense matrix
1075 , bool SO > // Storage order of the adapted dense matrix
1076inline LowerMatrix<MT,SO,true>::LowerMatrix( ElementType* ptr, size_t n )
1077 : matrix_( ptr, n, n ) // The adapted dense matrix
1078{
1079 if( !isLower( matrix_ ) ) {
1080 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of lower matrix" );
1081 }
1082
1083 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1084}
1086//*************************************************************************************************
1087
1088
1089//*************************************************************************************************
1123template< typename MT // Type of the adapted dense matrix
1124 , bool SO > // Storage order of the adapted dense matrix
1125inline LowerMatrix<MT,SO,true>::LowerMatrix( ElementType* ptr, size_t n, size_t nn )
1126 : matrix_( ptr, n, n, nn ) // The adapted dense matrix
1127{
1128 if( !isLower( matrix_ ) ) {
1129 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of lower matrix" );
1130 }
1131
1132 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1133}
1135//*************************************************************************************************
1136
1137
1138//*************************************************************************************************
1144template< typename MT // Type of the adapted dense matrix
1145 , bool SO > // Storage order of the adapted dense matrix
1146inline LowerMatrix<MT,SO,true>::LowerMatrix( const LowerMatrix& m )
1147 : matrix_( m.matrix_ ) // The adapted dense matrix
1148{
1149 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1150 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1151}
1153//*************************************************************************************************
1154
1155
1156//*************************************************************************************************
1162template< typename MT // Type of the adapted dense matrix
1163 , bool SO > // Storage order of the adapted dense matrix
1164inline LowerMatrix<MT,SO,true>::LowerMatrix( LowerMatrix&& m ) noexcept
1165 : matrix_( std::move( m.matrix_ ) ) // The adapted dense matrix
1166{
1167 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1168 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1169}
1171//*************************************************************************************************
1172
1173
1174
1175
1176//=================================================================================================
1177//
1178// DATA ACCESS FUNCTIONS
1179//
1180//=================================================================================================
1181
1182//*************************************************************************************************
1198template< typename MT // Type of the adapted dense matrix
1199 , bool SO > // Storage order of the adapted dense matrix
1200inline typename LowerMatrix<MT,SO,true>::Reference
1201 LowerMatrix<MT,SO,true>::operator()( size_t i, size_t j )
1202{
1203 BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1204 BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1205
1206 return Reference( matrix_, i, j );
1207}
1209//*************************************************************************************************
1210
1211
1212//*************************************************************************************************
1228template< typename MT // Type of the adapted dense matrix
1229 , bool SO > // Storage order of the adapted dense matrix
1230inline typename LowerMatrix<MT,SO,true>::ConstReference
1231 LowerMatrix<MT,SO,true>::operator()( size_t i, size_t j ) const
1232{
1233 BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
1234 BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
1235
1236 return matrix_(i,j);
1237}
1239//*************************************************************************************************
1240
1241
1242//*************************************************************************************************
1259template< typename MT // Type of the adapted dense matrix
1260 , bool SO > // Storage order of the adapted dense matrix
1261inline typename LowerMatrix<MT,SO,true>::Reference
1262 LowerMatrix<MT,SO,true>::at( size_t i, size_t j )
1263{
1264 if( i >= rows() ) {
1265 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1266 }
1267 if( j >= columns() ) {
1268 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1269 }
1270 return (*this)(i,j);
1271}
1273//*************************************************************************************************
1274
1275
1276//*************************************************************************************************
1293template< typename MT // Type of the adapted dense matrix
1294 , bool SO > // Storage order of the adapted dense matrix
1295inline typename LowerMatrix<MT,SO,true>::ConstReference
1296 LowerMatrix<MT,SO,true>::at( size_t i, size_t j ) const
1297{
1298 if( i >= rows() ) {
1299 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
1300 }
1301 if( j >= columns() ) {
1302 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
1303 }
1304 return (*this)(i,j);
1305}
1307//*************************************************************************************************
1308
1309
1310//*************************************************************************************************
1323template< typename MT // Type of the adapted dense matrix
1324 , bool SO > // Storage order of the adapted dense matrix
1325inline typename LowerMatrix<MT,SO,true>::ConstPointer
1326 LowerMatrix<MT,SO,true>::data() const noexcept
1327{
1328 return matrix_.data();
1329}
1331//*************************************************************************************************
1332
1333
1334//*************************************************************************************************
1343template< typename MT // Type of the adapted dense matrix
1344 , bool SO > // Storage order of the adapted dense matrix
1345inline typename LowerMatrix<MT,SO,true>::ConstPointer
1346 LowerMatrix<MT,SO,true>::data( size_t i ) const noexcept
1347{
1348 return matrix_.data(i);
1349}
1351//*************************************************************************************************
1352
1353
1354//*************************************************************************************************
1366template< typename MT // Type of the adapted dense matrix
1367 , bool SO > // Storage order of the adapted dense matrix
1368inline typename LowerMatrix<MT,SO,true>::Iterator
1370{
1371 if( SO )
1372 return Iterator( matrix_, 0UL, i );
1373 else
1374 return Iterator( matrix_, i, 0UL );
1375}
1377//*************************************************************************************************
1378
1379
1380//*************************************************************************************************
1392template< typename MT // Type of the adapted dense matrix
1393 , bool SO > // Storage order of the adapted dense matrix
1394inline typename LowerMatrix<MT,SO,true>::ConstIterator
1395 LowerMatrix<MT,SO,true>::begin( size_t i ) const
1396{
1397 return matrix_.begin(i);
1398}
1400//*************************************************************************************************
1401
1402
1403//*************************************************************************************************
1415template< typename MT // Type of the adapted dense matrix
1416 , bool SO > // Storage order of the adapted dense matrix
1417inline typename LowerMatrix<MT,SO,true>::ConstIterator
1418 LowerMatrix<MT,SO,true>::cbegin( size_t i ) const
1419{
1420 return matrix_.cbegin(i);
1421}
1423//*************************************************************************************************
1424
1425
1426//*************************************************************************************************
1438template< typename MT // Type of the adapted dense matrix
1439 , bool SO > // Storage order of the adapted dense matrix
1440inline typename LowerMatrix<MT,SO,true>::Iterator
1442{
1443 if( SO )
1444 return Iterator( matrix_, rows(), i );
1445 else
1446 return Iterator( matrix_, i, columns() );
1447}
1449//*************************************************************************************************
1450
1451
1452//*************************************************************************************************
1464template< typename MT // Type of the adapted dense matrix
1465 , bool SO > // Storage order of the adapted dense matrix
1466inline typename LowerMatrix<MT,SO,true>::ConstIterator
1467 LowerMatrix<MT,SO,true>::end( size_t i ) const
1468{
1469 return matrix_.end(i);
1470}
1472//*************************************************************************************************
1473
1474
1475//*************************************************************************************************
1487template< typename MT // Type of the adapted dense matrix
1488 , bool SO > // Storage order of the adapted dense matrix
1489inline typename LowerMatrix<MT,SO,true>::ConstIterator
1490 LowerMatrix<MT,SO,true>::cend( size_t i ) const
1491{
1492 return matrix_.cend(i);
1493}
1495//*************************************************************************************************
1496
1497
1498
1499
1500//=================================================================================================
1501//
1502// ASSIGNMENT OPERATORS
1503//
1504//=================================================================================================
1505
1506//*************************************************************************************************
1513template< typename MT // Type of the adapted dense matrix
1514 , bool SO > // Storage order of the adapted dense matrix
1515inline LowerMatrix<MT,SO,true>&
1516 LowerMatrix<MT,SO,true>::operator=( const ElementType& rhs )
1517{
1518 if( SO ) {
1519 for( size_t j=0UL; j<columns(); ++j )
1520 for( size_t i=j; i<rows(); ++i )
1521 matrix_(i,j) = rhs;
1522 }
1523 else {
1524 for( size_t i=0UL; i<rows(); ++i )
1525 for( size_t j=0UL; j<=i; ++j )
1526 matrix_(i,j) = rhs;
1527 }
1528
1529 return *this;
1530}
1532//*************************************************************************************************
1533
1534
1535//*************************************************************************************************
1560template< typename MT // Type of the adapted dense matrix
1561 , bool SO > // Storage order of the adapted dense matrix
1562inline LowerMatrix<MT,SO,true>&
1563 LowerMatrix<MT,SO,true>::operator=( initializer_list< initializer_list<ElementType> > list )
1564{
1565 const InitializerMatrix<ElementType> tmp( list, list.size() );
1566
1567 if( !isLower( tmp ) ) {
1568 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1569 }
1570
1571 matrix_ = list;
1572
1573 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1574 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1575
1576 return *this;
1577}
1579//*************************************************************************************************
1580
1581
1582//*************************************************************************************************
1606template< typename MT // Type of the adapted dense matrix
1607 , bool SO > // Storage order of the adapted dense matrix
1608template< typename Other // Data type of the initialization array
1609 , size_t N > // Number of rows and columns of the initialization array
1610inline LowerMatrix<MT,SO,true>&
1611 LowerMatrix<MT,SO,true>::operator=( const Other (&array)[N][N] )
1612{
1613 MT tmp( array );
1614
1615 if( !isLower( tmp ) ) {
1616 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1617 }
1618
1619 matrix_ = std::move( tmp );
1620
1621 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1622 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1623
1624 return *this;
1625}
1627//*************************************************************************************************
1628
1629
1630//*************************************************************************************************
1640template< typename MT // Type of the adapted dense matrix
1641 , bool SO > // Storage order of the adapted dense matrix
1642inline LowerMatrix<MT,SO,true>&
1643 LowerMatrix<MT,SO,true>::operator=( const LowerMatrix& rhs )
1644{
1645 matrix_ = rhs.matrix_;
1646
1647 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1648 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1649
1650 return *this;
1651}
1653//*************************************************************************************************
1654
1655
1656//*************************************************************************************************
1663template< typename MT // Type of the adapted dense matrix
1664 , bool SO > // Storage order of the adapted dense matrix
1665inline LowerMatrix<MT,SO,true>&
1666 LowerMatrix<MT,SO,true>::operator=( LowerMatrix&& rhs ) noexcept
1667{
1668 matrix_ = std::move( rhs.matrix_ );
1669
1670 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1671 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1672
1673 return *this;
1674}
1676//*************************************************************************************************
1677
1678
1679//*************************************************************************************************
1692template< typename MT // Type of the adapted dense matrix
1693 , bool SO > // Storage order of the adapted dense matrix
1694template< typename MT2 // Type of the right-hand side matrix
1695 , bool SO2 > // Storage order of the right-hand side matrix
1696inline auto LowerMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1697 -> DisableIf_t< IsComputation_v<MT2>, LowerMatrix& >
1698{
1699 if( !IsLower_v<MT2> && !isLower( *rhs ) ) {
1700 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1701 }
1702
1703 matrix_ = decllow( *rhs );
1704
1705 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1706 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1707
1708 return *this;
1709}
1711//*************************************************************************************************
1712
1713
1714//*************************************************************************************************
1727template< typename MT // Type of the adapted dense matrix
1728 , bool SO > // Storage order of the adapted dense matrix
1729template< typename MT2 // Type of the right-hand side matrix
1730 , bool SO2 > // Storage order of the right-hand side matrix
1731inline auto LowerMatrix<MT,SO,true>::operator=( const Matrix<MT2,SO2>& rhs )
1732 -> EnableIf_t< IsComputation_v<MT2>, LowerMatrix& >
1733{
1734 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
1735 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1736 }
1737
1738 if( IsLower_v<MT2> ) {
1739 matrix_ = *rhs;
1740 }
1741 else {
1742 MT tmp( *rhs );
1743
1744 if( !isLower( tmp ) ) {
1745 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1746 }
1747
1748 matrix_ = std::move( tmp );
1749 }
1750
1751 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1752 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1753
1754 return *this;
1755}
1757//*************************************************************************************************
1758
1759
1760//*************************************************************************************************
1773template< typename MT // Type of the adapted dense matrix
1774 , bool SO > // Storage order of the adapted dense matrix
1775template< typename MT2 // Type of the right-hand side matrix
1776 , bool SO2 > // Storage order of the right-hand side matrix
1777inline auto LowerMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1778 -> DisableIf_t< IsComputation_v<MT2>, LowerMatrix& >
1779{
1780 if( !IsLower_v<MT2> && !isLower( *rhs ) ) {
1781 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1782 }
1783
1784 matrix_ += decllow( *rhs );
1785
1786 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1787 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1788
1789 return *this;
1790}
1792//*************************************************************************************************
1793
1794
1795//*************************************************************************************************
1808template< typename MT // Type of the adapted dense matrix
1809 , bool SO > // Storage order of the adapted dense matrix
1810template< typename MT2 // Type of the right-hand side matrix
1811 , bool SO2 > // Storage order of the right-hand side matrix
1812inline auto LowerMatrix<MT,SO,true>::operator+=( const Matrix<MT2,SO2>& rhs )
1813 -> EnableIf_t< IsComputation_v<MT2>, LowerMatrix& >
1814{
1815 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
1816 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1817 }
1818
1819 if( IsLower_v<MT2> ) {
1820 matrix_ += *rhs;
1821 }
1822 else {
1823 const ResultType_t<MT2> tmp( *rhs );
1824
1825 if( !isLower( tmp ) ) {
1826 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1827 }
1828
1829 matrix_ += decllow( tmp );
1830 }
1831
1832 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1833 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1834
1835 return *this;
1836}
1838//*************************************************************************************************
1839
1840
1841//*************************************************************************************************
1854template< typename MT // Type of the adapted dense matrix
1855 , bool SO > // Storage order of the adapted dense matrix
1856template< typename MT2 // Type of the right-hand side matrix
1857 , bool SO2 > // Storage order of the right-hand side matrix
1858inline auto LowerMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1859 -> DisableIf_t< IsComputation_v<MT2>, LowerMatrix& >
1860{
1861 if( !IsLower_v<MT2> && !isLower( *rhs ) ) {
1862 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1863 }
1864
1865 matrix_ -= decllow( *rhs );
1866
1867 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1868 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1869
1870 return *this;
1871}
1873//*************************************************************************************************
1874
1875
1876//*************************************************************************************************
1889template< typename MT // Type of the adapted dense matrix
1890 , bool SO > // Storage order of the adapted dense matrix
1891template< typename MT2 // Type of the right-hand side matrix
1892 , bool SO2 > // Storage order of the right-hand side matrix
1893inline auto LowerMatrix<MT,SO,true>::operator-=( const Matrix<MT2,SO2>& rhs )
1894 -> EnableIf_t< IsComputation_v<MT2>, LowerMatrix& >
1895{
1896 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
1897 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1898 }
1899
1900 if( IsLower_v<MT2> ) {
1901 matrix_ -= *rhs;
1902 }
1903 else {
1904 const ResultType_t<MT2> tmp( *rhs );
1905
1906 if( !isLower( tmp ) ) {
1907 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1908 }
1909
1910 matrix_ -= decllow( tmp );
1911 }
1912
1913 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1914 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1915
1916 return *this;
1917}
1919//*************************************************************************************************
1920
1921
1922//*************************************************************************************************
1933template< typename MT // Type of the adapted dense matrix
1934 , bool SO > // Storage order of the adapted dense matrix
1935template< typename MT2 // Type of the right-hand side matrix
1936 , bool SO2 > // Storage order of the right-hand side matrix
1937inline auto LowerMatrix<MT,SO,true>::operator%=( const Matrix<MT2,SO2>& rhs )
1938 -> LowerMatrix&
1939{
1940 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
1941 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to lower matrix" );
1942 }
1943
1944 matrix_ %= *rhs;
1945
1946 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
1947 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1948
1949 return *this;
1950}
1952//*************************************************************************************************
1953
1954
1955//*************************************************************************************************
1963template< typename MT // Type of the adapted dense matrix
1964 , bool SO > // Storage order of the adapted dense matrix
1965template< typename ST > // Data type of the right-hand side scalar
1966inline auto LowerMatrix<MT,SO,true>::operator*=( ST rhs )
1967 -> EnableIf_t< IsScalar_v<ST>, LowerMatrix& >
1968{
1969 matrix_ *= rhs;
1970 return *this;
1971}
1972//*************************************************************************************************
1973
1974
1975//*************************************************************************************************
1983template< typename MT // Type of the adapted dense matrix
1984 , bool SO > // Storage order of the adapted dense matrix
1985template< typename ST > // Data type of the right-hand side scalar
1986inline auto LowerMatrix<MT,SO,true>::operator/=( ST rhs )
1987 -> EnableIf_t< IsScalar_v<ST>, LowerMatrix& >
1988{
1989 BLAZE_USER_ASSERT( !isZero( rhs ), "Division by zero detected" );
1990
1991 matrix_ /= rhs;
1992 return *this;
1993}
1995//*************************************************************************************************
1996
1997
1998
1999
2000//=================================================================================================
2001//
2002// UTILITY FUNCTIONS
2003//
2004//=================================================================================================
2005
2006//*************************************************************************************************
2012template< typename MT // Type of the adapted dense matrix
2013 , bool SO > // Storage order of the adapted dense matrix
2014inline size_t LowerMatrix<MT,SO,true>::rows() const noexcept
2015{
2016 return matrix_.rows();
2017}
2019//*************************************************************************************************
2020
2021
2022//*************************************************************************************************
2028template< typename MT // Type of the adapted dense matrix
2029 , bool SO > // Storage order of the adapted dense matrix
2030inline size_t LowerMatrix<MT,SO,true>::columns() const noexcept
2031{
2032 return matrix_.columns();
2033}
2035//*************************************************************************************************
2036
2037
2038//*************************************************************************************************
2049template< typename MT // Type of the adapted dense matrix
2050 , bool SO > // Storage order of the adapted dense matrix
2051inline size_t LowerMatrix<MT,SO,true>::spacing() const noexcept
2052{
2053 return matrix_.spacing();
2054}
2056//*************************************************************************************************
2057
2058
2059//*************************************************************************************************
2065template< typename MT // Type of the adapted dense matrix
2066 , bool SO > // Storage order of the adapted dense matrix
2067inline size_t LowerMatrix<MT,SO,true>::capacity() const noexcept
2068{
2069 return matrix_.capacity();
2070}
2072//*************************************************************************************************
2073
2074
2075//*************************************************************************************************
2087template< typename MT // Type of the adapted dense matrix
2088 , bool SO > // Storage order of the adapted dense matrix
2089inline size_t LowerMatrix<MT,SO,true>::capacity( size_t i ) const noexcept
2090{
2091 return matrix_.capacity(i);
2092}
2094//*************************************************************************************************
2095
2096
2097//*************************************************************************************************
2103template< typename MT // Type of the adapted dense matrix
2104 , bool SO > // Storage order of the adapted dense matrix
2105inline size_t LowerMatrix<MT,SO,true>::nonZeros() const
2106{
2107 return matrix_.nonZeros();
2108}
2110//*************************************************************************************************
2111
2112
2113//*************************************************************************************************
2125template< typename MT // Type of the adapted dense matrix
2126 , bool SO > // Storage order of the adapted dense matrix
2127inline size_t LowerMatrix<MT,SO,true>::nonZeros( size_t i ) const
2128{
2129 return matrix_.nonZeros(i);
2130}
2132//*************************************************************************************************
2133
2134
2135//*************************************************************************************************
2141template< typename MT // Type of the adapted dense matrix
2142 , bool SO > // Storage order of the adapted dense matrix
2144{
2145 using blaze::clear;
2146
2147 if( SO ) {
2148 for( size_t j=0UL; j<columns(); ++j )
2149 for( size_t i=j; i<rows(); ++i )
2150 clear( matrix_(i,j) );
2151 }
2152 else {
2153 for( size_t i=0UL; i<rows(); ++i )
2154 for( size_t j=0UL; j<=i; ++j )
2155 clear( matrix_(i,j) );
2156 }
2157}
2159//*************************************************************************************************
2160
2161
2162//*************************************************************************************************
2175template< typename MT // Type of the adapted dense matrix
2176 , bool SO > // Storage order of the adapted dense matrix
2177inline void LowerMatrix<MT,SO,true>::reset( size_t i )
2178{
2179 using blaze::clear;
2180
2181 if( SO ) {
2182 for( size_t j=i; j<rows(); ++j )
2183 clear( matrix_(j,i) );
2184 }
2185 else {
2186 for( size_t j=0UL; j<=i; ++j )
2187 clear( matrix_(i,j) );
2188 }
2189}
2191//*************************************************************************************************
2192
2193
2194//*************************************************************************************************
2206template< typename MT // Type of the adapted dense matrix
2207 , bool SO > // Storage order of the adapted dense matrix
2209{
2210 matrix_.clear();
2211
2212 BLAZE_INTERNAL_ASSERT( matrix_.rows() == 0UL, "Invalid number of rows" );
2213 BLAZE_INTERNAL_ASSERT( matrix_.columns() == 0UL, "Invalid number of columns" );
2214}
2216//*************************************************************************************************
2217
2218
2219//*************************************************************************************************
2255template< typename MT // Type of the adapted dense matrix
2256 , bool SO > // Storage order of the adapted dense matrix
2257void LowerMatrix<MT,SO,true>::resize( size_t n, bool preserve )
2258{
2260
2261 MAYBE_UNUSED( preserve );
2262
2263 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square lower matrix detected" );
2264
2265 const size_t oldsize( matrix_.rows() );
2266
2267 matrix_.resize( n, n, true );
2268
2269 if( n > oldsize ) {
2270 const size_t increment( n - oldsize );
2271 submatrix( matrix_, 0UL, oldsize, n-1UL, increment ).reset();
2272 }
2273}
2275//*************************************************************************************************
2276
2277
2278//*************************************************************************************************
2291template< typename MT // Type of the adapted dense matrix
2292 , bool SO > // Storage order of the adapted dense matrix
2293inline void LowerMatrix<MT,SO,true>::extend( size_t n, bool preserve )
2294{
2296
2297 MAYBE_UNUSED( preserve );
2298
2299 resize( rows() + n, true );
2300}
2301//*************************************************************************************************
2302
2303
2304//*************************************************************************************************
2314template< typename MT // Type of the adapted dense matrix
2315 , bool SO > // Storage order of the adapted dense matrix
2316inline void LowerMatrix<MT,SO,true>::reserve( size_t elements )
2317{
2318 matrix_.reserve( elements );
2319}
2321//*************************************************************************************************
2322
2323
2324//*************************************************************************************************
2334template< typename MT // Type of the adapted dense matrix
2335 , bool SO > // Storage order of the adapted dense matrix
2337{
2338 matrix_.shrinkToFit();
2339}
2341//*************************************************************************************************
2342
2343
2344//*************************************************************************************************
2351template< typename MT // Type of the adapted dense matrix
2352 , bool SO > // Storage order of the adapted dense matrix
2353inline void LowerMatrix<MT,SO,true>::swap( LowerMatrix& m ) noexcept
2354{
2355 using std::swap;
2356
2357 swap( matrix_, m.matrix_ );
2358}
2360//*************************************************************************************************
2361
2362
2363//*************************************************************************************************
2375template< typename MT // Type of the adapted dense matrix
2376 , bool SO > // Storage order of the adapted dense matrix
2377constexpr size_t LowerMatrix<MT,SO,true>::maxNonZeros() noexcept
2378{
2380
2381 return maxNonZeros( Size_v<MT,0UL> );
2382}
2384//*************************************************************************************************
2385
2386
2387//*************************************************************************************************
2397template< typename MT // Type of the adapted dense matrix
2398 , bool SO > // Storage order of the adapted dense matrix
2399constexpr size_t LowerMatrix<MT,SO,true>::maxNonZeros( size_t n ) noexcept
2400{
2401 return ( ( n + 1UL ) * n ) / 2UL;
2402}
2404//*************************************************************************************************
2405
2406
2407
2408
2409//=================================================================================================
2410//
2411// NUMERIC FUNCTIONS
2412//
2413//=================================================================================================
2414
2415//*************************************************************************************************
2433template< typename MT // Type of the adapted dense matrix
2434 , bool SO > // Storage order of the adapted dense matrix
2435template< typename Other > // Data type of the scalar value
2436inline LowerMatrix<MT,SO,true>& LowerMatrix<MT,SO,true>::scale( const Other& scalar )
2437{
2438 matrix_.scale( scalar );
2439 return *this;
2440}
2442//*************************************************************************************************
2443
2444
2445
2446
2447//=================================================================================================
2448//
2449// DEBUGGING FUNCTIONS
2450//
2451//=================================================================================================
2452
2453//*************************************************************************************************
2463template< typename MT // Type of the adapted dense matrix
2464 , bool SO > // Storage order of the adapted dense matrix
2465inline bool LowerMatrix<MT,SO,true>::isIntact() const noexcept
2466{
2467 using blaze::isIntact;
2468
2469 return ( isIntact( matrix_ ) && isLower( matrix_ ) );
2470}
2472//*************************************************************************************************
2473
2474
2475
2476
2477//=================================================================================================
2478//
2479// EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2480//
2481//=================================================================================================
2482
2483//*************************************************************************************************
2494template< typename MT // Type of the adapted dense matrix
2495 , bool SO > // Storage order of the adapted dense matrix
2496template< typename Other > // Data type of the foreign expression
2497inline bool LowerMatrix<MT,SO,true>::canAlias( const Other* alias ) const noexcept
2498{
2499 return matrix_.canAlias( alias );
2500}
2502//*************************************************************************************************
2503
2504
2505//*************************************************************************************************
2516template< typename MT // Type of the adapted dense matrix
2517 , bool SO > // Storage order of the adapted dense matrix
2518template< typename Other > // Data type of the foreign expression
2519inline bool LowerMatrix<MT,SO,true>::isAliased( const Other* alias ) const noexcept
2520{
2521 return matrix_.isAliased( alias );
2522}
2524//*************************************************************************************************
2525
2526
2527//*************************************************************************************************
2537template< typename MT // Type of the adapted dense matrix
2538 , bool SO > // Storage order of the adapted dense matrix
2539inline bool LowerMatrix<MT,SO,true>::isAligned() const noexcept
2540{
2541 return matrix_.isAligned();
2542}
2544//*************************************************************************************************
2545
2546
2547//*************************************************************************************************
2558template< typename MT // Type of the adapted dense matrix
2559 , bool SO > // Storage order of the adapted dense matrix
2560inline bool LowerMatrix<MT,SO,true>::canSMPAssign() const noexcept
2561{
2562 return matrix_.canSMPAssign();
2563}
2565//*************************************************************************************************
2566
2567
2568//*************************************************************************************************
2584template< typename MT // Type of the adapted dense matrix
2585 , bool SO > // Storage order of the adapted dense matrix
2586BLAZE_ALWAYS_INLINE typename LowerMatrix<MT,SO,true>::SIMDType
2587 LowerMatrix<MT,SO,true>::load( size_t i, size_t j ) const noexcept
2588{
2589 return matrix_.load( i, j );
2590}
2592//*************************************************************************************************
2593
2594
2595//*************************************************************************************************
2611template< typename MT // Type of the adapted dense matrix
2612 , bool SO > // Storage order of the adapted dense matrix
2613BLAZE_ALWAYS_INLINE typename LowerMatrix<MT,SO,true>::SIMDType
2614 LowerMatrix<MT,SO,true>::loada( size_t i, size_t j ) const noexcept
2615{
2616 return matrix_.loada( i, j );
2617}
2619//*************************************************************************************************
2620
2621
2622//*************************************************************************************************
2638template< typename MT // Type of the adapted dense matrix
2639 , bool SO > // Storage order of the adapted dense matrix
2640BLAZE_ALWAYS_INLINE typename LowerMatrix<MT,SO,true>::SIMDType
2641 LowerMatrix<MT,SO,true>::loadu( size_t i, size_t j ) const noexcept
2642{
2643 return matrix_.loadu( i, j );
2644}
2646//*************************************************************************************************
2647
2648
2649
2650
2651//=================================================================================================
2652//
2653// CONSTRUCTION FUNCTIONS
2654//
2655//=================================================================================================
2656
2657//*************************************************************************************************
2664template< typename MT // Type of the adapted dense matrix
2665 , bool SO > // Storage order of the adapted dense matrix
2666inline const MT LowerMatrix<MT,SO,true>::construct( size_t n, TrueType )
2667{
2669
2670 return MT( n, n, ElementType() );
2671}
2673//*************************************************************************************************
2674
2675
2676//*************************************************************************************************
2683template< typename MT // Type of the adapted dense matrix
2684 , bool SO > // Storage order of the adapted dense matrix
2685inline const MT LowerMatrix<MT,SO,true>::construct( const ElementType& init, FalseType )
2686{
2689
2690 MT tmp;
2691
2692 if( SO ) {
2693 for( size_t j=0UL; j<tmp.columns(); ++j )
2694 for( size_t i=j; i<tmp.rows(); ++i )
2695 tmp(i,j) = init;
2696 }
2697 else {
2698 for( size_t i=0UL; i<tmp.rows(); ++i )
2699 for( size_t j=0UL; j<=i; ++j )
2700 tmp(i,j) = init;
2701 }
2702
2703 return tmp;
2704}
2706//*************************************************************************************************
2707
2708
2709//*************************************************************************************************
2720template< typename MT // Type of the adapted dense matrix
2721 , bool SO > // Storage order of the adapted dense matrix
2722template< typename MT2 // Type of the foreign matrix
2723 , bool SO2 // Storage order of the foreign matrix
2724 , typename T > // Type of the third argument
2725inline const MT LowerMatrix<MT,SO,true>::construct( const Matrix<MT2,SO2>& m, T )
2726{
2727 const MT tmp( *m );
2728
2729 if( !IsLower_v<MT2> && !isLower( tmp ) ) {
2730 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of lower matrix" );
2731 }
2732
2733 return tmp;
2734}
2736//*************************************************************************************************
2737
2738} // namespace blaze
2739
2740#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 IsLower type trait.
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 LowerProxy class.
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.
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 LowerMatrix.
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 isLower(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is a lower triangular matrix.
Definition: DenseMatrix.h:1921
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.