Blaze 3.9
UniUpperMatrix.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_ADAPTORS_UNIUPPERMATRIX_H_
36#define _BLAZE_MATH_ADAPTORS_UNIUPPERMATRIX_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
54#include <blaze/math/Forward.h>
98#include <blaze/util/Assert.h>
99#include <blaze/util/EnableIf.h>
103
104
105namespace blaze {
106
107//=================================================================================================
108//
109// UNIUPPERMATRIX OPERATORS
110//
111//=================================================================================================
112
113//*************************************************************************************************
116template< RelaxationFlag RF, typename MT, bool SO, bool DF >
117bool isDefault( const UniUpperMatrix<MT,SO,DF>& m );
118
119template< typename MT, bool SO, bool DF >
120bool isIntact( const UniUpperMatrix<MT,SO,DF>& m );
121
122template< typename MT, bool SO, bool DF >
123void swap( UniUpperMatrix<MT,SO,DF>& a, UniUpperMatrix<MT,SO,DF>& b ) noexcept;
125//*************************************************************************************************
126
127
128//*************************************************************************************************
155template< RelaxationFlag RF // Relaxation flag
156 , typename MT // Type of the adapted matrix
157 , bool SO // Storage order of the adapted matrix
158 , bool DF > // Density flag
159inline bool isDefault( const UniUpperMatrix<MT,SO,DF>& m )
160{
161 if( Size_v<MT,0UL> == DefaultSize_v )
162 return m.rows() == 0UL;
163 else return isIdentity<RF>( m );
164}
165//*************************************************************************************************
166
167
168//*************************************************************************************************
189template< typename MT // Type of the adapted matrix
190 , bool SO // Storage order of the adapted matrix
191 , bool DF > // Density flag
192inline bool isIntact( const UniUpperMatrix<MT,SO,DF>& m )
193{
194 return m.isIntact();
195}
196//*************************************************************************************************
197
198
199//*************************************************************************************************
207template< typename MT // Type of the adapted matrix
208 , bool SO // Storage order of the adapted matrix
209 , bool DF > // Density flag
210inline void swap( UniUpperMatrix<MT,SO,DF>& a, UniUpperMatrix<MT,SO,DF>& b ) noexcept
211{
212 a.swap( b );
213}
214//*************************************************************************************************
215
216
217//*************************************************************************************************
240template< InversionFlag IF // Inversion algorithm
241 , typename MT // Type of the dense matrix
242 , bool SO > // Storage order of the dense matrix
243inline void invert( UniUpperMatrix<MT,SO,true>& m )
244{
246
247 if( IF == asLower || IF == asUniLower ) {
248 BLAZE_INTERNAL_ASSERT( isIdentity( m ), "Violation of preconditions detected" );
249 return;
250 }
251
252 constexpr InversionFlag flag( ( IF == byLU || IF == asGeneral || IF == asUpper || IF == asUniUpper)
253 ? ( asUniUpper )
254 : ( asDiagonal ) );
255
256 invert<flag>( derestrict( m ) );
257
258 BLAZE_INTERNAL_ASSERT( isIntact( m ), "Broken invariant detected" );
259}
261//*************************************************************************************************
262
263
264//*************************************************************************************************
283template< typename MT1, bool SO1, typename MT2, typename MT3, typename MT4, bool SO2 >
284inline void lu( const UniUpperMatrix<MT1,SO1,true>& A, DenseMatrix<MT2,SO1>& L,
285 DenseMatrix<MT3,SO1>& U, Matrix<MT4,SO2>& P )
286{
288
293
298
299 using ET2 = ElementType_t<MT2>;
300 using ET4 = ElementType_t<MT4>;
301
302 const size_t n( (*A).rows() );
303
304 decltype(auto) L2( derestrict( *L ) );
305
306 (*U) = A;
307
308 resize( *L, n, n );
309 reset( L2 );
310
311 resize( *P, n, n );
312 reset( *P );
313
314 for( size_t i=0UL; i<n; ++i ) {
315 L2(i,i) = ET2(1);
316 (*P)(i,i) = ET4(1);
317 }
318}
320//*************************************************************************************************
321
322
323//*************************************************************************************************
339template< typename MT // Type of the adapted matrix
340 , bool SO // Storage order of the adapted matrix
341 , bool DF // Density flag
342 , typename ET > // Type of the element
343inline bool trySet( const UniUpperMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
344{
345 BLAZE_INTERNAL_ASSERT( i < (*mat).rows(), "Invalid row access index" );
346 BLAZE_INTERNAL_ASSERT( j < (*mat).columns(), "Invalid column access index" );
347
348 MAYBE_UNUSED( mat );
349
350 return ( i < j ) ||
351 ( i == j && isOne( value ) ) ||
352 isDefault( value );
353}
355//*************************************************************************************************
356
357
358//*************************************************************************************************
376template< typename MT // Type of the adapted matrix
377 , bool SO // Storage order of the adapted matrix
378 , bool DF // Density flag
379 , typename ET > // Type of the element
381 trySet( const UniUpperMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
382{
383 BLAZE_INTERNAL_ASSERT( row <= (*mat).rows(), "Invalid row access index" );
384 BLAZE_INTERNAL_ASSERT( column <= (*mat).columns(), "Invalid column access index" );
385 BLAZE_INTERNAL_ASSERT( row + m <= (*mat).rows(), "Invalid number of rows" );
386 BLAZE_INTERNAL_ASSERT( column + n <= (*mat).columns(), "Invalid number of columns" );
387
388 MAYBE_UNUSED( mat );
389
390 return ( m == 0UL ) ||
391 ( n == 0UL ) ||
392 ( column >= row + m ) ||
393 ( ( row >= column + n ) && isDefault( value ) ) ||
394 ( row == column && m == 1UL && n == 1UL && isOne( value ) );
395}
397//*************************************************************************************************
398
399
400//*************************************************************************************************
416template< typename MT // Type of the adapted matrix
417 , bool SO // Storage order of the adapted matrix
418 , bool DF // Density flag
419 , typename ET > // Type of the element
420inline bool tryAdd( const UniUpperMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
421{
422 BLAZE_INTERNAL_ASSERT( i < (*mat).rows(), "Invalid row access index" );
423 BLAZE_INTERNAL_ASSERT( j < (*mat).columns(), "Invalid column access index" );
424
425 MAYBE_UNUSED( mat );
426
427 return ( i < j ) || isDefault( value );
428}
430//*************************************************************************************************
431
432
433//*************************************************************************************************
451template< typename MT // Type of the adapted matrix
452 , bool SO // Storage order of the adapted matrix
453 , bool DF // Density flag
454 , typename ET > // Type of the element
456 tryAdd( const UniUpperMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
457{
458 BLAZE_INTERNAL_ASSERT( row <= (*mat).rows(), "Invalid row access index" );
459 BLAZE_INTERNAL_ASSERT( column <= (*mat).columns(), "Invalid column access index" );
460 BLAZE_INTERNAL_ASSERT( row + m <= (*mat).rows(), "Invalid number of rows" );
461 BLAZE_INTERNAL_ASSERT( column + n <= (*mat).columns(), "Invalid number of columns" );
462
463 MAYBE_UNUSED( mat );
464
465 return ( m == 0UL ) ||
466 ( n == 0UL ) ||
467 ( column >= row + m ) ||
468 isDefault( value );
469}
471//*************************************************************************************************
472
473
474//*************************************************************************************************
490template< typename MT // Type of the adapted matrix
491 , bool SO // Storage order of the adapted matrix
492 , bool DF // Density flag
493 , typename ET > // Type of the element
494inline bool trySub( const UniUpperMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
495{
496 return tryAdd( mat, i, j, value );
497}
499//*************************************************************************************************
500
501
502//*************************************************************************************************
520template< typename MT // Type of the adapted matrix
521 , bool SO // Storage order of the adapted matrix
522 , bool DF // Density flag
523 , typename ET > // Type of the element
525 trySub( const UniUpperMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
526{
527 return tryAdd( mat, row, column, m, n, value );
528}
530//*************************************************************************************************
531
532
533//*************************************************************************************************
549template< typename MT // Type of the adapted matrix
550 , bool SO // Storage order of the adapted matrix
551 , bool DF // Density flag
552 , typename ET > // Type of the element
553inline bool tryMult( const UniUpperMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
554{
555 BLAZE_INTERNAL_ASSERT( i < (*mat).rows(), "Invalid row access index" );
556 BLAZE_INTERNAL_ASSERT( j < (*mat).columns(), "Invalid column access index" );
557
558 MAYBE_UNUSED( mat );
559
560 return ( i != j || isOne( value ) );
561}
563//*************************************************************************************************
564
565
566//*************************************************************************************************
584template< typename MT // Type of the adapted matrix
585 , bool SO // Storage order of the adapted matrix
586 , bool DF // Density flag
587 , typename ET > // Type of the element
589 tryMult( const UniUpperMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
590{
591 BLAZE_INTERNAL_ASSERT( row <= (*mat).rows(), "Invalid row access index" );
592 BLAZE_INTERNAL_ASSERT( column <= (*mat).columns(), "Invalid column access index" );
593 BLAZE_INTERNAL_ASSERT( row + m <= (*mat).rows(), "Invalid number of rows" );
594 BLAZE_INTERNAL_ASSERT( column + n <= (*mat).columns(), "Invalid number of columns" );
595
596 MAYBE_UNUSED( mat );
597
598 return ( m == 0UL ) ||
599 ( n == 0UL ) ||
600 ( column >= row + m ) ||
601 ( row >= column + n ) ||
602 isOne( value );
603}
605//*************************************************************************************************
606
607
608//*************************************************************************************************
624template< typename MT // Type of the adapted matrix
625 , bool SO // Storage order of the adapted matrix
626 , bool DF // Density flag
627 , typename ET > // Type of the element
628inline bool tryDiv( const UniUpperMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
629{
630 return tryMult( mat, i, j, value );
631}
633//*************************************************************************************************
634
635
636//*************************************************************************************************
654template< typename MT // Type of the adapted matrix
655 , bool SO // Storage order of the adapted matrix
656 , bool DF // Density flag
657 , typename ET > // Type of the element
659 tryDiv( const UniUpperMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
660{
661 BLAZE_INTERNAL_ASSERT( row <= (*mat).rows(), "Invalid row access index" );
662 BLAZE_INTERNAL_ASSERT( column <= (*mat).columns(), "Invalid column access index" );
663 BLAZE_INTERNAL_ASSERT( row + m <= (*mat).rows(), "Invalid number of rows" );
664 BLAZE_INTERNAL_ASSERT( column + n <= (*mat).columns(), "Invalid number of columns" );
665
666 MAYBE_UNUSED( mat );
667
668 return ( column >= row + m ) || ( row >= column + n ) || isOne( value );
669}
671//*************************************************************************************************
672
673
674//*************************************************************************************************
690template< typename MT // Type of the adapted matrix
691 , bool SO // Storage order of the adapted matrix
692 , bool DF > // Density flag
693inline bool tryShift( const UniUpperMatrix<MT,SO,DF>& mat, size_t i, size_t j, int count )
694{
695 BLAZE_INTERNAL_ASSERT( i < (*mat).rows(), "Invalid row access index" );
696 BLAZE_INTERNAL_ASSERT( j < (*mat).columns(), "Invalid column access index" );
697
698 MAYBE_UNUSED( mat );
699
700 return ( i != j || isDefault( count ) );
701}
703//*************************************************************************************************
704
705
706//*************************************************************************************************
724template< typename MT // Type of the adapted matrix
725 , bool SO // Storage order of the adapted matrix
726 , bool DF > // Density flag
728 tryShift( const UniUpperMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, int count )
729{
730 BLAZE_INTERNAL_ASSERT( row <= (*mat).rows(), "Invalid row access index" );
731 BLAZE_INTERNAL_ASSERT( column <= (*mat).columns(), "Invalid column access index" );
732 BLAZE_INTERNAL_ASSERT( row + m <= (*mat).rows(), "Invalid number of rows" );
733 BLAZE_INTERNAL_ASSERT( column + n <= (*mat).columns(), "Invalid number of columns" );
734
735 MAYBE_UNUSED( mat );
736
737 return ( m == 0UL ) ||
738 ( n == 0UL ) ||
739 ( column >= row + m ) ||
740 ( row >= column + n ) ||
741 isDefault( count );
742}
744//*************************************************************************************************
745
746
747//*************************************************************************************************
763template< typename MT // Type of the adapted matrix
764 , bool SO // Storage order of the adapted matrix
765 , bool DF // Density flag
766 , typename ET > // Type of the element
767inline bool tryBitand( const UniUpperMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
768{
769 BLAZE_INTERNAL_ASSERT( i < (*mat).rows(), "Invalid row access index" );
770 BLAZE_INTERNAL_ASSERT( j < (*mat).columns(), "Invalid column access index" );
771
772 MAYBE_UNUSED( mat );
773
774 return ( i != j ) || ( ElementType_t<MT>(1) & value );
775}
777//*************************************************************************************************
778
779
780//*************************************************************************************************
798template< typename MT // Type of the adapted matrix
799 , bool SO // Storage order of the adapted matrix
800 , bool DF // Density flag
801 , typename ET > // Type of the element
803 tryBitand( const UniUpperMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
804{
805 BLAZE_INTERNAL_ASSERT( row <= (*mat).rows(), "Invalid row access index" );
806 BLAZE_INTERNAL_ASSERT( column <= (*mat).columns(), "Invalid column access index" );
807 BLAZE_INTERNAL_ASSERT( row + m <= (*mat).rows(), "Invalid number of rows" );
808 BLAZE_INTERNAL_ASSERT( column + n <= (*mat).columns(), "Invalid number of columns" );
809
810 MAYBE_UNUSED( mat );
811
812 return ( m == 0UL ) ||
813 ( n == 0UL ) ||
814 ( column >= row + m ) ||
815 ( row >= column + n ) ||
816 ( ElementType_t<MT>(1) & value );
817}
819//*************************************************************************************************
820
821
822//*************************************************************************************************
838template< typename MT // Type of the adapted matrix
839 , bool SO // Storage order of the adapted matrix
840 , bool DF // Density flag
841 , typename ET > // Type of the element
842inline bool tryBitor( const UniUpperMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
843{
844 return trySet( mat, i, j, value );
845}
847//*************************************************************************************************
848
849
850//*************************************************************************************************
868template< typename MT // Type of the adapted matrix
869 , bool SO // Storage order of the adapted matrix
870 , bool DF // Density flag
871 , typename ET > // Type of the element
873 tryBitor( const UniUpperMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
874{
875 return trySet( mat, row, column, m, n, value );
876}
878//*************************************************************************************************
879
880
881//*************************************************************************************************
897template< typename MT // Type of the adapted matrix
898 , bool SO // Storage order of the adapted matrix
899 , bool DF // Density flag
900 , typename ET > // Type of the element
901inline bool tryBitxor( const UniUpperMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
902{
903 return tryAdd( mat, i, j, value );
904}
906//*************************************************************************************************
907
908
909//*************************************************************************************************
927template< typename MT // Type of the adapted matrix
928 , bool SO // Storage order of the adapted matrix
929 , bool DF // Density flag
930 , typename ET > // Type of the element
932 tryBitxor( const UniUpperMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
933{
934 return tryAdd( mat, row, column, m, n, value );
935}
937//*************************************************************************************************
938
939
940//*************************************************************************************************
956template< typename MT // Type of the adapted matrix
957 , bool SO // Storage order of the adapted matrix
958 , bool DF // Density flag
959 , typename VT > // Type of the right-hand side dense vector
960inline bool tryAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
961 const DenseVector<VT,false>& rhs, size_t row, size_t column )
962{
964
965 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
966 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
967 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
968
969 MAYBE_UNUSED( lhs );
970
971 if( column >= row + (*rhs).size() )
972 return true;
973
974 const bool containsDiagonal( column >= row );
975 const size_t ibegin( ( !containsDiagonal )?( 0UL ):( column - row + 1UL ) );
976
977 if( containsDiagonal && !isOne( (*rhs)[column-row] ) )
978 return false;
979
980 for( size_t i=ibegin; i<(*rhs).size(); ++i ) {
981 if( !isDefault( (*rhs)[i] ) )
982 return false;
983 }
984
985 return true;
986}
988//*************************************************************************************************
989
990
991//*************************************************************************************************
1007template< typename MT // Type of the adapted matrix
1008 , bool SO // Storage order of the adapted matrix
1009 , bool DF // Density flag
1010 , typename VT > // Type of the right-hand side dense vector
1011inline bool tryAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
1012 const DenseVector<VT,true>& rhs, size_t row, size_t column )
1013{
1015
1016 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1017 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1018 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1019
1020 MAYBE_UNUSED( lhs );
1021
1022 if( row < column )
1023 return true;
1024
1025 const bool containsDiagonal( row < column + (*rhs).size() );
1026 const size_t iend( min( row - column, (*rhs).size() ) );
1027
1028 for( size_t i=0UL; i<iend; ++i ) {
1029 if( !isDefault( (*rhs)[i] ) )
1030 return false;
1031 }
1032
1033 if( containsDiagonal && !isOne( (*rhs)[iend] ) )
1034 return false;
1035
1036 return true;
1037}
1039//*************************************************************************************************
1040
1041
1042//*************************************************************************************************
1060template< typename MT // Type of the adapted matrix
1061 , bool SO // Storage order of the adapted matrix
1062 , bool DF // Density flag
1063 , typename VT // Type of the right-hand side dense vector
1064 , bool TF > // Transpose flag of the right-hand side dense vector
1065inline bool tryAssign( const UniUpperMatrix<MT,SO,DF>& lhs, const DenseVector<VT,TF>& rhs,
1066 ptrdiff_t band, size_t row, size_t column )
1067{
1069
1070 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1071 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1072 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
1073 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1074
1075 MAYBE_UNUSED( lhs, row, column );
1076
1077 if( band == 0L ) {
1078 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
1079 if( !isOne( (*rhs)[i] ) )
1080 return false;
1081 }
1082 }
1083 else if( band < 0L ) {
1084 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
1085 if( !isDefault( (*rhs)[i] ) )
1086 return false;
1087 }
1088 }
1089
1090 return true;
1091}
1093//*************************************************************************************************
1094
1095
1096//*************************************************************************************************
1112template< typename MT // Type of the adapted matrix
1113 , bool SO // Storage order of the adapted matrix
1114 , bool DF // Density flag
1115 , typename VT > // Type of the right-hand side sparse vector
1116inline bool tryAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
1117 const SparseVector<VT,false>& rhs, size_t row, size_t column )
1118{
1120
1121 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1122 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1123 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
1124
1125 MAYBE_UNUSED( lhs );
1126
1127 if( column >= row + (*rhs).size() )
1128 return true;
1129
1130 const bool containsDiagonal( column >= row );
1131 const size_t index( ( containsDiagonal )?( column - row ):( 0UL ) );
1132 const auto last( (*rhs).end() );
1133 auto element( (*rhs).lowerBound( index ) );
1134
1135 if( containsDiagonal ) {
1136 if( element == last || element->index() != index || !isOne( element->value() ) )
1137 return false;
1138 ++element;
1139 }
1140
1141 for( ; element!=last; ++element ) {
1142 if( !isDefault( element->value() ) )
1143 return false;
1144 }
1145
1146 return true;
1147}
1149//*************************************************************************************************
1150
1151
1152//*************************************************************************************************
1168template< typename MT // Type of the adapted matrix
1169 , bool SO // Storage order of the adapted matrix
1170 , bool DF // Density flag
1171 , typename VT > // Type of the right-hand side sparse vector
1172inline bool tryAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
1173 const SparseVector<VT,true>& rhs, size_t row, size_t column )
1174{
1176
1177 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1178 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1179 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1180
1181 MAYBE_UNUSED( lhs );
1182
1183 if( row < column )
1184 return true;
1185
1186 const bool containsDiagonal( row < column + (*rhs).size() );
1187 const size_t index( row - column );
1188 const auto last( (*rhs).lowerBound( index ) );
1189
1190 if( containsDiagonal ) {
1191 if( last == (*rhs).end() || last->index() != index || !isOne( last->value() ) )
1192 return false;
1193 }
1194
1195 for( auto element=(*rhs).begin(); element!=last; ++element ) {
1196 if( !isDefault( element->value() ) )
1197 return false;
1198 }
1199
1200 return true;
1201}
1203//*************************************************************************************************
1204
1205
1206//*************************************************************************************************
1224template< typename MT // Type of the adapted matrix
1225 , bool SO // Storage order of the adapted matrix
1226 , bool DF // Density flag
1227 , typename VT // Type of the right-hand side sparse vector
1228 , bool TF > // Transpose flag of the right-hand side sparse vector
1229inline bool tryAssign( const UniUpperMatrix<MT,SO,DF>& lhs, const SparseVector<VT,TF>& rhs,
1230 ptrdiff_t band, size_t row, size_t column )
1231{
1233
1234 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1235 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1236 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
1237 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1238
1239 MAYBE_UNUSED( lhs, row, column );
1240
1241 if( band == 0L ) {
1242 if( (*rhs).nonZeros() != (*rhs).size() )
1243 return false;
1244 for( const auto& element : *rhs ) {
1245 if( !isOne( element.value() ) )
1246 return false;
1247 }
1248 }
1249 else if( band < 0L ) {
1250 for( const auto& element : *rhs ) {
1251 if( !isDefault( element.value() ) )
1252 return false;
1253 }
1254 }
1255
1256 return true;
1257}
1259//*************************************************************************************************
1260
1261
1262//*************************************************************************************************
1278template< typename MT1 // Type of the adapted matrix
1279 , bool SO // Storage order of the adapted matrix
1280 , bool DF // Density flag
1281 , typename MT2 > // Type of the right-hand side dense matrix
1282inline bool tryAssign( const UniUpperMatrix<MT1,SO,DF>& lhs,
1283 const DenseMatrix<MT2,false>& rhs, size_t row, size_t column )
1284{
1286
1287 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1288 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1289 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1290 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1291
1292 MAYBE_UNUSED( lhs );
1293
1294 const size_t M( (*rhs).rows() );
1295 const size_t N( (*rhs).columns() );
1296
1297 if( column >= row + M )
1298 return true;
1299
1300 const size_t ibegin( ( column < row )?( 0UL ):( column - row ) );
1301
1302 for( size_t i=ibegin; i<M; ++i )
1303 {
1304 const size_t jend( min( row + i - column, N ) );
1305
1306 for( size_t j=0UL; j<jend; ++j ) {
1307 if( !isDefault( (*rhs)(i,j) ) )
1308 return false;
1309 }
1310
1311 const bool containsDiagonal( row + i < column + N );
1312
1313 if( containsDiagonal && !isOne( (*rhs)(i,jend) ) )
1314 return false;
1315 }
1316
1317 return true;
1318}
1320//*************************************************************************************************
1321
1322
1323//*************************************************************************************************
1339template< typename MT1 // Type of the adapted matrix
1340 , bool SO // Storage order of the adapted matrix
1341 , bool DF // Density flag
1342 , typename MT2 > // Type of the right-hand side dense matrix
1343inline bool tryAssign( const UniUpperMatrix<MT1,SO,DF>& lhs,
1344 const DenseMatrix<MT2,true>& rhs, size_t row, size_t column )
1345{
1347
1348 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1349 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1350 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1351 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1352
1353 MAYBE_UNUSED( lhs );
1354
1355 const size_t M( (*rhs).rows() );
1356 const size_t N( (*rhs).columns() );
1357
1358 if( column >= row + M )
1359 return true;
1360
1361 const size_t jend( min( row + M - column, N ) );
1362
1363 for( size_t j=0UL; j<jend; ++j )
1364 {
1365 const bool containsDiagonal( column + j >= row );
1366
1367 if( containsDiagonal && !isOne( (*rhs)(column+j-row,j) ) )
1368 return false;
1369
1370 const size_t ibegin( ( containsDiagonal )?( column + j - row + 1UL ):( 0UL ) );
1371
1372 for( size_t i=ibegin; i<M; ++i ) {
1373 if( !isDefault( (*rhs)(i,j) ) )
1374 return false;
1375 }
1376 }
1377
1378 return true;
1379}
1381//*************************************************************************************************
1382
1383
1384//*************************************************************************************************
1400template< typename MT1 // Type of the adapted matrix
1401 , bool SO // Storage order of the adapted matrix
1402 , bool DF // Density flag
1403 , typename MT2 > // Type of the right-hand side sparse matrix
1404inline bool tryAssign( const UniUpperMatrix<MT1,SO,DF>& lhs,
1405 const SparseMatrix<MT2,false>& rhs, size_t row, size_t column )
1406{
1408
1409 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1410 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1411 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1412 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1413
1414 MAYBE_UNUSED( lhs );
1415
1416 const size_t M( (*rhs).rows() );
1417 const size_t N( (*rhs).columns() );
1418
1419 if( column >= row + M )
1420 return true;
1421
1422 const size_t ibegin( ( column < row )?( 0UL ):( column - row ) );
1423
1424 for( size_t i=ibegin; i<M; ++i )
1425 {
1426 const bool containsDiagonal( row + i < column + N );
1427
1428 const size_t index( row + i - column );
1429 const auto last( (*rhs).lowerBound( i, min( index, N ) ) );
1430
1431 if( containsDiagonal ) {
1432 if( last == (*rhs).end(i) || ( last->index() != index ) || !isOne( last->value() ) )
1433 return false;
1434 }
1435
1436 for( auto element=(*rhs).begin(i); element!=last; ++element ) {
1437 if( !isDefault( element->value() ) )
1438 return false;
1439 }
1440 }
1441
1442 return true;
1443}
1445//*************************************************************************************************
1446
1447
1448//*************************************************************************************************
1464template< typename MT1 // Type of the adapted matrix
1465 , bool SO // Storage order of the adapted matrix
1466 , bool DF // Density flag
1467 , typename MT2 > // Type of the right-hand side sparse matrix
1468inline bool tryAssign( const UniUpperMatrix<MT1,SO,DF>& lhs,
1469 const SparseMatrix<MT2,true>& rhs, size_t row, size_t column )
1470{
1472
1473 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1474 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1475 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1476 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1477
1478 MAYBE_UNUSED( lhs );
1479
1480 const size_t M( (*rhs).rows() );
1481 const size_t N( (*rhs).columns() );
1482
1483 if( column >= row + M )
1484 return true;
1485
1486 const size_t jend( min( row + M - column, N ) );
1487
1488 for( size_t j=0UL; j<jend; ++j )
1489 {
1490 const bool containsDiagonal( column + j >= row );
1491 const size_t index( ( containsDiagonal )?( column + j - row ):( 0UL ) );
1492
1493 const auto last( (*rhs).end(j) );
1494 auto element( (*rhs).lowerBound( index, j ) );
1495
1496 if( containsDiagonal ) {
1497 if( element == last || ( element->index() != index ) || !isOne( element->value() ) )
1498 return false;
1499 ++element;
1500 }
1501
1502 for( ; element!=last; ++element ) {
1503 if( !isDefault( element->value() ) )
1504 return false;
1505 }
1506 }
1507
1508 return true;
1509}
1511//*************************************************************************************************
1512
1513
1514//*************************************************************************************************
1531template< typename MT // Type of the adapted matrix
1532 , bool SO // Storage order of the adapted matrix
1533 , bool DF // Density flag
1534 , typename VT > // Type of the right-hand side dense vector
1535inline bool tryAddAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
1536 const DenseVector<VT,false>& rhs, size_t row, size_t column )
1537{
1539
1540 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1541 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1542 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
1543
1544 MAYBE_UNUSED( lhs );
1545
1546 const size_t ibegin( ( column <= row )?( 0UL ):( column - row ) );
1547
1548 for( size_t i=ibegin; i<(*rhs).size(); ++i ) {
1549 if( !isDefault( (*rhs)[i] ) )
1550 return false;
1551 }
1552
1553 return true;
1554}
1556//*************************************************************************************************
1557
1558
1559//*************************************************************************************************
1576template< typename MT // Type of the adapted matrix
1577 , bool SO // Storage order of the adapted matrix
1578 , bool DF // Density flag
1579 , typename VT > // Type of the right-hand side dense vector
1580inline bool tryAddAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
1581 const DenseVector<VT,true>& rhs, size_t row, size_t column )
1582{
1584
1585 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1586 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1587 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1588
1589 MAYBE_UNUSED( lhs );
1590
1591 if( row < column )
1592 return true;
1593
1594 const size_t iend( min( row - column + 1UL, (*rhs).size() ) );
1595
1596 for( size_t i=0UL; i<iend; ++i ) {
1597 if( !isDefault( (*rhs)[i] ) )
1598 return false;
1599 }
1600
1601 return true;
1602}
1604//*************************************************************************************************
1605
1606
1607//*************************************************************************************************
1624template< typename MT // Type of the adapted matrix
1625 , bool SO // Storage order of the adapted matrix
1626 , bool DF // Density flag
1627 , typename VT // Type of the right-hand side dense vector
1628 , bool TF > // Transpose flag of the right-hand side dense vector
1629inline bool tryAddAssign( const UniUpperMatrix<MT,SO,DF>& lhs, const DenseVector<VT,TF>& rhs,
1630 ptrdiff_t band, size_t row, size_t column )
1631{
1633
1634 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1635 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1636 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
1637 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1638
1639 MAYBE_UNUSED( lhs, row, column );
1640
1641 if( band <= 0L ) {
1642 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
1643 if( !isDefault( (*rhs)[i] ) )
1644 return false;
1645 }
1646 }
1647
1648 return true;
1649}
1651//*************************************************************************************************
1652
1653
1654//*************************************************************************************************
1671template< typename MT // Type of the adapted matrix
1672 , bool SO // Storage order of the adapted matrix
1673 , bool DF // Density flag
1674 , typename VT > // Type of the right-hand side sparse vector
1675inline bool tryAddAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
1676 const SparseVector<VT,false>& rhs, size_t row, size_t column )
1677{
1679
1680 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1681 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1682 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
1683
1684 MAYBE_UNUSED( lhs );
1685
1686 const auto last( (*rhs).end() );
1687 auto element( (*rhs).lowerBound( ( column <= row )?( 0UL ):( column - row ) ) );
1688
1689 for( ; element!=last; ++element ) {
1690 if( !isDefault( element->value() ) )
1691 return false;
1692 }
1693
1694 return true;
1695}
1697//*************************************************************************************************
1698
1699
1700//*************************************************************************************************
1717template< typename MT // Type of the adapted matrix
1718 , bool SO // Storage order of the adapted matrix
1719 , bool DF // Density flag
1720 , typename VT > // Type of the right-hand side sparse vector
1721inline bool tryAddAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
1722 const SparseVector<VT,true>& rhs, size_t row, size_t column )
1723{
1725
1726 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1727 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1728 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1729
1730 MAYBE_UNUSED( lhs );
1731
1732 if( row < column )
1733 return true;
1734
1735 const auto last( (*rhs).lowerBound( row - column + 1UL ) );
1736
1737 for( auto element=(*rhs).begin(); element!=last; ++element ) {
1738 if( !isDefault( element->value() ) )
1739 return false;
1740 }
1741
1742 return true;
1743}
1745//*************************************************************************************************
1746
1747
1748//*************************************************************************************************
1765template< typename MT // Type of the adapted matrix
1766 , bool SO // Storage order of the adapted matrix
1767 , bool DF // Density flag
1768 , typename VT // Type of the right-hand side sparse vector
1769 , bool TF > // Transpose flag of the right-hand side sparse vector
1770inline bool tryAddAssign( const UniUpperMatrix<MT,SO,DF>& lhs, const SparseVector<VT,TF>& rhs,
1771 ptrdiff_t band, size_t row, size_t column )
1772{
1774
1775 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1776 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1777 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
1778 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1779
1780 MAYBE_UNUSED( lhs, row, column );
1781
1782 if( band <= 0L ) {
1783 for( const auto& element : *rhs ) {
1784 if( !isDefault( element.value() ) )
1785 return false;
1786 }
1787 }
1788
1789 return true;
1790}
1792//*************************************************************************************************
1793
1794
1795//*************************************************************************************************
1812template< typename MT1 // Type of the adapted matrix
1813 , bool SO // Storage order of the adapted matrix
1814 , bool DF // Density flag
1815 , typename MT2 > // Type of the right-hand side dense matrix
1816inline bool tryAddAssign( const UniUpperMatrix<MT1,SO,DF>& lhs,
1817 const DenseMatrix<MT2,false>& rhs, size_t row, size_t column )
1818{
1820
1821 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1822 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1823 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1824 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1825
1826 MAYBE_UNUSED( lhs );
1827
1828 const size_t M( (*rhs).rows() );
1829 const size_t N( (*rhs).columns() );
1830
1831 if( column >= row + M )
1832 return true;
1833
1834 const size_t ibegin( ( column <= row )?( 0UL ):( column - row ) );
1835
1836 for( size_t i=ibegin; i<M; ++i )
1837 {
1838 const size_t jend( min( row + i - column + 1UL, N ) );
1839
1840 for( size_t j=0UL; j<jend; ++j ) {
1841 if( !isDefault( (*rhs)(i,j) ) )
1842 return false;
1843 }
1844 }
1845
1846 return true;
1847}
1849//*************************************************************************************************
1850
1851
1852//*************************************************************************************************
1869template< typename MT1 // Type of the adapted matrix
1870 , bool SO // Storage order of the adapted matrix
1871 , bool DF // Density flag
1872 , typename MT2 > // Type of the right-hand side dense matrix
1873inline bool tryAddAssign( const UniUpperMatrix<MT1,SO,DF>& lhs,
1874 const DenseMatrix<MT2,true>& rhs, size_t row, size_t column )
1875{
1877
1878 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1879 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1880 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1881 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1882
1883 MAYBE_UNUSED( lhs );
1884
1885 const size_t M( (*rhs).rows() );
1886 const size_t N( (*rhs).columns() );
1887
1888 if( column >= row + M )
1889 return true;
1890
1891 const size_t jend( min( row + M - column, N ) );
1892
1893 for( size_t j=0UL; j<jend; ++j )
1894 {
1895 const bool containsDiagonal( column + j >= row );
1896 const size_t ibegin( ( containsDiagonal )?( column + j - row ):( 0UL ) );
1897
1898 for( size_t i=ibegin; i<M; ++i ) {
1899 if( !isDefault( (*rhs)(i,j) ) )
1900 return false;
1901 }
1902 }
1903
1904 return true;
1905}
1907//*************************************************************************************************
1908
1909
1910//*************************************************************************************************
1927template< typename MT1 // Type of the adapted matrix
1928 , bool SO // Storage order of the adapted matrix
1929 , bool DF // Density flag
1930 , typename MT2 > // Type of the right-hand side sparse matrix
1931inline bool tryAddAssign( const UniUpperMatrix<MT1,SO,DF>& lhs,
1932 const SparseMatrix<MT2,false>& rhs, size_t row, size_t column )
1933{
1935
1936 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1937 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1938 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1939 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1940
1941 MAYBE_UNUSED( lhs );
1942
1943 const size_t M( (*rhs).rows() );
1944 const size_t N( (*rhs).columns() );
1945
1946 if( column >= row + M )
1947 return true;
1948
1949 const size_t ibegin( ( column < row )?( 0UL ):( column - row ) );
1950
1951 for( size_t i=ibegin; i<M; ++i )
1952 {
1953 const size_t index( row + i - column + 1UL );
1954 const auto last( (*rhs).lowerBound( i, min( index, N ) ) );
1955
1956 for( auto element=(*rhs).begin(i); element!=last; ++element ) {
1957 if( !isDefault( element->value() ) )
1958 return false;
1959 }
1960 }
1961
1962 return true;
1963}
1965//*************************************************************************************************
1966
1967
1968//*************************************************************************************************
1985template< typename MT1 // Type of the adapted matrix
1986 , bool SO // Storage order of the adapted matrix
1987 , bool DF // Density flag
1988 , typename MT2 > // Type of the right-hand side sparse matrix
1989inline bool tryAddAssign( const UniUpperMatrix<MT1,SO,DF>& lhs,
1990 const SparseMatrix<MT2,true>& rhs, size_t row, size_t column )
1991{
1993
1994 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1995 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1996 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1997 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1998
1999 MAYBE_UNUSED( lhs );
2000
2001 const size_t M( (*rhs).rows() );
2002 const size_t N( (*rhs).columns() );
2003
2004 if( column >= row + M )
2005 return true;
2006
2007 const size_t jend( min( row + M - column, N ) );
2008
2009 for( size_t j=0UL; j<jend; ++j )
2010 {
2011 const bool containsDiagonal( column + j >= row );
2012 const size_t index( ( containsDiagonal )?( column + j - row ):( 0UL ) );
2013
2014 const auto last( (*rhs).end(j) );
2015 auto element( (*rhs).lowerBound( index, j ) );
2016
2017 for( ; element!=last; ++element ) {
2018 if( !isDefault( element->value() ) )
2019 return false;
2020 }
2021 }
2022
2023 return true;
2024}
2026//*************************************************************************************************
2027
2028
2029//*************************************************************************************************
2046template< typename MT // Type of the adapted matrix
2047 , bool SO // Storage order of the adapted matrix
2048 , bool DF // Density flag
2049 , typename VT // Type of the right-hand side vector
2050 , bool TF > // Transpose flag of the right-hand side vector
2051inline bool trySubAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
2052 const Vector<VT,TF>& rhs, size_t row, size_t column )
2053{
2054 return tryAddAssign( lhs, *rhs, row, column );
2055}
2057//*************************************************************************************************
2058
2059
2060//*************************************************************************************************
2078template< typename MT // Type of the adapted matrix
2079 , bool SO // Storage order of the adapted matrix
2080 , bool DF // Density flag
2081 , typename VT // Type of the right-hand side vector
2082 , bool TF > // Transpose flag of the right-hand side vector
2083inline bool trySubAssign( const UniUpperMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
2084 ptrdiff_t band, size_t row, size_t column )
2085{
2086 return tryAddAssign( lhs, *rhs, band, row, column );
2087}
2089//*************************************************************************************************
2090
2091
2092//*************************************************************************************************
2109template< typename MT1 // Type of the adapted matrix
2110 , bool SO1 // Storage order of the adapted matrix
2111 , bool DF // Density flag
2112 , typename MT2 // Type of the right-hand side matrix
2113 , bool SO2 > // Storage order of the right-hand side matrix
2114inline bool trySubAssign( const UniUpperMatrix<MT1,SO1,DF>& lhs,
2115 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
2116{
2117 return tryAddAssign( lhs, *rhs, row, column );
2118}
2120//*************************************************************************************************
2121
2122
2123//*************************************************************************************************
2140template< typename MT // Type of the adapted matrix
2141 , bool SO // Storage order of the adapted matrix
2142 , bool DF // Density flag
2143 , typename VT > // Type of the right-hand side vector
2144inline bool tryMultAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
2145 const Vector<VT,false>& rhs, size_t row, size_t column )
2146{
2148
2149 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2150 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2151 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2152
2153 MAYBE_UNUSED( lhs );
2154
2155 return ( column < row ) ||
2156 ( (*rhs).size() <= column - row ) ||
2157 isOne( (*rhs)[column-row] );
2158}
2160//*************************************************************************************************
2161
2162
2163//*************************************************************************************************
2180template< typename MT // Type of the adapted matrix
2181 , bool SO // Storage order of the adapted matrix
2182 , bool DF // Density flag
2183 , typename VT > // Type of the right-hand side vector
2184inline bool tryMultAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
2185 const Vector<VT,true>& rhs, size_t row, size_t column )
2186{
2188
2189 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2190 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2191 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2192
2193 MAYBE_UNUSED( lhs );
2194
2195 return ( row < column ) ||
2196 ( (*rhs).size() <= row - column ) ||
2197 isOne( (*rhs)[row-column] );
2198}
2200//*************************************************************************************************
2201
2202
2203//*************************************************************************************************
2220template< typename MT // Type of the adapted matrix
2221 , bool SO // Storage order of the adapted matrix
2222 , bool DF // Density flag
2223 , typename VT // Type of the right-hand side dense vector
2224 , bool TF > // Transpose flag of the right-hand side dense vector
2225inline bool tryMultAssign( const UniUpperMatrix<MT,SO,DF>& lhs, const DenseVector<VT,TF>& rhs,
2226 ptrdiff_t band, size_t row, size_t column )
2227{
2229
2230 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2231 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2232 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2233 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2234
2235 MAYBE_UNUSED( lhs, row, column );
2236
2237 if( band == 0L ) {
2238 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2239 if( !isOne( (*rhs)[i] ) )
2240 return false;
2241 }
2242 }
2243
2244 return true;
2245}
2247//*************************************************************************************************
2248
2249
2250//*************************************************************************************************
2267template< typename MT // Type of the adapted matrix
2268 , bool SO // Storage order of the adapted matrix
2269 , bool DF // Density flag
2270 , typename VT // Type of the right-hand side sparse vector
2271 , bool TF > // Transpose flag of the right-hand side sparse vector
2272inline bool tryMultAssign( const UniUpperMatrix<MT,SO,DF>& lhs, const SparseVector<VT,TF>& rhs,
2273 ptrdiff_t band, size_t row, size_t column )
2274{
2276
2277 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2278 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2279 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2280 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2281
2282 MAYBE_UNUSED( lhs, row, column );
2283
2284 if( band == 0L ) {
2285 if( (*rhs).nonZeros() != (*rhs).size() )
2286 return false;
2287 for( const auto& element : *rhs ) {
2288 if( !isOne( element.value() ) )
2289 return false;
2290 }
2291 }
2292
2293 return true;
2294}
2296//*************************************************************************************************
2297
2298
2299//*************************************************************************************************
2316template< typename MT1 // Type of the adapted matrix
2317 , bool SO1 // Storage order of the adapted matrix
2318 , bool DF // Density flag
2319 , typename MT2 // Type of the right-hand side matrix
2320 , bool SO2 > // Storage order of the right-hand side matrix
2321inline bool trySchurAssign( const UniUpperMatrix<MT1,SO1,DF>& lhs,
2322 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
2323{
2325
2326 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2327 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2328 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
2329 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
2330
2331 MAYBE_UNUSED( lhs );
2332
2333 const size_t M( (*rhs).rows() );
2334 const size_t N( (*rhs).columns() );
2335
2336 if( ( column >= row + M ) || ( row >= column + N ) )
2337 return true;
2338
2339 size_t i( row < column ? column - row : 0UL );
2340 size_t j( column < row ? row - column : 0UL );
2341
2342 for( ; i<M && j<N; ++i, ++j )
2343 {
2344 if( !isOne( (*rhs)(i,j) ) )
2345 return false;
2346 }
2347
2348 return true;
2349}
2351//*************************************************************************************************
2352
2353
2354//*************************************************************************************************
2370template< typename MT // Type of the adapted matrix
2371 , bool SO // Storage order of the adapted matrix
2372 , bool DF // Density flag
2373 , typename VT // Type of the right-hand side vector
2374 , bool TF > // Transpose flag of the right-hand side vector
2375inline bool tryDivAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
2376 const Vector<VT,TF>& rhs, size_t row, size_t column )
2377{
2378 return tryMultAssign( lhs, *rhs, row, column );
2379}
2381//*************************************************************************************************
2382
2383
2384//*************************************************************************************************
2401template< typename MT // Type of the adapted matrix
2402 , bool SO // Storage order of the adapted matrix
2403 , bool DF // Density flag
2404 , typename VT // Type of the right-hand side vector
2405 , bool TF > // Transpose flag of the right-hand side vector
2406inline bool tryDivAssign( const UniUpperMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
2407 ptrdiff_t band, size_t row, size_t column )
2408{
2409 return tryMultAssign( lhs, *rhs, band, row, column );
2410}
2412//*************************************************************************************************
2413
2414
2415//*************************************************************************************************
2431template< typename MT // Type of the adapted matrix
2432 , bool SO // Storage order of the adapted matrix
2433 , bool DF // Density flag
2434 , typename VT > // Type of the right-hand side vector
2435inline bool tryShiftAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
2436 const Vector<VT,false>& rhs, size_t row, size_t column )
2437{
2439
2440 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2441 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2442 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2443
2444 MAYBE_UNUSED( lhs );
2445
2446 return ( column < row ) ||
2447 ( (*rhs).size() <= column - row ) ||
2448 isDefault( (*rhs)[column-row] );
2449}
2451//*************************************************************************************************
2452
2453
2454//*************************************************************************************************
2470template< typename MT // Type of the adapted matrix
2471 , bool SO // Storage order of the adapted matrix
2472 , bool DF // Density flag
2473 , typename VT > // Type of the right-hand side vector
2474inline bool tryShiftAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
2475 const Vector<VT,true>& rhs, size_t row, size_t column )
2476{
2478
2479 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2480 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2481 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2482
2483 MAYBE_UNUSED( lhs );
2484
2485 return ( row < column ) ||
2486 ( (*rhs).size() <= row - column ) ||
2487 isDefault( (*rhs)[row-column] );
2488}
2490//*************************************************************************************************
2491
2492
2493//*************************************************************************************************
2510template< typename MT // Type of the adapted matrix
2511 , bool SO // Storage order of the adapted matrix
2512 , bool DF // Density flag
2513 , typename VT // Type of the right-hand side dense vector
2514 , bool TF > // Transpose flag of the right-hand side dense vector
2515inline bool tryShiftAssign( const UniUpperMatrix<MT,SO,DF>& lhs, const DenseVector<VT,TF>& rhs,
2516 ptrdiff_t band, size_t row, size_t column )
2517{
2519
2520 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2521 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2522 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2523 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2524
2525 MAYBE_UNUSED( lhs, row, column );
2526
2527 if( band == 0L ) {
2528 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2529 if( !isDefault( (*rhs)[i] ) )
2530 return false;
2531 }
2532 }
2533
2534 return true;
2535}
2537//*************************************************************************************************
2538
2539
2540//*************************************************************************************************
2557template< typename MT // Type of the adapted matrix
2558 , bool SO // Storage order of the adapted matrix
2559 , bool DF // Density flag
2560 , typename VT // Type of the right-hand side sparse vector
2561 , bool TF > // Transpose flag of the right-hand side sparse vector
2562inline bool tryShiftAssign( const UniUpperMatrix<MT,SO,DF>& lhs, const SparseVector<VT,TF>& rhs,
2563 ptrdiff_t band, size_t row, size_t column )
2564{
2566
2567 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2568 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2569 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2570 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2571
2572 MAYBE_UNUSED( lhs, row, column );
2573
2574 if( band == 0L ) {
2575 if( (*rhs).nonZeros() != (*rhs).size() )
2576 return false;
2577 for( const auto& element : *rhs ) {
2578 if( !isDefault( element.value() ) )
2579 return false;
2580 }
2581 }
2582
2583 return true;
2584}
2586//*************************************************************************************************
2587
2588
2589//*************************************************************************************************
2605template< typename MT1 // Type of the adapted matrix
2606 , bool SO1 // Storage order of the adapted matrix
2607 , bool DF // Density flag
2608 , typename MT2 // Type of the right-hand side matrix
2609 , bool SO2 > // Storage order of the right-hand side matrix
2610inline bool tryShiftAssign( const UniUpperMatrix<MT1,SO1,DF>& lhs,
2611 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
2612{
2614
2615 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2616 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2617 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
2618 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
2619
2620 MAYBE_UNUSED( lhs );
2621
2622 const size_t M( (*rhs).rows() );
2623 const size_t N( (*rhs).columns() );
2624
2625 if( ( column >= row + M ) || ( row >= column + N ) )
2626 return true;
2627
2628 size_t i( row < column ? column - row : 0UL );
2629 size_t j( column < row ? row - column : 0UL );
2630
2631 for( ; i<M && j<N; ++i, ++j )
2632 {
2633 if( !isDefault( (*rhs)(i,j) ) )
2634 return false;
2635 }
2636
2637 return true;
2638}
2640//*************************************************************************************************
2641
2642
2643//*************************************************************************************************
2660template< typename MT // Type of the adapted matrix
2661 , bool SO // Storage order of the adapted matrix
2662 , bool DF // Density flag
2663 , typename VT > // Type of the right-hand side vector
2664inline bool tryBitandAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
2665 const Vector<VT,false>& rhs, size_t row, size_t column )
2666{
2668
2669 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2670 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2671 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2672
2673 MAYBE_UNUSED( lhs );
2674
2675 return ( column < row ) ||
2676 ( (*rhs).size() <= column - row ) ||
2677 ( ElementType_t<MT>(1) & (*rhs)[column-row] );
2678}
2680//*************************************************************************************************
2681
2682
2683//*************************************************************************************************
2700template< typename MT // Type of the adapted matrix
2701 , bool SO // Storage order of the adapted matrix
2702 , bool DF // Density flag
2703 , typename VT > // Type of the right-hand side vector
2704inline bool tryBitandAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
2705 const Vector<VT,true>& rhs, size_t row, size_t column )
2706{
2708
2709 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2710 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2711 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2712
2713 MAYBE_UNUSED( lhs );
2714
2715 return ( row < column ) ||
2716 ( (*rhs).size() <= row - column ) ||
2717 ( ElementType_t<MT>(1) & (*rhs)[row-column] );
2718}
2720//*************************************************************************************************
2721
2722
2723//*************************************************************************************************
2740template< typename MT // Type of the adapted matrix
2741 , bool SO // Storage order of the adapted matrix
2742 , bool DF // Density flag
2743 , typename VT // Type of the right-hand side dense vector
2744 , bool TF > // Transpose flag of the right-hand side dense vector
2745inline bool tryBitandAssign( const UniUpperMatrix<MT,SO,DF>& lhs, const DenseVector<VT,TF>& rhs,
2746 ptrdiff_t band, size_t row, size_t column )
2747{
2749
2750 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2751 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2752 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2753 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2754
2755 MAYBE_UNUSED( lhs, row, column );
2756
2757 if( band == 0L ) {
2758 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2759 if( !( ElementType_t<MT>(1) & (*rhs)[i] ) )
2760 return false;
2761 }
2762 }
2763
2764 return true;
2765}
2767//*************************************************************************************************
2768
2769
2770//*************************************************************************************************
2787template< typename MT // Type of the adapted matrix
2788 , bool SO // Storage order of the adapted matrix
2789 , bool DF // Density flag
2790 , typename VT // Type of the right-hand side sparse vector
2791 , bool TF > // Transpose flag of the right-hand side sparse vector
2792inline bool tryBitandAssign( const UniUpperMatrix<MT,SO,DF>& lhs, const SparseVector<VT,TF>& rhs,
2793 ptrdiff_t band, size_t row, size_t column )
2794{
2796
2797 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2798 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2799 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2800 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2801
2802 MAYBE_UNUSED( lhs, row, column );
2803
2804 if( band == 0L ) {
2805 if( (*rhs).nonZeros() != (*rhs).size() )
2806 return false;
2807 for( const auto& element : *rhs ) {
2808 if( !( ElementType_t<MT>(1) & element.value() ) )
2809 return false;
2810 }
2811 }
2812
2813 return true;
2814}
2816//*************************************************************************************************
2817
2818
2819//*************************************************************************************************
2836template< typename MT1 // Type of the adapted matrix
2837 , bool SO1 // Storage order of the adapted matrix
2838 , bool DF // Density flag
2839 , typename MT2 // Type of the right-hand side matrix
2840 , bool SO2 > // Storage order of the right-hand side matrix
2841inline bool tryBitandAssign( const UniUpperMatrix<MT1,SO1,DF>& lhs,
2842 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
2843{
2845
2846 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2847 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2848 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
2849 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
2850
2851 MAYBE_UNUSED( lhs );
2852
2853 const size_t M( (*rhs).rows() );
2854 const size_t N( (*rhs).columns() );
2855
2856 if( ( column >= row + M ) || ( row >= column + N ) )
2857 return true;
2858
2859 size_t i( row < column ? column - row : 0UL );
2860 size_t j( column < row ? row - column : 0UL );
2861
2862 for( ; i<M && j<N; ++i, ++j )
2863 {
2864 if( !( ElementType_t<MT1>(1) & (*rhs)(i,j) ) )
2865 return false;
2866 }
2867
2868 return true;
2869}
2871//*************************************************************************************************
2872
2873
2874//*************************************************************************************************
2891template< typename MT // Type of the adapted matrix
2892 , bool SO // Storage order of the adapted matrix
2893 , bool DF // Density flag
2894 , typename VT // Type of the right-hand side vector
2895 , bool TF > // Transpose flag of the right-hand side vector
2896inline bool tryBitorAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
2897 const Vector<VT,TF>& rhs, size_t row, size_t column )
2898{
2899 return tryAssign( lhs, *rhs, row, column );
2900}
2902//*************************************************************************************************
2903
2904
2905//*************************************************************************************************
2922template< typename MT // Type of the adapted matrix
2923 , bool SO // Storage order of the adapted matrix
2924 , bool DF // Density flag
2925 , typename VT // Type of the right-hand side vector
2926 , bool TF > // Transpose flag of the right-hand side vector
2927inline bool tryBitorAssign( const UniUpperMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
2928 ptrdiff_t band, size_t row, size_t column )
2929{
2930 return tryAssign( lhs, *rhs, band, row, column );
2931}
2933//*************************************************************************************************
2934
2935
2936//*************************************************************************************************
2953template< typename MT1 // Type of the adapted matrix
2954 , bool SO1 // Storage order of the adapted matrix
2955 , bool DF // Density flag
2956 , typename MT2 // Type of the right-hand side matrix
2957 , bool SO2 > // Storage order of the right-hand side matrix
2958inline bool tryBitorAssign( const UniUpperMatrix<MT1,SO1,DF>& lhs,
2959 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
2960{
2961 return tryAssign( lhs, *rhs, row, column );
2962}
2964//*************************************************************************************************
2965
2966
2967//*************************************************************************************************
2984template< typename MT // Type of the adapted matrix
2985 , bool SO // Storage order of the adapted matrix
2986 , bool DF // Density flag
2987 , typename VT // Type of the right-hand side vector
2988 , bool TF > // Transpose flag of the right-hand side vector
2989inline bool tryBitxorAssign( const UniUpperMatrix<MT,SO,DF>& lhs,
2990 const Vector<VT,TF>& rhs, size_t row, size_t column )
2991{
2992 return tryAddAssign( lhs, *rhs, row, column );
2993}
2995//*************************************************************************************************
2996
2997
2998//*************************************************************************************************
3015template< typename MT // Type of the adapted matrix
3016 , bool SO // Storage order of the adapted matrix
3017 , bool DF // Density flag
3018 , typename VT // Type of the right-hand side vector
3019 , bool TF > // Transpose flag of the right-hand side vector
3020inline bool tryBitxorAssign( const UniUpperMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
3021 ptrdiff_t band, size_t row, size_t column )
3022{
3023 return tryAddAssign( lhs, *rhs, band, row, column );
3024}
3026//*************************************************************************************************
3027
3028
3029//*************************************************************************************************
3046template< typename MT1 // Type of the adapted matrix
3047 , bool SO1 // Storage order of the adapted matrix
3048 , bool DF // Density flag
3049 , typename MT2 // Type of the right-hand side matrix
3050 , bool SO2 > // Storage order of the right-hand side matrix
3051inline bool tryBitxorAssign( const UniUpperMatrix<MT1,SO1,DF>& lhs,
3052 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3053{
3054 return tryAddAssign( lhs, *rhs, row, column );
3055}
3057//*************************************************************************************************
3058
3059
3060//*************************************************************************************************
3074template< typename MT // Type of the adapted matrix
3075 , bool SO // Storage order of the adapted matrix
3076 , bool DF > // Density flag
3077inline MT& derestrict( UniUpperMatrix<MT,SO,DF>& m )
3078{
3079 return m.matrix_;
3080}
3082//*************************************************************************************************
3083
3084
3085
3086
3087//=================================================================================================
3088//
3089// SIZE SPECIALIZATIONS
3090//
3091//=================================================================================================
3092
3093//*************************************************************************************************
3095template< typename MT, bool SO, bool DF >
3096struct Size< UniUpperMatrix<MT,SO,DF>, 0UL >
3097 : public Size<MT,0UL>
3098{};
3099
3100template< typename MT, bool SO, bool DF >
3101struct Size< UniUpperMatrix<MT,SO,DF>, 1UL >
3102 : public Size<MT,1UL>
3103{};
3105//*************************************************************************************************
3106
3107
3108
3109
3110//=================================================================================================
3111//
3112// MAXSIZE SPECIALIZATIONS
3113//
3114//=================================================================================================
3115
3116//*************************************************************************************************
3118template< typename MT, bool SO, bool DF >
3119struct MaxSize< UniUpperMatrix<MT,SO,DF>, 0UL >
3120 : public MaxSize<MT,0UL>
3121{};
3122
3123template< typename MT, bool SO, bool DF >
3124struct MaxSize< UniUpperMatrix<MT,SO,DF>, 1UL >
3125 : public MaxSize<MT,1UL>
3126{};
3128//*************************************************************************************************
3129
3130
3131
3132
3133//=================================================================================================
3134//
3135// ISSQUARE SPECIALIZATIONS
3136//
3137//=================================================================================================
3138
3139//*************************************************************************************************
3141template< typename MT, bool SO, bool DF >
3142struct IsSquare< UniUpperMatrix<MT,SO,DF> >
3143 : public TrueType
3144{};
3146//*************************************************************************************************
3147
3148
3149
3150
3151//=================================================================================================
3152//
3153// ISUNIUPPER SPECIALIZATIONS
3154//
3155//=================================================================================================
3156
3157//*************************************************************************************************
3159template< typename MT, bool SO, bool DF >
3160struct IsUniUpper< UniUpperMatrix<MT,SO,DF> >
3161 : public TrueType
3162{};
3164//*************************************************************************************************
3165
3166
3167
3168
3169//=================================================================================================
3170//
3171// ISADAPTOR SPECIALIZATIONS
3172//
3173//=================================================================================================
3174
3175//*************************************************************************************************
3177template< typename MT, bool SO, bool DF >
3178struct IsAdaptor< UniUpperMatrix<MT,SO,DF> >
3179 : public TrueType
3180{};
3182//*************************************************************************************************
3183
3184
3185
3186
3187//=================================================================================================
3188//
3189// ISRESTRICTED SPECIALIZATIONS
3190//
3191//=================================================================================================
3192
3193//*************************************************************************************************
3195template< typename MT, bool SO, bool DF >
3196struct IsRestricted< UniUpperMatrix<MT,SO,DF> >
3197 : public TrueType
3198{};
3200//*************************************************************************************************
3201
3202
3203
3204
3205//=================================================================================================
3206//
3207// HASCONSTDATAACCESS SPECIALIZATIONS
3208//
3209//=================================================================================================
3210
3211//*************************************************************************************************
3213template< typename MT, bool SO >
3214struct HasConstDataAccess< UniUpperMatrix<MT,SO,true> >
3215 : public TrueType
3216{};
3218//*************************************************************************************************
3219
3220
3221
3222
3223//=================================================================================================
3224//
3225// ISALIGNED SPECIALIZATIONS
3226//
3227//=================================================================================================
3228
3229//*************************************************************************************************
3231template< typename MT, bool SO, bool DF >
3232struct IsAligned< UniUpperMatrix<MT,SO,DF> >
3233 : public IsAligned<MT>
3234{};
3236//*************************************************************************************************
3237
3238
3239
3240
3241//=================================================================================================
3242//
3243// ISCONTIGUOUS SPECIALIZATIONS
3244//
3245//=================================================================================================
3246
3247//*************************************************************************************************
3249template< typename MT, bool SO, bool DF >
3250struct IsContiguous< UniUpperMatrix<MT,SO,DF> >
3251 : public IsContiguous<MT>
3252{};
3254//*************************************************************************************************
3255
3256
3257
3258
3259//=================================================================================================
3260//
3261// ISPADDED SPECIALIZATIONS
3262//
3263//=================================================================================================
3264
3265//*************************************************************************************************
3267template< typename MT, bool SO, bool DF >
3268struct IsPadded< UniUpperMatrix<MT,SO,DF> >
3269 : public IsPadded<MT>
3270{};
3272//*************************************************************************************************
3273
3274
3275
3276
3277//=================================================================================================
3278//
3279// REMOVEADAPTOR SPECIALIZATIONS
3280//
3281//=================================================================================================
3282
3283//*************************************************************************************************
3285template< typename MT, bool SO, bool DF >
3286struct RemoveAdaptor< UniUpperMatrix<MT,SO,DF> >
3287{
3288 using Type = MT;
3289};
3291//*************************************************************************************************
3292
3293
3294
3295
3296//=================================================================================================
3297//
3298// ADDTRAIT SPECIALIZATIONS
3299//
3300//=================================================================================================
3301
3302//*************************************************************************************************
3304template< typename T1, typename T2 >
3305struct AddTraitEval1< T1, T2
3306 , EnableIf_t< IsMatrix_v<T1> &&
3307 IsMatrix_v<T2> &&
3308 ( ( IsUniUpper_v<T1> && IsStrictlyUpper_v<T2> &&
3309 !( IsUniLower_v<T1> && IsStrictlyLower_v<T2> ) ) ||
3310 ( IsStrictlyUpper_v<T1> && IsUniUpper_v<T2> &&
3311 !( IsStrictlyLower_v<T1> && IsUniLower_v<T2> ) ) ) &&
3312 !( IsZero_v<T1> || IsZero_v<T2> ) > >
3313{
3314 using Type = UniUpperMatrix< typename AddTraitEval2<T1,T2>::Type >;
3315};
3317//*************************************************************************************************
3318
3319
3320
3321
3322//=================================================================================================
3323//
3324// SUBTRAIT SPECIALIZATIONS
3325//
3326//=================================================================================================
3327
3328//*************************************************************************************************
3330template< typename T1, typename T2 >
3331struct SubTraitEval1< T1, T2
3332 , EnableIf_t< IsMatrix_v<T1> &&
3333 IsMatrix_v<T2> &&
3334 ( IsUniUpper_v<T1> && IsStrictlyUpper_v<T2> &&
3335 !( IsUniLower_v<T1> && IsStrictlyLower_v<T2> ) ) &&
3336 !( IsZero_v<T1> || IsZero_v<T2> ) > >
3337{
3338 using Type = UniUpperMatrix< typename SubTraitEval2<T1,T2>::Type >;
3339};
3341//*************************************************************************************************
3342
3343
3344
3345
3346//=================================================================================================
3347//
3348// SCHURTRAIT SPECIALIZATIONS
3349//
3350//=================================================================================================
3351
3352//*************************************************************************************************
3354template< typename T1, typename T2 >
3355struct SchurTraitEval1< T1, T2
3356 , EnableIf_t< IsMatrix_v<T1> &&
3357 IsMatrix_v<T2> &&
3358 ( IsUniUpper_v<T1> && IsUniUpper_v<T2> ) &&
3359 !( IsDiagonal_v<T1> || IsDiagonal_v<T2> ) &&
3360 !( IsZero_v<T1> || IsZero_v<T2> ) > >
3361{
3362 using Type = UniUpperMatrix< typename SchurTraitEval2<T1,T2>::Type >;
3363};
3365//*************************************************************************************************
3366
3367
3368
3369
3370//=================================================================================================
3371//
3372// MULTTRAIT SPECIALIZATIONS
3373//
3374//=================================================================================================
3375
3376//*************************************************************************************************
3378template< typename T1, typename T2 >
3379struct MultTraitEval1< T1, T2
3380 , EnableIf_t< IsMatrix_v<T1> &&
3381 IsMatrix_v<T2> &&
3382 ( IsUniUpper_v<T1> && IsUniUpper_v<T2> ) &&
3383 !( IsIdentity_v<T1> || IsIdentity_v<T2> ) > >
3384{
3385 using Type = UniUpperMatrix< typename MultTraitEval2<T1,T2>::Type >;
3386};
3388//*************************************************************************************************
3389
3390
3391
3392
3393//=================================================================================================
3394//
3395// KRONTRAIT SPECIALIZATIONS
3396//
3397//=================================================================================================
3398
3399//*************************************************************************************************
3401template< typename T1, typename T2 >
3402struct KronTraitEval1< T1, T2
3403 , EnableIf_t< IsMatrix_v<T1> &&
3404 IsMatrix_v<T2> &&
3405 ( IsUniUpper_v<T1> && IsUniUpper_v<T2> ) &&
3406 !( IsIdentity_v<T1> && IsIdentity_v<T2> ) &&
3407 !( IsZero_v<T1> || IsZero_v<T2> ) > >
3408{
3409 using Type = UniUpperMatrix< typename KronTraitEval2<T1,T2>::Type >;
3410};
3412//*************************************************************************************************
3413
3414
3415
3416
3417//=================================================================================================
3418//
3419// MAPTRAIT SPECIALIZATIONS
3420//
3421//=================================================================================================
3422
3423//*************************************************************************************************
3425template< typename T, typename OP >
3426struct UnaryMapTraitEval1< T, OP
3427 , EnableIf_t< YieldsUniUpper_v<OP,T> &&
3428 !YieldsIdentity_v<OP,T> > >
3429{
3430 using Type = UniUpperMatrix< typename UnaryMapTraitEval2<T,OP>::Type, StorageOrder_v<T> >;
3431};
3433//*************************************************************************************************
3434
3435
3436//*************************************************************************************************
3438template< typename T1, typename T2, typename OP >
3439struct BinaryMapTraitEval1< T1, T2, OP
3440 , EnableIf_t< YieldsUniUpper_v<OP,T1,T2> &&
3441 !YieldsIdentity_v<OP,T1,T2> > >
3442{
3443 using Type = UniUpperMatrix< typename BinaryMapTraitEval2<T1,T2,OP>::Type >;
3444};
3446//*************************************************************************************************
3447
3448
3449
3450
3451//=================================================================================================
3452//
3453// DECLSYMTRAIT SPECIALIZATIONS
3454//
3455//=================================================================================================
3456
3457//*************************************************************************************************
3459template< typename MT, bool SO, bool DF >
3460struct DeclSymTrait< UniUpperMatrix<MT,SO,DF> >
3461{
3462 using Type = IdentityMatrix< ElementType_t<MT>, SO >;
3463};
3465//*************************************************************************************************
3466
3467
3468
3469
3470//=================================================================================================
3471//
3472// DECLHERMTRAIT SPECIALIZATIONS
3473//
3474//=================================================================================================
3475
3476//*************************************************************************************************
3478template< typename MT, bool SO, bool DF >
3479struct DeclHermTrait< UniUpperMatrix<MT,SO,DF> >
3480{
3481 using Type = IdentityMatrix< ElementType_t<MT>, SO >;
3482};
3484//*************************************************************************************************
3485
3486
3487
3488
3489//=================================================================================================
3490//
3491// DECLLOWTRAIT SPECIALIZATIONS
3492//
3493//=================================================================================================
3494
3495//*************************************************************************************************
3497template< typename MT, bool SO, bool DF >
3498struct DeclLowTrait< UniUpperMatrix<MT,SO,DF> >
3499{
3500 using Type = IdentityMatrix< ElementType_t<MT>, SO >;
3501};
3503//*************************************************************************************************
3504
3505
3506
3507
3508//=================================================================================================
3509//
3510// DECLUNILOWTRAIT SPECIALIZATIONS
3511//
3512//=================================================================================================
3513
3514//*************************************************************************************************
3516template< typename MT, bool SO, bool DF >
3517struct DeclUniLowTrait< UniUpperMatrix<MT,SO,DF> >
3518{
3519 using Type = IdentityMatrix< ElementType_t<MT>, SO >;
3520};
3522//*************************************************************************************************
3523
3524
3525
3526
3527//=================================================================================================
3528//
3529// DECLSTRLOWTRAIT SPECIALIZATIONS
3530//
3531//=================================================================================================
3532
3533//*************************************************************************************************
3535template< typename MT, bool SO, bool DF >
3536struct DeclStrLowTrait< UniUpperMatrix<MT,SO,DF> >
3537{
3538 using Type = INVALID_TYPE;
3539};
3541//*************************************************************************************************
3542
3543
3544
3545
3546//=================================================================================================
3547//
3548// DECLUPPTRAIT SPECIALIZATIONS
3549//
3550//=================================================================================================
3551
3552//*************************************************************************************************
3554template< typename MT, bool SO, bool DF >
3555struct DeclUppTrait< UniUpperMatrix<MT,SO,DF> >
3556{
3557 using Type = UniUpperMatrix<MT,SO,DF>;
3558};
3560//*************************************************************************************************
3561
3562
3563
3564
3565//=================================================================================================
3566//
3567// DECLUNIUPPTRAIT SPECIALIZATIONS
3568//
3569//=================================================================================================
3570
3571//*************************************************************************************************
3573template< typename MT, bool SO, bool DF >
3574struct DeclUniUppTrait< UniUpperMatrix<MT,SO,DF> >
3575{
3576 using Type = UniUpperMatrix<MT,SO,DF>;
3577};
3579//*************************************************************************************************
3580
3581
3582
3583
3584//=================================================================================================
3585//
3586// DECLSTRUPPTRAIT SPECIALIZATIONS
3587//
3588//=================================================================================================
3589
3590//*************************************************************************************************
3592template< typename MT, bool SO, bool DF >
3593struct DeclStrUppTrait< UniUpperMatrix<MT,SO,DF> >
3594{
3595 using Type = INVALID_TYPE;
3596};
3598//*************************************************************************************************
3599
3600
3601
3602
3603//=================================================================================================
3604//
3605// DECLDIAGTRAIT SPECIALIZATIONS
3606//
3607//=================================================================================================
3608
3609//*************************************************************************************************
3611template< typename MT, bool SO, bool DF >
3612struct DeclDiagTrait< UniUpperMatrix<MT,SO,DF> >
3613{
3614 using Type = IdentityMatrix< ElementType_t<MT>, SO >;
3615};
3617//*************************************************************************************************
3618
3619
3620
3621
3622//=================================================================================================
3623//
3624// HIGHTYPE SPECIALIZATIONS
3625//
3626//=================================================================================================
3627
3628//*************************************************************************************************
3630template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
3631struct HighType< UniUpperMatrix<MT1,SO1,DF1>, UniUpperMatrix<MT2,SO2,DF2> >
3632{
3633 using Type = UniUpperMatrix< typename HighType<MT1,MT2>::Type >;
3634};
3636//*************************************************************************************************
3637
3638
3639
3640
3641//=================================================================================================
3642//
3643// LOWTYPE SPECIALIZATIONS
3644//
3645//=================================================================================================
3646
3647//*************************************************************************************************
3649template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
3650struct LowType< UniUpperMatrix<MT1,SO1,DF1>, UniUpperMatrix<MT2,SO2,DF2> >
3651{
3652 using Type = UniUpperMatrix< typename LowType<MT1,MT2>::Type >;
3653};
3655//*************************************************************************************************
3656
3657
3658
3659
3660//=================================================================================================
3661//
3662// SUBMATRIXTRAIT SPECIALIZATIONS
3663//
3664//=================================================================================================
3665
3666//*************************************************************************************************
3668template< typename MT, size_t I, size_t N >
3669struct SubmatrixTraitEval1< MT, I, I, N, N
3670 , EnableIf_t< I != inf && N != inf &&
3671 IsUniUpper_v<MT> &&
3672 !IsIdentity_v<MT> > >
3673{
3674 using Type = UniUpperMatrix< typename SubmatrixTraitEval2<MT,I,I,N,N>::Type >;
3675};
3677//*************************************************************************************************
3678
3679} // namespace blaze
3680
3681#endif
Header file for the addition trait.
Header file for auxiliary alias declarations.
Header file for run time assertion macros.
Constraint on the data type.
Header file for the decldiag trait.
Header file for the declherm trait.
Header file for the decllow trait.
Header file for the declstrlow trait.
Header file for the declstrupp trait.
Header file for the declsym trait.
Header file for the declunilow trait.
Header file for the decluniupp trait.
Header file for the declupp trait.
Header file for the EnableIf class template.
Header file for the HasConstDataAccess type trait.
Constraint on the data type.
Header file for the HighType type trait.
Header file for the IntegralConstant class template.
Utility type for generic codes.
Header file for the dense matrix inversion flags.
Header file for the IsAdaptor type trait.
Header file for the IsAligned type trait.
Header file for the IsContiguous type trait.
Header file for the isDefault shim.
Header file for the IsDiagonal type trait.
Header file for the IsIdentity type trait.
Header file for the IsMatrix type trait.
Header file for the isOne shim.
Header file for the IsPadded type trait.
Header file for the IsRestricted type trait.
Header file for the IsSquare type trait.
Header file for the IsStrictlyLower type trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsUniLower type trait.
Header file for the IsUniUpper type trait.
Header file for the Kron product trait.
Header file for the LowType type trait.
Constraint on the data type.
Header file for the map trait.
Header file for the MAYBE_UNUSED function template.
Header file for the multiplication trait.
Header file for the relaxation flag enumeration.
Header file for the RemoveAdaptor type trait.
Header file for the Schur product trait.
Header file for the subtraction trait.
Header file for the submatrix trait.
Constraint on the data type.
Constraint on the data type.
Constraint on the data type.
Header file for the YieldsIdentity type trait.
Header file for the YieldsUniUpper type trait.
Header file for the implementation of the base template of the UniUpperMatrix.
UniUpperMatrix specialization for dense matrices.
UniUpperMatrix specialization for sparse matrices.
Pointer difference type of the Blaze library.
Constraint on the data type.
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
void lu(const DenseMatrix< MT1, SO1 > &A, DenseMatrix< MT2, SO1 > &L, DenseMatrix< MT3, SO1 > &U, Matrix< MT4, SO2 > &P)
LU decomposition of the given dense matrix.
Definition: LU.h:222
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
bool isIdentity(const DenseMatrix< MT, SO > &dm)
Checks if the given dense matrix is an identity matrix.
Definition: DenseMatrix.h:2561
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
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition: DiagonalMatrix.h:169
void invert(const HermitianProxy< MT > &proxy)
In-place inversion of the represented element.
Definition: HermitianProxy.h:693
#define BLAZE_CONSTRAINT_MUST_NOT_BE_SYMMETRIC_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Symmetric.h:79
#define BLAZE_CONSTRAINT_MUST_BE_BLAS_COMPATIBLE_TYPE(T)
Constraint on the data type.
Definition: BLASCompatible.h:61
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.
Definition: RequiresEvaluation.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_LOWER_MATRIX_TYPE(T)
Constraint on the data type.
Definition: Lower.h:81
#define BLAZE_CONSTRAINT_MUST_NOT_BE_UNITRIANGULAR_MATRIX_TYPE(T)
Constraint on the data type.
Definition: UniTriangular.h:81
constexpr ptrdiff_t DefaultSize_v
Default size of the Size type trait.
Definition: Size.h:72
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.
Definition: IsMatrix.h:124
constexpr bool YieldsUniUpper_v
Auxiliary variable template for the YieldsUniUpper type trait.
Definition: YieldsUniUpper.h:124
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
constexpr Infinity inf
Global Infinity instance.
Definition: Infinity.h:1080
bool isOne(const Proxy< PT, RT > &proxy)
Returns whether the represented element is 1.
Definition: Proxy.h:2337
InversionFlag
Inversion flag.
Definition: InversionFlag.h:102
@ asUniLower
Flag for the inversion of a lower unitriangular matrix.
Definition: InversionFlag.h:112
@ asLower
Flag for the inversion of a lower triangular matrix.
Definition: InversionFlag.h:111
@ asUpper
Flag for the inversion of a upper triangular matrix.
Definition: InversionFlag.h:113
@ asUniUpper
Flag for the inversion of a upper unitriangular matrix.
Definition: InversionFlag.h:114
@ asDiagonal
Flag for the inversion of a diagonal matrix.
Definition: InversionFlag.h:115
@ byLU
Flag for the LU-based matrix inversion.
Definition: InversionFlag.h:103
@ asGeneral
Flag for the inversion of a general matrix (same as byLU).
Definition: InversionFlag.h:108
constexpr void reset(Matrix< MT, SO > &matrix)
Resetting the given matrix.
Definition: Matrix.h:806
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
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_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
BoolConstant< true > TrueType
Type traits base class.
Definition: IntegralConstant.h:132
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.
Definition: EnableIf.h:138
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
Header file for all forward declarations of the math module.
Header file for the Size type trait.
Header file for the StorageOrder type trait.
Header file for the IsZero type trait.
Header file for the generic min algorithm.