Blaze 3.9
Sparse.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_VIEWS_BAND_SPARSE_H_
36#define _BLAZE_MATH_VIEWS_BAND_SPARSE_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <iterator>
44#include <blaze/math/Aliases.h>
81#include <blaze/util/Assert.h>
84#include <blaze/util/EnableIf.h>
86#include <blaze/util/mpl/If.h>
87#include <blaze/util/Types.h>
91
92
93namespace blaze {
94
95//=================================================================================================
96//
97// CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
98//
99//=================================================================================================
100
101//*************************************************************************************************
108template< typename MT // Type of the sparse matrix
109 , bool TF // Transpose flag
110 , ptrdiff_t... CBAs > // Compile time band arguments
111class Band<MT,TF,false,false,CBAs...>
112 : public View< SparseVector< Band<MT,TF,false,false,CBAs...>, TF > >
113 , private BandData<CBAs...>
114{
115 private:
116 //**Type definitions****************************************************************************
117 using RT = ResultType_t<MT>;
118 using DataType = BandData<CBAs...>;
119 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
120 //**********************************************************************************************
121
122 public:
123 //**Type definitions****************************************************************************
125 using This = Band<MT,TF,false,false,CBAs...>;
126
128 using BaseType = View< SparseVector<This,TF> >;
129
130 using ViewedType = MT;
131 using ResultType = BandTrait_t<RT,CBAs...>;
132 using TransposeType = TransposeType_t<ResultType>;
133 using ElementType = ElementType_t<MT>;
134 using ReturnType = ReturnType_t<MT>;
135
137 using CompositeType = If_t< RequiresEvaluation_v<MT>, const ResultType, const Band& >;
138
140 using ConstReference = ConstReference_t<MT>;
141
143 using Reference = If_t< IsConst_v<MT>, ConstReference, Reference_t<MT> >;
144 //**********************************************************************************************
145
146 //**BandElement class definition****************************************************************
149 template< typename MatrixType // Type of the sparse matrix
150 , typename IteratorType > // Type of the sparse matrix iterator
151 class BandElement
152 : private SparseElement
153 {
154 public:
155 //**Constructor******************************************************************************
161 inline BandElement( IteratorType pos, size_t index )
162 : pos_ ( pos ) // Iterator to the current position within the sparse band
163 , index_( index ) // Index of the element
164 {}
165 //*******************************************************************************************
166
167 //**Assignment operator**********************************************************************
173 template< typename T > inline BandElement& operator=( const T& v ) {
174 *pos_ = v;
175 return *this;
176 }
177 //*******************************************************************************************
178
179 //**Addition assignment operator*************************************************************
185 template< typename T > inline BandElement& operator+=( const T& v ) {
186 *pos_ += v;
187 return *this;
188 }
189 //*******************************************************************************************
190
191 //**Subtraction assignment operator**********************************************************
197 template< typename T > inline BandElement& operator-=( const T& v ) {
198 *pos_ -= v;
199 return *this;
200 }
201 //*******************************************************************************************
202
203 //**Multiplication assignment operator*******************************************************
209 template< typename T > inline BandElement& operator*=( const T& v ) {
210 *pos_ *= v;
211 return *this;
212 }
213 //*******************************************************************************************
214
215 //**Division assignment operator*************************************************************
221 template< typename T > inline BandElement& operator/=( const T& v ) {
222 *pos_ /= v;
223 return *this;
224 }
225 //*******************************************************************************************
226
227 //**Element access operator******************************************************************
232 inline const BandElement* operator->() const {
233 return this;
234 }
235 //*******************************************************************************************
236
237 //**Value function***************************************************************************
242 inline decltype(auto) value() const {
243 return pos_->value();
244 }
245 //*******************************************************************************************
246
247 //**Index function***************************************************************************
252 inline size_t index() const {
253 return index_;
254 }
255 //*******************************************************************************************
256
257 private:
258 //**Member variables*************************************************************************
259 IteratorType pos_;
260 size_t index_;
261 //*******************************************************************************************
262 };
263 //**********************************************************************************************
264
265 //**BandIterator class definition***************************************************************
268 template< typename MatrixType // Type of the sparse matrix
269 , typename IteratorType > // Type of the sparse matrix iterator
270 class BandIterator
271 {
272 public:
273 //**Type definitions*************************************************************************
274 using IteratorCategory = std::forward_iterator_tag;
275 using ValueType = BandElement<MatrixType,IteratorType>;
276 using PointerType = ValueType;
277 using ReferenceType = ValueType;
278 using DifferenceType = ptrdiff_t;
279
280 // STL iterator requirements
281 using iterator_category = IteratorCategory;
282 using value_type = ValueType;
283 using pointer = PointerType;
284 using reference = ReferenceType;
285 using difference_type = DifferenceType;
286 //*******************************************************************************************
287
288 //**Constructor******************************************************************************
291 inline BandIterator()
292 : matrix_( nullptr ) // The sparse matrix containing the band
293 , row_ ( 0UL ) // The current row index
294 , column_( 0UL ) // The current column index
295 , pos_ () // Iterator to the current sparse element
296 {}
297 //*******************************************************************************************
298
299 //**Constructor******************************************************************************
306 inline BandIterator( MatrixType& matrix, size_t rowIndex, size_t columnIndex )
307 : matrix_( &matrix ) // The sparse matrix containing the band
308 , row_ ( rowIndex ) // The current row index
309 , column_( columnIndex ) // The current column index
310 , pos_ () // Iterator to the current sparse element
311 {
312 for( ; row_ < matrix_->rows() && column_ < matrix_->columns(); ++row_, ++column_ ) {
313 pos_ = matrix_->find( row_, column_ );
314 if( pos_ != matrix_->end( IsRowMajorMatrix_v<MatrixType> ? row_ : column_ ) )
315 break;
316 }
317 }
318 //*******************************************************************************************
319
320 //**Constructor******************************************************************************
328 inline BandIterator( MatrixType& matrix, size_t rowIndex, size_t columnIndex, IteratorType pos )
329 : matrix_( &matrix ) // The sparse matrix containing the band
330 , row_ ( rowIndex ) // The current row index
331 , column_( columnIndex ) // The current column index
332 , pos_ ( pos ) // Iterator to the current sparse element
333 {
334 BLAZE_INTERNAL_ASSERT( matrix.find( row_, column_ ) == pos, "Invalid initial iterator position" );
335 }
336 //*******************************************************************************************
337
338 //**Constructor******************************************************************************
343 template< typename MatrixType2, typename IteratorType2 >
344 inline BandIterator( const BandIterator<MatrixType2,IteratorType2>& it )
345 : matrix_( it.matrix_ ) // The sparse matrix containing the band
346 , row_ ( it.row_ ) // The current row index
347 , column_( it.column_ ) // The current column index
348 , pos_ ( it.pos_ ) // Iterator to the current sparse element
349 {}
350 //*******************************************************************************************
351
352 //**Prefix increment operator****************************************************************
357 inline BandIterator& operator++() {
358 ++row_;
359 ++column_;
360
361 for( ; row_ < matrix_->rows() && column_ < matrix_->columns(); ++row_, ++column_ ) {
362 pos_ = matrix_->find( row_, column_ );
363 if( pos_ != matrix_->end( IsRowMajorMatrix_v<MatrixType> ? row_ : column_ ) )
364 break;
365 }
366
367 return *this;
368 }
369 //*******************************************************************************************
370
371 //**Postfix increment operator***************************************************************
376 inline const BandIterator operator++( int ) {
377 const BandIterator tmp( *this );
378 ++(*this);
379 return tmp;
380 }
381 //*******************************************************************************************
382
383 //**Element access operator******************************************************************
388 inline ReferenceType operator*() const {
389 return ReferenceType( pos_, min( row_, column_ ) );
390 }
391 //*******************************************************************************************
392
393 //**Element access operator******************************************************************
398 inline PointerType operator->() const {
399 return PointerType( pos_, min( row_, column_ ) );
400 }
401 //*******************************************************************************************
402
403 //**Equality operator************************************************************************
409 template< typename MatrixType2, typename IteratorType2 >
410 inline bool operator==( const BandIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
411 return row_ == rhs.row_;
412 }
413 //*******************************************************************************************
414
415 //**Inequality operator**********************************************************************
421 template< typename MatrixType2, typename IteratorType2 >
422 inline bool operator!=( const BandIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
423 return !( *this == rhs );
424 }
425 //*******************************************************************************************
426
427 //**Subtraction operator*********************************************************************
433 inline DifferenceType operator-( const BandIterator& rhs ) const {
434 size_t counter( 0UL );
435 size_t row( rhs.row_ );
436 size_t column( rhs.column_ );
437
438 for( ; row<row_; ++row, ++column ) {
439 const auto end( matrix_->end( IsRowMajorMatrix_v<MatrixType> ? row : column ) );
440 if( matrix_->find( row, column ) != end )
441 ++counter;
442 }
443
444 return counter;
445 }
446 //*******************************************************************************************
447
448 private:
449 //**Member variables*************************************************************************
450 MatrixType* matrix_;
451 size_t row_;
452 size_t column_;
453 IteratorType pos_;
454 //*******************************************************************************************
455
456 //**Friend declarations**********************************************************************
457 template< typename MatrixType2, typename IteratorType2 > friend class BandIterator;
458 template< typename MT2, bool DF2, bool TF2, bool MF2, ptrdiff_t... CBAs2 > friend class Band;
459 //*******************************************************************************************
460 };
461 //**********************************************************************************************
462
463 //**Type definitions****************************************************************************
465 using ConstIterator = BandIterator< const MT, ConstIterator_t<MT> >;
466
468 using Iterator = If_t< IsConst_v<MT>, ConstIterator, BandIterator< MT, Iterator_t<MT> > >;
469 //**********************************************************************************************
470
471 //**Compilation flags***************************************************************************
473 static constexpr bool smpAssignable = false;
474
476 static constexpr bool compileTimeArgs = DataType::compileTimeArgs;
477 //**********************************************************************************************
478
479 //**Constructors********************************************************************************
482 template< typename... RBAs >
483 explicit inline Band( MT& matrix, RBAs... args );
484
485 Band( const Band& ) = default;
487 //**********************************************************************************************
488
489 //**Destructor**********************************************************************************
492 ~Band() = default;
494 //**********************************************************************************************
495
496 //**Data access functions***********************************************************************
499 inline Reference operator[]( size_t index );
500 inline ConstReference operator[]( size_t index ) const;
501 inline Reference at( size_t index );
502 inline ConstReference at( size_t index ) const;
503 inline Iterator begin ();
504 inline ConstIterator begin () const;
505 inline ConstIterator cbegin() const;
506 inline Iterator end ();
507 inline ConstIterator end () const;
508 inline ConstIterator cend () const;
510 //**********************************************************************************************
511
512 //**Assignment operators************************************************************************
515 inline Band& operator= ( initializer_list<ElementType> list );
516 inline Band& operator= ( const Band& rhs );
517 template< typename VT > inline Band& operator= ( const Vector<VT,TF>& rhs );
518 template< typename VT > inline Band& operator+=( const Vector<VT,TF>& rhs );
519 template< typename VT > inline Band& operator-=( const Vector<VT,TF>& rhs );
520 template< typename VT > inline Band& operator*=( const Vector<VT,TF>& rhs );
521 template< typename VT > inline Band& operator/=( const DenseVector<VT,TF>& rhs );
522 template< typename VT > inline Band& operator%=( const Vector<VT,TF>& rhs );
524 //**********************************************************************************************
525
526 //**Utility functions***************************************************************************
529 using DataType::band;
530 using DataType::row;
531 using DataType::column;
532
533 inline MT& operand() noexcept;
534 inline const MT& operand() const noexcept;
535
536 inline size_t size() const noexcept;
537 inline size_t capacity() const noexcept;
538 inline size_t nonZeros() const;
539 inline void reset();
540 inline void reserve( size_t n );
542 //**********************************************************************************************
543
544 //**Insertion functions*************************************************************************
547 inline Iterator set ( size_t index, const ElementType& value );
548 inline Iterator insert( size_t index, const ElementType& value );
549 inline void append( size_t index, const ElementType& value, bool check=false );
551 //**********************************************************************************************
552
553 //**Erase functions*****************************************************************************
556 inline void erase( size_t index );
557 inline Iterator erase( Iterator pos );
558 inline Iterator erase( Iterator first, Iterator last );
559
560 template< typename Pred, typename = DisableIf_t< IsIntegral_v<Pred> > >
561 inline void erase( Pred predicate );
562
563 template< typename Pred >
564 inline void erase( Iterator first, Iterator last, Pred predicate );
566 //**********************************************************************************************
567
568 //**Lookup functions****************************************************************************
571 inline Iterator find ( size_t index );
572 inline ConstIterator find ( size_t index ) const;
573 inline Iterator lowerBound( size_t index );
574 inline ConstIterator lowerBound( size_t index ) const;
575 inline Iterator upperBound( size_t index );
576 inline ConstIterator upperBound( size_t index ) const;
578 //**********************************************************************************************
579
580 //**Numeric functions***************************************************************************
583 template< typename Other > inline Band& scale( const Other& scalar );
585 //**********************************************************************************************
586
587 //**Expression template evaluation functions****************************************************
590 template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
591 template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
592
593 template< typename VT > inline void assign ( const DenseVector <VT,TF>& rhs );
594 template< typename VT > inline void assign ( const SparseVector<VT,TF>& rhs );
595 template< typename VT > inline void addAssign( const Vector<VT,TF>& rhs );
596 template< typename VT > inline void subAssign( const Vector<VT,TF>& rhs );
598 //**********************************************************************************************
599
600 private:
601 //**Member variables****************************************************************************
604 Operand matrix_;
606 //**********************************************************************************************
607
608 //**Compile time checks*************************************************************************
614 //**********************************************************************************************
615};
617//*************************************************************************************************
618
619
620
621
622//=================================================================================================
623//
624// CONSTRUCTORS
625//
626//=================================================================================================
627
628//*************************************************************************************************
641template< typename MT // Type of the sparse matrix
642 , bool TF // Transpose flag
643 , ptrdiff_t... CBAs > // Compile time band arguments
644template< typename... RBAs > // Runtime band arguments
645inline Band<MT,TF,false,false,CBAs...>::Band( MT& matrix, RBAs... args )
646 : DataType( args... ) // Base class initialization
647 , matrix_ ( matrix ) // The matrix containing the band
648{
649 if( isChecked( args... ) ) {
650 if( ( band() > 0L && column() >= matrix.columns() ) ||
651 ( band() < 0L && row() >= matrix.rows() ) ) {
652 BLAZE_THROW_INVALID_ARGUMENT( "Invalid band access index" );
653 }
654 }
655 else {
656 BLAZE_USER_ASSERT( band() <= 0L || column() < matrix.columns(), "Invalid band access index" );
657 BLAZE_USER_ASSERT( band() >= 0L || row() < matrix.rows(), "Invalid band access index" );
658 }
659}
661//*************************************************************************************************
662
663
664
665
666//=================================================================================================
667//
668// DATA ACCESS FUNCTIONS
669//
670//=================================================================================================
671
672//*************************************************************************************************
682template< typename MT // Type of the sparse matrix
683 , bool TF // Transpose flag
684 , ptrdiff_t... CBAs > // Compile time band arguments
685inline typename Band<MT,TF,false,false,CBAs...>::Reference
686 Band<MT,TF,false,false,CBAs...>::operator[]( size_t index )
687{
688 BLAZE_USER_ASSERT( index < size(), "Invalid band access index" );
689 return matrix_(row()+index,column()+index);
690}
692//*************************************************************************************************
693
694
695//*************************************************************************************************
705template< typename MT // Type of the sparse matrix
706 , bool TF // Transpose flag
707 , ptrdiff_t... CBAs > // Compile time band arguments
708inline typename Band<MT,TF,false,false,CBAs...>::ConstReference
709 Band<MT,TF,false,false,CBAs...>::operator[]( size_t index ) const
710{
711 BLAZE_USER_ASSERT( index < size(), "Invalid band access index" );
712 return const_cast<const MT&>( matrix_ )(row()+index,column()+index);
713}
715//*************************************************************************************************
716
717
718//*************************************************************************************************
729template< typename MT // Type of the sparse matrix
730 , bool TF // Transpose flag
731 , ptrdiff_t... CBAs > // Compile time band arguments
732inline typename Band<MT,TF,false,false,CBAs...>::Reference
733 Band<MT,TF,false,false,CBAs...>::at( size_t index )
734{
735 if( index >= size() ) {
736 BLAZE_THROW_OUT_OF_RANGE( "Invalid band access index" );
737 }
738 return (*this)[index];
739}
741//*************************************************************************************************
742
743
744//*************************************************************************************************
755template< typename MT // Type of the sparse matrix
756 , bool TF // Transpose flag
757 , ptrdiff_t... CBAs > // Compile time band arguments
758inline typename Band<MT,TF,false,false,CBAs...>::ConstReference
759 Band<MT,TF,false,false,CBAs...>::at( size_t index ) const
760{
761 if( index >= size() ) {
762 BLAZE_THROW_OUT_OF_RANGE( "Invalid band access index" );
763 }
764 return (*this)[index];
765}
767//*************************************************************************************************
768
769
770//*************************************************************************************************
778template< typename MT // Type of the sparse matrix
779 , bool TF // Transpose flag
780 , ptrdiff_t... CBAs > // Compile time band arguments
781inline typename Band<MT,TF,false,false,CBAs...>::Iterator
783{
784 return Iterator( matrix_, row(), column() );
785}
787//*************************************************************************************************
788
789
790//*************************************************************************************************
798template< typename MT // Type of the sparse matrix
799 , bool TF // Transpose flag
800 , ptrdiff_t... CBAs > // Compile time band arguments
801inline typename Band<MT,TF,false,false,CBAs...>::ConstIterator
803{
804 return ConstIterator( matrix_, row(), column() );
805}
807//*************************************************************************************************
808
809
810//*************************************************************************************************
818template< typename MT // Type of the sparse matrix
819 , bool TF // Transpose flag
820 , ptrdiff_t... CBAs > // Compile time band arguments
821inline typename Band<MT,TF,false,false,CBAs...>::ConstIterator
823{
824 return ConstIterator( matrix_, row(), column() );
825}
827//*************************************************************************************************
828
829
830//*************************************************************************************************
838template< typename MT // Type of the sparse matrix
839 , bool TF // Transpose flag
840 , ptrdiff_t... CBAs > // Compile time band arguments
841inline typename Band<MT,TF,false,false,CBAs...>::Iterator
843{
844 const size_t n( size() );
845 return Iterator( matrix_, row()+n, column()+n );
846}
848//*************************************************************************************************
849
850
851//*************************************************************************************************
859template< typename MT // Type of the sparse matrix
860 , bool TF // Transpose flag
861 , ptrdiff_t... CBAs > // Compile time band arguments
862inline typename Band<MT,TF,false,false,CBAs...>::ConstIterator
864{
865 const size_t n( size() );
866 return ConstIterator( matrix_, row()+n, column()+n );
867}
869//*************************************************************************************************
870
871
872//*************************************************************************************************
880template< typename MT // Type of the sparse matrix
881 , bool TF // Transpose flag
882 , ptrdiff_t... CBAs > // Compile time band arguments
883inline typename Band<MT,TF,false,false,CBAs...>::ConstIterator
885{
886 const size_t n( size() );
887 return ConstIterator( matrix_, row()+n, column()+n );
888}
890//*************************************************************************************************
891
892
893
894
895//=================================================================================================
896//
897// ASSIGNMENT OPERATORS
898//
899//=================================================================================================
900
901//*************************************************************************************************
916template< typename MT // Type of the dense matrix
917 , bool TF // Transpose flag
918 , ptrdiff_t... CBAs > // Compile time band arguments
919inline Band<MT,TF,false,false,CBAs...>&
920 Band<MT,TF,false,false,CBAs...>::operator=( initializer_list<ElementType> list )
921{
922 using blaze::assign;
923
924 if( list.size() > size() ) {
925 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to band" );
926 }
927
928 const InitializerVector<ElementType,false> tmp( list, size() );
929
930 if( !tryAssign( matrix_, tmp, band(), row(), column() ) ) {
931 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
932 }
933
934 decltype(auto) left( derestrict( *this ) );
935
936 assign( left, tmp );
937
938 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
939
940 return *this;
941}
943//*************************************************************************************************
944
945
946//*************************************************************************************************
960template< typename MT // Type of the sparse matrix
961 , bool TF // Transpose flag
962 , ptrdiff_t... CBAs > // Compile time band arguments
963inline Band<MT,TF,false,false,CBAs...>&
964 Band<MT,TF,false,false,CBAs...>::operator=( const Band& rhs )
965{
966 using blaze::assign;
967
971
972 if( this == &rhs || ( &matrix_ == &rhs.matrix_ && band() == rhs.band() ) )
973 return *this;
974
975 if( size() != rhs.size() ) {
976 BLAZE_THROW_INVALID_ARGUMENT( "Row sizes do not match" );
977 }
978
979 if( !tryAssign( matrix_, rhs, band(), row(), column() ) ) {
980 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
981 }
982
983 decltype(auto) left( derestrict( *this ) );
984
985 if( rhs.canAlias( this ) ) {
986 const ResultType tmp( rhs );
987 assign( left, tmp );
988 }
989 else {
990 assign( left, rhs );
991 }
992
993 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
994
995 return *this;
996}
998//*************************************************************************************************
999
1000
1001//*************************************************************************************************
1015template< typename MT // Type of the sparse matrix
1016 , bool TF // Transpose flag
1017 , ptrdiff_t... CBAs > // Compile time band arguments
1018template< typename VT > // Type of the right-hand side vector
1019inline Band<MT,TF,false,false,CBAs...>&
1020 Band<MT,TF,false,false,CBAs...>::operator=( const Vector<VT,TF>& rhs )
1021{
1022 using blaze::assign;
1023
1024 if( size() != (*rhs).size() ) {
1025 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1026 }
1027
1028 const CompositeType_t<VT> tmp( *rhs );
1029
1030 if( !tryAssign( matrix_, tmp, band(), row(), column() ) ) {
1031 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1032 }
1033
1034 decltype(auto) left( derestrict( *this ) );
1035
1036 assign( left, tmp );
1037
1038 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1039
1040 return *this;
1041}
1043//*************************************************************************************************
1044
1045
1046//*************************************************************************************************
1060template< typename MT // Type of the sparse matrix
1061 , bool TF // Transpose flag
1062 , ptrdiff_t... CBAs > // Compile time band arguments
1063template< typename VT > // Type of the right-hand side vector
1064inline Band<MT,TF,false,false,CBAs...>&
1065 Band<MT,TF,false,false,CBAs...>::operator+=( const Vector<VT,TF>& rhs )
1066{
1067 using blaze::assign;
1068
1074
1075 using AddType = AddTrait_t< ResultType, ResultType_t<VT> >;
1076
1079
1080 if( size() != (*rhs).size() ) {
1081 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1082 }
1083
1084 const AddType tmp( *this + (*rhs) );
1085
1086 if( !tryAssign( matrix_, tmp, band(), row(), column() ) ) {
1087 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1088 }
1089
1090 decltype(auto) left( derestrict( *this ) );
1091
1092 assign( left, tmp );
1093
1094 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1095
1096 return *this;
1097}
1099//*************************************************************************************************
1100
1101
1102//*************************************************************************************************
1116template< typename MT // Type of the sparse matrix
1117 , bool TF // Transpose flag
1118 , ptrdiff_t... CBAs > // Compile time band arguments
1119template< typename VT > // Type of the right-hand side vector
1120inline Band<MT,TF,false,false,CBAs...>&
1121 Band<MT,TF,false,false,CBAs...>::operator-=( const Vector<VT,TF>& rhs )
1122{
1123 using blaze::assign;
1124
1130
1131 using SubType = SubTrait_t< ResultType, ResultType_t<VT> >;
1132
1135
1136 if( size() != (*rhs).size() ) {
1137 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1138 }
1139
1140 const SubType tmp( *this - (*rhs) );
1141
1142 if( !tryAssign( matrix_, tmp, band(), row(), column() ) ) {
1143 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1144 }
1145
1146 decltype(auto) left( derestrict( *this ) );
1147
1148 assign( left, tmp );
1149
1150 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1151
1152 return *this;
1153}
1155//*************************************************************************************************
1156
1157
1158//*************************************************************************************************
1171template< typename MT // Type of the sparse matrix
1172 , bool TF // Transpose flag
1173 , ptrdiff_t... CBAs > // Compile time band arguments
1174template< typename VT > // Type of the right-hand side vector
1175inline Band<MT,TF,false,false,CBAs...>&
1176 Band<MT,TF,false,false,CBAs...>::operator*=( const Vector<VT,TF>& rhs )
1177{
1178 using blaze::assign;
1179
1185
1186 using MultType = MultTrait_t< ResultType, ResultType_t<VT> >;
1187
1190
1191 if( size() != (*rhs).size() ) {
1192 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1193 }
1194
1195 const MultType tmp( *this * (*rhs) );
1196
1197 if( !tryAssign( matrix_, tmp, band(), row(), column() ) ) {
1198 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1199 }
1200
1201 decltype(auto) left( derestrict( *this ) );
1202
1203 assign( left, tmp );
1204
1205 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1206
1207 return *this;
1208}
1210//*************************************************************************************************
1211
1212
1213//*************************************************************************************************
1225template< typename MT // Type of the sparse matrix
1226 , bool TF // Transpose flag
1227 , ptrdiff_t... CBAs > // Compile time band arguments
1228template< typename VT > // Type of the right-hand side vector
1229inline Band<MT,TF,false,false,CBAs...>&
1230 Band<MT,TF,false,false,CBAs...>::operator/=( const DenseVector<VT,TF>& rhs )
1231{
1232 using blaze::assign;
1233
1240
1241 using DivType = DivTrait_t< ResultType, ResultType_t<VT> >;
1242
1246
1247 if( size() != (*rhs).size() ) {
1248 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1249 }
1250
1251 const DivType tmp( *this / (*rhs) );
1252
1253 if( !tryAssign( matrix_, tmp, band(), row(), column() ) ) {
1254 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1255 }
1256
1257 decltype(auto) left( derestrict( *this ) );
1258
1259 assign( left, tmp );
1260
1261 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1262
1263 return *this;
1264}
1266//*************************************************************************************************
1267
1268
1269//*************************************************************************************************
1282template< typename MT // Type of the sparse matrix
1283 , bool TF // Transpose flag
1284 , ptrdiff_t... CBAs > // Compile time band arguments
1285template< typename VT > // Type of the right-hand side vector
1286inline Band<MT,TF,false,false,CBAs...>&
1287 Band<MT,TF,false,false,CBAs...>::operator%=( const Vector<VT,TF>& rhs )
1288{
1289 using blaze::assign;
1290
1293
1294 using CrossType = CrossTrait_t< ResultType, ResultType_t<VT> >;
1295
1299
1300 if( size() != 3UL || (*rhs).size() != 3UL ) {
1301 BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
1302 }
1303
1304 const CrossType tmp( *this % (*rhs) );
1305
1306 if( !tryAssign( matrix_, tmp, band(), row(), column() ) ) {
1307 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1308 }
1309
1310 decltype(auto) left( derestrict( *this ) );
1311
1312 assign( left, tmp );
1313
1314 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1315
1316 return *this;
1317}
1319//*************************************************************************************************
1320
1321
1322
1323
1324//=================================================================================================
1325//
1326// UTILITY FUNCTIONS
1327//
1328//=================================================================================================
1329
1330//*************************************************************************************************
1336template< typename MT // Type of the sparse matrix
1337 , bool TF // Transpose flag
1338 , ptrdiff_t... CBAs > // Compile time band arguments
1339inline MT& Band<MT,TF,false,false,CBAs...>::operand() noexcept
1340{
1341 return matrix_;
1342}
1344//*************************************************************************************************
1345
1346
1347//*************************************************************************************************
1353template< typename MT // Type of the sparse matrix
1354 , bool TF // Transpose flag
1355 , ptrdiff_t... CBAs > // Compile time band arguments
1356inline const MT& Band<MT,TF,false,false,CBAs...>::operand() const noexcept
1357{
1358 return matrix_;
1359}
1361//*************************************************************************************************
1362
1363
1364//*************************************************************************************************
1370template< typename MT // Type of the sparse matrix
1371 , bool TF // Transpose flag
1372 , ptrdiff_t... CBAs > // Compile time band arguments
1373inline size_t Band<MT,TF,false,false,CBAs...>::size() const noexcept
1374{
1375 return min( matrix_.rows() - row(), matrix_.columns() - column() );
1376}
1378//*************************************************************************************************
1379
1380
1381//*************************************************************************************************
1387template< typename MT // Type of the sparse matrix
1388 , bool TF // Transpose flag
1389 , ptrdiff_t... CBAs > // Compile time band arguments
1390inline size_t Band<MT,TF,false,false,CBAs...>::capacity() const noexcept
1391{
1392 return size();
1393}
1395//*************************************************************************************************
1396
1397
1398//*************************************************************************************************
1407template< typename MT // Type of the sparse matrix
1408 , bool TF // Transpose flag
1409 , ptrdiff_t... CBAs > // Compile time band arguments
1411{
1412 return end() - begin();
1413}
1415//*************************************************************************************************
1416
1417
1418//*************************************************************************************************
1424template< typename MT // Type of the sparse matrix
1425 , bool TF // Transpose flag
1426 , ptrdiff_t... CBAs > // Compile time band arguments
1428{
1429 using blaze::clear;
1430
1431 if( ( IsLower_v<MT> && column() > 0UL ) ||
1432 ( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> ) && row() == 0UL ) ||
1433 ( IsUpper_v<MT> && row() > 0UL ) ||
1434 ( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> ) && column() == 0UL ) )
1435 return;
1436
1437 const size_t n( size() );
1438 for( size_t i=0UL; i<n; ++i )
1439 matrix_.erase( row()+i, column()+i );
1440}
1442//*************************************************************************************************
1443
1444
1445//*************************************************************************************************
1455template< typename MT // Type of the sparse matrix
1456 , bool TF // Transpose flag
1457 , ptrdiff_t... CBAs > // Compile time band arguments
1458void Band<MT,TF,false,false,CBAs...>::reserve( size_t n )
1459{
1460 MAYBE_UNUSED( n );
1461
1462 return;
1463}
1465//*************************************************************************************************
1466
1467
1468
1469
1470//=================================================================================================
1471//
1472// INSERTION FUNCTIONS
1473//
1474//=================================================================================================
1475
1476//*************************************************************************************************
1488template< typename MT // Type of the sparse matrix
1489 , bool TF // Transpose flag
1490 , ptrdiff_t... CBAs > // Compile time band arguments
1491inline typename Band<MT,TF,false,false,CBAs...>::Iterator
1492 Band<MT,TF,false,false,CBAs...>::set( size_t index, const ElementType& value )
1493{
1494 const size_t rowIndex ( row() + index );
1495 const size_t columnIndex( column() + index );
1496 return Iterator( matrix_, rowIndex, columnIndex, matrix_.set( rowIndex, columnIndex, value ) );
1497}
1499//*************************************************************************************************
1500
1501
1502//*************************************************************************************************
1515template< typename MT // Type of the sparse matrix
1516 , bool TF // Transpose flag
1517 , ptrdiff_t... CBAs > // Compile time band arguments
1518inline typename Band<MT,TF,false,false,CBAs...>::Iterator
1519 Band<MT,TF,false,false,CBAs...>::insert( size_t index, const ElementType& value )
1520{
1521 const size_t rowIndex ( row() + index );
1522 const size_t columnIndex( column() + index );
1523 return Iterator( matrix_, rowIndex, columnIndex, matrix_.insert( rowIndex, columnIndex, value ) );
1524}
1526//*************************************************************************************************
1527
1528
1529//*************************************************************************************************
1554template< typename MT // Type of the sparse matrix
1555 , bool TF // Transpose flag
1556 , ptrdiff_t... CBAs > // Compile time band arguments
1557inline void Band<MT,TF,false,false,CBAs...>::append( size_t index, const ElementType& value, bool check )
1558{
1559 if( !check || !isDefault<strict>( value ) )
1560 matrix_.insert( row()+index, column()+index, value );
1561}
1563//*************************************************************************************************
1564
1565
1566
1567
1568//=================================================================================================
1569//
1570// ERASE FUNCTIONS
1571//
1572//=================================================================================================
1573
1574//*************************************************************************************************
1583template< typename MT // Type of the sparse matrix
1584 , bool TF // Transpose flag
1585 , ptrdiff_t... CBAs > // Compile time band arguments
1586inline void Band<MT,TF,false,false,CBAs...>::erase( size_t index )
1587{
1588 matrix_.erase( row()+index, column()+index );
1589}
1591//*************************************************************************************************
1592
1593
1594//*************************************************************************************************
1603template< typename MT // Type of the sparse matrix
1604 , bool TF // Transpose flag
1605 , ptrdiff_t... CBAs > // Compile time band arguments
1606inline typename Band<MT,TF,false,false,CBAs...>::Iterator
1607 Band<MT,TF,false,false,CBAs...>::erase( Iterator pos )
1608{
1609 const size_t rowIndex ( pos.row_ );
1610 const size_t columnIndex( pos.column_ );
1611
1612 if( rowIndex == matrix_.rows() || columnIndex == matrix_.columns() )
1613 return pos;
1614
1615 matrix_.erase( ( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ), pos.pos_ );
1616 return Iterator( matrix_, rowIndex+1UL, columnIndex+1UL );
1617}
1619//*************************************************************************************************
1620
1621
1622//*************************************************************************************************
1632template< typename MT // Type of the sparse matrix
1633 , bool TF // Transpose flag
1634 , ptrdiff_t... CBAs > // Compile time band arguments
1635inline typename Band<MT,TF,false,false,CBAs...>::Iterator
1636 Band<MT,TF,false,false,CBAs...>::erase( Iterator first, Iterator last )
1637{
1638 for( ; first!=last; ++first ) {
1639 const size_t index( IsRowMajorMatrix<MT>::value ? first.row_ : first.column_ );
1640 matrix_.erase( index, first.pos_ );
1641 }
1642 return last;
1643}
1645//*************************************************************************************************
1646
1647
1648//*************************************************************************************************
1671template< typename MT // Type of the sparse matrix
1672 , bool TF // Transpose flag
1673 , ptrdiff_t... CBAs > // Compile time band arguments
1674template< typename Pred // Type of the unary predicate
1675 , typename > // Type restriction on the unary predicate
1676inline void Band<MT,TF,false,false,CBAs...>::erase( Pred predicate )
1677{
1678 for( Iterator element=begin(); element!=end(); ++element ) {
1679 if( predicate( element->value() ) ) {
1680 const size_t index( IsRowMajorMatrix<MT>::value ? element.row_ : element.column_ );
1681 matrix_.erase( index, element.pos_ );
1682 }
1683 }
1684}
1686//*************************************************************************************************
1687
1688
1689//*************************************************************************************************
1714template< typename MT // Type of the sparse matrix
1715 , bool TF // Transpose flag
1716 , ptrdiff_t... CBAs > // Compile time band arguments
1717template< typename Pred > // Type of the unary predicate
1718inline void Band<MT,TF,false,false,CBAs...>::erase( Iterator first, Iterator last, Pred predicate )
1719{
1720 for( ; first!=last; ++first ) {
1721 if( predicate( first->value() ) ) {
1722 const size_t index( IsRowMajorMatrix<MT>::value ? first.row_ : first.column_ );
1723 matrix_.erase( index, first.pos_ );
1724 }
1725 }
1726}
1728//*************************************************************************************************
1729
1730
1731
1732
1733//=================================================================================================
1734//
1735// LOOKUP FUNCTIONS
1736//
1737//=================================================================================================
1738
1739//*************************************************************************************************
1753template< typename MT // Type of the sparse matrix
1754 , bool TF // Transpose flag
1755 , ptrdiff_t... CBAs > // Compile time band arguments
1756inline typename Band<MT,TF,false,false,CBAs...>::Iterator
1758{
1759 const size_t rowIndex ( row()+index );
1760 const size_t columnIndex( column()+index );
1761 const Iterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1762
1763 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1764 return Iterator( matrix_, rowIndex, columnIndex, pos );
1765 else
1766 return end();
1767}
1769//*************************************************************************************************
1770
1771
1772//*************************************************************************************************
1786template< typename MT // Type of the sparse matrix
1787 , bool TF // Transpose flag
1788 , ptrdiff_t... CBAs > // Compile time band arguments
1789inline typename Band<MT,TF,false,false,CBAs...>::ConstIterator
1790 Band<MT,TF,false,false,CBAs...>::find( size_t index ) const
1791{
1792 const size_t rowIndex ( row()+index );
1793 const size_t columnIndex( column()+index );
1794 const ConstIterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1795
1796 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1797 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1798 else
1799 return end();
1800}
1802//*************************************************************************************************
1803
1804
1805//*************************************************************************************************
1818template< typename MT // Type of the sparse matrix
1819 , bool TF // Transpose flag
1820 , ptrdiff_t... CBAs > // Compile time band arguments
1821inline typename Band<MT,TF,false,false,CBAs...>::Iterator
1823{
1824 for( size_t i=index; i<size(); ++i )
1825 {
1826 const size_t rowIndex ( row()+i );
1827 const size_t columnIndex( column()+i );
1828 const Iterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1829
1830 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1831 return Iterator( matrix_, rowIndex, columnIndex, pos );
1832 }
1833
1834 return end();
1835}
1837//*************************************************************************************************
1838
1839
1840//*************************************************************************************************
1853template< typename MT // Type of the sparse matrix
1854 , bool TF // Transpose flag
1855 , ptrdiff_t... CBAs > // Compile time band arguments
1856inline typename Band<MT,TF,false,false,CBAs...>::ConstIterator
1858{
1859 for( size_t i=index; i<size(); ++i )
1860 {
1861 const size_t rowIndex ( row()+i );
1862 const size_t columnIndex( column()+i );
1863 const ConstIterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1864
1865 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1866 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1867 }
1868
1869 return end();
1870}
1872//*************************************************************************************************
1873
1874
1875//*************************************************************************************************
1888template< typename MT // Type of the sparse matrix
1889 , bool TF // Transpose flag
1890 , ptrdiff_t... CBAs > // Compile time band arguments
1891inline typename Band<MT,TF,false,false,CBAs...>::Iterator
1893{
1894 for( size_t i=index+1UL; i<size(); ++i )
1895 {
1896 const size_t rowIndex ( row()+i );
1897 const size_t columnIndex( column()+i );
1898 const Iterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1899
1900 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1901 return Iterator( matrix_, rowIndex, columnIndex, pos );
1902 }
1903
1904 return end();
1905}
1907//*************************************************************************************************
1908
1909
1910//*************************************************************************************************
1923template< typename MT // Type of the sparse matrix
1924 , bool TF // Transpose flag
1925 , ptrdiff_t... CBAs > // Compile time band arguments
1926inline typename Band<MT,TF,false,false,CBAs...>::ConstIterator
1928{
1929 for( size_t i=index+1UL; i<size(); ++i )
1930 {
1931 const size_t rowIndex ( row()+i );
1932 const size_t columnIndex( column()+i );
1933 const ConstIterator_t<MT> pos( matrix_.find( rowIndex, columnIndex ) );
1934
1935 if( pos != matrix_.end( IsRowMajorMatrix_v<MT> ? rowIndex : columnIndex ) )
1936 return ConstIterator( matrix_, rowIndex, columnIndex, pos );
1937 }
1938
1939 return end();
1940}
1942//*************************************************************************************************
1943
1944
1945
1946
1947//=================================================================================================
1948//
1949// NUMERIC FUNCTIONS
1950//
1951//=================================================================================================
1952
1953//*************************************************************************************************
1966template< typename MT // Type of the sparse matrix
1967 , bool TF // Transpose flag
1968 , ptrdiff_t... CBAs > // Compile time band arguments
1969template< typename Other > // Data type of the scalar value
1970inline Band<MT,TF,false,false,CBAs...>&
1971 Band<MT,TF,false,false,CBAs...>::scale( const Other& scalar )
1972{
1974
1975 if( ( IsLower_v<MT> && column() > 0UL ) ||
1976 ( IsStrictlyLower_v<MT> && row() == 0UL ) ||
1977 ( IsUpper_v<MT> && row() > 0UL ) ||
1978 ( IsStrictlyUpper_v<MT> && column() == 0UL ) )
1979 return *this;
1980
1981 for( Iterator element=begin(); element!=end(); ++element )
1982 element->value() *= scalar;
1983
1984 return *this;
1985}
1987//*************************************************************************************************
1988
1989
1990
1991
1992//=================================================================================================
1993//
1994// EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1995//
1996//=================================================================================================
1997
1998//*************************************************************************************************
2009template< typename MT // Type of the sparse matrix
2010 , bool TF // Transpose flag
2011 , ptrdiff_t... CBAs > // Compile time band arguments
2012template< typename Other > // Data type of the foreign expression
2013inline bool Band<MT,TF,false,false,CBAs...>::canAlias( const Other* alias ) const noexcept
2014{
2015 return matrix_.isAliased( &unview( *alias ) );
2016}
2018//*************************************************************************************************
2019
2020
2021//*************************************************************************************************
2032template< typename MT // Type of the sparse matrix
2033 , bool TF // Transpose flag
2034 , ptrdiff_t... CBAs > // Compile time band arguments
2035template< typename Other > // Data type of the foreign expression
2036inline bool Band<MT,TF,false,false,CBAs...>::isAliased( const Other* alias ) const noexcept
2037{
2038 return matrix_.isAliased( &unview( *alias ) );
2039}
2041//*************************************************************************************************
2042
2043
2044//*************************************************************************************************
2056template< typename MT // Type of the sparse matrix
2057 , bool TF // Transpose flag
2058 , ptrdiff_t... CBAs > // Compile time band arguments
2059template< typename VT > // Type of the right-hand side dense vector
2060inline void Band<MT,TF,false,false,CBAs...>::assign( const DenseVector<VT,TF>& rhs )
2061{
2062 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
2063
2064 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2065 matrix_(row()+i,column()+i) = (*rhs)[i];
2066 }
2067}
2069//*************************************************************************************************
2070
2071
2072//*************************************************************************************************
2084template< typename MT // Type of the sparse matrix
2085 , bool TF // Transpose flag
2086 , ptrdiff_t... CBAs > // Compile time band arguments
2087template< typename VT > // Type of the right-hand side sparse vector
2088inline void Band<MT,TF,false,false,CBAs...>::assign( const SparseVector<VT,TF>& rhs )
2089{
2090 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
2091
2092 size_t i( 0UL );
2093
2094 for( ConstIterator_t<VT> element=(*rhs).begin(); element!=(*rhs).end(); ++element ) {
2095 for( ; i<element->index(); ++i )
2096 matrix_.erase( row()+i, column()+i );
2097 matrix_(row()+i,column()+i) = element->value();
2098 ++i;
2099 }
2100 for( ; i<size(); ++i ) {
2101 matrix_.erase( row()+i, column()+i );
2102 }
2103}
2105//*************************************************************************************************
2106
2107
2108//*************************************************************************************************
2120template< typename MT // Type of the sparse matrix
2121 , bool TF // Transpose flag
2122 , ptrdiff_t... CBAs > // Compile time band arguments
2123template< typename VT > // Type of the right-hand side vector
2124inline void Band<MT,TF,false,false,CBAs...>::addAssign( const Vector<VT,TF>& rhs )
2125{
2126 using AddType = AddTrait_t< ResultType, ResultType_t<VT> >;
2127
2130
2131 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
2132
2133 const AddType tmp( serial( *this + (*rhs) ) );
2134 assign( tmp );
2135}
2137//*************************************************************************************************
2138
2139
2140//*************************************************************************************************
2152template< typename MT // Type of the sparse matrix
2153 , bool TF // Transpose flag
2154 , ptrdiff_t... CBAs > // Compile time band arguments
2155template< typename VT > // Type of the right-hand side vector
2156inline void Band<MT,TF,false,false,CBAs...>::subAssign( const Vector<VT,TF>& rhs )
2157{
2158 using SubType = SubTrait_t< ResultType, ResultType_t<VT> >;
2159
2162
2163 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
2164
2165 const SubType tmp( serial( *this - (*rhs) ) );
2166 assign( tmp );
2167}
2169//*************************************************************************************************
2170
2171
2172
2173
2174//=================================================================================================
2175//
2176// CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRIX MULTIPLICATIONS
2177//
2178//=================================================================================================
2179
2180//*************************************************************************************************
2188template< typename MT // Type of the sparse matrix multiplication
2189 , bool TF // Transpose flag
2190 , ptrdiff_t... CBAs > // Compile time band arguments
2191class Band<MT,TF,false,true,CBAs...>
2192 : public View< SparseVector< Band<MT,TF,false,true,CBAs...>, TF > >
2193 , private BandData<CBAs...>
2194 , private Computation
2195{
2196 private:
2197 //**Type definitions****************************************************************************
2199 using DataType = BandData<CBAs...>;
2200
2202 using LeftOperand = RemoveReference_t< LeftOperand_t<MT> >;
2203
2205 using RightOperand = RemoveReference_t< RightOperand_t<MT> >;
2206 //**********************************************************************************************
2207
2208 public:
2209 //**Type definitions****************************************************************************
2211 using This = Band<MT,TF,false,true,CBAs...>;
2212
2214 using BaseType = View< SparseVector<This,TF> >;
2215
2217 using ViewedType = MT;
2218
2220 using ResultType = BandTrait_t<ResultType_t<MT>,CBAs...>;
2221
2222 using TransposeType = TransposeType_t<ResultType>;
2223 using ElementType = ElementType_t<ResultType>;
2224 using ReturnType = ReturnType_t<MT>;
2225 using CompositeType = const ResultType;
2226
2228 using LT = If_t< IsSparseMatrix_v<LeftOperand> && IsColumnMajorMatrix_v<LeftOperand>
2229 , OppositeType_t<LeftOperand>
2230 , CompositeType_t<LeftOperand> >;
2231
2233 using RT = If_t< IsSparseMatrix_v<RightOperand> && IsRowMajorMatrix_v<RightOperand>
2234 , OppositeType_t<RightOperand>
2235 , CompositeType_t<RightOperand> >;
2236 //**********************************************************************************************
2237
2238 //**Compilation flags***************************************************************************
2240 static constexpr bool smpAssignable = false;
2241
2243 static constexpr bool compileTimeArgs = DataType::compileTimeArgs;
2244 //**********************************************************************************************
2245
2246 //**Constructor*********************************************************************************
2253 template< typename... RBAs > // Runtime band arguments
2254 explicit inline Band( const MT& mmm, RBAs... args )
2255 : DataType( args... ) // Base class initialization
2256 , matrix_ ( mmm ) // The matrix multiplication containing the band
2257 {
2258 if( isChecked( args... ) ) {
2259 if( ( band() > 0L && column() >= mmm.columns() ) ||
2260 ( band() < 0L && row() >= mmm.rows() ) ) {
2261 BLAZE_THROW_INVALID_ARGUMENT( "Invalid band access index" );
2262 }
2263 }
2264 else {
2265 BLAZE_USER_ASSERT( band() <= 0L || column() < mmm.columns(), "Invalid band access index" );
2266 BLAZE_USER_ASSERT( band() >= 0L || row() < mmm.rows(), "Invalid band access index" );
2267 }
2268 }
2269 //**********************************************************************************************
2270
2271 //**Subscript operator**************************************************************************
2277 inline ReturnType operator[]( size_t index ) const {
2278 BLAZE_INTERNAL_ASSERT( index < size(), "Invalid vector access index" );
2279 return matrix_(row()+index,column()+index);
2280 }
2281 //**********************************************************************************************
2282
2283 //**At function*********************************************************************************
2290 inline ReturnType at( size_t index ) const {
2291 if( index >= size() ) {
2292 BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
2293 }
2294 return (*this)[index];
2295 }
2296 //**********************************************************************************************
2297
2298 //**Size function*******************************************************************************
2303 inline size_t size() const noexcept {
2304 return min( matrix_.rows() - row(), matrix_.columns() - column() );
2305 }
2306 //**********************************************************************************************
2307
2308 //**NonZeros function***************************************************************************
2313 inline size_t nonZeros() const {
2314 return 0UL;
2315 }
2316 //**********************************************************************************************
2317
2318 //**********************************************************************************************
2319 using DataType::band;
2320 using DataType::row;
2321 using DataType::column;
2322 //**********************************************************************************************
2323
2324 //**Operand access******************************************************************************
2329 inline const MT& operand() const noexcept {
2330 return matrix_;
2331 }
2332 //**********************************************************************************************
2333
2334 //**********************************************************************************************
2340 template< typename T >
2341 inline bool canAlias( const T* alias ) const noexcept {
2342 return matrix_.isAliased( &unview( *alias ) );
2343 }
2344 //**********************************************************************************************
2345
2346 //**********************************************************************************************
2352 template< typename T >
2353 inline bool isAliased( const T* alias ) const noexcept {
2354 return matrix_.isAliased( &unview( *alias ) );
2355 }
2356 //**********************************************************************************************
2357
2358 private:
2359 //**Member variables****************************************************************************
2360 MT matrix_;
2361 //**********************************************************************************************
2362
2363 //**Assignment to dense vectors*****************************************************************
2374 template< typename VT > // Type of the target dense vector
2375 friend inline void assign( DenseVector<VT,TF>& lhs, const Band& rhs )
2376 {
2377 using blaze::row;
2378 using blaze::column;
2379
2381
2382 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2383
2384 LT A( serial( rhs.operand().leftOperand() ) );
2385 RT B( serial( rhs.operand().rightOperand() ) );
2386
2387 const size_t n( rhs.size() );
2388 for( size_t i=0UL; i<n; ++i ) {
2389 (*lhs)[i] = row( A, rhs.row()+i, unchecked ) * column( B, rhs.column()+i, unchecked );
2390 }
2391 }
2392 //**********************************************************************************************
2393
2394 //**Assignment to sparse vectors****************************************************************
2405 template< typename VT > // Type of the target sparse vector
2406 friend inline void assign( SparseVector<VT,TF>& lhs, const Band& rhs )
2407 {
2408 using blaze::row;
2409 using blaze::column;
2410
2412
2413 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2414
2415 LT A( serial( rhs.operand().leftOperand() ) );
2416 RT B( serial( rhs.operand().rightOperand() ) );
2417
2418 const size_t n( rhs.size() );
2419 ElementType_t<VT> tmp{};
2420 size_t nonzeros( 0UL );
2421
2422 for( size_t i=0UL; i<n; ++i ) {
2423 tmp = row( A, rhs.row()+i, unchecked ) * column( B, rhs.column()+i, unchecked );
2424 if( !isDefault<strict>( tmp ) ) {
2425 if( (*lhs).capacity() <= nonzeros ) {
2426 (*lhs).reserve( min( max( 2UL*(*lhs).capacity(), 7UL ), (*lhs).size() ) );
2427 }
2428 (*lhs).append( i, tmp, false );
2429 ++nonzeros;
2430 }
2431 }
2432 }
2433 //**********************************************************************************************
2434
2435 //**Addition assignment to dense vectors********************************************************
2446 template< typename VT > // Type of the target dense vector
2447 friend inline void addAssign( DenseVector<VT,TF>& lhs, const Band& rhs )
2448 {
2449 using blaze::row;
2450 using blaze::column;
2451
2453
2454 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2455
2456 LT A( serial( rhs.operand().leftOperand() ) );
2457 RT B( serial( rhs.operand().rightOperand() ) );
2458
2459 const size_t n( rhs.size() );
2460 for( size_t i=0UL; i<n; ++i ) {
2461 (*lhs)[i] += row( A, rhs.row()+i, unchecked ) * column( B, rhs.column()+i, unchecked );
2462 }
2463 }
2464 //**********************************************************************************************
2465
2466 //**Addition assignment to sparse vectors*******************************************************
2467 // No special implementation for the addition assignment to sparse vectors.
2468 //**********************************************************************************************
2469
2470 //**Subtraction assignment to dense vectors*****************************************************
2481 template< typename VT > // Type of the target dense vector
2482 friend inline void subAssign( DenseVector<VT,TF>& lhs, const Band& rhs )
2483 {
2484 using blaze::row;
2485 using blaze::column;
2486
2488
2489 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2490
2491 LT A( serial( rhs.operand().leftOperand() ) );
2492 RT B( serial( rhs.operand().rightOperand() ) );
2493
2494 const size_t n( rhs.size() );
2495 for( size_t i=0UL; i<n; ++i ) {
2496 (*lhs)[i] -= row( A, rhs.row()+i, unchecked ) * column( B, rhs.column()+i, unchecked );
2497 }
2498 }
2499 //**********************************************************************************************
2500
2501 //**Subtraction assignment to sparse vectors****************************************************
2502 // No special implementation for the subtraction assignment to sparse vectors.
2503 //**********************************************************************************************
2504
2505 //**Multiplication assignment to dense vectors**************************************************
2517 template< typename VT > // Type of the target dense vector
2518 friend inline void multAssign( DenseVector<VT,TF>& lhs, const Band& rhs )
2519 {
2520 using blaze::row;
2521 using blaze::column;
2522
2524
2525 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2526
2527 LT A( serial( rhs.operand().leftOperand() ) );
2528 RT B( serial( rhs.operand().rightOperand() ) );
2529
2530 const size_t n( rhs.size() );
2531 for( size_t i=0UL; i<n; ++i ) {
2532 (*lhs)[i] *= row( A, rhs.row()+i, unchecked ) * column( B, rhs.column()+i, unchecked );
2533 }
2534 }
2535 //**********************************************************************************************
2536
2537 //**Multiplication assignment to sparse vectors*************************************************
2538 // No special implementation for the multiplication assignment to sparse vectors.
2539 //**********************************************************************************************
2540
2541 //**Compile time checks*************************************************************************
2546 //**********************************************************************************************
2547};
2549//*************************************************************************************************
2550
2551
2552
2553
2554//=================================================================================================
2555//
2556// CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRIX REPEATER EXPRESSIONS
2557//
2558//=================================================================================================
2559
2560//*************************************************************************************************
2568template< typename MT // Type of the sparse matrix
2569 , bool SO // Storage order
2570 , size_t... CRAs // Compile time repeater arguments
2571 , bool TF // Transpose flag
2572 , ptrdiff_t... CBAs > // Compile time band arguments
2573class Band< SMatRepeatExpr<MT,SO,CRAs...>, TF, false, false, CBAs... >
2574 : public View< SparseVector< Band< SMatRepeatExpr<MT,SO,CRAs...>, TF, false, false, CBAs... >, TF > >
2575 , private BandData<CBAs...>
2576 , private Computation
2577{
2578 private:
2579 //**Type definitions****************************************************************************
2581 using RE = SMatRepeatExpr<MT,SO,CRAs...>;
2582
2584 using DataType = BandData<CBAs...>;
2585 //**********************************************************************************************
2586
2587 public:
2588 //**Type definitions****************************************************************************
2590 using This = Band<RE,TF,false,false,CBAs...>;
2591
2593 using BaseType = View< SparseVector<This,TF> >;
2594
2596 using ViewedType = RE;
2597
2599 using ResultType = BandTrait_t<ResultType_t<RE>,CBAs...>;
2600
2601 using TransposeType = TransposeType_t<ResultType>;
2602 using ElementType = ElementType_t<ResultType>;
2603 using ReturnType = ReturnType_t<MT>;
2604 using CompositeType = const ResultType;
2605 //**********************************************************************************************
2606
2607 //**Compilation flags***************************************************************************
2609 static constexpr bool smpAssignable = false;
2610
2612 static constexpr bool compileTimeArgs = DataType::compileTimeArgs;
2613 //**********************************************************************************************
2614
2615 //**Constructor*********************************************************************************
2622 template< typename... RBAs > // Runtime band arguments
2623 explicit inline Band( const RE& re, RBAs... args )
2624 : DataType( args... ) // Base class initialization
2625 , matrix_ ( re ) // The matrix repeater expression containing the band
2626 {
2627 if( isChecked( args... ) ) {
2628 if( ( band() > 0L && column() >= re.columns() ) ||
2629 ( band() < 0L && row() >= re.rows() ) ) {
2630 BLAZE_THROW_INVALID_ARGUMENT( "Invalid band access index" );
2631 }
2632 }
2633 else {
2634 BLAZE_USER_ASSERT( band() <= 0L || column() < re.columns(), "Invalid band access index" );
2635 BLAZE_USER_ASSERT( band() >= 0L || row() < re.rows(), "Invalid band access index" );
2636 }
2637 }
2638 //**********************************************************************************************
2639
2640 //**Subscript operator**************************************************************************
2646 inline ReturnType operator[]( size_t index ) const {
2647 BLAZE_INTERNAL_ASSERT( index < size(), "Invalid vector access index" );
2648 return matrix_(row()+index,column()+index);
2649 }
2650 //**********************************************************************************************
2651
2652 //**At function*********************************************************************************
2659 inline ReturnType at( size_t index ) const {
2660 if( index >= size() ) {
2661 BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
2662 }
2663 return (*this)[index];
2664 }
2665 //**********************************************************************************************
2666
2667 //**Size function*******************************************************************************
2672 inline size_t size() const noexcept {
2673 return min( matrix_.rows() - row(), matrix_.columns() - column() );
2674 }
2675 //**********************************************************************************************
2676
2677 //**NonZeros function***************************************************************************
2682 inline size_t nonZeros() const {
2683 return 0UL;
2684 }
2685 //**********************************************************************************************
2686
2687 //**********************************************************************************************
2688 using DataType::band;
2689 using DataType::row;
2690 using DataType::column;
2691 //**********************************************************************************************
2692
2693 //**Operand access******************************************************************************
2698 inline const MT& operand() const noexcept {
2699 return matrix_;
2700 }
2701 //**********************************************************************************************
2702
2703 //**********************************************************************************************
2709 template< typename T >
2710 inline bool canAlias( const T* alias ) const noexcept {
2711 return matrix_.isAliased( &unview( *alias ) );
2712 }
2713 //**********************************************************************************************
2714
2715 //**********************************************************************************************
2721 template< typename T >
2722 inline bool isAliased( const T* alias ) const noexcept {
2723 return matrix_.isAliased( &unview( *alias ) );
2724 }
2725 //**********************************************************************************************
2726
2727 private:
2728 //**Member variables****************************************************************************
2729 RE matrix_;
2730 //**********************************************************************************************
2731
2732 //**Assignment to dense vectors*****************************************************************
2743 template< typename VT > // Type of the target dense vector
2744 friend inline void assign( DenseVector<VT,TF>& lhs, const Band& rhs )
2745 {
2747
2748 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2749
2750 const size_t n( rhs.size() );
2751 for( size_t i=0UL; i<n; ++i ) {
2752 (*lhs)[i] = rhs[i];
2753 }
2754 }
2755 //**********************************************************************************************
2756
2757 //**Assignment to sparse vectors****************************************************************
2768 template< typename VT > // Type of the target sparse vector
2769 friend inline void assign( SparseVector<VT,TF>& lhs, const Band& rhs )
2770 {
2772
2773 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2774
2775 const size_t n( rhs.size() );
2776 ElementType_t<VT> tmp{};
2777 size_t nonzeros( 0UL );
2778
2779 for( size_t i=0UL; i<n; ++i ) {
2780 tmp = rhs[i];
2781 if( !isDefault<strict>( tmp ) ) {
2782 if( (*lhs).capacity() <= nonzeros ) {
2783 (*lhs).reserve( min( max( 2UL*(*lhs).capacity(), 7UL ), (*lhs).size() ) );
2784 }
2785 (*lhs).append( i, tmp, false );
2786 ++nonzeros;
2787 }
2788 }
2789 }
2790 //**********************************************************************************************
2791
2792 //**Addition assignment to dense vectors********************************************************
2804 template< typename VT > // Type of the target dense vector
2805 friend inline void addAssign( DenseVector<VT,TF>& lhs, const Band& rhs )
2806 {
2808
2809 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2810
2811 const size_t n( rhs.size() );
2812 for( size_t i=0UL; i<n; ++i ) {
2813 (*lhs)[i] += rhs[i];
2814 }
2815 }
2816 //**********************************************************************************************
2817
2818 //**Addition assignment to sparse vectors*******************************************************
2819 // No special implementation for the addition assignment to sparse vectors.
2820 //**********************************************************************************************
2821
2822 //**Subtraction assignment to dense vectors*****************************************************
2834 template< typename VT > // Type of the target dense vector
2835 friend inline void subAssign( DenseVector<VT,TF>& lhs, const Band& rhs )
2836 {
2838
2839 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2840
2841 const size_t n( rhs.size() );
2842 for( size_t i=0UL; i<n; ++i ) {
2843 (*lhs)[i] -= rhs[i];
2844 }
2845 }
2846 //**********************************************************************************************
2847
2848 //**Subtraction assignment to sparse vectors****************************************************
2849 // No special implementation for the subtraction assignment to sparse vectors.
2850 //**********************************************************************************************
2851
2852 //**Multiplication assignment to dense vectors**************************************************
2864 template< typename VT > // Type of the target dense vector
2865 friend inline void multAssign( DenseVector<VT,TF>& lhs, const Band& rhs )
2866 {
2868
2869 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2870
2871 const size_t n( rhs.size() );
2872 for( size_t i=0UL; i<n; ++i ) {
2873 (*lhs)[i] *= rhs[i];
2874 }
2875 }
2876 //**********************************************************************************************
2877
2878 //**Multiplication assignment to sparse vectors*************************************************
2879 // No special implementation for the multiplication assignment to sparse vectors.
2880 //**********************************************************************************************
2881};
2883//*************************************************************************************************
2884
2885} // namespace blaze
2886
2887#endif
Header file for the addition trait.
Header file for auxiliary alias declarations.
Header file for run time assertion macros.
Header file for the implementation of the BandData class template.
Header file for the band trait.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the cross product trait.
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 division trait.
Header file for the EnableIf class template.
Header file for the If class template.
Header file for the IsColumnMajorMatrix type trait.
Header file for the IsConst type trait.
Header file for the isDefault shim.
Header file for the IsExpression type trait class.
Header file for the IsIntegral type trait.
Header file for the IsLower type trait.
Header file for the IsRowMajorMatrix type trait.
Header file for the IsSparseMatrix type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsUniLower type trait.
Header file for the IsUniUpper type trait.
Header file for the IsUpper type trait.
Header file for the MAYBE_UNUSED function template.
Header file for the multiplication trait.
Constraint on the data type.
Constraint on the data type.
Header file for the RemoveReference type trait.
Header file for the subtraction trait.
Constraint on the data type.
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.
Constraint on the data type.
Header file for the implementation of a vector representation of an initializer list.
Header file for the DenseVector base class.
Header file for the SparseVector base class.
Header file for the View base class.
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:140
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_POINTER_TYPE(T)
Constraint on the data type.
Definition: Pointer.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
decltype(auto) min(const DenseMatrix< MT1, SO1 > &lhs, const DenseMatrix< MT2, SO2 > &rhs)
Computes the componentwise minimum of the dense matrices lhs and rhs.
Definition: DMatDMatMapExpr.h:1339
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
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
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
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
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition: RequiresEvaluation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_MATMATMULTEXPR_TYPE(T)
Constraint on the data type.
Definition: MatMatMultExpr.h:63
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSEXPR_TYPE(T)
Constraint on the data type.
Definition: TransExpr.h:81
#define BLAZE_CONSTRAINT_MUST_BE_VECTOR_WITH_TRANSPOSE_FLAG(T, TF)
Constraint on the data type.
Definition: TransposeFlag.h:63
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: SparseVector.h:61
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: SparseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_BE_DENSE_VECTOR_TYPE(T)
Constraint on the data type.
Definition: DenseVector.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: UniTriangular.h:81
typename BandTrait< MT, CBAs... >::Type BandTrait_t
Auxiliary alias declaration for the BandTrait type trait.
Definition: BandTrait.h:145
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
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
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
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:676
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 > > 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
constexpr bool IsIntegral_v
Auxiliary variable template for the IsIntegral type trait.
Definition: IsIntegral.h:95
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
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
constexpr bool isChecked(const Ts &... args)
Extracting blaze::Check arguments from a given list of arguments.
Definition: Check.h:225
constexpr Unchecked unchecked
Global Unchecked instance.
Definition: Check.h:146
Header file for the exception macros of the math module.
Constraint on the data type.
Header file for all forward declarations for expression class templates.
Header file for the SparseElement base class.
Header file for basic type definitions.
Header file for the generic max algorithm.
Header file for the generic min algorithm.
Header file for the implementation of the Band base template.