Blaze 3.9
Dense.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_VIEWS_BAND_DENSE_H_
36#define _BLAZE_MATH_VIEWS_BAND_DENSE_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <algorithm>
44#include <iterator>
45#include <blaze/math/Aliases.h>
87#include <blaze/util/Assert.h>
90#include <blaze/util/mpl/If.h>
91#include <blaze/util/Types.h>
95
96
97namespace blaze {
98
99//=================================================================================================
100//
101// CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRICES
102//
103//=================================================================================================
104
105//*************************************************************************************************
112template< typename MT // Type of the dense matrix
113 , bool TF // Transpose flag
114 , ptrdiff_t... CBAs > // Compile time band arguments
115class Band<MT,TF,true,false,CBAs...>
116 : public View< DenseVector< Band<MT,TF,true,false,CBAs...>, TF > >
117 , private BandData<CBAs...>
118{
119 private:
120 //**Type definitions****************************************************************************
121 using RT = ResultType_t<MT>;
122 using DataType = BandData<CBAs...>;
123 using Operand = If_t< IsExpression_v<MT>, MT, MT& >;
124 //**********************************************************************************************
125
126 public:
127 //**Type definitions****************************************************************************
129 using This = Band<MT,TF,true,false,CBAs...>;
130
132 using BaseType = View< DenseVector<This,TF> >;
133
134 using ViewedType = MT;
135 using ResultType = BandTrait_t<RT,CBAs...>;
136 using TransposeType = TransposeType_t<ResultType>;
137 using ElementType = ElementType_t<MT>;
138 using ReturnType = ReturnType_t<MT>;
139
141 using CompositeType = If_t< RequiresEvaluation_v<MT>, const ResultType, const Band& >;
142
144 using ConstReference = ConstReference_t<MT>;
145
147 using Reference = If_t< IsConst_v<MT>, ConstReference, Reference_t<MT> >;
148
150 using ConstPointer = ConstPointer_t<MT>;
151
153 using Pointer = If_t< IsConst_v<MT> || !HasMutableDataAccess_v<MT>, ConstPointer, Pointer_t<MT> >;
154 //**********************************************************************************************
155
156 //**BandIterator class definition***************************************************************
159 template< typename MatrixType // Type of the dense matrix
160 , typename IteratorType > // Type of the dense matrix iterator
161 class BandIterator
162 {
163 public:
164 //**Type definitions*************************************************************************
166 using IteratorCategory = typename std::iterator_traits<IteratorType>::iterator_category;
167
169 using ValueType = typename std::iterator_traits<IteratorType>::value_type;
170
172 using PointerType = typename std::iterator_traits<IteratorType>::pointer;
173
175 using ReferenceType = typename std::iterator_traits<IteratorType>::reference;
176
178 using DifferenceType = typename std::iterator_traits<IteratorType>::difference_type;
179
180 // STL iterator requirements
181 using iterator_category = IteratorCategory;
182 using value_type = ValueType;
183 using pointer = PointerType;
184 using reference = ReferenceType;
185 using difference_type = DifferenceType;
186 //*******************************************************************************************
187
188 //**Constructor******************************************************************************
191 inline BandIterator() noexcept
192 : matrix_( nullptr ) // The dense matrix containing the band
193 , row_ ( 0UL ) // The current row index
194 , column_( 0UL ) // The current column index
195 , pos_ ( ) // Iterator to the current dense element
196 {}
197 //*******************************************************************************************
198
199 //**Constructor******************************************************************************
206 inline BandIterator( MatrixType& matrix, size_t rowIndex, size_t columnIndex ) noexcept
207 : matrix_( &matrix ) // The dense matrix containing the band
208 , row_ ( rowIndex ) // The current row index
209 , column_( columnIndex ) // The current column index
210 , pos_ ( ) // Iterator to the current dense element
211 {
212 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
213 pos_ = matrix_->begin( row_ ) + column_;
214 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
215 pos_ = matrix_->begin( column_ ) + row_;
216 }
217 //*******************************************************************************************
218
219 //**Constructor******************************************************************************
224 template< typename MatrixType2, typename IteratorType2 >
225 inline BandIterator( const BandIterator<MatrixType2,IteratorType2>& it ) noexcept
226 : matrix_( it.matrix_ ) // The dense matrix containing the band
227 , row_ ( it.row_ ) // The current row index
228 , column_( it.column_ ) // The current column index
229 , pos_ ( it.pos_ ) // Iterator to the current dense element
230 {}
231 //*******************************************************************************************
232
233 //**Addition assignment operator*************************************************************
239 inline BandIterator& operator+=( size_t inc ) noexcept {
240 using blaze::reset;
241
242 row_ += inc;
243 column_ += inc;
244
245 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
246 pos_ = matrix_->begin( row_ ) + column_;
247 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
248 pos_ = matrix_->begin( column_ ) + row_;
249 else reset( pos_ );
250
251 return *this;
252 }
253 //*******************************************************************************************
254
255 //**Subtraction assignment operator**********************************************************
261 inline BandIterator& operator-=( size_t dec ) noexcept {
262 using blaze::reset;
263
264 row_ -= dec;
265 column_ -= dec;
266
267 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
268 pos_ = matrix_->begin( row_ ) + column_;
269 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
270 pos_ = matrix_->begin( column_ ) + row_;
271 else reset( pos_ );
272
273 return *this;
274 }
275 //*******************************************************************************************
276
277 //**Prefix increment operator****************************************************************
282 inline BandIterator& operator++() noexcept {
283 using blaze::reset;
284
285 ++row_;
286 ++column_;
287
288 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
289 pos_ = matrix_->begin( row_ ) + column_;
290 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
291 pos_ = matrix_->begin( column_ ) + row_;
292 else reset( pos_ );
293
294 return *this;
295 }
296 //*******************************************************************************************
297
298 //**Postfix increment operator***************************************************************
303 inline const BandIterator operator++( int ) noexcept {
304 const BandIterator tmp( *this );
305 ++(*this);
306 return tmp;
307 }
308 //*******************************************************************************************
309
310 //**Prefix decrement operator****************************************************************
315 inline BandIterator& operator--() noexcept {
316 using blaze::reset;
317
318 --row_;
319 --column_;
320
321 if( IsRowMajorMatrix_v<MatrixType> && row_ != matrix_->rows() )
322 pos_ = matrix_->begin( row_ ) + column_;
323 else if( IsColumnMajorMatrix_v<MatrixType> && column_ != matrix_->columns() )
324 pos_ = matrix_->begin( column_ ) + row_;
325 else reset( pos_ );
326
327 return *this;
328 }
329 //*******************************************************************************************
330
331 //**Postfix decrement operator***************************************************************
336 inline const BandIterator operator--( int ) noexcept {
337 const BandIterator tmp( *this );
338 --(*this);
339 return tmp;
340 }
341 //*******************************************************************************************
342
343 //**Subscript operator***********************************************************************
349 inline ReferenceType operator[]( size_t index ) const {
350 BLAZE_USER_ASSERT( row_ +index < matrix_->rows() , "Invalid access index detected" );
351 BLAZE_USER_ASSERT( column_+index < matrix_->columns(), "Invalid access index detected" );
352 const IteratorType pos( IsRowMajorMatrix_v<MatrixType>
353 ? matrix_->begin( row_+index ) + column_ + index
354 : matrix_->begin( column_+index ) + row_ + index );
355 return *pos;
356 }
357 //*******************************************************************************************
358
359 //**Element access operator******************************************************************
364 inline ReferenceType operator*() const {
365 return *pos_;
366 }
367 //*******************************************************************************************
368
369 //**Element access operator******************************************************************
374 inline PointerType operator->() const {
375 return pos_;
376 }
377 //*******************************************************************************************
378
379 //**Equality operator************************************************************************
385 template< typename MatrixType2, typename IteratorType2 >
386 inline bool operator==( const BandIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
387 return row_ == rhs.row_;
388 }
389 //*******************************************************************************************
390
391 //**Inequality operator**********************************************************************
397 template< typename MatrixType2, typename IteratorType2 >
398 inline bool operator!=( const BandIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
399 return !( *this == rhs );
400 }
401 //*******************************************************************************************
402
403 //**Less-than 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 //**Greater-than operator********************************************************************
421 template< typename MatrixType2, typename IteratorType2 >
422 inline bool operator>( const BandIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
423 return row_ > rhs.row_;
424 }
425 //*******************************************************************************************
426
427 //**Less-or-equal-than operator**************************************************************
433 template< typename MatrixType2, typename IteratorType2 >
434 inline bool operator<=( const BandIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
435 return row_ <= rhs.row_;
436 }
437 //*******************************************************************************************
438
439 //**Greater-or-equal-than operator***********************************************************
445 template< typename MatrixType2, typename IteratorType2 >
446 inline bool operator>=( const BandIterator<MatrixType2,IteratorType2>& rhs ) const noexcept {
447 return row_ >= rhs.row_;
448 }
449 //*******************************************************************************************
450
451 //**Subtraction operator*********************************************************************
457 inline DifferenceType operator-( const BandIterator& rhs ) const noexcept {
458 return row_ - rhs.row_;
459 }
460 //*******************************************************************************************
461
462 //**Addition operator************************************************************************
469 friend inline const BandIterator operator+( const BandIterator& it, size_t inc ) noexcept {
470 return BandIterator( *it.matrix_, it.row_+inc, it.column_+inc );
471 }
472 //*******************************************************************************************
473
474 //**Addition operator************************************************************************
481 friend inline const BandIterator operator+( size_t inc, const BandIterator& it ) noexcept {
482 return BandIterator( *it.matrix_, it.row_+inc, it.column_+inc );
483 }
484 //*******************************************************************************************
485
486 //**Subtraction operator*********************************************************************
493 friend inline const BandIterator operator-( const BandIterator& it, size_t dec ) noexcept {
494 return BandIterator( *it.matrix_, it.row_-dec, it.column_-dec );
495 }
496 //*******************************************************************************************
497
498 private:
499 //**Member variables*************************************************************************
500 MatrixType* matrix_;
501 size_t row_;
502 size_t column_;
503 IteratorType pos_;
504 //*******************************************************************************************
505
506 //**Friend declarations**********************************************************************
507 template< typename MatrixType2, typename IteratorType2 > friend class BandIterator;
508 //*******************************************************************************************
509 };
510 //**********************************************************************************************
511
512 //**Type definitions****************************************************************************
514 using ConstIterator = BandIterator< const MT, ConstIterator_t<MT> >;
515
517 using Iterator = If_t< IsConst_v<MT>, ConstIterator, BandIterator< MT, Iterator_t<MT> > >;
518 //**********************************************************************************************
519
520 //**Compilation flags***************************************************************************
522 static constexpr bool simdEnabled = false;
523
525 static constexpr bool smpAssignable = MT::smpAssignable;
526
528 static constexpr bool compileTimeArgs = DataType::compileTimeArgs;
529 //**********************************************************************************************
530
531 //**Constructors********************************************************************************
534 template< typename... RBAs >
535 explicit inline Band( MT& matrix, RBAs... args );
536
537 Band( const Band& ) = default;
539 //**********************************************************************************************
540
541 //**Destructor**********************************************************************************
544 ~Band() = default;
546 //**********************************************************************************************
547
548 //**Data access functions***********************************************************************
551 inline Reference operator[]( size_t index );
552 inline ConstReference operator[]( size_t index ) const;
553 inline Reference at( size_t index );
554 inline ConstReference at( size_t index ) const;
555 inline Pointer data () noexcept;
556 inline ConstPointer data () const noexcept;
557 inline Iterator begin ();
558 inline ConstIterator begin () const;
559 inline ConstIterator cbegin() const;
560 inline Iterator end ();
561 inline ConstIterator end () const;
562 inline ConstIterator cend () const;
564 //**********************************************************************************************
565
566 //**Assignment operators************************************************************************
569 inline Band& operator=( const ElementType& rhs );
570 inline Band& operator=( initializer_list<ElementType> list );
571 inline Band& operator=( const Band& rhs );
572
573 template< typename VT > inline Band& operator= ( const Vector<VT,TF>& rhs );
574 template< typename VT > inline Band& operator+=( const Vector<VT,TF>& rhs );
575 template< typename VT > inline Band& operator-=( const Vector<VT,TF>& rhs );
576 template< typename VT > inline Band& operator*=( const Vector<VT,TF>& rhs );
577 template< typename VT > inline Band& operator/=( const DenseVector<VT,TF>& rhs );
578 template< typename VT > inline Band& operator%=( const Vector<VT,TF>& rhs );
580 //**********************************************************************************************
581
582 //**Utility functions***************************************************************************
585 using DataType::band;
586 using DataType::row;
587 using DataType::column;
588
589 inline MT& operand() noexcept;
590 inline const MT& operand() const noexcept;
591
592 inline size_t size() const noexcept;
593 inline size_t spacing() const noexcept;
594 inline size_t capacity() const noexcept;
595 inline size_t nonZeros() const;
596 inline void reset();
598 //**********************************************************************************************
599
600 //**Numeric functions***************************************************************************
603 template< typename Other > inline Band& scale( const Other& scalar );
605 //**********************************************************************************************
606
607 //**Expression template evaluation functions****************************************************
610 template< typename Other >
611 inline bool canAlias( const Other* alias ) const noexcept;
612
613 template< typename MT2, ptrdiff_t... CBAs2 >
614 inline bool canAlias( const Band<MT2,TF,true,false,CBAs2...>* alias ) const noexcept;
615
616 template< typename Other >
617 inline bool isAliased( const Other* alias ) const noexcept;
618
619 template< typename MT2, ptrdiff_t... CBAs2 >
620 inline bool isAliased( const Band<MT2,TF,true,false,CBAs2...>* alias ) const noexcept;
621
622 inline bool isAligned () const noexcept;
623 inline bool canSMPAssign() const noexcept;
624
625 template< typename VT > inline void assign ( const DenseVector <VT,TF>& rhs );
626 template< typename VT > inline void assign ( const SparseVector<VT,TF>& rhs );
627 template< typename VT > inline void addAssign ( const DenseVector <VT,TF>& rhs );
628 template< typename VT > inline void addAssign ( const SparseVector<VT,TF>& rhs );
629 template< typename VT > inline void subAssign ( const DenseVector <VT,TF>& rhs );
630 template< typename VT > inline void subAssign ( const SparseVector<VT,TF>& rhs );
631 template< typename VT > inline void multAssign( const DenseVector <VT,TF>& rhs );
632 template< typename VT > inline void multAssign( const SparseVector<VT,TF>& rhs );
633 template< typename VT > inline void divAssign ( const DenseVector <VT,TF>& rhs );
635 //**********************************************************************************************
636
637 private:
638 //**Member variables****************************************************************************
641 Operand matrix_;
643 //**********************************************************************************************
644
645 //**Friend declarations*************************************************************************
646 template< typename MT2, bool TF2, bool DF2, bool MF2, ptrdiff_t... CBAs2 > friend class Band;
647 //**********************************************************************************************
648
649 //**Compile time checks*************************************************************************
655 //**********************************************************************************************
656};
658//*************************************************************************************************
659
660
661
662
663//=================================================================================================
664//
665// CONSTRUCTORS
666//
667//=================================================================================================
668
669//*************************************************************************************************
682template< typename MT // Type of the dense matrix
683 , bool TF // Transpose flag
684 , ptrdiff_t... CBAs > // Compile time band arguments
685template< typename... RBAs > // Runtime band arguments
686inline Band<MT,TF,true,false,CBAs...>::Band( MT& matrix, RBAs... args )
687 : DataType( args... ) // Base class initialization
688 , matrix_ ( matrix ) // The matrix containing the band
689{
690 if( isChecked( args... ) ) {
691 if( ( band() > 0L && column() >= matrix.columns() ) ||
692 ( band() < 0L && row() >= matrix.rows() ) ) {
693 BLAZE_THROW_INVALID_ARGUMENT( "Invalid band access index" );
694 }
695 }
696 else {
697 BLAZE_USER_ASSERT( band() <= 0L || column() < matrix.columns(), "Invalid band access index" );
698 BLAZE_USER_ASSERT( band() >= 0L || row() < matrix.rows(), "Invalid band access index" );
699 }
700}
702//*************************************************************************************************
703
704
705
706
707//=================================================================================================
708//
709// DATA ACCESS FUNCTIONS
710//
711//=================================================================================================
712
713//*************************************************************************************************
723template< typename MT // Type of the dense matrix
724 , bool TF // Transpose flag
725 , ptrdiff_t... CBAs > // Compile time band arguments
726inline typename Band<MT,TF,true,false,CBAs...>::Reference
727 Band<MT,TF,true,false,CBAs...>::operator[]( size_t index )
728{
729 BLAZE_USER_ASSERT( index < size(), "Invalid band access index" );
730 return matrix_(row()+index,column()+index);
731}
733//*************************************************************************************************
734
735
736//*************************************************************************************************
746template< typename MT // Type of the dense matrix
747 , bool TF // Transpose flag
748 , ptrdiff_t... CBAs > // Compile time band arguments
749inline typename Band<MT,TF,true,false,CBAs...>::ConstReference
750 Band<MT,TF,true,false,CBAs...>::operator[]( size_t index ) const
751{
752 BLAZE_USER_ASSERT( index < size(), "Invalid band access index" );
753 return const_cast<const MT&>( matrix_ )(row()+index,column()+index);
754}
756//*************************************************************************************************
757
758
759//*************************************************************************************************
770template< typename MT // Type of the dense matrix
771 , bool TF // Transpose flag
772 , ptrdiff_t... CBAs > // Compile time band arguments
773inline typename Band<MT,TF,true,false,CBAs...>::Reference
774 Band<MT,TF,true,false,CBAs...>::at( size_t index )
775{
776 if( index >= size() ) {
777 BLAZE_THROW_OUT_OF_RANGE( "Invalid band access index" );
778 }
779 return (*this)[index];
780}
782//*************************************************************************************************
783
784
785//*************************************************************************************************
796template< typename MT // Type of the dense matrix
797 , bool TF // Transpose flag
798 , ptrdiff_t... CBAs > // Compile time band arguments
799inline typename Band<MT,TF,true,false,CBAs...>::ConstReference
800 Band<MT,TF,true,false,CBAs...>::at( size_t index ) const
801{
802 if( index >= size() ) {
803 BLAZE_THROW_OUT_OF_RANGE( "Invalid band access index" );
804 }
805 return (*this)[index];
806}
808//*************************************************************************************************
809
810
811//*************************************************************************************************
820template< typename MT // Type of the dense matrix
821 , bool TF // Transpose flag
822 , ptrdiff_t... CBAs > // Compile time band arguments
823inline typename Band<MT,TF,true,false,CBAs...>::Pointer
825{
826 if( IsRowMajorMatrix_v<MT> )
827 return matrix_.data() + row() * matrix_.spacing() + column();
828 else
829 return matrix_.data() + row() + column() * matrix_.spacing();
830}
832//*************************************************************************************************
833
834
835//*************************************************************************************************
844template< typename MT // Type of the dense matrix
845 , bool TF // Transpose flag
846 , ptrdiff_t... CBAs > // Compile time band arguments
847inline typename Band<MT,TF,true,false,CBAs...>::ConstPointer
849{
850 if( IsRowMajorMatrix_v<MT> )
851 return matrix_.data() + row() * matrix_.spacing() + column();
852 else
853 return matrix_.data() + row() + column() * matrix_.spacing();
854}
856//*************************************************************************************************
857
858
859//*************************************************************************************************
867template< typename MT // Type of the dense matrix
868 , bool TF // Transpose flag
869 , ptrdiff_t... CBAs > // Compile time band arguments
870inline typename Band<MT,TF,true,false,CBAs...>::Iterator
872{
873 return Iterator( matrix_, row(), column() );
874}
876//*************************************************************************************************
877
878
879//*************************************************************************************************
887template< typename MT // Type of the dense matrix
888 , bool TF // Transpose flag
889 , ptrdiff_t... CBAs > // Compile time band arguments
890inline typename Band<MT,TF,true,false,CBAs...>::ConstIterator
892{
893 return ConstIterator( matrix_, row(), column() );
894}
896//*************************************************************************************************
897
898
899//*************************************************************************************************
907template< typename MT // Type of the dense matrix
908 , bool TF // Transpose flag
909 , ptrdiff_t... CBAs > // Compile time band arguments
910inline typename Band<MT,TF,true,false,CBAs...>::ConstIterator
912{
913 return ConstIterator( matrix_, row(), column() );
914}
916//*************************************************************************************************
917
918
919//*************************************************************************************************
927template< typename MT // Type of the dense matrix
928 , bool TF // Transpose flag
929 , ptrdiff_t... CBAs > // Compile time band arguments
930inline typename Band<MT,TF,true,false,CBAs...>::Iterator
932{
933 const size_t n( size() );
934 return Iterator( matrix_, row()+n, column()+n );
935}
937//*************************************************************************************************
938
939
940//*************************************************************************************************
948template< typename MT // Type of the dense matrix
949 , bool TF // Transpose flag
950 , ptrdiff_t... CBAs > // Compile time band arguments
951inline typename Band<MT,TF,true,false,CBAs...>::ConstIterator
953{
954 const size_t n( size() );
955 return ConstIterator( matrix_, row()+n, column()+n );
956}
958//*************************************************************************************************
959
960
961//*************************************************************************************************
969template< typename MT // Type of the dense matrix
970 , bool TF // Transpose flag
971 , ptrdiff_t... CBAs > // Compile time band arguments
972inline typename Band<MT,TF,true,false,CBAs...>::ConstIterator
974{
975 const size_t n( size() );
976 return ConstIterator( matrix_, row()+n, column()+n );
977}
979//*************************************************************************************************
980
981
982
983
984//=================================================================================================
985//
986// ASSIGNMENT OPERATORS
987//
988//=================================================================================================
989
990//*************************************************************************************************
1001template< typename MT // Type of the dense matrix
1002 , bool TF // Transpose flag
1003 , ptrdiff_t... CBAs > // Compile time band arguments
1004inline Band<MT,TF,true,false,CBAs...>&
1005 Band<MT,TF,true,false,CBAs...>::operator=( const ElementType& rhs )
1006{
1007 decltype(auto) left( derestrict( matrix_ ) );
1008
1009 if( ( IsLower_v<MT> && column() > 0UL ) ||
1010 ( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> ) && row() == 0UL ) ||
1011 ( IsUpper_v<MT> && row() > 0UL ) ||
1012 ( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> ) && column() == 0UL ) )
1013 return *this;
1014
1015 const size_t n( size() );
1016 for( size_t i=0UL; i<n; ++i ) {
1017 if( !IsRestricted_v<MT> || IsTriangular_v<MT> || trySet( matrix_, row()+i, column()+i, rhs ) )
1018 left(row()+i,column()+i) = rhs;
1019 }
1020
1021 return *this;
1022}
1024//*************************************************************************************************
1025
1026
1027//*************************************************************************************************
1042template< typename MT // Type of the dense matrix
1043 , bool TF // Transpose flag
1044 , ptrdiff_t... CBAs > // Compile time band arguments
1045inline Band<MT,TF,true,false,CBAs...>&
1046 Band<MT,TF,true,false,CBAs...>::operator=( initializer_list<ElementType> list )
1047{
1048 if( list.size() > size() ) {
1049 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to band" );
1050 }
1051
1052 if( IsRestricted_v<MT> ) {
1053 const InitializerVector<ElementType,false> tmp( list, size() );
1054 if( !tryAssign( matrix_, tmp, band(), row(), column() ) ) {
1055 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1056 }
1057 }
1058
1059 decltype(auto) left( derestrict( *this ) );
1060
1061 std::fill( std::copy( list.begin(), list.end(), left.begin() ), left.end(), ElementType() );
1062
1063 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1064
1065 return *this;
1066}
1068//*************************************************************************************************
1069
1070
1071//*************************************************************************************************
1085template< typename MT // Type of the dense matrix
1086 , bool TF // Transpose flag
1087 , ptrdiff_t... CBAs > // Compile time band arguments
1088inline Band<MT,TF,true,false,CBAs...>&
1089 Band<MT,TF,true,false,CBAs...>::operator=( const Band& rhs )
1090{
1091 if( &rhs == this ) return *this;
1092
1093 if( size() != rhs.size() ) {
1094 BLAZE_THROW_INVALID_ARGUMENT( "Band sizes do not match" );
1095 }
1096
1097 if( !tryAssign( matrix_, rhs, band(), row(), column() ) ) {
1098 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1099 }
1100
1101 decltype(auto) left( derestrict( *this ) );
1102
1103 if( IsExpression_v<MT> && rhs.canAlias( this ) ) {
1104 const ResultType tmp( rhs );
1105 smpAssign( left, tmp );
1106 }
1107 else {
1108 smpAssign( left, rhs );
1109 }
1110
1111 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1112
1113 return *this;
1114}
1116//*************************************************************************************************
1117
1118
1119//*************************************************************************************************
1133template< typename MT // Type of the dense matrix
1134 , bool TF // Transpose flag
1135 , ptrdiff_t... CBAs > // Compile time band arguments
1136template< typename VT > // Type of the right-hand side vector
1137inline Band<MT,TF,true,false,CBAs...>&
1138 Band<MT,TF,true,false,CBAs...>::operator=( const Vector<VT,TF>& rhs )
1139{
1142
1143 if( size() != (*rhs).size() ) {
1144 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1145 }
1146
1147 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>, const VT& >;
1148 Right right( *rhs );
1149
1150 if( !tryAssign( matrix_, right, band(), row(), column() ) ) {
1151 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1152 }
1153
1154 decltype(auto) left( derestrict( *this ) );
1155
1156 if( IsReference_v<Right> && right.canAlias( this ) ) {
1157 const ResultType_t<VT> tmp( right );
1158 smpAssign( left, tmp );
1159 }
1160 else {
1161 if( IsSparseVector_v<VT> )
1162 reset();
1163 smpAssign( left, right );
1164 }
1165
1166 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1167
1168 return *this;
1169}
1171//*************************************************************************************************
1172
1173
1174//*************************************************************************************************
1188template< typename MT // Type of the dense matrix
1189 , bool TF // Transpose flag
1190 , ptrdiff_t... CBAs > // Compile time band arguments
1191template< typename VT > // Type of the right-hand side vector
1192inline Band<MT,TF,true,false,CBAs...>&
1193 Band<MT,TF,true,false,CBAs...>::operator+=( const Vector<VT,TF>& rhs )
1194{
1197
1198 if( size() != (*rhs).size() ) {
1199 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1200 }
1201
1202 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>, const VT& >;
1203 Right right( *rhs );
1204
1205 if( !tryAddAssign( matrix_, right, band(), row(), column() ) ) {
1206 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1207 }
1208
1209 decltype(auto) left( derestrict( *this ) );
1210
1211 if( IsReference_v<Right> && right.canAlias( this ) ) {
1212 const ResultType_t<VT> tmp( right );
1213 smpAddAssign( left, tmp );
1214 }
1215 else {
1216 smpAddAssign( left, right );
1217 }
1218
1219 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1220
1221 return *this;
1222}
1224//*************************************************************************************************
1225
1226
1227//*************************************************************************************************
1241template< typename MT // Type of the dense matrix
1242 , bool TF // Transpose flag
1243 , ptrdiff_t... CBAs > // Compile time band arguments
1244template< typename VT > // Type of the right-hand side vector
1245inline Band<MT,TF,true,false,CBAs...>&
1246 Band<MT,TF,true,false,CBAs...>::operator-=( const Vector<VT,TF>& rhs )
1247{
1250
1251 if( size() != (*rhs).size() ) {
1252 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1253 }
1254
1255 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>, const VT& >;
1256 Right right( *rhs );
1257
1258 if( !trySubAssign( matrix_, right, band(), row(), column() ) ) {
1259 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1260 }
1261
1262 decltype(auto) left( derestrict( *this ) );
1263
1264 if( IsReference_v<Right> && right.canAlias( this ) ) {
1265 const ResultType_t<VT> tmp( right );
1266 smpSubAssign( left, tmp );
1267 }
1268 else {
1269 smpSubAssign( left, right );
1270 }
1271
1272 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1273
1274 return *this;
1275}
1277//*************************************************************************************************
1278
1279
1280//*************************************************************************************************
1293template< typename MT // Type of the dense matrix
1294 , bool TF // Transpose flag
1295 , ptrdiff_t... CBAs > // Compile time band arguments
1296template< typename VT > // Type of the right-hand side vector
1297inline Band<MT,TF,true,false,CBAs...>&
1298 Band<MT,TF,true,false,CBAs...>::operator*=( const Vector<VT,TF>& rhs )
1299{
1305
1306 if( size() != (*rhs).size() ) {
1307 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1308 }
1309
1310 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>, const VT& >;
1311 Right right( *rhs );
1312
1313 if( !tryMultAssign( matrix_, right, band(), row(), column() ) ) {
1314 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1315 }
1316
1317 decltype(auto) left( derestrict( *this ) );
1318
1319 if( IsReference_v<Right> && right.canAlias( this ) ) {
1320 const ResultType_t<VT> tmp( right );
1321 smpMultAssign( left, tmp );
1322 }
1323 else {
1324 smpMultAssign( left, right );
1325 }
1326
1327 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1328
1329 return *this;
1330}
1332//*************************************************************************************************
1333
1334
1335//*************************************************************************************************
1347template< typename MT // Type of the dense matrix
1348 , bool TF // Transpose flag
1349 , ptrdiff_t... CBAs > // Compile time band arguments
1350template< typename VT > // Type of the right-hand side dense vector
1351inline Band<MT,TF,true,false,CBAs...>&
1352 Band<MT,TF,true,false,CBAs...>::operator/=( const DenseVector<VT,TF>& rhs )
1353{
1356
1357 if( size() != (*rhs).size() ) {
1358 BLAZE_THROW_INVALID_ARGUMENT( "Vector sizes do not match" );
1359 }
1360
1361 using Right = If_t< IsRestricted_v<MT>, CompositeType_t<VT>, const VT& >;
1362 Right right( *rhs );
1363
1364 if( !tryDivAssign( matrix_, right, band(), row(), column() ) ) {
1365 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1366 }
1367
1368 decltype(auto) left( derestrict( *this ) );
1369
1370 if( IsReference_v<Right> && right.canAlias( this ) ) {
1371 const ResultType_t<VT> tmp( right );
1372 smpDivAssign( left, tmp );
1373 }
1374 else {
1375 smpDivAssign( left, right );
1376 }
1377
1378 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1379
1380 return *this;
1381}
1383//*************************************************************************************************
1384
1385
1386//*************************************************************************************************
1399template< typename MT // Type of the dense matrix
1400 , bool TF // Transpose flag
1401 , ptrdiff_t... CBAs > // Compile time band arguments
1402template< typename VT > // Type of the right-hand side vector
1403inline Band<MT,TF,true,false,CBAs...>&
1404 Band<MT,TF,true,false,CBAs...>::operator%=( const Vector<VT,TF>& rhs )
1405{
1406 using blaze::assign;
1407
1410
1411 using CrossType = CrossTrait_t< ResultType, ResultType_t<VT> >;
1412
1416
1417 if( size() != 3UL || (*rhs).size() != 3UL ) {
1418 BLAZE_THROW_INVALID_ARGUMENT( "Invalid vector size for cross product" );
1419 }
1420
1421 const CrossType right( *this % (*rhs) );
1422
1423 if( !tryAssign( matrix_, right, band(), row(), column() ) ) {
1424 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to restricted matrix" );
1425 }
1426
1427 decltype(auto) left( derestrict( *this ) );
1428
1429 assign( left, right );
1430
1431 BLAZE_INTERNAL_ASSERT( isIntact( matrix_ ), "Invariant violation detected" );
1432
1433 return *this;
1434}
1436//*************************************************************************************************
1437
1438
1439
1440
1441//=================================================================================================
1442//
1443// UTILITY FUNCTIONS
1444//
1445//=================================================================================================
1446
1447//*************************************************************************************************
1453template< typename MT // Type of the dense matrix
1454 , bool TF // Transpose flag
1455 , ptrdiff_t... CBAs > // Compile time band arguments
1456inline MT& Band<MT,TF,true,false,CBAs...>::operand() noexcept
1457{
1458 return matrix_;
1459}
1461//*************************************************************************************************
1462
1463
1464//*************************************************************************************************
1470template< typename MT // Type of the dense matrix
1471 , bool TF // Transpose flag
1472 , ptrdiff_t... CBAs > // Compile time band arguments
1473inline const MT& Band<MT,TF,true,false,CBAs...>::operand() const noexcept
1474{
1475 return matrix_;
1476}
1478//*************************************************************************************************
1479
1480
1481//*************************************************************************************************
1487template< typename MT // Type of the dense matrix
1488 , bool TF // Transpose flag
1489 , ptrdiff_t... CBAs > // Compile time band arguments
1490inline size_t Band<MT,TF,true,false,CBAs...>::size() const noexcept
1491{
1492 return min( matrix_.rows() - row(), matrix_.columns() - column() );
1493}
1495//*************************************************************************************************
1496
1497
1498//*************************************************************************************************
1507template< typename MT // Type of the dense matrix
1508 , bool TF // Transpose flag
1509 , ptrdiff_t... CBAs > // Compile time band arguments
1510inline size_t Band<MT,TF,true,false,CBAs...>::spacing() const noexcept
1511{
1512 return size();
1513}
1515//*************************************************************************************************
1516
1517
1518//*************************************************************************************************
1524template< typename MT // Type of the dense matrix
1525 , bool TF // Transpose flag
1526 , ptrdiff_t... CBAs > // Compile time band arguments
1527inline size_t Band<MT,TF,true,false,CBAs...>::capacity() const noexcept
1528{
1529 return size();
1530}
1532//*************************************************************************************************
1533
1534
1535//*************************************************************************************************
1544template< typename MT // Type of the dense matrix
1545 , bool TF // Transpose flag
1546 , ptrdiff_t... CBAs > // Compile time band arguments
1547inline size_t Band<MT,TF,true,false,CBAs...>::nonZeros() const
1548{
1549 const size_t n( size() );
1550 size_t nonzeros( 0UL );
1551
1552 for( size_t i=0UL; i<n; ++i )
1553 if( !isDefault( matrix_(row()+i,column()+i) ) )
1554 ++nonzeros;
1555
1556 return nonzeros;
1557}
1559//*************************************************************************************************
1560
1561
1562//*************************************************************************************************
1568template< typename MT // Type of the dense matrix
1569 , bool TF // Transpose flag
1570 , ptrdiff_t... CBAs > // Compile time band arguments
1572{
1573 using blaze::clear;
1574
1575 if( ( IsLower_v<MT> && column() > 0UL ) ||
1576 ( ( IsUniLower_v<MT> || IsStrictlyLower_v<MT> ) && row() == 0UL ) ||
1577 ( IsUpper_v<MT> && row() > 0UL ) ||
1578 ( ( IsUniUpper_v<MT> || IsStrictlyUpper_v<MT> ) && column() == 0UL ) )
1579 return;
1580
1581 const size_t n( size() );
1582 for( size_t i=0UL; i<n; ++i )
1583 clear( matrix_(row()+i,column()+i) );
1584}
1586//*************************************************************************************************
1587
1588
1589
1590
1591//=================================================================================================
1592//
1593// NUMERIC FUNCTIONS
1594//
1595//=================================================================================================
1596
1597//*************************************************************************************************
1610template< typename MT // Type of the dense matrix
1611 , bool TF // Transpose flag
1612 , ptrdiff_t... CBAs > // Compile time band arguments
1613template< typename Other > // Data type of the scalar value
1614inline Band<MT,TF,true,false,CBAs...>&
1615 Band<MT,TF,true,false,CBAs...>::scale( const Other& scalar )
1616{
1618
1619 if( ( IsLower_v<MT> && column() > 0UL ) ||
1620 ( IsStrictlyLower_v<MT> && row() == 0UL ) ||
1621 ( IsUpper_v<MT> && row() > 0UL ) ||
1622 ( IsStrictlyUpper_v<MT> && column() == 0UL ) )
1623 return *this;
1624
1625 const size_t n( size() );
1626 for( size_t i=0UL; i<n; ++i ) {
1627 matrix_(row()+i,column()+i) *= scalar;
1628 }
1629
1630 return *this;
1631}
1633//*************************************************************************************************
1634
1635
1636
1637
1638//=================================================================================================
1639//
1640// EXPRESSION TEMPLATE EVALUATION FUNCTIONS
1641//
1642//=================================================================================================
1643
1644//*************************************************************************************************
1655template< typename MT // Type of the dense matrix
1656 , bool TF // Transpose flag
1657 , ptrdiff_t... CBAs > // Compile time band arguments
1658template< typename Other > // Data type of the foreign expression
1659inline bool Band<MT,TF,true,false,CBAs...>::canAlias( const Other* alias ) const noexcept
1660{
1661 return matrix_.isAliased( &unview( *alias ) );
1662}
1664//*************************************************************************************************
1665
1666
1667//*************************************************************************************************
1678template< typename MT // Type of the dense matrix
1679 , bool TF // Transpose flag
1680 , ptrdiff_t... CBAs > // Compile time band arguments
1681template< typename MT2 // Matrix type of the foreign dense band
1682 , ptrdiff_t... CBAs2 > // Compile time band arguments of the foreign dense band
1683inline bool
1684 Band<MT,TF,true,false,CBAs...>::canAlias( const Band<MT2,TF,true,false,CBAs2...>* alias ) const noexcept
1685{
1686 return matrix_.isAliased( &alias->matrix_ ) && ( band() == alias->band() );
1687}
1689//*************************************************************************************************
1690
1691
1692//*************************************************************************************************
1703template< typename MT // Type of the dense matrix
1704 , bool TF // Transpose flag
1705 , ptrdiff_t... CBAs > // Compile time band arguments
1706template< typename Other > // Data type of the foreign expression
1707inline bool Band<MT,TF,true,false,CBAs...>::isAliased( const Other* alias ) const noexcept
1708{
1709 return matrix_.isAliased( &unview( *alias ) );
1710}
1712//*************************************************************************************************
1713
1714
1715//*************************************************************************************************
1726template< typename MT // Type of the dense matrix
1727 , bool TF // Transpose flag
1728 , ptrdiff_t... CBAs > // Compile time band arguments
1729template< typename MT2 // Matrix type of the foreign dense band
1730 , ptrdiff_t... CBAs2 > // Compile time band arguments of the foreign dense band
1731inline bool
1732 Band<MT,TF,true,false,CBAs...>::isAliased( const Band<MT2,TF,true,false,CBAs2...>* alias ) const noexcept
1733{
1734 return matrix_.isAliased( &alias->matrix_ ) && ( band() == alias->band() );
1735}
1737//*************************************************************************************************
1738
1739
1740//*************************************************************************************************
1750template< typename MT // Type of the dense matrix
1751 , bool TF // Transpose flag
1752 , ptrdiff_t... CBAs > // Compile time band arguments
1753inline bool Band<MT,TF,true,false,CBAs...>::isAligned() const noexcept
1754{
1755 return false;
1756}
1758//*************************************************************************************************
1759
1760
1761//*************************************************************************************************
1772template< typename MT // Type of the dense matrix
1773 , bool TF // Transpose flag
1774 , ptrdiff_t... CBAs > // Compile time band arguments
1775inline bool Band<MT,TF,true,false,CBAs...>::canSMPAssign() const noexcept
1776{
1777 return ( size() > SMP_DVECASSIGN_THRESHOLD );
1778}
1780//*************************************************************************************************
1781
1782
1783//*************************************************************************************************
1795template< typename MT // Type of the dense matrix
1796 , bool TF // Transpose flag
1797 , ptrdiff_t... CBAs > // Compile time band arguments
1798template< typename VT > // Type of the right-hand side dense vector
1799inline void Band<MT,TF,true,false,CBAs...>::assign( const DenseVector<VT,TF>& rhs )
1800{
1801 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
1802
1803 const size_t ipos( prevMultiple( (*rhs).size(), 2UL ) );
1804 BLAZE_INTERNAL_ASSERT( ipos <= (*rhs).size(), "Invalid end calculation" );
1805
1806 for( size_t i=0UL; i<ipos; i+=2UL ) {
1807 matrix_(row()+i ,column()+i ) = (*rhs)[i ];
1808 matrix_(row()+i+1UL,column()+i+1UL) = (*rhs)[i+1UL];
1809 }
1810 if( ipos < (*rhs).size() ) {
1811 matrix_(row()+ipos,column()+ipos) = (*rhs)[ipos];
1812 }
1813}
1815//*************************************************************************************************
1816
1817
1818//*************************************************************************************************
1830template< typename MT // Type of the dense matrix
1831 , bool TF // Transpose flag
1832 , ptrdiff_t... CBAs > // Compile time band arguments
1833template< typename VT > // Type of the right-hand side sparse vector
1834inline void Band<MT,TF,true,false,CBAs...>::assign( const SparseVector<VT,TF>& rhs )
1835{
1836 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
1837
1838 for( ConstIterator_t<VT> element=(*rhs).begin(); element!=(*rhs).end(); ++element ) {
1839 const size_t index( element->index() );
1840 matrix_(row()+index,column()+index) = element->value();
1841 }
1842}
1844//*************************************************************************************************
1845
1846
1847//*************************************************************************************************
1859template< typename MT // Type of the dense matrix
1860 , bool TF // Transpose flag
1861 , ptrdiff_t... CBAs > // Compile time band arguments
1862template< typename VT > // Type of the right-hand side dense vector
1863inline void Band<MT,TF,true,false,CBAs...>::addAssign( const DenseVector<VT,TF>& rhs )
1864{
1865 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
1866
1867 const size_t ipos( prevMultiple( (*rhs).size(), 2UL ) );
1868 BLAZE_INTERNAL_ASSERT( ipos <= (*rhs).size(), "Invalid end calculation" );
1869
1870 for( size_t i=0UL; i<ipos; i+=2UL ) {
1871 matrix_(row()+i ,column()+i ) += (*rhs)[i ];
1872 matrix_(row()+i+1UL,column()+i+1UL) += (*rhs)[i+1UL];
1873 }
1874 if( ipos < (*rhs).size() ) {
1875 matrix_(row()+ipos,column()+ipos) += (*rhs)[ipos];
1876 }
1877}
1879//*************************************************************************************************
1880
1881
1882//*************************************************************************************************
1894template< typename MT // Type of the dense matrix
1895 , bool TF // Transpose flag
1896 , ptrdiff_t... CBAs > // Compile time band arguments
1897template< typename VT > // Type of the right-hand side sparse vector
1898inline void Band<MT,TF,true,false,CBAs...>::addAssign( const SparseVector<VT,TF>& rhs )
1899{
1900 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
1901
1902 for( ConstIterator_t<VT> element=(*rhs).begin(); element!=(*rhs).end(); ++element ) {
1903 const size_t index( element->index() );
1904 matrix_(row()+index,column()+index) += element->value();
1905 }
1906}
1908//*************************************************************************************************
1909
1910
1911//*************************************************************************************************
1923template< typename MT // Type of the dense matrix
1924 , bool TF // Transpose flag
1925 , ptrdiff_t... CBAs > // Compile time band arguments
1926template< typename VT > // Type of the right-hand side dense vector
1927inline void Band<MT,TF,true,false,CBAs...>::subAssign( const DenseVector<VT,TF>& rhs )
1928{
1929 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
1930
1931 const size_t ipos( prevMultiple( (*rhs).size(), 2UL ) );
1932 BLAZE_INTERNAL_ASSERT( ipos <= (*rhs).size(), "Invalid end calculation" );
1933
1934 for( size_t i=0UL; i<ipos; i+=2UL ) {
1935 matrix_(row()+i ,column()+i ) -= (*rhs)[i ];
1936 matrix_(row()+i+1UL,column()+i+1UL) -= (*rhs)[i+1UL];
1937 }
1938 if( ipos < (*rhs).size() ) {
1939 matrix_(row()+ipos,column()+ipos) -= (*rhs)[ipos];
1940 }
1941}
1943//*************************************************************************************************
1944
1945
1946//*************************************************************************************************
1958template< typename MT // Type of the dense matrix
1959 , bool TF // Transpose flag
1960 , ptrdiff_t... CBAs > // Compile time band arguments
1961template< typename VT > // Type of the right-hand side sparse vector
1962inline void Band<MT,TF,true,false,CBAs...>::subAssign( const SparseVector<VT,TF>& rhs )
1963{
1964 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
1965
1966 for( ConstIterator_t<VT> element=(*rhs).begin(); element!=(*rhs).end(); ++element ) {
1967 const size_t index( element->index() );
1968 matrix_(row()+index,column()+index) -= element->value();
1969 }
1970}
1972//*************************************************************************************************
1973
1974
1975//*************************************************************************************************
1987template< typename MT // Type of the dense matrix
1988 , bool TF // Transpose flag
1989 , ptrdiff_t... CBAs > // Compile time band arguments
1990template< typename VT > // Type of the right-hand side dense vector
1991inline void Band<MT,TF,true,false,CBAs...>::multAssign( const DenseVector<VT,TF>& rhs )
1992{
1993 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
1994
1995 const size_t ipos( prevMultiple( (*rhs).size(), 2UL ) );
1996 BLAZE_INTERNAL_ASSERT( ipos <= (*rhs).size(), "Invalid end calculation" );
1997
1998 for( size_t i=0UL; i<ipos; i+=2UL ) {
1999 matrix_(row()+i ,column()+i ) *= (*rhs)[i ];
2000 matrix_(row()+i+1UL,column()+i+1UL) *= (*rhs)[i+1UL];
2001 }
2002 if( ipos < (*rhs).size() ) {
2003 matrix_(row()+ipos,column()+ipos) *= (*rhs)[ipos];
2004 }
2005}
2007//*************************************************************************************************
2008
2009
2010//*************************************************************************************************
2022template< typename MT // Type of the dense matrix
2023 , bool TF // Transpose flag
2024 , ptrdiff_t... CBAs > // Compile time band arguments
2025template< typename VT > // Type of the right-hand side sparse vector
2026inline void Band<MT,TF,true,false,CBAs...>::multAssign( const SparseVector<VT,TF>& rhs )
2027{
2028 using blaze::reset;
2029
2030 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
2031
2032 size_t i( 0UL );
2033
2034 for( ConstIterator_t<VT> element=(*rhs).begin(); element!=(*rhs).end(); ++element ) {
2035 const size_t index( element->index() );
2036 for( ; i<index; ++i )
2037 reset( matrix_(row()+i,column()+i) );
2038 matrix_(row()+index,column()+index) *= element->value();
2039 ++i;
2040 }
2041
2042 for( ; i<size(); ++i ) {
2043 reset( matrix_(row()+i,column()+i) );
2044 }
2045}
2047//*************************************************************************************************
2048
2049
2050//*************************************************************************************************
2062template< typename MT // Type of the dense matrix
2063 , bool TF // Transpose flag
2064 , ptrdiff_t... CBAs > // Compile time band arguments
2065template< typename VT > // Type of the right-hand side dense vector
2066inline void Band<MT,TF,true,false,CBAs...>::divAssign( const DenseVector<VT,TF>& rhs )
2067{
2068 BLAZE_INTERNAL_ASSERT( size() == (*rhs).size(), "Invalid vector sizes" );
2069
2070 const size_t ipos( prevMultiple( (*rhs).size(), 2UL ) );
2071 BLAZE_INTERNAL_ASSERT( ipos <= (*rhs).size(), "Invalid end calculation" );
2072
2073 for( size_t i=0UL; i<ipos; i+=2UL ) {
2074 matrix_(row()+i ,column()+i ) /= (*rhs)[i ];
2075 matrix_(row()+i+1UL,column()+i+1UL) /= (*rhs)[i+1UL];
2076 }
2077 if( ipos < (*rhs).size() ) {
2078 matrix_(row()+ipos,column()+ipos) /= (*rhs)[ipos];
2079 }
2080}
2082//*************************************************************************************************
2083
2084
2085
2086
2087//=================================================================================================
2088//
2089// CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRIX MULTIPLICATIONS
2090//
2091//=================================================================================================
2092
2093//*************************************************************************************************
2101template< typename MT // Type of the dense matrix multiplication
2102 , bool TF // Transpose flag
2103 , ptrdiff_t... CBAs > // Compile time band arguments
2104class Band<MT,TF,true,true,CBAs...>
2105 : public View< DenseVector< Band<MT,TF,true,true,CBAs...>, TF > >
2106 , private BandData<CBAs...>
2107 , private Computation
2108{
2109 private:
2110 //**Type definitions****************************************************************************
2112 using DataType = BandData<CBAs...>;
2113
2115 using LeftOperand = RemoveReference_t< LeftOperand_t<MT> >;
2116
2118 using RightOperand = RemoveReference_t< RightOperand_t<MT> >;
2119 //**********************************************************************************************
2120
2121 public:
2122 //**Type definitions****************************************************************************
2124 using This = Band<MT,TF,true,true,CBAs...>;
2125
2127 using BaseType = View< DenseVector<This,TF> >;
2128
2130 using ViewedType = MT;
2131
2133 using ResultType = BandTrait_t<ResultType_t<MT>,CBAs...>;
2134
2135 using TransposeType = TransposeType_t<ResultType>;
2136 using ElementType = ElementType_t<ResultType>;
2137 using ReturnType = ReturnType_t<MT>;
2138
2140 using CompositeType = If_t< RequiresEvaluation_v<LeftOperand> ||
2141 RequiresEvaluation_v<RightOperand>
2142 , const ResultType, const Band& >;
2143
2145 using LT = If_t< IsSparseMatrix_v<LeftOperand> && IsColumnMajorMatrix_v<LeftOperand>
2146 , OppositeType_t<LeftOperand>
2147 , CompositeType_t<LeftOperand> >;
2148
2150 using RT = If_t< IsSparseMatrix_v<RightOperand> && IsRowMajorMatrix_v<RightOperand>
2151 , OppositeType_t<RightOperand>
2152 , CompositeType_t<RightOperand> >;
2153 //**********************************************************************************************
2154
2155 //**Compilation flags***************************************************************************
2157 static constexpr bool simdEnabled = false;
2158
2160 static constexpr bool smpAssignable = false;
2161
2163 static constexpr bool compileTimeArgs = DataType::compileTimeArgs;
2164 //**********************************************************************************************
2165
2166 //**Constructor*********************************************************************************
2173 template< typename... RBAs > // Runtime band arguments
2174 explicit inline Band( const MT& mmm, RBAs... args )
2175 : DataType( args... ) // Base class initialization
2176 , matrix_ ( mmm ) // The matrix multiplication containing the band
2177 {
2178 if( isChecked( args... ) ) {
2179 if( ( band() > 0L && column() >= mmm.columns() ) ||
2180 ( band() < 0L && row() >= mmm.rows() ) ) {
2181 BLAZE_THROW_INVALID_ARGUMENT( "Invalid band access index" );
2182 }
2183 }
2184 else {
2185 BLAZE_USER_ASSERT( band() <= 0L || column() < mmm.columns(), "Invalid band access index" );
2186 BLAZE_USER_ASSERT( band() >= 0L || row() < mmm.rows(), "Invalid band access index" );
2187 }
2188 }
2189 //**********************************************************************************************
2190
2191 //**Subscript operator**************************************************************************
2197 inline ReturnType operator[]( size_t index ) const {
2198 BLAZE_INTERNAL_ASSERT( index < size(), "Invalid vector access index" );
2199 return matrix_(row()+index,column()+index);
2200 }
2201 //**********************************************************************************************
2202
2203 //**At function*********************************************************************************
2210 inline ReturnType at( size_t index ) const {
2211 if( index >= size() ) {
2212 BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
2213 }
2214 return (*this)[index];
2215 }
2216 //**********************************************************************************************
2217
2218 //**Size function*******************************************************************************
2223 inline size_t size() const noexcept {
2224 return min( matrix_.rows() - row(), matrix_.columns() - column() );
2225 }
2226 //**********************************************************************************************
2227
2228 //**********************************************************************************************
2229 using DataType::band;
2230 using DataType::row;
2231 using DataType::column;
2232 //**********************************************************************************************
2233
2234 //**Operand access******************************************************************************
2239 inline const MT& operand() const noexcept {
2240 return matrix_;
2241 }
2242 //**********************************************************************************************
2243
2244 //**********************************************************************************************
2250 template< typename T >
2251 inline bool canAlias( const T* alias ) const noexcept {
2252 return matrix_.isAliased( &unview( *alias ) );
2253 }
2254 //**********************************************************************************************
2255
2256 //**********************************************************************************************
2262 template< typename T >
2263 inline bool isAliased( const T* alias ) const noexcept {
2264 return matrix_.isAliased( &unview( *alias ) );
2265 }
2266 //**********************************************************************************************
2267
2268 //**********************************************************************************************
2273 constexpr bool isAligned() const noexcept {
2274 return false;
2275 }
2276 //**********************************************************************************************
2277
2278 private:
2279 //**Member variables****************************************************************************
2280 MT matrix_;
2281 //**********************************************************************************************
2282
2283 //**Assignment to dense vectors*****************************************************************
2294 template< typename VT > // Type of the target dense vector
2295 friend inline void assign( DenseVector<VT,TF>& lhs, const Band& rhs )
2296 {
2297 using blaze::row;
2298 using blaze::column;
2299
2301
2302 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2303
2304 LT A( serial( rhs.operand().leftOperand() ) );
2305 RT B( serial( rhs.operand().rightOperand() ) );
2306
2307 const size_t n( rhs.size() );
2308 for( size_t i=0UL; i<n; ++i ) {
2309 (*lhs)[i] = row( A, rhs.row()+i, unchecked ) * column( B, rhs.column()+i, unchecked );
2310 }
2311 }
2312 //**********************************************************************************************
2313
2314 //**Assignment to sparse vectors****************************************************************
2325 template< typename VT > // Type of the target sparse vector
2326 friend inline void assign( SparseVector<VT,TF>& lhs, const Band& rhs )
2327 {
2329
2333
2334 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2335
2336 const ResultType tmp( serial( rhs ) );
2337 assign( *lhs, tmp );
2338 }
2339 //**********************************************************************************************
2340
2341 //**Addition assignment to dense vectors********************************************************
2352 template< typename VT > // Type of the target dense vector
2353 friend inline void addAssign( DenseVector<VT,TF>& lhs, const Band& rhs )
2354 {
2355 using blaze::row;
2356 using blaze::column;
2357
2359
2360 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2361
2362 LT A( serial( rhs.operand().leftOperand() ) );
2363 RT B( serial( rhs.operand().rightOperand() ) );
2364
2365 const size_t n( rhs.size() );
2366 for( size_t i=0UL; i<n; ++i ) {
2367 (*lhs)[i] += row( A, rhs.row()+i, unchecked ) * column( B, rhs.column()+i, unchecked );
2368 }
2369 }
2370 //**********************************************************************************************
2371
2372 //**Addition assignment to sparse vectors*******************************************************
2373 // No special implementation for the addition assignment to sparse vectors.
2374 //**********************************************************************************************
2375
2376 //**Subtraction assignment to dense vectors*****************************************************
2387 template< typename VT > // Type of the target dense vector
2388 friend inline void subAssign( DenseVector<VT,TF>& lhs, const Band& rhs )
2389 {
2390 using blaze::row;
2391 using blaze::column;
2392
2394
2395 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2396
2397 LT A( serial( rhs.operand().leftOperand() ) );
2398 RT B( serial( rhs.operand().rightOperand() ) );
2399
2400 const size_t n( rhs.size() );
2401 for( size_t i=0UL; i<n; ++i ) {
2402 (*lhs)[i] -= row( A, rhs.row()+i, unchecked ) * column( B, rhs.column()+i, unchecked );
2403 }
2404 }
2405 //**********************************************************************************************
2406
2407 //**Subtraction assignment to sparse vectors****************************************************
2408 // No special implementation for the subtraction assignment to sparse vectors.
2409 //**********************************************************************************************
2410
2411 //**Multiplication assignment to dense vectors**************************************************
2423 template< typename VT > // Type of the target dense vector
2424 friend inline void multAssign( DenseVector<VT,TF>& lhs, const Band& rhs )
2425 {
2426 using blaze::row;
2427 using blaze::column;
2428
2430
2431 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2432
2433 LT A( serial( rhs.operand().leftOperand() ) );
2434 RT B( serial( rhs.operand().rightOperand() ) );
2435
2436 const size_t n( rhs.size() );
2437 for( size_t i=0UL; i<n; ++i ) {
2438 (*lhs)[i] *= row( A, rhs.row()+i, unchecked ) * column( B, rhs.column()+i, unchecked );
2439 }
2440 }
2441 //**********************************************************************************************
2442
2443 //**Multiplication assignment to sparse vectors*************************************************
2444 // No special implementation for the multiplication assignment to sparse vectors.
2445 //**********************************************************************************************
2446
2447 //**Division assignment to dense vectors********************************************************
2458 template< typename VT > // Type of the target dense vector
2459 friend inline void divAssign( DenseVector<VT,TF>& lhs, const Band& rhs )
2460 {
2461 using blaze::row;
2462 using blaze::column;
2463
2465
2466 BLAZE_INTERNAL_ASSERT( (*lhs).size() == rhs.size(), "Invalid vector sizes" );
2467
2468 LT A( serial( rhs.operand().leftOperand() ) );
2469 RT B( serial( rhs.operand().rightOperand() ) );
2470
2471 const size_t n( rhs.size() );
2472 for( size_t i=0UL; i<n; ++i ) {
2473 (*lhs)[i] /= row( A, rhs.row()+i, unchecked ) * column( B, rhs.column()+i, unchecked );
2474 }
2475 }
2476 //**********************************************************************************************
2477
2478 //**Division assignment to sparse vectors*******************************************************
2479 // No special implementation for the division assignment to sparse vectors.
2480 //**********************************************************************************************
2481
2482 //**Compile time checks*************************************************************************
2487 //**********************************************************************************************
2488};
2490//*************************************************************************************************
2491
2492
2493
2494
2495//=================================================================================================
2496//
2497// CLASS TEMPLATE SPECIALIZATION FOR DENSE MATRIX REPEATER EXPRESSIONS
2498//
2499//=================================================================================================
2500
2501//*************************************************************************************************
2509template< typename MT // Type of the dense matrix
2510 , bool SO // Storage order
2511 , size_t... CRAs // Compile time repeater arguments
2512 , bool TF // Transpose flag
2513 , ptrdiff_t... CBAs > // Compile time band arguments
2514class Band< DMatRepeatExpr<MT,SO,CRAs...>, TF, true, false, CBAs... >
2515 : public View< DenseVector< Band< DMatRepeatExpr<MT,SO,CRAs...>, TF, true, false, CBAs... >, TF > >
2516 , private BandData<CBAs...>
2517 , private Computation
2518{
2519 private:
2520 //**Type definitions****************************************************************************
2522 using RE = DMatRepeatExpr<MT,SO,CRAs...>;
2523
2525 using DataType = BandData<CBAs...>;
2526 //**********************************************************************************************
2527
2528 public:
2529 //**Type definitions****************************************************************************
2531 using This = Band<RE,TF,true,false,CBAs...>;
2532
2534 using BaseType = View< DenseVector<This,TF> >;
2535
2537 using ViewedType = RE;
2538
2540 using ResultType = BandTrait_t<ResultType_t<RE>,CBAs...>;
2541
2542 using TransposeType = TransposeType_t<ResultType>;
2543 using ElementType = ElementType_t<ResultType>;
2544 using ReturnType = ReturnType_t<MT>;
2545 using CompositeType = const ResultType;
2546 //**********************************************************************************************
2547
2548 //**Compilation flags***************************************************************************
2550 static constexpr bool simdEnabled = false;
2551
2553 static constexpr bool smpAssignable = false;
2554
2556 static constexpr bool compileTimeArgs = DataType::compileTimeArgs;
2557 //**********************************************************************************************
2558
2559 //**Constructor*********************************************************************************
2566 template< typename... RBAs > // Runtime band arguments
2567 explicit inline Band( const RE& re, RBAs... args )
2568 : DataType( args... ) // Base class initialization
2569 , matrix_ ( re ) // The matrix repeater expression containing the band
2570 {
2571 if( isChecked( args... ) ) {
2572 if( ( band() > 0L && column() >= re.columns() ) ||
2573 ( band() < 0L && row() >= re.rows() ) ) {
2574 BLAZE_THROW_INVALID_ARGUMENT( "Invalid band access index" );
2575 }
2576 }
2577 else {
2578 BLAZE_USER_ASSERT( band() <= 0L || column() < re.columns(), "Invalid band access index" );
2579 BLAZE_USER_ASSERT( band() >= 0L || row() < re.rows(), "Invalid band access index" );
2580 }
2581 }
2582 //**********************************************************************************************
2583
2584 //**Subscript operator**************************************************************************
2590 inline ReturnType operator[]( size_t index ) const {
2591 BLAZE_INTERNAL_ASSERT( index < size(), "Invalid vector access index" );
2592 return matrix_(row()+index,column()+index);
2593 }
2594 //**********************************************************************************************
2595
2596 //**At function*********************************************************************************
2603 inline ReturnType at( size_t index ) const {
2604 if( index >= size() ) {
2605 BLAZE_THROW_OUT_OF_RANGE( "Invalid vector access index" );
2606 }
2607 return (*this)[index];
2608 }
2609 //**********************************************************************************************
2610
2611 //**Size function*******************************************************************************
2616 inline size_t size() const noexcept {
2617 return min( matrix_.rows() - row(), matrix_.columns() - column() );
2618 }
2619 //**********************************************************************************************
2620
2621 //**********************************************************************************************
2622 using DataType::band;
2623 using DataType::row;
2624 using DataType::column;
2625 //**********************************************************************************************
2626
2627 //**Operand access******************************************************************************
2632 inline const MT& operand() const noexcept {
2633 return matrix_;
2634 }
2635 //**********************************************************************************************
2636
2637 //**********************************************************************************************
2643 template< typename T >
2644 inline bool canAlias( const T* alias ) const noexcept {
2645 return matrix_.isAliased( &unview( *alias ) );
2646 }
2647 //**********************************************************************************************
2648
2649 //**********************************************************************************************
2655 template< typename T >
2656 inline bool isAliased( const T* alias ) const noexcept {
2657 return matrix_.isAliased( &unview( *alias ) );
2658 }
2659 //**********************************************************************************************
2660
2661 //**********************************************************************************************
2666 constexpr bool isAligned() const noexcept {
2667 return false;
2668 }
2669 //**********************************************************************************************
2670
2671 private:
2672 //**Member variables****************************************************************************
2673 RE matrix_;
2674 //**********************************************************************************************
2675};
2677//*************************************************************************************************
2678
2679} // namespace blaze
2680
2681#endif
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
constexpr const DenseIterator< Type, AF > operator+(const DenseIterator< Type, AF > &it, ptrdiff_t inc) noexcept
Addition between a DenseIterator and an integral value.
Definition: DenseIterator.h:719
Header file for the HasMutableDataAccess type trait.
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 IsLower type trait.
Header file for the IsReference type trait.
Header file for the IsRestricted type trait.
Header file for the IsRowMajorMatrix type trait.
Header file for the IsSparseMatrix type trait.
Header file for the IsSparseVector type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsTriangular type trait.
Header file for the IsUniLower type trait.
Header file for the IsUniUpper type trait.
Header file for the IsUpper type trait.
Constraint on the data type.
Header file for the prevMultiple shim.
Constraint on the data type.
Header file for the RemoveReference type 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.
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
MT::ElementType * data(DenseMatrix< MT, SO > &dm) noexcept
Low-level data access to the dense matrix elements.
Definition: DenseMatrix.h:182
auto operator+=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Addition assignment operator for the addition of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:386
auto operator*=(DenseMatrix< MT, SO > &mat, ST scalar) -> EnableIf_t< IsScalar_v< ST >, MT & >
Multiplication assignment operator for the multiplication of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:510
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
size_t spacing(const DenseMatrix< MT, SO > &dm) noexcept
Returns the spacing between the beginning of two rows/columns.
Definition: DenseMatrix.h:265
decltype(auto) 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
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition: DiagonalMatrix.h:169
#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_BE_DENSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: DenseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.h:81
#define BLAZE_CONSTRAINT_MUST_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
BLAZE_ALWAYS_INLINE constexpr auto prevMultiple(T1 value, T2 factor) noexcept
Rounds down an integral value to the previous multiple of a given factor.
Definition: PrevMultiple.h:68
constexpr bool operator>(const NegativeAccuracy< A > &lhs, const T &rhs)
Greater-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:370
constexpr bool operator==(const NegativeAccuracy< A > &lhs, const T &rhs)
Equality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:253
constexpr bool operator<(const NegativeAccuracy< A > &lhs, const T &rhs)
Less-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:332
constexpr bool operator>=(const NegativeAccuracy< A > &, const T &rhs)
Greater-or-equal-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:446
constexpr bool operator!=(const NegativeAccuracy< A > &lhs, const T &rhs)
Inequality comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:293
constexpr bool operator<=(const NegativeAccuracy< A > &, const T &rhs)
Less-or-equal-than comparison between a NegativeAccuracy object and a floating point value.
Definition: Accuracy.h:408
constexpr void clear(Matrix< MT, SO > &matrix)
Clearing the given matrix.
Definition: Matrix.h:960
MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:628
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:644
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:730
MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:562
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:692
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:660
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
auto smpDivAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP division assignment of a vector to a dense vector.
Definition: DenseVector.h:221
auto smpSubAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP subtraction assignment of a matrix to dense matrix.
Definition: DenseMatrix.h:162
auto smpAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:100
auto smpMultAssign(Vector< VT1, TF1 > &lhs, const Vector< VT2, TF2 > &rhs) -> EnableIf_t< IsDenseVector_v< VT1 > >
Default implementation of the SMP multiplication assignment of a vector to a dense vector.
Definition: DenseVector.h:192
auto smpAddAssign(Matrix< MT1, SO1 > &lhs, const Matrix< MT2, SO2 > &rhs) -> EnableIf_t< IsDenseMatrix_v< MT1 > >
Default implementation of the SMP addition assignment of a matrix to a dense matrix.
Definition: DenseMatrix.h:131
#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
#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.
Header file for the extended initializer_list functionality.
Constraint on the data type.
Header file for all forward declarations for expression class templates.
Header file for the clear shim.
Header file for the reset shim.
Header file for the thresholds for matrix/vector and matrix/matrix multiplications.
Header file for the RequiresEvaluation type trait.
Header file for basic type definitions.
Header file for the generic min algorithm.
Header file for the implementation of the Band base template.