Blaze 3.9
Sparse.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_ADAPTORS_DIAGONALMATRIX_SPARSE_H_
36#define _BLAZE_MATH_ADAPTORS_DIAGONALMATRIX_SPARSE_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <vector>
44#include <utility>
47#include <blaze/math/Aliases.h>
68#include <blaze/util/Assert.h>
73#include <blaze/util/EnableIf.h>
75#include <blaze/util/Types.h>
76
77
78namespace blaze {
79
80//=================================================================================================
81//
82// CLASS TEMPLATE SPECIALIZATION FOR SPARSE MATRICES
83//
84//=================================================================================================
85
86//*************************************************************************************************
94template< typename MT // Type of the adapted sparse matrix
95 , bool SO > // Storage order of the adapted sparse matrix
96class DiagonalMatrix<MT,SO,false>
97 : public SparseMatrix< DiagonalMatrix<MT,SO,false>, SO >
98{
99 private:
100 //**Type definitions****************************************************************************
101 using OT = OppositeType_t<MT>;
102 using TT = TransposeType_t<MT>;
103 using ET = ElementType_t<MT>;
104 //**********************************************************************************************
105
106 public:
107 //**Type definitions****************************************************************************
108 using This = DiagonalMatrix<MT,SO,false>;
109 using BaseType = SparseMatrix<This,SO>;
110 using ResultType = This;
111 using OppositeType = DiagonalMatrix<OT,!SO,false>;
112 using TransposeType = DiagonalMatrix<TT,!SO,false>;
113 using ElementType = ET;
114 using TagType = TagType_t<MT>;
115 using ReturnType = ReturnType_t<MT>;
116 using CompositeType = const This&;
117 using Reference = DiagonalProxy<MT>;
118 using ConstReference = ConstReference_t<MT>;
119 using Iterator = Iterator_t<MT>;
120 using ConstIterator = ConstIterator_t<MT>;
121 //**********************************************************************************************
122
123 //**Rebind struct definition********************************************************************
126 template< typename NewType > // Data type of the other matrix
127 struct Rebind {
129 using Other = DiagonalMatrix< typename MT::template Rebind<NewType>::Other >;
130 };
131 //**********************************************************************************************
132
133 //**Resize struct definition********************************************************************
136 template< size_t NewM // Number of rows of the other matrix
137 , size_t NewN > // Number of columns of the other matrix
138 struct Resize {
140 using Other = DiagonalMatrix< typename MT::template Resize<NewM,NewN>::Other >;
141 };
142 //**********************************************************************************************
143
144 //**Compilation flags***************************************************************************
146 static constexpr bool smpAssignable = false;
147 //**********************************************************************************************
148
149 //**Constructors********************************************************************************
152 inline DiagonalMatrix();
153 explicit inline DiagonalMatrix( size_t n );
154 inline DiagonalMatrix( size_t n, size_t nonzeros );
155 inline DiagonalMatrix( size_t n, const std::vector<size_t>& nonzeros );
156 inline DiagonalMatrix( initializer_list< initializer_list<ElementType> > list );
157
158 inline DiagonalMatrix( const DiagonalMatrix& m );
159 inline DiagonalMatrix( DiagonalMatrix&& m ) noexcept;
160
161 template< typename MT2, bool SO2 >
162 inline DiagonalMatrix( const Matrix<MT2,SO2>& m );
164 //**********************************************************************************************
165
166 //**Destructor**********************************************************************************
169 ~DiagonalMatrix() = default;
171 //**********************************************************************************************
172
173 //**Data access functions***********************************************************************
176 inline Reference operator()( size_t i, size_t j );
177 inline ConstReference operator()( size_t i, size_t j ) const;
178 inline Reference at( size_t i, size_t j );
179 inline ConstReference at( size_t i, size_t j ) const;
180 inline Iterator begin ( size_t i );
181 inline ConstIterator begin ( size_t i ) const;
182 inline ConstIterator cbegin( size_t i ) const;
183 inline Iterator end ( size_t i );
184 inline ConstIterator end ( size_t i ) const;
185 inline ConstIterator cend ( size_t i ) const;
187 //**********************************************************************************************
188
189 //**Assignment operators************************************************************************
192 inline DiagonalMatrix& operator=( initializer_list< initializer_list<ElementType> > list );
193
194 inline DiagonalMatrix& operator=( const DiagonalMatrix& rhs );
195 inline DiagonalMatrix& operator=( DiagonalMatrix&& rhs ) noexcept;
196
197 template< typename MT2, bool SO2 >
198 inline auto operator=( const Matrix<MT2,SO2>& rhs )
199 -> DisableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >;
200
201 template< typename MT2, bool SO2 >
202 inline auto operator=( const Matrix<MT2,SO2>& rhs )
203 -> EnableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >;
204
205 template< typename MT2, bool SO2 >
206 inline auto operator+=( const Matrix<MT2,SO2>& rhs )
207 -> DisableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >;
208
209 template< typename MT2, bool SO2 >
210 inline auto operator+=( const Matrix<MT2,SO2>& rhs )
211 -> EnableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >;
212
213 template< typename MT2, bool SO2 >
214 inline auto operator-=( const Matrix<MT2,SO2>& rhs )
215 -> DisableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >;
216
217 template< typename MT2, bool SO2 >
218 inline auto operator-=( const Matrix<MT2,SO2>& rhs )
219 -> EnableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >;
220
221 template< typename MT2, bool SO2 >
222 inline auto operator%=( const Matrix<MT2,SO2>& rhs ) -> DiagonalMatrix&;
224 //**********************************************************************************************
225
226 //**Utility functions***************************************************************************
229 inline size_t rows() const noexcept;
230 inline size_t columns() const noexcept;
231 inline size_t capacity() const noexcept;
232 inline size_t capacity( size_t i ) const noexcept;
233 inline size_t nonZeros() const;
234 inline size_t nonZeros( size_t i ) const;
235 inline void reset();
236 inline void reset( size_t i );
237 inline void clear();
238 inline void resize ( size_t n, bool preserve=true );
239 inline void reserve( size_t nonzeros );
240 inline void reserve( size_t i, size_t nonzeros );
241 inline void trim();
242 inline void trim( size_t i );
243 inline void shrinkToFit();
244 inline void swap( DiagonalMatrix& m ) noexcept;
246 //**********************************************************************************************
247
248 //**Insertion functions*************************************************************************
251 inline Iterator set ( size_t i, size_t j, const ElementType& value );
252 inline Iterator insert ( size_t i, size_t j, const ElementType& value );
253 inline void append ( size_t i, size_t j, const ElementType& value, bool check=false );
254 inline void finalize( size_t i );
256 //**********************************************************************************************
257
258 //**Erase functions*****************************************************************************
261 inline void erase( size_t i, size_t j );
262 inline Iterator erase( size_t i, Iterator pos );
263 inline Iterator erase( size_t i, Iterator first, Iterator last );
264
265 template< typename Pred >
266 inline void erase( Pred predicate );
267
268 template< typename Pred >
269 inline void erase( size_t i, Iterator first, Iterator last, Pred predicate );
271 //**********************************************************************************************
272
273 //**Lookup functions****************************************************************************
276 inline Iterator find ( size_t i, size_t j );
277 inline ConstIterator find ( size_t i, size_t j ) const;
278 inline Iterator lowerBound( size_t i, size_t j );
279 inline ConstIterator lowerBound( size_t i, size_t j ) const;
280 inline Iterator upperBound( size_t i, size_t j );
281 inline ConstIterator upperBound( size_t i, size_t j ) const;
283 //**********************************************************************************************
284
285 //**Numeric functions***************************************************************************
288 template< typename Other > inline DiagonalMatrix& scale( const Other& scalar );
290 //**********************************************************************************************
291
292 //**Debugging functions*************************************************************************
295 inline bool isIntact() const noexcept;
297 //**********************************************************************************************
298
299 //**Expression template evaluation functions****************************************************
302 template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
303 template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
304
305 inline bool canSMPAssign() const noexcept;
307 //**********************************************************************************************
308
309 private:
310 //**Utility functions***************************************************************************
313 inline void resetNonDiagonal();
315 //**********************************************************************************************
316
317 //**Member variables****************************************************************************
320 MT matrix_;
322 //**********************************************************************************************
323
324 //**Friend declarations*************************************************************************
325 template< typename MT2, bool SO2, bool DF2 >
326 friend MT2& derestrict( DiagonalMatrix<MT2,SO2,DF2>& m );
327 //**********************************************************************************************
328
329 //**Compile time checks*************************************************************************
344 BLAZE_STATIC_ASSERT( ( Size_v<MT,0UL> == Size_v<MT,1UL> ) );
345 //**********************************************************************************************
346};
348//*************************************************************************************************
349
350
351
352
353//=================================================================================================
354//
355// CONSTRUCTORS
356//
357//=================================================================================================
358
359//*************************************************************************************************
363template< typename MT // Type of the adapted sparse matrix
364 , bool SO > // Storage order of the adapted sparse matrix
365inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix()
366 : matrix_() // The adapted sparse matrix
367{
368 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
369}
371//*************************************************************************************************
372
373
374//*************************************************************************************************
382template< typename MT // Type of the adapted sparse matrix
383 , bool SO > // Storage order of the adapted sparse matrix
384inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n )
385 : matrix_( n, n ) // The adapted sparse matrix
386{
388
389 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
390}
392//*************************************************************************************************
393
394
395//*************************************************************************************************
404template< typename MT // Type of the adapted sparse matrix
405 , bool SO > // Storage order of the adapted sparse matrix
406inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n, size_t nonzeros )
407 : matrix_( n, n, nonzeros ) // The adapted sparse matrix
408{
410
411 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
412}
414//*************************************************************************************************
415
416
417//*************************************************************************************************
428template< typename MT // Type of the adapted sparse matrix
429 , bool SO > // Storage order of the adapted sparse matrix
430inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( size_t n, const std::vector<size_t>& nonzeros )
431 : matrix_( n, n, nonzeros ) // The adapted sparse matrix
432{
434
435 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
436}
438//*************************************************************************************************
439
440
441//*************************************************************************************************
465template< typename MT // Type of the adapted sparse matrix
466 , bool SO > // Storage order of the adapted sparse matrix
467inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( initializer_list< initializer_list<ElementType> > list )
468 : matrix_( list ) // The adapted sparse matrix
469{
470 if( !isDiagonal( matrix_ ) ) {
471 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
472 }
473
474 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
475}
477//*************************************************************************************************
478
479
480//*************************************************************************************************
486template< typename MT // Type of the adapted sparse matrix
487 , bool SO > // Storage order of the adapted sparse matrix
488inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( const DiagonalMatrix& m )
489 : matrix_( m.matrix_ ) // The adapted sparse matrix
490{
491 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
492 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
493}
495//*************************************************************************************************
496
497
498//*************************************************************************************************
504template< typename MT // Type of the adapted sparse matrix
505 , bool SO > // Storage order of the adapted sparse matrix
506inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( DiagonalMatrix&& m ) noexcept
507 : matrix_( std::move( m.matrix_ ) ) // The adapted sparse matrix
508{
509 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
510 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
511}
513//*************************************************************************************************
514
515
516//*************************************************************************************************
526template< typename MT // Type of the adapted sparse matrix
527 , bool SO > // Storage order of the adapted sparse matrix
528template< typename MT2 // Type of the foreign matrix
529 , bool SO2 > // Storage order of the foreign matrix
530inline DiagonalMatrix<MT,SO,false>::DiagonalMatrix( const Matrix<MT2,SO2>& m )
531 : matrix_( *m ) // The adapted sparse matrix
532{
533 if( !IsDiagonal_v<MT2> && !isDiagonal( matrix_ ) ) {
534 BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of diagonal matrix" );
535 }
536
537 if( !IsDiagonal_v<MT2> )
538 resetNonDiagonal();
539
540 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
541 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
542}
544//*************************************************************************************************
545
546
547
548
549//=================================================================================================
550//
551// DATA ACCESS FUNCTIONS
552//
553//=================================================================================================
554
555//*************************************************************************************************
571template< typename MT // Type of the adapted sparse matrix
572 , bool SO > // Storage order of the adapted sparse matrix
573inline typename DiagonalMatrix<MT,SO,false>::Reference
574 DiagonalMatrix<MT,SO,false>::operator()( size_t i, size_t j )
575{
576 BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
577 BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
578
579 return Reference( matrix_, i, j );
580}
582//*************************************************************************************************
583
584
585//*************************************************************************************************
601template< typename MT // Type of the adapted sparse matrix
602 , bool SO > // Storage order of the adapted sparse matrix
603inline typename DiagonalMatrix<MT,SO,false>::ConstReference
604 DiagonalMatrix<MT,SO,false>::operator()( size_t i, size_t j ) const
605{
606 BLAZE_USER_ASSERT( i<rows() , "Invalid row access index" );
607 BLAZE_USER_ASSERT( j<columns(), "Invalid column access index" );
608
609 return matrix_(i,j);
610}
612//*************************************************************************************************
613
614
615//*************************************************************************************************
632template< typename MT // Type of the adapted sparse matrix
633 , bool SO > // Storage order of the adapted sparse matrix
634inline typename DiagonalMatrix<MT,SO,false>::Reference
635 DiagonalMatrix<MT,SO,false>::at( size_t i, size_t j )
636{
637 if( i >= rows() ) {
638 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
639 }
640 if( j >= columns() ) {
641 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
642 }
643 return (*this)(i,j);
644}
646//*************************************************************************************************
647
648
649//*************************************************************************************************
666template< typename MT // Type of the adapted sparse matrix
667 , bool SO > // Storage order of the adapted sparse matrix
668inline typename DiagonalMatrix<MT,SO,false>::ConstReference
669 DiagonalMatrix<MT,SO,false>::at( size_t i, size_t j ) const
670{
671 if( i >= rows() ) {
672 BLAZE_THROW_OUT_OF_RANGE( "Invalid row access index" );
673 }
674 if( j >= columns() ) {
675 BLAZE_THROW_OUT_OF_RANGE( "Invalid column access index" );
676 }
677 return (*this)(i,j);
678}
680//*************************************************************************************************
681
682
683//*************************************************************************************************
695template< typename MT // Type of the adapted sparse matrix
696 , bool SO > // Storage order of the adapted sparse matrix
697inline typename DiagonalMatrix<MT,SO,false>::Iterator
699{
700 return matrix_.begin(i);
701}
703//*************************************************************************************************
704
705
706//*************************************************************************************************
718template< typename MT // Type of the adapted sparse matrix
719 , bool SO > // Storage order of the adapted sparse matrix
720inline typename DiagonalMatrix<MT,SO,false>::ConstIterator
721 DiagonalMatrix<MT,SO,false>::begin( size_t i ) const
722{
723 return matrix_.begin(i);
724}
726//*************************************************************************************************
727
728
729//*************************************************************************************************
741template< typename MT // Type of the adapted sparse matrix
742 , bool SO > // Storage order of the adapted sparse matrix
743inline typename DiagonalMatrix<MT,SO,false>::ConstIterator
745{
746 return matrix_.cbegin(i);
747}
749//*************************************************************************************************
750
751
752//*************************************************************************************************
764template< typename MT // Type of the adapted sparse matrix
765 , bool SO > // Storage order of the adapted sparse matrix
766inline typename DiagonalMatrix<MT,SO,false>::Iterator
768{
769 return matrix_.end(i);
770}
772//*************************************************************************************************
773
774
775//*************************************************************************************************
787template< typename MT // Type of the adapted sparse matrix
788 , bool SO > // Storage order of the adapted sparse matrix
789inline typename DiagonalMatrix<MT,SO,false>::ConstIterator
790 DiagonalMatrix<MT,SO,false>::end( size_t i ) const
791{
792 return matrix_.end(i);
793}
795//*************************************************************************************************
796
797
798//*************************************************************************************************
810template< typename MT // Type of the adapted sparse matrix
811 , bool SO > // Storage order of the adapted sparse matrix
812inline typename DiagonalMatrix<MT,SO,false>::ConstIterator
813 DiagonalMatrix<MT,SO,false>::cend( size_t i ) const
814{
815 return matrix_.cend(i);
816}
818//*************************************************************************************************
819
820
821
822
823//=================================================================================================
824//
825// ASSIGNMENT OPERATORS
826//
827//=================================================================================================
828
829//*************************************************************************************************
854template< typename MT // Type of the adapted sparse matrix
855 , bool SO > // Storage order of the adapted sparse matrix
856inline DiagonalMatrix<MT,SO,false>&
857 DiagonalMatrix<MT,SO,false>::operator=( initializer_list< initializer_list<ElementType> > list )
858{
859 const InitializerMatrix<ElementType> tmp( list, list.size() );
860
861 if( !isDiagonal( tmp ) ) {
862 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
863 }
864
865 matrix_ = list;
866
867 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
868 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
869
870 return *this;
871}
873//*************************************************************************************************
874
875
876//*************************************************************************************************
886template< typename MT // Type of the adapted sparse matrix
887 , bool SO > // Storage order of the adapted sparse matrix
888inline DiagonalMatrix<MT,SO,false>&
889 DiagonalMatrix<MT,SO,false>::operator=( const DiagonalMatrix& rhs )
890{
891 matrix_ = rhs.matrix_;
892
893 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
894 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
895
896 return *this;
897}
899//*************************************************************************************************
900
901
902//*************************************************************************************************
909template< typename MT // Type of the adapted sparse matrix
910 , bool SO > // Storage order of the adapted sparse matrix
911inline DiagonalMatrix<MT,SO,false>&
912 DiagonalMatrix<MT,SO,false>::operator=( DiagonalMatrix&& rhs ) noexcept
913{
914 matrix_ = std::move( rhs.matrix_ );
915
916 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
917 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
918
919 return *this;
920}
922//*************************************************************************************************
923
924
925//*************************************************************************************************
938template< typename MT // Type of the adapted sparse matrix
939 , bool SO > // Storage order of the adapted sparse matrix
940template< typename MT2 // Type of the right-hand side matrix
941 , bool SO2 > // Storage order of the right-hand side matrix
942inline auto DiagonalMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
943 -> DisableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >
944{
945 if( !IsDiagonal_v<MT2> && !isDiagonal( *rhs ) ) {
946 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
947 }
948
949 matrix_ = decldiag( *rhs );
950
951 if( !IsDiagonal_v<MT2> )
952 resetNonDiagonal();
953
954 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
955 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
956
957 return *this;
958}
960//*************************************************************************************************
961
962
963//*************************************************************************************************
976template< typename MT // Type of the adapted sparse matrix
977 , bool SO > // Storage order of the adapted sparse matrix
978template< typename MT2 // Type of the right-hand side matrix
979 , bool SO2 > // Storage order of the right-hand side matrix
980inline auto DiagonalMatrix<MT,SO,false>::operator=( const Matrix<MT2,SO2>& rhs )
981 -> EnableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >
982{
983 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
984 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
985 }
986
987 if( IsDiagonal_v<MT2> ) {
988 matrix_ = *rhs;
989 }
990 else {
991 MT tmp( *rhs );
992
993 if( !isDiagonal( tmp ) ) {
994 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
995 }
996
997 matrix_ = std::move( tmp );
998 }
999
1000 if( !IsDiagonal_v<MT2> )
1001 resetNonDiagonal();
1002
1003 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1004 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1005
1006 return *this;
1007}
1009//*************************************************************************************************
1010
1011
1012//*************************************************************************************************
1025template< typename MT // Type of the adapted sparse matrix
1026 , bool SO > // Storage order of the adapted sparse matrix
1027template< typename MT2 // Type of the right-hand side matrix
1028 , bool SO2 > // Storage order of the right-hand side matrix
1029inline auto DiagonalMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1030 -> DisableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >
1031{
1032 if( !IsDiagonal_v<MT2> && !isDiagonal( *rhs ) ) {
1033 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1034 }
1035
1036 matrix_ += decldiag( *rhs );
1037
1038 if( !IsDiagonal_v<MT2> )
1039 resetNonDiagonal();
1040
1041 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1042 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1043
1044 return *this;
1045}
1047//*************************************************************************************************
1048
1049
1050//*************************************************************************************************
1063template< typename MT // Type of the adapted sparse matrix
1064 , bool SO > // Storage order of the adapted sparse matrix
1065template< typename MT2 // Type of the right-hand side matrix
1066 , bool SO2 > // Storage order of the right-hand side matrix
1067inline auto DiagonalMatrix<MT,SO,false>::operator+=( const Matrix<MT2,SO2>& rhs )
1068 -> EnableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >
1069{
1070 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
1071 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1072 }
1073
1074 if( IsDiagonal_v<MT2> ) {
1075 matrix_ += *rhs;
1076 }
1077 else {
1078 const ResultType_t<MT2> tmp( *rhs );
1079
1080 if( !isDiagonal( tmp ) ) {
1081 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1082 }
1083
1084 matrix_ += decldiag( tmp );
1085 }
1086
1087 if( !IsDiagonal_v<MT2> )
1088 resetNonDiagonal();
1089
1090 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1091 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1092
1093 return *this;
1094}
1096//*************************************************************************************************
1097
1098
1099//*************************************************************************************************
1112template< typename MT // Type of the adapted sparse matrix
1113 , bool SO > // Storage order of the adapted sparse matrix
1114template< typename MT2 // Type of the right-hand side matrix
1115 , bool SO2 > // Storage order of the right-hand side matrix
1116inline auto DiagonalMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1117 -> DisableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >
1118{
1119 if( !IsDiagonal_v<MT2> && !isDiagonal( *rhs ) ) {
1120 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1121 }
1122
1123 matrix_ -= decldiag( *rhs );
1124
1125 if( !IsDiagonal_v<MT2> )
1126 resetNonDiagonal();
1127
1128 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1129 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1130
1131 return *this;
1132}
1134//*************************************************************************************************
1135
1136
1137//*************************************************************************************************
1150template< typename MT // Type of the adapted sparse matrix
1151 , bool SO > // Storage order of the adapted sparse matrix
1152template< typename MT2 // Type of the right-hand side matrix
1153 , bool SO2 > // Storage order of the right-hand side matrix
1154inline auto DiagonalMatrix<MT,SO,false>::operator-=( const Matrix<MT2,SO2>& rhs )
1155 -> EnableIf_t< IsComputation_v<MT2>, DiagonalMatrix& >
1156{
1157 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
1158 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1159 }
1160
1161 if( IsDiagonal_v<MT2> ) {
1162 matrix_ -= *rhs;
1163 }
1164 else {
1165 const ResultType_t<MT2> tmp( *rhs );
1166
1167 if( !isDiagonal( tmp ) ) {
1168 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1169 }
1170
1171 matrix_ -= decldiag( tmp );
1172 }
1173
1174 if( !IsDiagonal_v<MT2> )
1175 resetNonDiagonal();
1176
1177 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1178 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1179
1180 return *this;
1181}
1183//*************************************************************************************************
1184
1185
1186//*************************************************************************************************
1197template< typename MT // Type of the adapted sparse matrix
1198 , bool SO > // Storage order of the adapted sparse matrix
1199template< typename MT2 // Type of the right-hand side matrix
1200 , bool SO2 > // Storage order of the right-hand side matrix
1201inline auto DiagonalMatrix<MT,SO,false>::operator%=( const Matrix<MT2,SO2>& rhs )
1202 -> DiagonalMatrix&
1203{
1204 if( !IsSquare_v<MT2> && !isSquare( *rhs ) ) {
1205 BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment to diagonal matrix" );
1206 }
1207
1208 matrix_ %= *rhs;
1209
1210 if( !IsDiagonal_v<MT2> )
1211 resetNonDiagonal();
1212
1213 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1214 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1215
1216 return *this;
1217}
1219//*************************************************************************************************
1220
1221
1222
1223
1224//=================================================================================================
1225//
1226// UTILITY FUNCTIONS
1227//
1228//=================================================================================================
1229
1230//*************************************************************************************************
1236template< typename MT // Type of the adapted sparse matrix
1237 , bool SO > // Storage order of the adapted sparse matrix
1238inline size_t DiagonalMatrix<MT,SO,false>::rows() const noexcept
1239{
1240 return matrix_.rows();
1241}
1243//*************************************************************************************************
1244
1245
1246//*************************************************************************************************
1252template< typename MT // Type of the adapted sparse matrix
1253 , bool SO > // Storage order of the adapted sparse matrix
1254inline size_t DiagonalMatrix<MT,SO,false>::columns() const noexcept
1255{
1256 return matrix_.columns();
1257}
1259//*************************************************************************************************
1260
1261
1262//*************************************************************************************************
1268template< typename MT // Type of the adapted sparse matrix
1269 , bool SO > // Storage order of the adapted sparse matrix
1270inline size_t DiagonalMatrix<MT,SO,false>::capacity() const noexcept
1271{
1272 return matrix_.capacity();
1273}
1275//*************************************************************************************************
1276
1277
1278//*************************************************************************************************
1290template< typename MT // Type of the adapted sparse matrix
1291 , bool SO > // Storage order of the adapted sparse matrix
1292inline size_t DiagonalMatrix<MT,SO,false>::capacity( size_t i ) const noexcept
1293{
1294 return matrix_.capacity(i);
1295}
1297//*************************************************************************************************
1298
1299
1300//*************************************************************************************************
1306template< typename MT // Type of the adapted sparse matrix
1307 , bool SO > // Storage order of the adapted sparse matrix
1308inline size_t DiagonalMatrix<MT,SO,false>::nonZeros() const
1309{
1310 return matrix_.nonZeros();
1311}
1313//*************************************************************************************************
1314
1315
1316//*************************************************************************************************
1328template< typename MT // Type of the adapted sparse matrix
1329 , bool SO > // Storage order of the adapted sparse matrix
1330inline size_t DiagonalMatrix<MT,SO,false>::nonZeros( size_t i ) const
1331{
1332 return matrix_.nonZeros(i);
1333}
1335//*************************************************************************************************
1336
1337
1338//*************************************************************************************************
1344template< typename MT // Type of the adapted sparse matrix
1345 , bool SO > // Storage order of the adapted sparse matrix
1347{
1348 matrix_.reset();
1349}
1351//*************************************************************************************************
1352
1353
1354//*************************************************************************************************
1367template< typename MT // Type of the adapted sparse matrix
1368 , bool SO > // Storage order of the adapted sparse matrix
1369inline void DiagonalMatrix<MT,SO,false>::reset( size_t i )
1370{
1371 matrix_.reset( i );
1372}
1374//*************************************************************************************************
1375
1376
1377//*************************************************************************************************
1385template< typename MT // Type of the adapted sparse matrix
1386 , bool SO > // Storage order of the adapted sparse matrix
1388{
1389 matrix_.clear();
1390
1391 BLAZE_INTERNAL_ASSERT( matrix_.rows() == 0UL, "Invalid number of rows" );
1392 BLAZE_INTERNAL_ASSERT( matrix_.columns() == 0UL, "Invalid number of columns" );
1393}
1395//*************************************************************************************************
1396
1397
1398//*************************************************************************************************
1413template< typename MT // Type of the adapted sparse matrix
1414 , bool SO > // Storage order of the adapted sparse matrix
1415void DiagonalMatrix<MT,SO,false>::resize( size_t n, bool preserve )
1416{
1418
1419 BLAZE_INTERNAL_ASSERT( isSquare( matrix_ ), "Non-square diagonal matrix detected" );
1420
1421 matrix_.resize( n, n, preserve );
1422}
1424//*************************************************************************************************
1425
1426
1427//*************************************************************************************************
1438template< typename MT // Type of the adapted sparse matrix
1439 , bool SO > // Storage order of the adapted sparse matrix
1440inline void DiagonalMatrix<MT,SO,false>::reserve( size_t nonzeros )
1441{
1442 matrix_.reserve( nonzeros );
1443}
1445//*************************************************************************************************
1446
1447
1448//*************************************************************************************************
1462template< typename MT // Type of the adapted sparse matrix
1463 , bool SO > // Storage order of the adapted sparse matrix
1464inline void DiagonalMatrix<MT,SO,false>::reserve( size_t i, size_t nonzeros )
1465{
1466 matrix_.reserve( i, nonzeros );
1467}
1469//*************************************************************************************************
1470
1471
1472//*************************************************************************************************
1483template< typename MT // Type of the adapted sparse matrix
1484 , bool SO > // Storage order of the adapted sparse matrix
1485inline void DiagonalMatrix<MT,SO,false>::trim()
1486{
1487 matrix_.trim();
1488}
1490//*************************************************************************************************
1491
1492
1493//*************************************************************************************************
1505template< typename MT // Type of the adapted sparse matrix
1506 , bool SO > // Storage order of the adapted sparse matrix
1507inline void DiagonalMatrix<MT,SO,false>::trim( size_t i )
1508{
1509 matrix_.trim( i );
1510}
1512//*************************************************************************************************
1513
1514
1515//*************************************************************************************************
1525template< typename MT // Type of the adapted sparse matrix
1526 , bool SO > // Storage order of the adapted sparse matrix
1528{
1529 matrix_.shrinkToFit();
1530}
1532//*************************************************************************************************
1533
1534
1535//*************************************************************************************************
1542template< typename MT // Type of the adapted sparse matrix
1543 , bool SO > // Storage order of the adapted sparse matrix
1544inline void DiagonalMatrix<MT,SO,false>::swap( DiagonalMatrix& m ) noexcept
1545{
1546 using std::swap;
1547
1548 swap( matrix_, m.matrix_ );
1549}
1551//*************************************************************************************************
1552
1553
1554//*************************************************************************************************
1560template< typename MT // Type of the adapted sparse matrix
1561 , bool SO > // Storage order of the adapted sparse matrix
1562inline void DiagonalMatrix<MT,SO,false>::resetNonDiagonal()
1563{
1564 using blaze::erase;
1565
1566 for( size_t i=0UL; i<rows(); ++i ) {
1567 erase( matrix_, i, matrix_.begin( i ), matrix_.lowerBound( i, i ) );
1568 erase( matrix_, i, matrix_.upperBound( i, i ), matrix_.end( i ) );
1569 }
1570}
1572//*************************************************************************************************
1573
1574
1575
1576
1577//=================================================================================================
1578//
1579// INSERTION FUNCTIONS
1580//
1581//=================================================================================================
1582
1583//*************************************************************************************************
1599template< typename MT // Type of the adapted sparse matrix
1600 , bool SO > // Storage order of the adapted sparse matrix
1601inline typename DiagonalMatrix<MT,SO,false>::Iterator
1602 DiagonalMatrix<MT,SO,false>::set( size_t i, size_t j, const ElementType& value )
1603{
1604 if( i < j ) {
1605 BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1606 }
1607
1608 return matrix_.set( i, j, value );
1609}
1611//*************************************************************************************************
1612
1613
1614//*************************************************************************************************
1631template< typename MT // Type of the adapted sparse matrix
1632 , bool SO > // Storage order of the adapted sparse matrix
1633inline typename DiagonalMatrix<MT,SO,false>::Iterator
1634 DiagonalMatrix<MT,SO,false>::insert( size_t i, size_t j, const ElementType& value )
1635{
1636 if( i < j ) {
1637 BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1638 }
1639
1640 return matrix_.insert( i, j, value );
1641}
1643//*************************************************************************************************
1644
1645
1646//*************************************************************************************************
1696template< typename MT // Type of the adapted sparse matrix
1697 , bool SO > // Storage order of the adapted sparse matrix
1698inline void DiagonalMatrix<MT,SO,false>::append( size_t i, size_t j, const ElementType& value, bool check )
1699{
1700 if( i < j ) {
1701 BLAZE_THROW_INVALID_ARGUMENT( "Invalid access to upper matrix element" );
1702 }
1703
1704 matrix_.append( i, j, value, check );
1705}
1707//*************************************************************************************************
1708
1709
1710//*************************************************************************************************
1724template< typename MT // Type of the adapted sparse matrix
1725 , bool SO > // Storage order of the adapted sparse matrix
1726inline void DiagonalMatrix<MT,SO,false>::finalize( size_t i )
1727{
1728 matrix_.finalize( i );
1729}
1731//*************************************************************************************************
1732
1733
1734
1735
1736//=================================================================================================
1737//
1738// ERASE FUNCTIONS
1739//
1740//=================================================================================================
1741
1742//*************************************************************************************************
1752template< typename MT // Type of the adapted sparse matrix
1753 , bool SO > // Storage order of the adapted sparse matrix
1754inline void DiagonalMatrix<MT,SO,false>::erase( size_t i, size_t j )
1755{
1756 using blaze::erase;
1757
1758 erase( matrix_, i, j );
1759}
1761//*************************************************************************************************
1762
1763
1764//*************************************************************************************************
1776template< typename MT // Type of the adapted sparse matrix
1777 , bool SO > // Storage order of the adapted sparse matrix
1778inline typename DiagonalMatrix<MT,SO,false>::Iterator
1779 DiagonalMatrix<MT,SO,false>::erase( size_t i, Iterator pos )
1780{
1781 using blaze::erase;
1782
1783 return erase( matrix_, i, pos );
1784}
1786//*************************************************************************************************
1787
1788
1789//*************************************************************************************************
1803template< typename MT // Type of the adapted sparse matrix
1804 , bool SO > // Storage order of the adapted sparse matrix
1805inline typename DiagonalMatrix<MT,SO,false>::Iterator
1806 DiagonalMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last )
1807{
1808 using blaze::erase;
1809
1810 return erase( matrix_, i, first, last );
1811}
1813//*************************************************************************************************
1814
1815
1816//*************************************************************************************************
1838template< typename MT // Type of the adapted sparse matrix
1839 , bool SO > // Storage order of the adapted sparse matrix
1840template< typename Pred > // Type of the unary predicate
1841inline void DiagonalMatrix<MT,SO,false>::erase( Pred predicate )
1842{
1843 using blaze::erase;
1844
1845 erase( matrix_, predicate );
1846
1847 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1848}
1850//*************************************************************************************************
1851
1852
1853//*************************************************************************************************
1881template< typename MT // Type of the adapted sparse matrix
1882 , bool SO > // Storage order of the adapted sparse matrix
1883template< typename Pred > // Type of the unary predicate
1884inline void DiagonalMatrix<MT,SO,false>::erase( size_t i, Iterator first, Iterator last, Pred predicate )
1885{
1886 using blaze::erase;
1887
1888 erase( matrix_, i, first, last, predicate );
1889
1890 BLAZE_INTERNAL_ASSERT( isIntact(), "Broken invariant detected" );
1891}
1893//*************************************************************************************************
1894
1895
1896
1897
1898//=================================================================================================
1899//
1900// LOOKUP FUNCTIONS
1901//
1902//=================================================================================================
1903
1904//*************************************************************************************************
1920template< typename MT // Type of the adapted sparse matrix
1921 , bool SO > // Storage order of the adapted sparse matrix
1922inline typename DiagonalMatrix<MT,SO,false>::Iterator
1923 DiagonalMatrix<MT,SO,false>::find( size_t i, size_t j )
1924{
1925 return matrix_.find( i, j );
1926}
1928//*************************************************************************************************
1929
1930
1931//*************************************************************************************************
1947template< typename MT // Type of the adapted sparse matrix
1948 , bool SO > // Storage order of the adapted sparse matrix
1949inline typename DiagonalMatrix<MT,SO,false>::ConstIterator
1950 DiagonalMatrix<MT,SO,false>::find( size_t i, size_t j ) const
1951{
1952 return matrix_.find( i, j );
1953}
1955//*************************************************************************************************
1956
1957
1958//*************************************************************************************************
1974template< typename MT // Type of the adapted sparse matrix
1975 , bool SO > // Storage order of the adapted sparse matrix
1976inline typename DiagonalMatrix<MT,SO,false>::Iterator
1977 DiagonalMatrix<MT,SO,false>::lowerBound( size_t i, size_t j )
1978{
1979 return matrix_.lowerBound( i, j );
1980}
1982//*************************************************************************************************
1983
1984
1985//*************************************************************************************************
2001template< typename MT // Type of the adapted sparse matrix
2002 , bool SO > // Storage order of the adapted sparse matrix
2003inline typename DiagonalMatrix<MT,SO,false>::ConstIterator
2004 DiagonalMatrix<MT,SO,false>::lowerBound( size_t i, size_t j ) const
2005{
2006 return matrix_.lowerBound( i, j );
2007}
2009//*************************************************************************************************
2010
2011
2012//*************************************************************************************************
2028template< typename MT // Type of the adapted sparse matrix
2029 , bool SO > // Storage order of the adapted sparse matrix
2030inline typename DiagonalMatrix<MT,SO,false>::Iterator
2031 DiagonalMatrix<MT,SO,false>::upperBound( size_t i, size_t j )
2032{
2033 return matrix_.upperBound( i, j );
2034}
2036//*************************************************************************************************
2037
2038
2039//*************************************************************************************************
2055template< typename MT // Type of the adapted sparse matrix
2056 , bool SO > // Storage order of the adapted sparse matrix
2057inline typename DiagonalMatrix<MT,SO,false>::ConstIterator
2058 DiagonalMatrix<MT,SO,false>::upperBound( size_t i, size_t j ) const
2059{
2060 return matrix_.upperBound( i, j );
2061}
2063//*************************************************************************************************
2064
2065
2066
2067
2068//=================================================================================================
2069//
2070// NUMERIC FUNCTIONS
2071//
2072//=================================================================================================
2073
2074//*************************************************************************************************
2092template< typename MT // Type of the adapted sparse matrix
2093 , bool SO > // Storage order of the adapted sparse matrix
2094template< typename Other > // Data type of the scalar value
2095inline DiagonalMatrix<MT,SO,false>&
2096 DiagonalMatrix<MT,SO,false>::scale( const Other& scalar )
2097{
2098 matrix_.scale( scalar );
2099 return *this;
2100}
2102//*************************************************************************************************
2103
2104
2105
2106
2107//=================================================================================================
2108//
2109// DEBUGGING FUNCTIONS
2110//
2111//=================================================================================================
2112
2113//*************************************************************************************************
2123template< typename MT // Type of the adapted sparse matrix
2124 , bool SO > // Storage order of the adapted sparse matrix
2125inline bool DiagonalMatrix<MT,SO,false>::isIntact() const noexcept
2126{
2127 using blaze::isIntact;
2128
2129 return ( isIntact( matrix_ ) && isDiagonal( matrix_ ) );
2130}
2132//*************************************************************************************************
2133
2134
2135
2136
2137//=================================================================================================
2138//
2139// EXPRESSION TEMPLATE EVALUATION FUNCTIONS
2140//
2141//=================================================================================================
2142
2143//*************************************************************************************************
2154template< typename MT // Type of the adapted sparse matrix
2155 , bool SO > // Storage order of the adapted sparse matrix
2156template< typename Other > // Data type of the foreign expression
2157inline bool DiagonalMatrix<MT,SO,false>::canAlias( const Other* alias ) const noexcept
2158{
2159 return matrix_.canAlias( alias );
2160}
2162//*************************************************************************************************
2163
2164
2165//*************************************************************************************************
2176template< typename MT // Type of the adapted sparse matrix
2177 , bool SO > // Storage order of the adapted sparse matrix
2178template< typename Other > // Data type of the foreign expression
2179inline bool DiagonalMatrix<MT,SO,false>::isAliased( const Other* alias ) const noexcept
2180{
2181 return matrix_.isAliased( alias );
2182}
2184//*************************************************************************************************
2185
2186
2187//*************************************************************************************************
2198template< typename MT // Type of the adapted sparse matrix
2199 , bool SO > // Storage order of the adapted sparse matrix
2200inline bool DiagonalMatrix<MT,SO,false>::canSMPAssign() const noexcept
2201{
2202 return matrix_.canSMPAssign();
2203}
2205//*************************************************************************************************
2206
2207} // namespace blaze
2208
2209#endif
Header file for auxiliary alias declarations.
Header file for run time assertion macros.
Constraint on the data type.
Header file for the DiagonalProxy class.
Header file for the EnableIf class template.
Constraint on the data type.
Header file for the IsComputation type trait class.
Header file for the isDefault shim.
Header file for the IsDiagonal type trait.
Header file for the IsSquare type trait.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Compile time assertion.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the implementation of the base template of the DiagonalMatrix.
Initializer list type of the Blaze library.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the implementation of a matrix representation of an initializer list.
Header file for the SparseMatrix base class.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.
Definition: Volatile.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.
Definition: Pointer.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.
Definition: Const.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.
Definition: Reference.h:79
decltype(auto) decldiag(const DenseMatrix< MT, SO > &dm)
Declares the given dense matrix expression dm as diagonal.
Definition: DMatDeclDiagExpr.h:978
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 & >
Subtraction assignment operator for the subtraction of a dense matrix and a scalar value ( ).
Definition: DenseMatrix.h:448
bool isDiagonal(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is diagonal.
Definition: DenseMatrix.h:2456
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:207
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:225
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VIEW_TYPE(T)
Constraint on the data type.
Definition: View.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_HERMITIAN_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Hermitian.h:79
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UPPER_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Upper.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_COMPUTATION_TYPE(T)
Constraint on the data type.
Definition: Computation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_SPARSE_MATRIX_TYPE(T)
Constraint on the data type.
Definition: SparseMatrix.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_LOWER_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_BE_RESIZABLE_TYPE(T)
Constraint on the data type.
Definition: Resizable.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_BE_TRANSFORMATION_TYPE(T)
Constraint on the data type.
Definition: Transformation.h:81
#define BLAZE_CONSTRAINT_MUST_BE_MATRIX_WITH_STORAGE_ORDER(T, SO)
Constraint on the data type.
Definition: StorageOrder.h:63
constexpr ptrdiff_t Size_v
Auxiliary variable template for the Size type trait.
Definition: Size.h:176
constexpr void clear(Matrix< MT, SO > &matrix)
Clearing the given matrix.
Definition: Matrix.h:960
MT::ConstIterator cend(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:628
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:644
size_t nonZeros(const Matrix< MT, SO > &matrix)
Returns the total number of non-zero elements in the matrix.
Definition: Matrix.h:730
MT::ConstIterator cbegin(const Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:562
size_t capacity(const Matrix< MT, SO > &matrix) noexcept
Returns the maximum capacity of the matrix.
Definition: Matrix.h:692
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:660
void resize(Matrix< MT, SO > &matrix, size_t rows, size_t columns, bool preserve=true)
Changing the size of the matrix.
Definition: Matrix.h:1108
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:584
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:518
void shrinkToFit(Matrix< MT, SO > &matrix)
Requesting the removal of unused capacity.
Definition: Matrix.h:1169
bool isSquare(const Matrix< MT, SO > &matrix) noexcept
Checks if the given matrix is a square matrix.
Definition: Matrix.h:1383
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.
Definition: Assert.h:117
BLAZE_ALWAYS_INLINE const EnableIf_t< IsIntegral_v< T > &&HasSize_v< T, 1UL >, If_t< IsSigned_v< T >, SIMDint8, SIMDuint8 > > set(T value) noexcept
Sets all values in the vector to the given 1-byte integral value.
Definition: Set.h:75
MT::Iterator upperBound(SparseMatrix< MT, SO > &sm, size_t i, size_t j)
Returns an iterator to the first index greater than the given index.
Definition: SparseMatrix.h:244
MT::Iterator lowerBound(SparseMatrix< MT, SO > &sm, size_t i, size_t j)
Returns an iterator to the first index not less than the given index.
Definition: SparseMatrix.h:194
MT::Iterator find(SparseMatrix< MT, SO > &sm, size_t i, size_t j)
Searches for a specific matrix element.
Definition: SparseMatrix.h:144
#define BLAZE_STATIC_ASSERT(expr)
Compile time assertion macro.
Definition: StaticAssert.h:112
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.
Definition: Exception.h:331
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
Header file for the exception macros of the math module.
Header file for the extended initializer_list functionality.
Constraints on the storage order of matrix types.
Header file for the Size type trait.
Header file for utility functions for sparse matrices.
Header file for basic type definitions.