Blaze 3.9
Sparse.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_ADAPTORS_UNILOWERMATRIX_SPARSE_H_
36#define _BLAZE_MATH_ADAPTORS_UNILOWERMATRIX_SPARSE_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <iterator>
44#include <utility>
45#include <vector>
51#include <blaze/math/Aliases.h>
81#include <blaze/util/Assert.h>
86#include <blaze/util/EnableIf.h>
88#include <blaze/util/Types.h>
89
90
91namespace blaze {
92
93//=================================================================================================
94//
95// CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
96//
97//=================================================================================================
98
99//*************************************************************************************************
107template< typename MT // Type of the adapted sparse matrix
108 , bool SO > // Storage order of the adapted sparse matrix
109class UniLowerMatrix<MT,SO,false>
110 : public SparseMatrix< UniLowerMatrix<MT,SO,false>, SO >
111{
112 private:
113 //**Type definitions****************************************************************************
114 using OT = OppositeType_t<MT>;
115 using TT = TransposeType_t<MT>;
116 using ET = ElementType_t<MT>;
117 //**********************************************************************************************
118
119 public:
120 //**Type definitions****************************************************************************
121 using This = UniLowerMatrix<MT,SO,false>;
122 using BaseType = SparseMatrix<This,SO>;
123 using ResultType = This;
124 using OppositeType = UniLowerMatrix<OT,!SO,false>;
125 using TransposeType = UniUpperMatrix<TT,!SO,false>;
126 using ElementType = ET;
127 using TagType = TagType_t<MT>;
128 using ReturnType = ReturnType_t<MT>;
129 using CompositeType = const This&;
130 using Reference = UniLowerProxy<MT>;
131 using ConstReference = ConstReference_t<MT>;
132 using ConstIterator = ConstIterator_t<MT>;
133 //**********************************************************************************************
134
135 //**Rebind struct definition********************************************************************
138 template< typename NewType > // Data type of the other matrix
139 struct Rebind {
141 using Other = UniLowerMatrix< typename MT::template Rebind<NewType>::Other >;
142 };
143 //**********************************************************************************************
144
145 //**Resize struct definition********************************************************************
148 template< size_t NewM // Number of rows of the other matrix
149 , size_t NewN > // Number of columns of the other matrix
150 struct Resize {
152 using Other = UniLowerMatrix< typename MT::template Resize<NewM,NewN>::Other >;
153 };
154 //**********************************************************************************************
155
156 //**Iterator class definition*******************************************************************
159 class Iterator
160 {
161 public:
162 //**Type definitions*************************************************************************
163 using IteratorType = Iterator_t<MT>;
164
165 using IteratorCategory = std::forward_iterator_tag;
166 using ValueType = UniLowerElement<MT>;
167 using PointerType = ValueType;
168 using ReferenceType = ValueType;
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 //**Default constructor**********************************************************************
182 inline Iterator()
183 : pos_ ( ) // Iterator to the current lower unitriangular matrix element
184 , index_ ( 0UL ) // The row/column index of the iterator
185 {}
186 //*******************************************************************************************
187
188 //**Constructor******************************************************************************
194 inline Iterator( IteratorType pos, size_t index )
195 : pos_ ( pos ) // Iterator to the current lower unitriangular matrix element
196 , index_( index ) // The row/column index of the iterator
197 {}
198 //*******************************************************************************************
199
200 //**Prefix increment operator****************************************************************
205 inline Iterator& operator++() {
206 ++pos_;
207 return *this;
208 }
209 //*******************************************************************************************
210
211 //**Postfix increment operator***************************************************************
216 inline const Iterator operator++( int ) {
217 const Iterator tmp( *this );
218 ++(*this);
219 return tmp;
220 }
221 //*******************************************************************************************
222
223 //**Element access operator******************************************************************
228 inline ReferenceType operator*() const {
229 return ReferenceType( pos_, pos_->index() == index_ );
230 }
231 //*******************************************************************************************
232
233 //**Element access operator******************************************************************
238 inline PointerType operator->() const {
239 return PointerType( pos_, pos_->index() == index_ );
240 }
241 //*******************************************************************************************
242
243 //**Conversion operator**********************************************************************
248 inline operator ConstIterator() const {
249 return pos_;
250 }
251 //*******************************************************************************************
252
253 //**Equality operator************************************************************************
259 inline bool operator==( const Iterator& rhs ) const {
260 return pos_ == rhs.pos_;
261 }
262 //*******************************************************************************************
263
264 //**Inequality operator**********************************************************************
270 inline bool operator!=( const Iterator& rhs ) const {
271 return !( *this == rhs );
272 }
273 //*******************************************************************************************
274
275 //**Subtraction operator*********************************************************************
281 inline DifferenceType operator-( const Iterator& rhs ) const {
282 return pos_ - rhs.pos_;
283 }
284 //*******************************************************************************************
285
286 //**Base function****************************************************************************
291 inline IteratorType base() const {
292 return pos_;
293 }
294 //*******************************************************************************************
295
296 private:
297 //**Member variables*************************************************************************
298 IteratorType pos_;
299 size_t index_;
300 //*******************************************************************************************
301 };
302 //**********************************************************************************************
303
304 //**Compilation flags***************************************************************************
306 static constexpr bool smpAssignable = false;
307 //**********************************************************************************************
308
309 //**Constructors********************************************************************************
312 inline UniLowerMatrix();
313 explicit inline UniLowerMatrix( size_t n );
314 inline UniLowerMatrix( size_t n, size_t nonzeros );
315 inline UniLowerMatrix( size_t n, const std::vector<size_t>& nonzeros );
316 inline UniLowerMatrix( initializer_list< initializer_list<ElementType> > list );
317
318 inline UniLowerMatrix( const UniLowerMatrix& m );
319 inline UniLowerMatrix( UniLowerMatrix&& m ) noexcept;
320
321 template< typename MT2, bool SO2 >
322 inline UniLowerMatrix( const Matrix<MT2,SO2>& m );
324 //**********************************************************************************************
325
326 //**Destructor**********************************************************************************
329 ~UniLowerMatrix() = default;
331 //**********************************************************************************************
332
333 //**Data access functions***********************************************************************
336 inline Reference operator()( size_t i, size_t j );
337 inline ConstReference operator()( size_t i, size_t j ) const;
338 inline Reference at( size_t i, size_t j );
339 inline ConstReference at( size_t i, size_t j ) const;
340 inline Iterator begin ( size_t i );
341 inline ConstIterator begin ( size_t i ) const;
342 inline ConstIterator cbegin( size_t i ) const;
343 inline Iterator end ( size_t i );
344 inline ConstIterator end ( size_t i ) const;
345 inline ConstIterator cend ( size_t i ) const;
347 //**********************************************************************************************
348
349 //**Assignment operators************************************************************************
352 inline UniLowerMatrix& operator=( initializer_list< initializer_list<ElementType> > list );
353
354 inline UniLowerMatrix& operator=( const UniLowerMatrix& rhs );
355 inline UniLowerMatrix& operator=( UniLowerMatrix&& rhs ) noexcept;
356
357 template< typename MT2, bool SO2 >
358 inline auto operator=( const Matrix<MT2,SO2>& rhs )
359 -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
360
361 template< typename MT2, bool SO2 >
362 inline auto operator=( const Matrix<MT2,SO2>& rhs )
363 -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
364
365 template< typename MT2, bool SO2 >
366 inline auto operator+=( const Matrix<MT2,SO2>& rhs )
367 -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
368
369 template< typename MT2, bool SO2 >
370 inline auto operator+=( const Matrix<MT2,SO2>& rhs )
371 -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
372
373 template< typename MT2, bool SO2 >
374 inline auto operator-=( const Matrix<MT2,SO2>& rhs )
375 -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
376
377 template< typename MT2, bool SO2 >
378 inline auto operator-=( const Matrix<MT2,SO2>& rhs )
379 -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >;
380
381 template< typename MT2, bool SO2 >
382 inline auto operator%=( const Matrix<MT2,SO2>& rhs ) -> UniLowerMatrix&;
384 //**********************************************************************************************
385
386 //**Utility functions***************************************************************************
389 inline size_t rows() const noexcept;
390 inline size_t columns() const noexcept;
391 inline size_t capacity() const noexcept;
392 inline size_t capacity( size_t i ) const noexcept;
393 inline size_t nonZeros() const;
394 inline size_t nonZeros( size_t i ) const;
395 inline void reset();
396 inline void reset( size_t i );
397 inline void clear();
398 inline void resize ( size_t n, bool preserve=true );
399 inline void reserve( size_t nonzeros );
400 inline void reserve( size_t i, size_t nonzeros );
401 inline void trim();
402 inline void trim( size_t i );
403 inline void shrinkToFit();
404 inline void swap( UniLowerMatrix& m ) noexcept;
405
406 static constexpr size_t maxNonZeros() noexcept;
407 static constexpr size_t maxNonZeros( size_t n ) noexcept;
409 //**********************************************************************************************
410
411 //**Insertion functions*************************************************************************
414 inline Iterator set ( size_t i, size_t j, const ElementType& value );
415 inline Iterator insert ( size_t i, size_t j, const ElementType& value );
416 inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
417 inline void finalize( size_t i );
419 //**********************************************************************************************
420
421 //**Erase functions*****************************************************************************
424 inline void erase( size_t i, size_t j );
425 inline Iterator erase( size_t i, Iterator pos );
426 inline Iterator erase( size_t i, Iterator first, Iterator last );
427
428 template< typename Pred >
429 inline void erase( Pred predicate );
430
431 template< typename Pred >
432 inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
434 //**********************************************************************************************
435
436 //**Lookup functions****************************************************************************
439 inline Iterator find ( size_t i, size_t j );
440 inline ConstIterator find ( size_t i, size_t j ) const;
441 inline Iterator lowerBound( size_t i, size_t j );
442 inline ConstIterator lowerBound( size_t i, size_t j ) const;
443 inline Iterator upperBound( size_t i, size_t j );
444 inline ConstIterator upperBound( size_t i, size_t j ) const;
446 //**********************************************************************************************
447
448 //**Debugging functions*************************************************************************
451 inline bool isIntact() const noexcept;
453 //**********************************************************************************************
454
455 //**Expression template evaluation functions****************************************************
458 template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
459 template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
460
461 inline bool canSMPAssign() const noexcept;
463 //**********************************************************************************************
464
465 private:
466 //**Utility functions***************************************************************************
469 inline void resetUpper();
471 //**********************************************************************************************
472
473 //**Member variables****************************************************************************
476 MT matrix_;
478 //**********************************************************************************************
479
480 //**Friend declarations*************************************************************************
481 template< typename MT2, bool SO2, bool DF2 >
482 friend MT2& derestrict( UniLowerMatrix<MT2,SO2,DF2>& m );
483 //**********************************************************************************************
484
485 //**Compile time checks*************************************************************************
502 BLAZE_STATIC_ASSERT( ( Size_v<MT,0UL> == Size_v<MT,1UL> ) );
503 //**********************************************************************************************
504};
506//*************************************************************************************************
507
508
509
510
511//=================================================================================================
512//
513// CONSTRUCTORS
514//
515//=================================================================================================
516
517//*************************************************************************************************
521template< typename MT // Type of the adapted sparse matrix
522 , bool SO > // Storage order of the adapted sparse matrix
523inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix()
524 : matrix_() // The adapted sparse matrix
525{
526 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
527}
529//*************************************************************************************************
530
531
532//*************************************************************************************************
540template< typename MT // Type of the adapted sparse matrix
541 , bool SO > // Storage order of the adapted sparse matrix
542inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n )
543 : matrix_( n, n, n ) // The adapted sparse matrix
544{
546
547 for( size_t i=0UL; i<n; ++i ) {
548 matrix_.append( i, i, ElementType(1) );
549 matrix_.finalize( i );
550 }
551
552 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
553}
555//*************************************************************************************************
556
557
558//*************************************************************************************************
568template< typename MT // Type of the adapted sparse matrix
569 , bool SO > // Storage order of the adapted sparse matrix
570inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n, size_t nonzeros )
571 : matrix_( n, n, max( nonzeros, n ) ) // The adapted sparse matrix
572{
574
575 for( size_t i=0UL; i<n; ++i ) {
576 matrix_.append( i, i, ElementType(1) );
577 matrix_.finalize( i );
578 }
579
580 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
581}
583//*************************************************************************************************
584
585
586//*************************************************************************************************
600template< typename MT // Type of the adapted sparse matrix
601 , bool SO > // Storage order of the adapted sparse matrix
602inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( size_t n, const std::vector<size_t>& nonzeros )
603 : matrix_( n, n, nonzeros ) // The adapted sparse matrix
604{
606
607 for( size_t i=0UL; i<n; ++i )
608 {
609 if( nonzeros[i] == 0UL ) {
610 BLAZE_THROW_INVALID_ARGUMENT( "Invalid capacity specification" );
611 }
612
613 matrix_.append( i, i, ElementType(1) );
614 matrix_.finalize( i );
615 }
616
617 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
618}
620//*************************************************************************************************
621
622
623//*************************************************************************************************
647template< typename MT // Type of the adapted sparse matrix
648 , bool SO > // Storage order of the adapted sparse matrix
649inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( initializer_list< initializer_list<ElementType> > list )
650 : matrix_( list ) // The adapted sparse matrix
651{
652 if( !isUniLower( matrix_ ) ) {
653 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
654 }
655
656 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
657}
659//*************************************************************************************************
660
661
662//*************************************************************************************************
668template< typename MT // Type of the adapted sparse matrix
669 , bool SO > // Storage order of the adapted sparse matrix
670inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( const UniLowerMatrix& m )
671 : matrix_( m.matrix_ ) // The adapted sparse matrix
672{
673 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
674 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
675}
677//*************************************************************************************************
678
679
680//*************************************************************************************************
686template< typename MT // Type of the adapted sparse matrix
687 , bool SO > // Storage order of the adapted sparse matrix
688inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( UniLowerMatrix&& m ) noexcept
689 : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
690{
691 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
692 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
693}
695//*************************************************************************************************
696
697
698//*************************************************************************************************
708template< typename MT // Type of the adapted sparse matrix
709 , bool SO > // Storage order of the adapted sparse matrix
710template< typename MT2 // Type of the foreign matrix
711 , bool SO2 > // Storage order of the foreign matrix
712inline UniLowerMatrix<MT,SO,false>::UniLowerMatrix( const Matrix<MT2,SO2>& m )
713 : matrix_( *m ) // The adapted sparse matrix
714{
715 if( !IsUniLower_v<MT2> && !isUniLower( matrix_ ) ) {
716 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of unilower matrix" );
717 }
718
719 if( !IsUniLower_v<MT2> )
720 resetUpper();
721
722 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
723 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
724}
726//*************************************************************************************************
727
728
729
730
731//=================================================================================================
732//
733// DATA ACCESS FUNCTIONS
734//
735//=================================================================================================
736
737//*************************************************************************************************
753template< typename MT // Type of the adapted sparse matrix
754 , bool SO > // Storage order of the adapted sparse matrix
755inline typename UniLowerMatrix<MT,SO,false>::Reference
756 UniLowerMatrix<MT,SO,false>::operator()( size_t i, size_t j )
757{
758 BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
759 BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
760
761 return Reference( matrix_, i, j );
762}
764//*************************************************************************************************
765
766
767//*************************************************************************************************
783template< typename MT // Type of the adapted sparse matrix
784 , bool SO > // Storage order of the adapted sparse matrix
785inline typename UniLowerMatrix<MT,SO,false>::ConstReference
786 UniLowerMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
787{
788 BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
789 BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
790
791 return matrix_(i,j);
792}
794//*************************************************************************************************
795
796
797//*************************************************************************************************
814template< typename MT // Type of the adapted sparse matrix
815 , bool SO > // Storage order of the adapted sparse matrix
816inline typename UniLowerMatrix<MT,SO,false>::Reference
817 UniLowerMatrix<MT,SO,false>::at( size_t i, size_t j )
818{
819 if( i >= rows() ) {
820 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
821 }
822 if( j >= columns() ) {
823 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
824 }
825 return (*this)(i,j);
826}
828//*************************************************************************************************
829
830
831//*************************************************************************************************
848template< typename MT // Type of the adapted sparse matrix
849 , bool SO > // Storage order of the adapted sparse matrix
850inline typename UniLowerMatrix<MT,SO,false>::ConstReference
851 UniLowerMatrix<MT,SO,false>::at( size_t i, size_t j ) const
852{
853 if( i >= rows() ) {
854 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
855 }
856 if( j >= columns() ) {
857 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
858 }
859 return (*this)(i,j);
860}
862//*************************************************************************************************
863
864
865//*************************************************************************************************
877template< typename MT // Type of the adapted sparse matrix
878 , bool SO > // Storage order of the adapted sparse matrix
879inline typename UniLowerMatrix<MT,SO,false>::Iterator
881{
882 return Iterator( matrix_.begin(i), i );
883}
885//*************************************************************************************************
886
887
888//*************************************************************************************************
900template< typename MT // Type of the adapted sparse matrix
901 , bool SO > // Storage order of the adapted sparse matrix
902inline typename UniLowerMatrix<MT,SO,false>::ConstIterator
903 UniLowerMatrix<MT,SO,false>::begin( size_t i ) const
904{
905 return matrix_.begin(i);
906}
908//*************************************************************************************************
909
910
911//*************************************************************************************************
923template< typename MT // Type of the adapted sparse matrix
924 , bool SO > // Storage order of the adapted sparse matrix
925inline typename UniLowerMatrix<MT,SO,false>::ConstIterator
927{
928 return matrix_.cbegin(i);
929}
931//*************************************************************************************************
932
933
934//*************************************************************************************************
946template< typename MT // Type of the adapted sparse matrix
947 , bool SO > // Storage order of the adapted sparse matrix
948inline typename UniLowerMatrix<MT,SO,false>::Iterator
950{
951 return Iterator( matrix_.end(i), i );
952}
954//*************************************************************************************************
955
956
957//*************************************************************************************************
969template< typename MT // Type of the adapted sparse matrix
970 , bool SO > // Storage order of the adapted sparse matrix
971inline typename UniLowerMatrix<MT,SO,false>::ConstIterator
972 UniLowerMatrix<MT,SO,false>::end( size_t i ) const
973{
974 return matrix_.end(i);
975}
977//*************************************************************************************************
978
979
980//*************************************************************************************************
992template< typename MT // Type of the adapted sparse matrix
993 , bool SO > // Storage order of the adapted sparse matrix
994inline typename UniLowerMatrix<MT,SO,false>::ConstIterator
995 UniLowerMatrix<MT,SO,false>::cend( size_t i ) const
996{
997 return matrix_.cend(i);
998}
1000//*************************************************************************************************
1001
1002
1003
1004
1005//=================================================================================================
1006//
1007// ASSIGNMENT OPERATORS
1008//
1009//=================================================================================================
1010
1011//*************************************************************************************************
1036template< typename MT // Type of the adapted sparse matrix
1037 , bool SO > // Storage order of the adapted sparse matrix
1038inline UniLowerMatrix<MT,SO,false>&
1039 UniLowerMatrix<MT,SO,false>::operator=( initializer_list< initializer_list<ElementType> > list )
1040{
1041 const InitializerMatrix<ElementType> tmp( list, list.size() );
1042
1043 if( !isUniLower( tmp ) ) {
1044 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1045 }
1046
1047 matrix_ = list;
1048
1049 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1050 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1051
1052 return *this;
1053}
1055//*************************************************************************************************
1056
1057
1058//*************************************************************************************************
1068template< typename MT // Type of the adapted sparse matrix
1069 , bool SO > // Storage order of the adapted sparse matrix
1070inline UniLowerMatrix<MT,SO,false>&
1071 UniLowerMatrix<MT,SO,false>::operator=( const UniLowerMatrix& rhs )
1072{
1073 matrix_ = rhs.matrix_;
1074
1075 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1076 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1077
1078 return *this;
1079}
1081//*************************************************************************************************
1082
1083
1084//*************************************************************************************************
1091template< typename MT // Type of the adapted sparse matrix
1092 , bool SO > // Storage order of the adapted sparse matrix
1093inline UniLowerMatrix<MT,SO,false>&
1094 UniLowerMatrix<MT,SO,false>::operator=( UniLowerMatrix&& rhs ) noexcept
1095{
1096 matrix_ = std::move( rhs.matrix_ );
1097
1098 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1099 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1100
1101 return *this;
1102}
1104//*************************************************************************************************
1105
1106
1107//*************************************************************************************************
1120template< typename MT // Type of the adapted sparse matrix
1121 , bool SO > // Storage order of the adapted sparse matrix
1122template< typename MT2 // Type of the right-hand side matrix
1123 , bool SO2 > // Storage order of the right-hand side matrix
1124inline auto UniLowerMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
1125 -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1126{
1127 if( IsStrictlyTriangular_v<MT2> || ( !IsUniLower_v<MT2> && !isUniLower( *rhs ) ) ) {
1128 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1129 }
1130
1131 matrix_ = decllow( *rhs );
1132
1133 if( !IsUniLower_v<MT2> )
1134 resetUpper();
1135
1136 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1137 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1138
1139 return *this;
1140}
1142//*************************************************************************************************
1143
1144
1145//*************************************************************************************************
1158template< typename MT // Type of the adapted sparse matrix
1159 , bool SO > // Storage order of the adapted sparse matrix
1160template< typename MT2 // Type of the right-hand side matrix
1161 , bool SO2 > // Storage order of the right-hand side matrix
1162inline auto UniLowerMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
1163 -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1164{
1165 if( IsStrictlyTriangular_v<MT2> || ( !IsSquare_v<MT2> && !isSquare( *rhs ) ) ) {
1166 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1167 }
1168
1169 if( IsUniLower_v<MT2> ) {
1170 matrix_ = *rhs;
1171 }
1172 else {
1173 MT tmp( *rhs );
1174
1175 if( !isUniLower( tmp ) ) {
1176 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1177 }
1178
1179 matrix_ = std::move( tmp );
1180 }
1181
1182 if( !IsUniLower_v<MT2> )
1183 resetUpper();
1184
1185 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1186 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1187
1188 return *this;
1189}
1191//*************************************************************************************************
1192
1193
1194//*************************************************************************************************
1207template< typename MT // Type of the adapted sparse matrix
1208 , bool SO > // Storage order of the adapted sparse matrix
1209template< typename MT2 // Type of the right-hand side matrix
1210 , bool SO2 > // Storage order of the right-hand side matrix
1211inline auto UniLowerMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1212 -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1213{
1214 if( IsUpper_v<MT2> || IsUniTriangular_v<MT2> ||
1215 ( !IsStrictlyLower_v<MT2> && !isStrictlyLower( *rhs ) ) ) {
1216 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1217 }
1218
1219 matrix_ += decllow( *rhs );
1220
1221 if( !IsStrictlyLower_v<MT2> )
1222 resetUpper();
1223
1224 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1225 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1226
1227 return *this;
1228}
1230//*************************************************************************************************
1231
1232
1233//*************************************************************************************************
1246template< typename MT // Type of the adapted sparse matrix
1247 , bool SO > // Storage order of the adapted sparse matrix
1248template< typename MT2 // Type of the right-hand side matrix
1249 , bool SO2 > // Storage order of the right-hand side matrix
1250inline auto UniLowerMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1251 -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1252{
1253 if( IsUpper_v<MT2> || IsUniTriangular_v<MT2> ||
1254 ( !IsSquare_v<MT2> && !isSquare( *rhs ) ) ) {
1255 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1256 }
1257
1258 if( IsStrictlyLower_v<MT2> ) {
1259 matrix_ += *rhs;
1260 }
1261 else {
1262 const ResultType_t<MT2> tmp( *rhs );
1263
1264 if( !isStrictlyLower( tmp ) ) {
1265 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1266 }
1267
1268 matrix_ += decllow( tmp );
1269 }
1270
1271 if( !IsStrictlyLower_v<MT2> )
1272 resetUpper();
1273
1274 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1275 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1276
1277 return *this;
1278}
1280//*************************************************************************************************
1281
1282
1283//*************************************************************************************************
1296template< typename MT // Type of the adapted sparse matrix
1297 , bool SO > // Storage order of the adapted sparse matrix
1298template< typename MT2 // Type of the right-hand side matrix
1299 , bool SO2 > // Storage order of the right-hand side matrix
1300inline auto UniLowerMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1301 -> DisableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1302{
1303 if( IsUpper_v<MT2> || IsUniTriangular_v<MT2> ||
1304 ( !IsStrictlyLower_v<MT2> && !isStrictlyLower( *rhs ) ) ) {
1305 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1306 }
1307
1308 matrix_ -= decllow( *rhs );
1309
1310 if( !IsStrictlyLower_v<MT2> )
1311 resetUpper();
1312
1313 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1314 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1315
1316 return *this;
1317}
1319//*************************************************************************************************
1320
1321
1322//*************************************************************************************************
1335template< typename MT // Type of the adapted sparse matrix
1336 , bool SO > // Storage order of the adapted sparse matrix
1337template< typename MT2 // Type of the right-hand side matrix
1338 , bool SO2 > // Storage order of the right-hand side matrix
1339inline auto UniLowerMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1340 -> EnableIf_t< IsComputation_v<MT2>, UniLowerMatrix& >
1341{
1342 if( IsUpper_v<MT2> || IsUniTriangular_v<MT2> ||
1343 ( !IsSquare_v<MT2> && !isSquare( *rhs ) ) ) {
1344 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1345 }
1346
1347 if( IsStrictlyLower_v<MT2> ) {
1348 matrix_ -= *rhs;
1349 }
1350 else {
1351 const ResultType_t<MT2> tmp( *rhs );
1352
1353 if( !isStrictlyLower( tmp ) ) {
1354 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1355 }
1356
1357 matrix_ -= decllow( tmp );
1358 }
1359
1360 if( !IsStrictlyLower_v<MT2> )
1361 resetUpper();
1362
1363 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1364 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1365
1366 return *this;
1367}
1369//*************************************************************************************************
1370
1371
1372//*************************************************************************************************
1385template< typename MT // Type of the adapted sparse matrix
1386 , bool SO > // Storage order of the adapted sparse matrix
1387template< typename MT2 // Type of the right-hand side matrix
1388 , bool SO2 > // Storage order of the right-hand side matrix
1389inline auto UniLowerMatrix<MT,SO,false>::operator%=( const Matrix<MT2,SO2>& rhs )
1390 -> UniLowerMatrix&
1391{
1392 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
1393 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1394 }
1395
1396 If_t< IsComputation_v<MT2>, ResultType_t<MT2>, const MT2& > tmp( *rhs );
1397
1398 for( size_t i=0UL; i<(*rhs).rows(); ++i ) {
1399 if( !isOne( tmp(i,i) ) ) {
1400 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to unilower matrix" );
1401 }
1402 }
1403
1404 matrix_ %= tmp;
1405
1406 if( !IsUniLower_v<MT2> )
1407 resetUpper();
1408
1409 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1410 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1411
1412 return *this;
1413}
1415//*************************************************************************************************
1416
1417
1418
1419
1420//=================================================================================================
1421//
1422// UTILITY FUNCTIONS
1423//
1424//=================================================================================================
1425
1426//*************************************************************************************************
1432template< typename MT // Type of the adapted sparse matrix
1433 , bool SO > // Storage order of the adapted sparse matrix
1434inline size_t UniLowerMatrix<MT,SO,false>::rows() const noexcept
1435{
1436 return matrix_.rows();
1437}
1439//*************************************************************************************************
1440
1441
1442//*************************************************************************************************
1448template< typename MT // Type of the adapted sparse matrix
1449 , bool SO > // Storage order of the adapted sparse matrix
1450inline size_t UniLowerMatrix<MT,SO,false>::columns() const noexcept
1451{
1452 return matrix_.columns();
1453}
1455//*************************************************************************************************
1456
1457
1458//*************************************************************************************************
1464template< typename MT // Type of the adapted sparse matrix
1465 , bool SO > // Storage order of the adapted sparse matrix
1466inline size_t UniLowerMatrix<MT,SO,false>::capacity() const noexcept
1467{
1468 return matrix_.capacity();
1469}
1471//*************************************************************************************************
1472
1473
1474//*************************************************************************************************
1486template< typename MT // Type of the adapted sparse matrix
1487 , bool SO > // Storage order of the adapted sparse matrix
1488inline size_t UniLowerMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1489{
1490 return matrix_.capacity(i);
1491}
1493//*************************************************************************************************
1494
1495
1496//*************************************************************************************************
1502template< typename MT // Type of the adapted sparse matrix
1503 , bool SO > // Storage order of the adapted sparse matrix
1504inline size_t UniLowerMatrix<MT,SO,false>::nonZeros() const
1505{
1506 return matrix_.nonZeros();
1507}
1509//*************************************************************************************************
1510
1511
1512//*************************************************************************************************
1524template< typename MT // Type of the adapted sparse matrix
1525 , bool SO > // Storage order of the adapted sparse matrix
1526inline size_t UniLowerMatrix<MT,SO,false>::nonZeros( size_t i ) const
1527{
1528 return matrix_.nonZeros(i);
1529}
1531//*************************************************************************************************
1532
1533
1534//*************************************************************************************************
1540template< typename MT // Type of the adapted sparse matrix
1541 , bool SO > // Storage order of the adapted sparse matrix
1543{
1544 if( SO ) {
1545 for( size_t j=0UL; j<columns(); ++j ) {
1546 matrix_.erase( j, matrix_.lowerBound(j+1UL,j), matrix_.end(j) );
1547 }
1548 }
1549 else {
1550 for( size_t i=1UL; i<rows(); ++i ) {
1551 matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1552 }
1553 }
1554}
1556//*************************************************************************************************
1557
1558
1559//*************************************************************************************************
1572template< typename MT // Type of the adapted sparse matrix
1573 , bool SO > // Storage order of the adapted sparse matrix
1574inline void UniLowerMatrix<MT,SO,false>::reset( size_t i )
1575{
1576 if( SO ) {
1577 matrix_.erase( i, matrix_.lowerBound(i+1UL,i), matrix_.end(i) );
1578 }
1579 else {
1580 matrix_.erase( i, matrix_.begin(i), matrix_.lowerBound(i,i) );
1581 }
1582}
1584//*************************************************************************************************
1585
1586
1587//*************************************************************************************************
1595template< typename MT // Type of the adapted sparse matrix
1596 , bool SO > // Storage order of the adapted sparse matrix
1598{
1599 matrix_.clear();
1600
1601 BLAZE_INTERNAL_ASSERT( matrix_.rows() == 0UL, "Invalid number of rows" );
1602 BLAZE_INTERNAL_ASSERT( matrix_.columns() == 0UL, "Invalid number of columns" );
1603}
1605//*************************************************************************************************
1606
1607
1608//*************************************************************************************************
1623template< typename MT // Type of the adapted sparse matrix
1624 , bool SO > // Storage order of the adapted sparse matrix
1625void UniLowerMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1626{
1628
1629 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square unilower matrix detected" );
1630
1631 const size_t oldsize( matrix_.rows() );
1632
1633 matrix_.resize( n, n, preserve );
1634
1635 if( n > oldsize ) {
1636 for( size_t i=oldsize; i<n; ++i )
1637 matrix_.insert( i, i, ElementType(1) );
1638 }
1639}
1641//*************************************************************************************************
1642
1643
1644//*************************************************************************************************
1655template< typename MT // Type of the adapted sparse matrix
1656 , bool SO > // Storage order of the adapted sparse matrix
1657inline void UniLowerMatrix<MT,SO,false>::reserve( size_t nonzeros )
1658{
1659 matrix_.reserve( nonzeros );
1660}
1662//*************************************************************************************************
1663
1664
1665//*************************************************************************************************
1679template< typename MT // Type of the adapted sparse matrix
1680 , bool SO > // Storage order of the adapted sparse matrix
1681inline void UniLowerMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1682{
1683 matrix_.reserve( i, nonzeros );
1684}
1686//*************************************************************************************************
1687
1688
1689//*************************************************************************************************
1700template< typename MT // Type of the adapted sparse matrix
1701 , bool SO > // Storage order of the adapted sparse matrix
1702inline void UniLowerMatrix<MT,SO,false>::trim()
1703{
1704 matrix_.trim();
1705}
1707//*************************************************************************************************
1708
1709
1710//*************************************************************************************************
1722template< typename MT // Type of the adapted sparse matrix
1723 , bool SO > // Storage order of the adapted sparse matrix
1724inline void UniLowerMatrix<MT,SO,false>::trim( size_t i )
1725{
1726 matrix_.trim( i );
1727}
1729//*************************************************************************************************
1730
1731
1732//*************************************************************************************************
1742template< typename MT // Type of the adapted sparse matrix
1743 , bool SO > // Storage order of the adapted sparse matrix
1745{
1746 matrix_.shrinkToFit();
1747}
1749//*************************************************************************************************
1750
1751
1752//*************************************************************************************************
1759template< typename MT // Type of the adapted sparse matrix
1760 , bool SO > // Storage order of the adapted sparse matrix
1761inline void UniLowerMatrix<MT,SO,false>::swap( UniLowerMatrix& m ) noexcept
1762{
1763 using std::swap;
1764
1765 swap( matrix_, m.matrix_ );
1766}
1768//*************************************************************************************************
1769
1770
1771//*************************************************************************************************
1782template< typename MT // Type of the adapted dense matrix
1783 , bool SO > // Storage order of the adapted dense matrix
1784constexpr size_t UniLowerMatrix<MT,SO,false>::maxNonZeros() noexcept
1785{
1787
1788 return maxNonZeros( Size_v<MT,0UL> );
1789}
1791//*************************************************************************************************
1792
1793
1794//*************************************************************************************************
1804template< typename MT // Type of the adapted dense matrix
1805 , bool SO > // Storage order of the adapted dense matrix
1806constexpr size_t UniLowerMatrix<MT,SO,false>::maxNonZeros( size_t n ) noexcept
1807{
1808 return ( ( n + 1UL ) * n ) / 2UL;
1809}
1811//*************************************************************************************************
1812
1813
1814//*************************************************************************************************
1820template< typename MT // Type of the adapted dense matrix
1821 , bool SO > // Storage order of the adapted dense matrix
1822inline void UniLowerMatrix<MT,SO,false>::resetUpper()
1823{
1824 if( SO ) {
1825 for( size_t j=1UL; j<columns(); ++j )
1826 matrix_.erase( j, matrix_.begin( j ), matrix_.lowerBound( j, j ) );
1827 }
1828 else {
1829 for( size_t i=0UL; i<rows(); ++i )
1830 matrix_.erase( i, matrix_.upperBound( i, i ), matrix_.end( i ) );
1831 }
1832}
1834//*************************************************************************************************
1835
1836
1837
1838
1839//=================================================================================================
1840//
1841// INSERTION FUNCTIONS
1842//
1843//=================================================================================================
1844
1845//*************************************************************************************************
1861template< typename MT // Type of the adapted sparse matrix
1862 , bool SO > // Storage order of the adapted sparse matrix
1863inline typename UniLowerMatrix<MT,SO,false>::Iterator
1864 UniLowerMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1865{
1866 if( i <= j ) {
1867 BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1868 }
1869
1870 return Iterator( matrix_.set( i, j, value ), ( SO ? j : i ) );
1871}
1873//*************************************************************************************************
1874
1875
1876//*************************************************************************************************
1893template< typename MT // Type of the adapted sparse matrix
1894 , bool SO > // Storage order of the adapted sparse matrix
1895inline typename UniLowerMatrix<MT,SO,false>::Iterator
1896 UniLowerMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1897{
1898 if( i <= j ) {
1899 BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1900 }
1901
1902 return Iterator( matrix_.insert( i, j, value ), ( SO ? j : i ) );
1903}
1905//*************************************************************************************************
1906
1907
1908//*************************************************************************************************
1958template< typename MT // Type of the adapted sparse matrix
1959 , bool SO > // Storage order of the adapted sparse matrix
1960inline void UniLowerMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1961{
1962 if( i <= j ) {
1963 BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal or upper matrix element" );
1964 }
1965
1966 if( !check || !isDefault<strict>( value ) )
1967 matrix_.insert( i, j, value );
1968}
1970//*************************************************************************************************
1971
1972
1973//*************************************************************************************************
1987template< typename MT // Type of the adapted sparse matrix
1988 , bool SO > // Storage order of the adapted sparse matrix
1989inline void UniLowerMatrix<MT,SO,false>::finalize( size_t i )
1990{
1991 matrix_.trim( i );
1992}
1994//*************************************************************************************************
1995
1996
1997
1998
1999//=================================================================================================
2000//
2001// ERASE FUNCTIONS
2002//
2003//=================================================================================================
2004
2005//*************************************************************************************************
2017template< typename MT // Type of the adapted sparse matrix
2018 , bool SO > // Storage order of the adapted sparse matrix
2019inline void UniLowerMatrix<MT,SO,false>::erase( size_t i, size_t j )
2020{
2021 if( i == j ) {
2022 BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2023 }
2024
2025 matrix_.erase( i, j );
2026}
2028//*************************************************************************************************
2029
2030
2031//*************************************************************************************************
2045template< typename MT // Type of the adapted sparse matrix
2046 , bool SO > // Storage order of the adapted sparse matrix
2047inline typename UniLowerMatrix<MT,SO,false>::Iterator
2048 UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
2049{
2050 if( pos != matrix_.end(i) && pos->index() == i ) {
2051 BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2052 }
2053
2054 return Iterator( matrix_.erase( i, pos.base() ), i );
2055}
2057//*************************************************************************************************
2058
2059
2060//*************************************************************************************************
2075template< typename MT // Type of the adapted sparse matrix
2076 , bool SO > // Storage order of the adapted sparse matrix
2077inline typename UniLowerMatrix<MT,SO,false>::Iterator
2078 UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
2079{
2080 if( first == last )
2081 return last;
2082
2083 if( ( !SO && last.base() == matrix_.end(i) ) ||
2084 ( SO && first.base() == matrix_.begin(i) ) ) {
2085 BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2086 }
2087
2088 return Iterator( matrix_.erase( i, first.base(), last.base() ), i );
2089}
2091//*************************************************************************************************
2092
2093
2094//*************************************************************************************************
2116template< typename MT // Type of the adapted sparse matrix
2117 , bool SO > // Storage order of the adapted sparse matrix
2118template< typename Pred > // Type of the unary predicate
2119inline void UniLowerMatrix<MT,SO,false>::erase( Pred predicate )
2120{
2121 if( SO ) {
2122 for( size_t j=0UL; (j+1UL) < columns(); ++j ) {
2123 matrix_.erase( j, matrix_.lowerBound(j+1UL,j), matrix_.end(j), predicate );
2124 }
2125 }
2126 else {
2127 for( size_t i=1UL; i<rows(); ++i ) {
2128 matrix_.erase( i, matrix_.begin(i), matrix_.find(i,i), predicate );
2129 }
2130 }
2131
2132 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2133}
2135//*************************************************************************************************
2136
2137
2138//*************************************************************************************************
2169template< typename MT // Type of the adapted sparse matrix
2170 , bool SO > // Storage order of the adapted sparse matrix
2171template< typename Pred > // Type of the unary predicate
2172inline void UniLowerMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
2173{
2174 if( first == last )
2175 return;
2176
2177 if( ( !SO && last.base() == matrix_.end(i) && predicate( ElementType(1) ) ) ||
2178 ( SO && first.base() == matrix_.begin(i) && predicate( ElementType(1) ) ) ) {
2179 BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to diagonal matrix element" );
2180 }
2181
2182 matrix_.erase( i, first.base(), last.base(), predicate );
2183
2184 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
2185}
2187//*************************************************************************************************
2188
2189
2190
2191
2192//=================================================================================================
2193//
2194// LOOKUP FUNCTIONS
2195//
2196//=================================================================================================
2197
2198//*************************************************************************************************
2214template< typename MT // Type of the adapted sparse matrix
2215 , bool SO > // Storage order of the adapted sparse matrix
2216inline typename UniLowerMatrix<MT,SO,false>::Iterator
2217 UniLowerMatrix<MT,SO,false>::find( size_t i, size_t j )
2218{
2219 return Iterator( matrix_.find( i, j ), ( SO ? j : i ) );
2220}
2222//*************************************************************************************************
2223
2224
2225//*************************************************************************************************
2241template< typename MT // Type of the adapted sparse matrix
2242 , bool SO > // Storage order of the adapted sparse matrix
2243inline typename UniLowerMatrix<MT,SO,false>::ConstIterator
2244 UniLowerMatrix<MT,SO,false>::find( size_t i, size_t j ) const
2245{
2246 return matrix_.find( i, j );
2247}
2249//*************************************************************************************************
2250
2251
2252//*************************************************************************************************
2268template< typename MT // Type of the adapted sparse matrix
2269 , bool SO > // Storage order of the adapted sparse matrix
2270inline typename UniLowerMatrix<MT,SO,false>::Iterator
2271 UniLowerMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
2272{
2273 return Iterator( matrix_.lowerBound( i, j ), ( SO ? j : i ) );
2274}
2276//*************************************************************************************************
2277
2278
2279//*************************************************************************************************
2295template< typename MT // Type of the adapted sparse matrix
2296 , bool SO > // Storage order of the adapted sparse matrix
2297inline typename UniLowerMatrix<MT,SO,false>::ConstIterator
2298 UniLowerMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
2299{
2300 return matrix_.lowerBound( i, j );
2301}
2303//*************************************************************************************************
2304
2305
2306//*************************************************************************************************
2322template< typename MT // Type of the adapted sparse matrix
2323 , bool SO > // Storage order of the adapted sparse matrix
2324inline typename UniLowerMatrix<MT,SO,false>::Iterator
2325 UniLowerMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
2326{
2327 return Iterator( matrix_.upperBound( i, j ), ( SO ? j : i ) );
2328}
2330//*************************************************************************************************
2331
2332
2333//*************************************************************************************************
2349template< typename MT // Type of the adapted sparse matrix
2350 , bool SO > // Storage order of the adapted sparse matrix
2351inline typename UniLowerMatrix<MT,SO,false>::ConstIterator
2352 UniLowerMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
2353{
2354 return matrix_.upperBound( i, j );
2355}
2357//*************************************************************************************************
2358
2359
2360
2361
2362//=================================================================================================
2363//
2364// DEBUGGING FUNCTIONS
2365//
2366//=================================================================================================
2367
2368//*************************************************************************************************
2378template< typename MT // Type of the adapted sparse matrix
2379 , bool SO > // Storage order of the adapted sparse matrix
2380inline bool UniLowerMatrix<MT,SO,false>::isIntact() const noexcept
2381{
2382 using blaze::isIntact;
2383
2384 return ( isIntact( matrix_ ) && isUniLower( matrix_ ) );
2385}
2387//*************************************************************************************************
2388
2389
2390
2391
2392//=================================================================================================
2393//
2394// EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2395//
2396//=================================================================================================
2397
2398//*************************************************************************************************
2409template< typename MT // Type of the adapted sparse matrix
2410 , bool SO > // Storage order of the adapted sparse matrix
2411template< typename Other > // Data type of the foreign expression
2412inline bool UniLowerMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2413{
2414 return matrix_.canAlias( alias );
2415}
2417//*************************************************************************************************
2418
2419
2420//*************************************************************************************************
2431template< typename MT // Type of the adapted sparse matrix
2432 , bool SO > // Storage order of the adapted sparse matrix
2433template< typename Other > // Data type of the foreign expression
2434inline bool UniLowerMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2435{
2436 return matrix_.isAliased( alias );
2437}
2439//*************************************************************************************************
2440
2441
2442//*************************************************************************************************
2453template< typename MT // Type of the adapted sparse matrix
2454 , bool SO > // Storage order of the adapted sparse matrix
2455inline bool UniLowerMatrix<MT,SO,false>::canSMPAssign() const noexcept
2456{
2457 return matrix_.canSMPAssign();
2458}
2460//*************************************************************************************************
2461
2462} // namespace blaze
2463
2464#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
Header file for the EnableIf class template.
Constraint on the data type.
Header file for the IsComputation type trait class.
Header file for the isDefault shim.
Header file for the isOne shim.
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.
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 UniLowerElement class.
Header file for the UniLowerProxy class.
Header file for the UniLowerValue class.
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 the implementation of a matrix representation of an initializer list.
Header file for the SparseMatrix base class.
#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
decltype(auto) max(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise maximum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1375
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
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
#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_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Upper.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.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_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: SparseMatrix.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_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
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)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
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
#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 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
MT::Iterator upperBound(SparseMatrix< MT, SO > &sm, size_t i, size_t j)
Returns an iterator to the first index greater than the given index.
Definition: SparseMatrix.h:244
MT::Iterator lowerBound(SparseMatrix< MT, SO > &sm, size_t i, size_t j)
Returns an iterator to the first index not less than the given index.
Definition: SparseMatrix.h:194
MT::Iterator find(SparseMatrix< MT, SO > &sm, size_t i, size_t j)
Searches for a specific matrix element.
Definition: SparseMatrix.h:144
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.
Definition: StaticAssert.h:112
#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
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 utility functions for sparse matrices.
Header file for basic type definitions.
Header file for the generic max algorithm.