Blaze 3.9
UniLowerMatrix.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_ADAPTORS_UNILOWERMATRIX_H_
36#define _BLAZE_MATH_ADAPTORS_UNILOWERMATRIX_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <blaze/math/Aliases.h>
54#include <blaze/math/Forward.h>
99#include <blaze/util/Assert.h>
100#include <blaze/util/EnableIf.h>
104
105
106namespace blaze {
107
108//=================================================================================================
109//
110// UNILOWERMATRIX OPERATORS
111//
112//=================================================================================================
113
114//*************************************************************************************************
117template< RelaxationFlag RF, typename MT, bool SO, bool DF >
118bool isDefault( const UniLowerMatrix<MT,SO,DF>& m );
119
120template< typename MT, bool SO, bool DF >
121bool isIntact( const UniLowerMatrix<MT,SO,DF>& m );
122
123template< typename MT, bool SO, bool DF >
124void swap( UniLowerMatrix<MT,SO,DF>& a, UniLowerMatrix<MT,SO,DF>& b ) noexcept;
126//*************************************************************************************************
127
128
129//*************************************************************************************************
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 UniLowerMatrix<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 UniLowerMatrix<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( UniLowerMatrix<MT,SO,DF>& a, UniLowerMatrix<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( UniLowerMatrix<MT,SO,true>& m )
244{
246
247 if( IF == asUpper || IF == asUniUpper ) {
248 BLAZE_INTERNAL_ASSERT( isIdentity( m ), "Violation of preconditions detected" );
249 return;
250 }
251
252 constexpr InversionFlag flag( ( IF == byLU || IF == asGeneral || IF == asLower || IF == asUniLower )
253 ? ( asUniLower )
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 UniLowerMatrix<MT1,SO1,true>& A, DenseMatrix<MT2,SO1>& L,
285 DenseMatrix<MT3,SO1>& U, Matrix<MT4,SO2>& P )
286{
288
293
298
299 using ET3 = ElementType_t<MT3>;
300 using ET4 = ElementType_t<MT4>;
301
302 const size_t n( (*A).rows() );
303
304 decltype(auto) U2( derestrict( *U ) );
305
306 (*L) = A;
307
308 resize( *U, n, n );
309 reset( U2 );
310
311 resize( *P, n, n );
312 reset( *P );
313
314 for( size_t i=0UL; i<n; ++i ) {
315 U2(i,i) = ET3(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 UniLowerMatrix<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 UniLowerMatrix<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 ( row >= column + n ) ||
393 ( ( column >= row + m ) && 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 UniLowerMatrix<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 UniLowerMatrix<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 ( row >= column + n ) ||
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 UniLowerMatrix<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 UniLowerMatrix<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 UniLowerMatrix<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 UniLowerMatrix<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 ( row >= column + n ) ||
601 ( column >= row + m ) ||
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 UniLowerMatrix<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 UniLowerMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
660{
661 return tryMult( mat, row, column, m, n, value );
662}
664//*************************************************************************************************
665
666
667//*************************************************************************************************
683template< typename MT // Type of the adapted matrix
684 , bool SO // Storage order of the adapted matrix
685 , bool DF > // Density flag
686inline bool tryShift( const UniLowerMatrix<MT,SO,DF>& mat, size_t i, size_t j, int count )
687{
688 BLAZE_INTERNAL_ASSERT( i < (*mat).rows(), "Invalid row access index" );
689 BLAZE_INTERNAL_ASSERT( j < (*mat).columns(), "Invalid column access index" );
690
691 MAYBE_UNUSED( mat );
692
693 return ( i != j || isDefault( count ) );
694}
696//*************************************************************************************************
697
698
699//*************************************************************************************************
717template< typename MT // Type of the adapted matrix
718 , bool SO // Storage order of the adapted matrix
719 , bool DF > // Density flag
721 tryShift( const UniLowerMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, int count )
722{
723 BLAZE_INTERNAL_ASSERT( row <= (*mat).rows(), "Invalid row access index" );
724 BLAZE_INTERNAL_ASSERT( column <= (*mat).columns(), "Invalid column access index" );
725 BLAZE_INTERNAL_ASSERT( row + m <= (*mat).rows(), "Invalid number of rows" );
726 BLAZE_INTERNAL_ASSERT( column + n <= (*mat).columns(), "Invalid number of columns" );
727
728 MAYBE_UNUSED( mat );
729
730 return ( m == 0UL ) ||
731 ( n == 0UL ) ||
732 ( row >= column + n ) ||
733 ( column >= row + m ) ||
734 isDefault( count );
735}
737//*************************************************************************************************
738
739
740//*************************************************************************************************
756template< typename MT // Type of the adapted matrix
757 , bool SO // Storage order of the adapted matrix
758 , bool DF // Density flag
759 , typename ET > // Type of the element
760inline bool tryBitand( const UniLowerMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
761{
762 BLAZE_INTERNAL_ASSERT( i < (*mat).rows(), "Invalid row access index" );
763 BLAZE_INTERNAL_ASSERT( j < (*mat).columns(), "Invalid column access index" );
764
765 MAYBE_UNUSED( mat );
766
767 return ( i != j ) || ( ElementType_t<MT>(1) & value );
768}
770//*************************************************************************************************
771
772
773//*************************************************************************************************
791template< typename MT // Type of the adapted matrix
792 , bool SO // Storage order of the adapted matrix
793 , bool DF // Density flag
794 , typename ET > // Type of the element
796 tryBitand( const UniLowerMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
797{
798 BLAZE_INTERNAL_ASSERT( row <= (*mat).rows(), "Invalid row access index" );
799 BLAZE_INTERNAL_ASSERT( column <= (*mat).columns(), "Invalid column access index" );
800 BLAZE_INTERNAL_ASSERT( row + m <= (*mat).rows(), "Invalid number of rows" );
801 BLAZE_INTERNAL_ASSERT( column + n <= (*mat).columns(), "Invalid number of columns" );
802
803 MAYBE_UNUSED( mat );
804
805 return ( m == 0UL ) ||
806 ( n == 0UL ) ||
807 ( row >= column + n ) ||
808 ( column >= row + m ) ||
809 ( ElementType_t<MT>(1) & value );
810}
812//*************************************************************************************************
813
814
815//*************************************************************************************************
831template< typename MT // Type of the adapted matrix
832 , bool SO // Storage order of the adapted matrix
833 , bool DF // Density flag
834 , typename ET > // Type of the element
835inline bool tryBitor( const UniLowerMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
836{
837 return trySet( mat, i, j, value );
838}
840//*************************************************************************************************
841
842
843//*************************************************************************************************
861template< typename MT // Type of the adapted matrix
862 , bool SO // Storage order of the adapted matrix
863 , bool DF // Density flag
864 , typename ET > // Type of the element
866 tryBitor( const UniLowerMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
867{
868 return trySet( mat, row, column, m, n, value );
869}
871//*************************************************************************************************
872
873
874//*************************************************************************************************
890template< typename MT // Type of the adapted matrix
891 , bool SO // Storage order of the adapted matrix
892 , bool DF // Density flag
893 , typename ET > // Type of the element
894inline bool tryBitxor( const UniLowerMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
895{
896 return tryAdd( mat, i, j, value );
897}
899//*************************************************************************************************
900
901
902//*************************************************************************************************
920template< typename MT // Type of the adapted matrix
921 , bool SO // Storage order of the adapted matrix
922 , bool DF // Density flag
923 , typename ET > // Type of the element
925 tryBitxor( const UniLowerMatrix<MT,SO,DF>& mat, size_t row, size_t column, size_t m, size_t n, const ET& value )
926{
927 return tryAdd( mat, row, column, m, n, value );
928}
930//*************************************************************************************************
931
932
933//*************************************************************************************************
949template< typename MT // Type of the adapted matrix
950 , bool SO // Storage order of the adapted matrix
951 , bool DF // Density flag
952 , typename VT > // Type of the right-hand side dense vector
953inline bool tryAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
954 const DenseVector<VT,false>& rhs, size_t row, size_t column )
955{
957
958 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
959 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
960 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
961
962 MAYBE_UNUSED( lhs );
963
964 if( column < row )
965 return true;
966
967 const bool containsDiagonal( column < row + (*rhs).size() );
968 const size_t iend( min( column - row, (*rhs).size() ) );
969
970 for( size_t i=0UL; i<iend; ++i ) {
971 if( !isDefault( (*rhs)[i] ) )
972 return false;
973 }
974
975 if( containsDiagonal && !isOne( (*rhs)[iend] ) )
976 return false;
977
978 return true;
979}
981//*************************************************************************************************
982
983
984//*************************************************************************************************
1000template< typename MT // Type of the adapted matrix
1001 , bool SO // Storage order of the adapted matrix
1002 , bool DF // Density flag
1003 , typename VT > // Type of the right-hand side dense vector
1004inline bool tryAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
1005 const DenseVector<VT,true>& rhs, size_t row, size_t column )
1006{
1008
1009 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1010 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1011 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1012
1013 MAYBE_UNUSED( lhs );
1014
1015 if( row >= column + (*rhs).size() )
1016 return true;
1017
1018 const bool containsDiagonal( row >= column );
1019 const size_t ibegin( ( !containsDiagonal )?( 0UL ):( row - column + 1UL ) );
1020
1021 if( containsDiagonal && !isOne( (*rhs)[row-column] ) )
1022 return false;
1023
1024 for( size_t i=ibegin; i<(*rhs).size(); ++i ) {
1025 if( !isDefault( (*rhs)[i] ) )
1026 return false;
1027 }
1028
1029 return true;
1030}
1032//*************************************************************************************************
1033
1034
1035//*************************************************************************************************
1053template< typename MT // Type of the adapted matrix
1054 , bool SO // Storage order of the adapted matrix
1055 , bool DF // Density flag
1056 , typename VT // Type of the right-hand side dense vector
1057 , bool TF > // Transpose flag of the right-hand side dense vector
1058inline bool tryAssign( const UniLowerMatrix<MT,SO,DF>& lhs, const DenseVector<VT,TF>& rhs,
1059 ptrdiff_t band, size_t row, size_t column )
1060{
1062
1063 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1064 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1065 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
1066 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1067
1068 MAYBE_UNUSED( lhs, row, column );
1069
1070 if( band == 0L ) {
1071 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
1072 if( !isOne( (*rhs)[i] ) )
1073 return false;
1074 }
1075 }
1076 else if( band > 0L ) {
1077 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
1078 if( !isDefault( (*rhs)[i] ) )
1079 return false;
1080 }
1081 }
1082
1083 return true;
1084}
1086//*************************************************************************************************
1087
1088
1089//*************************************************************************************************
1105template< typename MT // Type of the adapted matrix
1106 , bool SO // Storage order of the adapted matrix
1107 , bool DF // Density flag
1108 , typename VT > // Type of the right-hand side sparse vector
1109inline bool tryAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
1110 const SparseVector<VT,false>& rhs, size_t row, size_t column )
1111{
1113
1114 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1115 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1116 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
1117
1118 MAYBE_UNUSED( lhs );
1119
1120 if( column < row )
1121 return true;
1122
1123 const bool containsDiagonal( column < row + (*rhs).size() );
1124 const size_t index( column - row );
1125 const auto last( (*rhs).lowerBound( index ) );
1126
1127 if( containsDiagonal ) {
1128 if( last == (*rhs).end() || last->index() != index || !isOne( last->value() ) )
1129 return false;
1130 }
1131
1132 for( auto element=(*rhs).begin(); element!=last; ++element ) {
1133 if( !isDefault( element->value() ) )
1134 return false;
1135 }
1136
1137 return true;
1138}
1140//*************************************************************************************************
1141
1142
1143//*************************************************************************************************
1159template< typename MT // Type of the adapted matrix
1160 , bool SO // Storage order of the adapted matrix
1161 , bool DF // Density flag
1162 , typename VT > // Type of the right-hand side sparse vector
1163inline bool tryAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
1164 const SparseVector<VT,true>& rhs, size_t row, size_t column )
1165{
1167
1168 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1169 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1170 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1171
1172 MAYBE_UNUSED( lhs );
1173
1174 if( row >= column + (*rhs).size() )
1175 return true;
1176
1177 const bool containsDiagonal( row >= column );
1178 const size_t index( ( containsDiagonal )?( row - column ):( 0UL ) );
1179 const auto last( (*rhs).end() );
1180 auto element( (*rhs).lowerBound( index ) );
1181
1182 if( containsDiagonal ) {
1183 if( element == last || element->index() != index || !isOne( element->value() ) )
1184 return false;
1185 ++element;
1186 }
1187
1188 for( ; element!=last; ++element ) {
1189 if( !isDefault( element->value() ) )
1190 return false;
1191 }
1192
1193 return true;
1194}
1196//*************************************************************************************************
1197
1198
1199//*************************************************************************************************
1217template< typename MT // Type of the adapted matrix
1218 , bool SO // Storage order of the adapted matrix
1219 , bool DF // Density flag
1220 , typename VT // Type of the right-hand side sparse vector
1221 , bool TF > // Transpose flag of the right-hand side sparse vector
1222inline bool tryAssign( const UniLowerMatrix<MT,SO,DF>& lhs, const SparseVector<VT,TF>& rhs,
1223 ptrdiff_t band, size_t row, size_t column )
1224{
1226
1227 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1228 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1229 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
1230 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1231
1232 MAYBE_UNUSED( lhs, row, column );
1233
1234 if( band == 0L ) {
1235 if( (*rhs).nonZeros() != (*rhs).size() )
1236 return false;
1237 for( const auto& element : *rhs ) {
1238 if( !isOne( element.value() ) )
1239 return false;
1240 }
1241 }
1242 else if( band > 0L ) {
1243 for( const auto& element : *rhs ) {
1244 if( !isDefault( element.value() ) )
1245 return false;
1246 }
1247 }
1248
1249 return true;
1250}
1252//*************************************************************************************************
1253
1254
1255//*************************************************************************************************
1271template< typename MT1 // Type of the adapted matrix
1272 , bool SO // Storage order of the adapted matrix
1273 , bool DF // Density flag
1274 , typename MT2 > // Type of the right-hand side dense matrix
1275inline bool tryAssign( const UniLowerMatrix<MT1,SO,DF>& lhs,
1276 const DenseMatrix<MT2,false>& rhs, size_t row, size_t column )
1277{
1279
1280 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1281 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1282 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1283 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1284
1285 MAYBE_UNUSED( lhs );
1286
1287 const size_t M( (*rhs).rows() );
1288 const size_t N( (*rhs).columns() );
1289
1290 if( row >= column + N )
1291 return true;
1292
1293 const size_t iend( min( column + N - row, M ) );
1294
1295 for( size_t i=0UL; i<iend; ++i )
1296 {
1297 const bool containsDiagonal( row + i >= column );
1298
1299 if( containsDiagonal && !isOne( (*rhs)(i,row+i-column) ) )
1300 return false;
1301
1302 const size_t jbegin( ( containsDiagonal )?( row + i - column + 1UL ):( 0UL ) );
1303
1304 for( size_t j=jbegin; j<N; ++j ) {
1305 if( !isDefault( (*rhs)(i,j) ) )
1306 return false;
1307 }
1308 }
1309
1310 return true;
1311}
1313//*************************************************************************************************
1314
1315
1316//*************************************************************************************************
1332template< typename MT1 // Type of the adapted matrix
1333 , bool SO // Storage order of the adapted matrix
1334 , bool DF // Density flag
1335 , typename MT2 > // Type of the right-hand side dense matrix
1336inline bool tryAssign( const UniLowerMatrix<MT1,SO,DF>& lhs,
1337 const DenseMatrix<MT2,true>& rhs, size_t row, size_t column )
1338{
1340
1341 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1342 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1343 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1344 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1345
1346 MAYBE_UNUSED( lhs );
1347
1348 const size_t M( (*rhs).rows() );
1349 const size_t N( (*rhs).columns() );
1350
1351 if( row >= column + N )
1352 return true;
1353
1354 const size_t jbegin( ( row < column )?( 0UL ):( row - column ) );
1355
1356 for( size_t j=jbegin; j<N; ++j )
1357 {
1358 const size_t iend( min( column + j - row, M ) );
1359
1360 for( size_t i=0UL; i<iend; ++i ) {
1361 if( !isDefault( (*rhs)(i,j) ) )
1362 return false;
1363 }
1364
1365 const bool containsDiagonal( column + j < row + M );
1366
1367 if( containsDiagonal && !isOne( (*rhs)(iend,j) ) )
1368 return false;
1369 }
1370
1371 return true;
1372}
1374//*************************************************************************************************
1375
1376
1377//*************************************************************************************************
1393template< typename MT1 // Type of the adapted matrix
1394 , bool SO // Storage order of the adapted matrix
1395 , bool DF // Density flag
1396 , typename MT2 > // Type of the right-hand side sparse matrix
1397inline bool tryAssign( const UniLowerMatrix<MT1,SO,DF>& lhs,
1398 const SparseMatrix<MT2,false>& rhs, size_t row, size_t column )
1399{
1401
1402 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1403 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1404 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1405 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1406
1407 MAYBE_UNUSED( lhs );
1408
1409 const size_t M( (*rhs).rows() );
1410 const size_t N( (*rhs).columns() );
1411
1412 if( row >= column + N )
1413 return true;
1414
1415 const size_t iend( min( column + N - row, M ) );
1416
1417 for( size_t i=0UL; i<iend; ++i )
1418 {
1419 const bool containsDiagonal( row + i >= column );
1420 const size_t index( ( containsDiagonal )?( row + i - column ):( 0UL ) );
1421
1422 const auto last( (*rhs).end(i) );
1423 auto element( (*rhs).lowerBound( i, index ) );
1424
1425 if( containsDiagonal ) {
1426 if( element == last || ( element->index() != index ) || !isOne( element->value() ) )
1427 return false;
1428 ++element;
1429 }
1430
1431 for( ; element!=last; ++element ) {
1432 if( !isDefault( element->value() ) )
1433 return false;
1434 }
1435 }
1436
1437 return true;
1438}
1440//*************************************************************************************************
1441
1442
1443//*************************************************************************************************
1459template< typename MT1 // Type of the adapted matrix
1460 , bool SO // Storage order of the adapted matrix
1461 , bool DF // Density flag
1462 , typename MT2 > // Type of the right-hand side sparse matrix
1463inline bool tryAssign( const UniLowerMatrix<MT1,SO,DF>& lhs,
1464 const SparseMatrix<MT2,true>& rhs, size_t row, size_t column )
1465{
1467
1468 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1469 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1470 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1471 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1472
1473 MAYBE_UNUSED( lhs );
1474
1475 const size_t M( (*rhs).rows() );
1476 const size_t N( (*rhs).columns() );
1477
1478 if( row >= column + N )
1479 return true;
1480
1481 const size_t jbegin( ( row < column )?( 0UL ):( row - column ) );
1482
1483 for( size_t j=jbegin; j<N; ++j )
1484 {
1485 const bool containsDiagonal( column + j < row + M );
1486
1487 const size_t index( column + j - row );
1488 const auto last( (*rhs).lowerBound( min( index, M ), j ) );
1489
1490 if( containsDiagonal ) {
1491 if( last == (*rhs).end(j) || ( last->index() != index ) || !isOne( last->value() ) )
1492 return false;
1493 }
1494
1495 for( auto element=(*rhs).begin(j); element!=last; ++element ) {
1496 if( !isDefault( element->value() ) )
1497 return false;
1498 }
1499 }
1500
1501 return true;
1502}
1504//*************************************************************************************************
1505
1506
1507//*************************************************************************************************
1524template< typename MT // Type of the adapted matrix
1525 , bool SO // Storage order of the adapted matrix
1526 , bool DF // Density flag
1527 , typename VT > // Type of the right-hand side dense vector
1528inline bool tryAddAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
1529 const DenseVector<VT,false>& rhs, size_t row, size_t column )
1530{
1532
1533 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1534 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1535 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
1536
1537 MAYBE_UNUSED( lhs );
1538
1539 if( column < row )
1540 return true;
1541
1542 const size_t iend( min( column - row + 1UL, (*rhs).size() ) );
1543
1544 for( size_t i=0UL; i<iend; ++i ) {
1545 if( !isDefault( (*rhs)[i] ) )
1546 return false;
1547 }
1548
1549 return true;
1550}
1552//*************************************************************************************************
1553
1554
1555//*************************************************************************************************
1572template< typename MT // Type of the adapted matrix
1573 , bool SO // Storage order of the adapted matrix
1574 , bool DF // Density flag
1575 , typename VT > // Type of the right-hand side dense vector
1576inline bool tryAddAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
1577 const DenseVector<VT,true>& rhs, size_t row, size_t column )
1578{
1580
1581 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1582 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1583 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1584
1585 MAYBE_UNUSED( lhs );
1586
1587 const size_t ibegin( ( row <= column )?( 0UL ):( row - column ) );
1588
1589 for( size_t i=ibegin; i<(*rhs).size(); ++i ) {
1590 if( !isDefault( (*rhs)[i] ) )
1591 return false;
1592 }
1593
1594 return true;
1595}
1597//*************************************************************************************************
1598
1599
1600//*************************************************************************************************
1617template< typename MT // Type of the adapted matrix
1618 , bool SO // Storage order of the adapted matrix
1619 , bool DF // Density flag
1620 , typename VT // Type of the right-hand side dense vector
1621 , bool TF > // Transpose flag of the right-hand side dense vector
1622inline bool tryAddAssign( const UniLowerMatrix<MT,SO,DF>& lhs, const DenseVector<VT,TF>& rhs,
1623 ptrdiff_t band, size_t row, size_t column )
1624{
1626
1627 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1628 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1629 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
1630 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1631
1632 MAYBE_UNUSED( lhs, row, column );
1633
1634 if( band >= 0L ) {
1635 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
1636 if( !isDefault( (*rhs)[i] ) )
1637 return false;
1638 }
1639 }
1640
1641 return true;
1642}
1644//*************************************************************************************************
1645
1646
1647//*************************************************************************************************
1664template< typename MT // Type of the adapted matrix
1665 , bool SO // Storage order of the adapted matrix
1666 , bool DF // Density flag
1667 , typename VT > // Type of the right-hand side sparse vector
1668inline bool tryAddAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
1669 const SparseVector<VT,false>& rhs, size_t row, size_t column )
1670{
1672
1673 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1674 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1675 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
1676
1677 MAYBE_UNUSED( lhs );
1678
1679 if( column < row )
1680 return true;
1681
1682 const auto last( (*rhs).lowerBound( column - row + 1UL ) );
1683
1684 for( auto element=(*rhs).begin(); element!=last; ++element ) {
1685 if( !isDefault( element->value() ) )
1686 return false;
1687 }
1688
1689 return true;
1690}
1692//*************************************************************************************************
1693
1694
1695//*************************************************************************************************
1712template< typename MT // Type of the adapted matrix
1713 , bool SO // Storage order of the adapted matrix
1714 , bool DF // Density flag
1715 , typename VT > // Type of the right-hand side sparse vector
1716inline bool tryAddAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
1717 const SparseVector<VT,true>& rhs, size_t row, size_t column )
1718{
1720
1721 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1722 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1723 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1724
1725 MAYBE_UNUSED( lhs );
1726
1727 const auto last( (*rhs).end() );
1728 auto element( (*rhs).lowerBound( ( row <= column )?( 0UL ):( row - column ) ) );
1729
1730 for( ; element!=last; ++element ) {
1731 if( !isDefault( element->value() ) )
1732 return false;
1733 }
1734
1735 return true;
1736}
1738//*************************************************************************************************
1739
1740
1741//*************************************************************************************************
1758template< typename MT // Type of the adapted matrix
1759 , bool SO // Storage order of the adapted matrix
1760 , bool DF // Density flag
1761 , typename VT // Type of the right-hand side sparse vector
1762 , bool TF > // Transpose flag of the right-hand side sparse vector
1763inline bool tryAddAssign( const UniLowerMatrix<MT,SO,DF>& lhs, const SparseVector<VT,TF>& rhs,
1764 ptrdiff_t band, size_t row, size_t column )
1765{
1767
1768 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1769 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1770 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
1771 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
1772
1773 MAYBE_UNUSED( lhs, row, column );
1774
1775 if( band >= 0L ) {
1776 for( const auto& element : *rhs ) {
1777 if( !isDefault( element.value() ) )
1778 return false;
1779 }
1780 }
1781
1782 return true;
1783}
1785//*************************************************************************************************
1786
1787
1788//*************************************************************************************************
1805template< typename MT1 // Type of the adapted matrix
1806 , bool SO // Storage order of the adapted matrix
1807 , bool DF // Density flag
1808 , typename MT2 > // Type of the right-hand side dense matrix
1809inline bool tryAddAssign( const UniLowerMatrix<MT1,SO,DF>& lhs,
1810 const DenseMatrix<MT2,false>& rhs, size_t row, size_t column )
1811{
1813
1814 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1815 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1816 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1817 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1818
1819 MAYBE_UNUSED( lhs );
1820
1821 const size_t M( (*rhs).rows() );
1822 const size_t N( (*rhs).columns() );
1823
1824 if( row >= column + N )
1825 return true;
1826
1827 const size_t iend( min( column + N - row, M ) );
1828
1829 for( size_t i=0UL; i<iend; ++i )
1830 {
1831 const bool containsDiagonal( row + i >= column );
1832 const size_t jbegin( ( containsDiagonal )?( row + i - column ):( 0UL ) );
1833
1834 for( size_t j=jbegin; j<N; ++j ) {
1835 if( !isDefault( (*rhs)(i,j) ) )
1836 return false;
1837 }
1838 }
1839
1840 return true;
1841}
1843//*************************************************************************************************
1844
1845
1846//*************************************************************************************************
1863template< typename MT1 // Type of the adapted matrix
1864 , bool SO // Storage order of the adapted matrix
1865 , bool DF // Density flag
1866 , typename MT2 > // Type of the right-hand side dense matrix
1867inline bool tryAddAssign( const UniLowerMatrix<MT1,SO,DF>& lhs,
1868 const DenseMatrix<MT2,true>& rhs, size_t row, size_t column )
1869{
1871
1872 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1873 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1874 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1875 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1876
1877 MAYBE_UNUSED( lhs );
1878
1879 const size_t M( (*rhs).rows() );
1880 const size_t N( (*rhs).columns() );
1881
1882 if( row >= column + N )
1883 return true;
1884
1885 const size_t jbegin( ( row <= column )?( 0UL ):( row - column ) );
1886
1887 for( size_t j=jbegin; j<N; ++j )
1888 {
1889 const size_t iend( min( column + j - row + 1UL, M ) );
1890
1891 for( size_t i=0UL; i<iend; ++i ) {
1892 if( !isDefault( (*rhs)(i,j) ) )
1893 return false;
1894 }
1895 }
1896
1897 return true;
1898}
1900//*************************************************************************************************
1901
1902
1903//*************************************************************************************************
1920template< typename MT1 // Type of the adapted matrix
1921 , bool SO // Storage order of the adapted matrix
1922 , bool DF // Density flag
1923 , typename MT2 > // Type of the right-hand side sparse matrix
1924inline bool tryAddAssign( const UniLowerMatrix<MT1,SO,DF>& lhs,
1925 const SparseMatrix<MT2,false>& rhs, size_t row, size_t column )
1926{
1928
1929 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1930 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1931 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1932 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1933
1934 MAYBE_UNUSED( lhs );
1935
1936 const size_t M( (*rhs).rows() );
1937 const size_t N( (*rhs).columns() );
1938
1939 if( row >= column + N )
1940 return true;
1941
1942 const size_t iend( min( column + N - row, M ) );
1943
1944 for( size_t i=0UL; i<iend; ++i )
1945 {
1946 const bool containsDiagonal( row + i >= column );
1947 const size_t index( ( containsDiagonal )?( row + i - column ):( 0UL ) );
1948
1949 const auto last( (*rhs).end(i) );
1950 auto element( (*rhs).lowerBound( i, index ) );
1951
1952 for( ; element!=last; ++element ) {
1953 if( !isDefault( element->value() ) )
1954 return false;
1955 }
1956 }
1957
1958 return true;
1959}
1961//*************************************************************************************************
1962
1963
1964//*************************************************************************************************
1981template< typename MT1 // Type of the adapted matrix
1982 , bool SO // Storage order of the adapted matrix
1983 , bool DF // Density flag
1984 , typename MT2 > // Type of the right-hand side sparse matrix
1985inline bool tryAddAssign( const UniLowerMatrix<MT1,SO,DF>& lhs,
1986 const SparseMatrix<MT2,true>& rhs, size_t row, size_t column )
1987{
1989
1990 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
1991 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
1992 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
1993 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
1994
1995 MAYBE_UNUSED( lhs );
1996
1997 const size_t M( (*rhs).rows() );
1998 const size_t N( (*rhs).columns() );
1999
2000 if( row >= column + N )
2001 return true;
2002
2003 const size_t jbegin( ( row < column )?( 0UL ):( row - column ) );
2004
2005 for( size_t j=jbegin; j<N; ++j )
2006 {
2007 const size_t index( column + j - row + 1UL );
2008 const auto last( (*rhs).lowerBound( min( index, M ), j ) );
2009
2010 for( auto element=(*rhs).begin(j); element!=last; ++element ) {
2011 if( !isDefault( element->value() ) )
2012 return false;
2013 }
2014 }
2015
2016 return true;
2017}
2019//*************************************************************************************************
2020
2021
2022//*************************************************************************************************
2039template< typename MT // Type of the adapted matrix
2040 , bool SO // Storage order of the adapted matrix
2041 , bool DF // Density flag
2042 , typename VT // Type of the right-hand side vector
2043 , bool TF > // Transpose flag of the right-hand side vector
2044inline bool trySubAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
2045 const Vector<VT,TF>& rhs, size_t row, size_t column )
2046{
2047 return tryAddAssign( lhs, *rhs, row, column );
2048}
2050//*************************************************************************************************
2051
2052
2053//*************************************************************************************************
2071template< typename MT // Type of the adapted matrix
2072 , bool SO // Storage order of the adapted matrix
2073 , bool DF // Density flag
2074 , typename VT // Type of the right-hand side vector
2075 , bool TF > // Transpose flag of the right-hand side vector
2076inline bool trySubAssign( const UniLowerMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
2077 ptrdiff_t band, size_t row, size_t column )
2078{
2079 return tryAddAssign( lhs, *rhs, band, row, column );
2080}
2082//*************************************************************************************************
2083
2084
2085//*************************************************************************************************
2102template< typename MT1 // Type of the adapted matrix
2103 , bool SO1 // Storage order of the adapted matrix
2104 , bool DF // Density flag
2105 , typename MT2 // Type of the right-hand side matrix
2106 , bool SO2 > // Storage order of the right-hand side matrix
2107inline bool trySubAssign( const UniLowerMatrix<MT1,SO1,DF>& lhs,
2108 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
2109{
2110 return tryAddAssign( lhs, *rhs, row, column );
2111}
2113//*************************************************************************************************
2114
2115
2116//*************************************************************************************************
2133template< typename MT // Type of the adapted matrix
2134 , bool SO // Storage order of the adapted matrix
2135 , bool DF // Density flag
2136 , typename VT > // Type of the right-hand side vector
2137inline bool tryMultAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
2138 const Vector<VT,false>& rhs, size_t row, size_t column )
2139{
2141
2142 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2143 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2144 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2145
2146 MAYBE_UNUSED( lhs );
2147
2148 return ( column < row ) ||
2149 ( (*rhs).size() <= column - row ) ||
2150 isOne( (*rhs)[column-row] );
2151}
2153//*************************************************************************************************
2154
2155
2156//*************************************************************************************************
2173template< typename MT // Type of the adapted matrix
2174 , bool SO // Storage order of the adapted matrix
2175 , bool DF // Density flag
2176 , typename VT > // Type of the right-hand side vector
2177inline bool tryMultAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
2178 const Vector<VT,true>& rhs, size_t row, size_t column )
2179{
2181
2182 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2183 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2184 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2185
2186 MAYBE_UNUSED( lhs );
2187
2188 return ( row < column ) ||
2189 ( (*rhs).size() <= row - column ) ||
2190 isOne( (*rhs)[row-column] );
2191}
2193//*************************************************************************************************
2194
2195
2196//*************************************************************************************************
2213template< typename MT // Type of the adapted matrix
2214 , bool SO // Storage order of the adapted matrix
2215 , bool DF // Density flag
2216 , typename VT // Type of the right-hand side dense vector
2217 , bool TF > // Transpose flag of the right-hand side dense vector
2218inline bool tryMultAssign( const UniLowerMatrix<MT,SO,DF>& lhs, const DenseVector<VT,TF>& rhs,
2219 ptrdiff_t band, size_t row, size_t column )
2220{
2222
2223 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2224 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2225 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2226 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2227
2228 MAYBE_UNUSED( lhs, row, column );
2229
2230 if( band == 0L ) {
2231 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2232 if( !isOne( (*rhs)[i] ) )
2233 return false;
2234 }
2235 }
2236
2237 return true;
2238}
2240//*************************************************************************************************
2241
2242
2243//*************************************************************************************************
2260template< typename MT // Type of the adapted matrix
2261 , bool SO // Storage order of the adapted matrix
2262 , bool DF // Density flag
2263 , typename VT // Type of the right-hand side sparse vector
2264 , bool TF > // Transpose flag of the right-hand side sparse vector
2265inline bool tryMultAssign( const UniLowerMatrix<MT,SO,DF>& lhs, const SparseVector<VT,TF>& rhs,
2266 ptrdiff_t band, size_t row, size_t column )
2267{
2269
2270 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2271 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2272 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2273 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2274
2275 MAYBE_UNUSED( lhs, row, column );
2276
2277 if( band == 0L ) {
2278 if( (*rhs).nonZeros() != (*rhs).size() )
2279 return false;
2280 for( const auto& element : *rhs ) {
2281 if( !isOne( element.value() ) )
2282 return false;
2283 }
2284 }
2285
2286 return true;
2287}
2289//*************************************************************************************************
2290
2291
2292//*************************************************************************************************
2309template< typename MT1 // Type of the adapted matrix
2310 , bool SO1 // Storage order of the adapted matrix
2311 , bool DF // Density flag
2312 , typename MT2 // Type of the right-hand side matrix
2313 , bool SO2 > // Storage order of the right-hand side matrix
2314inline bool trySchurAssign( const UniLowerMatrix<MT1,SO1,DF>& lhs,
2315 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
2316{
2318
2319 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2320 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2321 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
2322 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
2323
2324 MAYBE_UNUSED( lhs );
2325
2326 const size_t M( (*rhs).rows() );
2327 const size_t N( (*rhs).columns() );
2328
2329 if( ( row >= column + N ) || ( column >= row + M ) )
2330 return true;
2331
2332 size_t i( row < column ? column - row : 0UL );
2333 size_t j( column < row ? row - column : 0UL );
2334
2335 for( ; i<M && j<N; ++i, ++j )
2336 {
2337 if( !isOne( (*rhs)(i,j) ) )
2338 return false;
2339 }
2340
2341 return true;
2342}
2344//*************************************************************************************************
2345
2346
2347//*************************************************************************************************
2363template< typename MT // Type of the adapted matrix
2364 , bool SO // Storage order of the adapted matrix
2365 , bool DF // Density flag
2366 , typename VT // Type of the right-hand side vector
2367 , bool TF > // Transpose flag of the right-hand side vector
2368inline bool tryDivAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
2369 const Vector<VT,TF>& rhs, size_t row, size_t column )
2370{
2371 return tryMultAssign( lhs, *rhs, row, column );
2372}
2374//*************************************************************************************************
2375
2376
2377//*************************************************************************************************
2394template< typename MT // Type of the adapted matrix
2395 , bool SO // Storage order of the adapted matrix
2396 , bool DF // Density flag
2397 , typename VT // Type of the right-hand side vector
2398 , bool TF > // Transpose flag of the right-hand side vector
2399inline bool tryDivAssign( const UniLowerMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
2400 ptrdiff_t band, size_t row, size_t column )
2401{
2402 return tryMultAssign( lhs, *rhs, band, row, column );
2403}
2405//*************************************************************************************************
2406
2407
2408//*************************************************************************************************
2424template< typename MT // Type of the adapted matrix
2425 , bool SO // Storage order of the adapted matrix
2426 , bool DF // Density flag
2427 , typename VT > // Type of the right-hand side vector
2428inline bool tryShiftAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
2429 const Vector<VT,false>& rhs, size_t row, size_t column )
2430{
2432
2433 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2434 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2435 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2436
2437 MAYBE_UNUSED( lhs );
2438
2439 return ( column < row ) ||
2440 ( (*rhs).size() <= column - row ) ||
2441 isDefault( (*rhs)[column-row] );
2442}
2444//*************************************************************************************************
2445
2446
2447//*************************************************************************************************
2463template< typename MT // Type of the adapted matrix
2464 , bool SO // Storage order of the adapted matrix
2465 , bool DF // Density flag
2466 , typename VT > // Type of the right-hand side vector
2467inline bool tryShiftAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
2468 const Vector<VT,true>& rhs, size_t row, size_t column )
2469{
2471
2472 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2473 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2474 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2475
2476 MAYBE_UNUSED( lhs );
2477
2478 return ( row < column ) ||
2479 ( (*rhs).size() <= row - column ) ||
2480 isDefault( (*rhs)[row-column] );
2481}
2483//*************************************************************************************************
2484
2485
2486//*************************************************************************************************
2503template< typename MT // Type of the adapted matrix
2504 , bool SO // Storage order of the adapted matrix
2505 , bool DF // Density flag
2506 , typename VT // Type of the right-hand side dense vector
2507 , bool TF > // Transpose flag of the right-hand side dense vector
2508inline bool tryShiftAssign( const UniLowerMatrix<MT,SO,DF>& lhs, const DenseVector<VT,TF>& rhs,
2509 ptrdiff_t band, size_t row, size_t column )
2510{
2512
2513 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2514 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2515 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2516 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2517
2518 MAYBE_UNUSED( lhs, row, column );
2519
2520 if( band == 0L ) {
2521 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2522 if( !isDefault( (*rhs)[i] ) )
2523 return false;
2524 }
2525 }
2526
2527 return true;
2528}
2530//*************************************************************************************************
2531
2532
2533//*************************************************************************************************
2550template< typename MT // Type of the adapted matrix
2551 , bool SO // Storage order of the adapted matrix
2552 , bool DF // Density flag
2553 , typename VT // Type of the right-hand side sparse vector
2554 , bool TF > // Transpose flag of the right-hand side sparse vector
2555inline bool tryShiftAssign( const UniLowerMatrix<MT,SO,DF>& lhs, const SparseVector<VT,TF>& rhs,
2556 ptrdiff_t band, size_t row, size_t column )
2557{
2559
2560 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2561 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2562 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2563 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2564
2565 MAYBE_UNUSED( lhs, row, column );
2566
2567 if( band == 0L ) {
2568 if( (*rhs).nonZeros() != (*rhs).size() )
2569 return false;
2570 for( const auto& element : *rhs ) {
2571 if( !isDefault( element.value() ) )
2572 return false;
2573 }
2574 }
2575
2576 return true;
2577}
2579//*************************************************************************************************
2580
2581
2582//*************************************************************************************************
2598template< typename MT1 // Type of the adapted matrix
2599 , bool SO1 // Storage order of the adapted matrix
2600 , bool DF // Density flag
2601 , typename MT2 // Type of the right-hand side matrix
2602 , bool SO2 > // Storage order of the right-hand side matrix
2603inline bool tryShiftAssign( const UniLowerMatrix<MT1,SO1,DF>& lhs,
2604 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
2605{
2607
2608 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2609 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2610 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
2611 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
2612
2613 MAYBE_UNUSED( lhs );
2614
2615 const size_t M( (*rhs).rows() );
2616 const size_t N( (*rhs).columns() );
2617
2618 if( ( row >= column + N ) || ( column >= row + M ) )
2619 return true;
2620
2621 size_t i( row < column ? column - row : 0UL );
2622 size_t j( column < row ? row - column : 0UL );
2623
2624 for( ; i<M && j<N; ++i, ++j )
2625 {
2626 if( !isDefault( (*rhs)(i,j) ) )
2627 return false;
2628 }
2629
2630 return true;
2631}
2633//*************************************************************************************************
2634
2635
2636//*************************************************************************************************
2653template< typename MT // Type of the adapted matrix
2654 , bool SO // Storage order of the adapted matrix
2655 , bool DF // Density flag
2656 , typename VT > // Type of the right-hand side vector
2657inline bool tryBitandAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
2658 const Vector<VT,false>& rhs, size_t row, size_t column )
2659{
2661
2662 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2663 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2664 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2665
2666 MAYBE_UNUSED( lhs );
2667
2668 return ( column < row ) ||
2669 ( (*rhs).size() <= column - row ) ||
2670 ( ElementType_t<MT>(1) & (*rhs)[column-row] );
2671}
2673//*************************************************************************************************
2674
2675
2676//*************************************************************************************************
2693template< typename MT // Type of the adapted matrix
2694 , bool SO // Storage order of the adapted matrix
2695 , bool DF // Density flag
2696 , typename VT > // Type of the right-hand side vector
2697inline bool tryBitandAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
2698 const Vector<VT,true>& rhs, size_t row, size_t column )
2699{
2701
2702 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2703 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2704 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2705
2706 MAYBE_UNUSED( lhs );
2707
2708 return ( row < column ) ||
2709 ( (*rhs).size() <= row - column ) ||
2710 ( ElementType_t<MT>(1) & (*rhs)[row-column] );
2711}
2713//*************************************************************************************************
2714
2715
2716//*************************************************************************************************
2733template< typename MT // Type of the adapted matrix
2734 , bool SO // Storage order of the adapted matrix
2735 , bool DF // Density flag
2736 , typename VT // Type of the right-hand side dense vector
2737 , bool TF > // Transpose flag of the right-hand side dense vector
2738inline bool tryBitandAssign( const UniLowerMatrix<MT,SO,DF>& lhs, const DenseVector<VT,TF>& rhs,
2739 ptrdiff_t band, size_t row, size_t column )
2740{
2742
2743 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2744 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2745 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2746 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2747
2748 MAYBE_UNUSED( lhs, row, column );
2749
2750 if( band == 0L ) {
2751 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2752 if( !( ElementType_t<MT>(1) & (*rhs)[i] ) )
2753 return false;
2754 }
2755 }
2756
2757 return true;
2758}
2760//*************************************************************************************************
2761
2762
2763//*************************************************************************************************
2780template< typename MT // Type of the adapted matrix
2781 , bool SO // Storage order of the adapted matrix
2782 , bool DF // Density flag
2783 , typename VT // Type of the right-hand side sparse vector
2784 , bool TF > // Transpose flag of the right-hand side sparse vector
2785inline bool tryBitandAssign( const UniLowerMatrix<MT,SO,DF>& lhs, const SparseVector<VT,TF>& rhs,
2786 ptrdiff_t band, size_t row, size_t column )
2787{
2789
2790 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2791 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2792 BLAZE_INTERNAL_ASSERT( row + (*rhs).size() <= lhs.rows(), "Invalid number of rows" );
2793 BLAZE_INTERNAL_ASSERT( column + (*rhs).size() <= lhs.columns(), "Invalid number of columns" );
2794
2795 MAYBE_UNUSED( lhs, row, column );
2796
2797 if( band == 0L ) {
2798 if( (*rhs).nonZeros() != (*rhs).size() )
2799 return false;
2800 for( const auto& element : *rhs ) {
2801 if( !( ElementType_t<MT>(1) & element.value() ) )
2802 return false;
2803 }
2804 }
2805
2806 return true;
2807}
2809//*************************************************************************************************
2810
2811
2812//*************************************************************************************************
2829template< typename MT1 // Type of the adapted matrix
2830 , bool SO1 // Storage order of the adapted matrix
2831 , bool DF // Density flag
2832 , typename MT2 // Type of the right-hand side matrix
2833 , bool SO2 > // Storage order of the right-hand side matrix
2834inline bool tryBitandAssign( const UniLowerMatrix<MT1,SO1,DF>& lhs,
2835 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
2836{
2838
2839 BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
2840 BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
2841 BLAZE_INTERNAL_ASSERT( row + (*rhs).rows() <= lhs.rows(), "Invalid number of rows" );
2842 BLAZE_INTERNAL_ASSERT( column + (*rhs).columns() <= lhs.columns(), "Invalid number of columns" );
2843
2844 MAYBE_UNUSED( lhs );
2845
2846 const size_t M( (*rhs).rows() );
2847 const size_t N( (*rhs).columns() );
2848
2849 if( ( row >= column + N ) || ( column >= row + M ) )
2850 return true;
2851
2852 size_t i( row < column ? column - row : 0UL );
2853 size_t j( column < row ? row - column : 0UL );
2854
2855 for( ; i<M && j<N; ++i, ++j )
2856 {
2857 if( !( ElementType_t<MT1>(1) & (*rhs)(i,j) ) )
2858 return false;
2859 }
2860
2861 return true;
2862}
2864//*************************************************************************************************
2865
2866
2867//*************************************************************************************************
2884template< typename MT // Type of the adapted matrix
2885 , bool SO // Storage order of the adapted matrix
2886 , bool DF // Density flag
2887 , typename VT // Type of the right-hand side vector
2888 , bool TF > // Transpose flag of the right-hand side vector
2889inline bool tryBitorAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
2890 const Vector<VT,TF>& rhs, size_t row, size_t column )
2891{
2892 return tryAssign( lhs, *rhs, row, column );
2893}
2895//*************************************************************************************************
2896
2897
2898//*************************************************************************************************
2915template< typename MT // Type of the adapted matrix
2916 , bool SO // Storage order of the adapted matrix
2917 , bool DF // Density flag
2918 , typename VT // Type of the right-hand side vector
2919 , bool TF > // Transpose flag of the right-hand side vector
2920inline bool tryBitorAssign( const UniLowerMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
2921 ptrdiff_t band, size_t row, size_t column )
2922{
2923 return tryAssign( lhs, *rhs, band, row, column );
2924}
2926//*************************************************************************************************
2927
2928
2929//*************************************************************************************************
2946template< typename MT1 // Type of the adapted matrix
2947 , bool SO1 // Storage order of the adapted matrix
2948 , bool DF // Density flag
2949 , typename MT2 // Type of the right-hand side matrix
2950 , bool SO2 > // Storage order of the right-hand side matrix
2951inline bool tryBitorAssign( const UniLowerMatrix<MT1,SO1,DF>& lhs,
2952 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
2953{
2954 return tryAssign( lhs, *rhs, row, column );
2955}
2957//*************************************************************************************************
2958
2959
2960//*************************************************************************************************
2977template< typename MT // Type of the adapted matrix
2978 , bool SO // Storage order of the adapted matrix
2979 , bool DF // Density flag
2980 , typename VT // Type of the right-hand side vector
2981 , bool TF > // Transpose flag of the right-hand side vector
2982inline bool tryBitxorAssign( const UniLowerMatrix<MT,SO,DF>& lhs,
2983 const Vector<VT,TF>& rhs, size_t row, size_t column )
2984{
2985 return tryAddAssign( lhs, *rhs, row, column );
2986}
2988//*************************************************************************************************
2989
2990
2991//*************************************************************************************************
3008template< typename MT // Type of the adapted matrix
3009 , bool SO // Storage order of the adapted matrix
3010 , bool DF // Density flag
3011 , typename VT // Type of the right-hand side vector
3012 , bool TF > // Transpose flag of the right-hand side vector
3013inline bool tryBitxorAssign( const UniLowerMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
3014 ptrdiff_t band, size_t row, size_t column )
3015{
3016 return tryAddAssign( lhs, *rhs, band, row, column );
3017}
3019//*************************************************************************************************
3020
3021
3022//*************************************************************************************************
3039template< typename MT1 // Type of the adapted matrix
3040 , bool SO1 // Storage order of the adapted matrix
3041 , bool DF // Density flag
3042 , typename MT2 // Type of the right-hand side matrix
3043 , bool SO2 > // Storage order of the right-hand side matrix
3044inline bool tryBitxorAssign( const UniLowerMatrix<MT1,SO1,DF>& lhs,
3045 const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
3046{
3047 return tryAddAssign( lhs, *rhs, row, column );
3048}
3050//*************************************************************************************************
3051
3052
3053//*************************************************************************************************
3067template< typename MT // Type of the adapted matrix
3068 , bool SO // Storage order of the adapted matrix
3069 , bool DF > // Density flag
3070inline MT& derestrict( UniLowerMatrix<MT,SO,DF>& m )
3071{
3072 return m.matrix_;
3073}
3075//*************************************************************************************************
3076
3077
3078
3079
3080//=================================================================================================
3081//
3082// SIZE SPECIALIZATIONS
3083//
3084//=================================================================================================
3085
3086//*************************************************************************************************
3088template< typename MT, bool SO, bool DF >
3089struct Size< UniLowerMatrix<MT,SO,DF>, 0UL >
3090 : public Size<MT,0UL>
3091{};
3092
3093template< typename MT, bool SO, bool DF >
3094struct Size< UniLowerMatrix<MT,SO,DF>, 1UL >
3095 : public Size<MT,1UL>
3096{};
3098//*************************************************************************************************
3099
3100
3101
3102
3103//=================================================================================================
3104//
3105// MAXSIZE SPECIALIZATIONS
3106//
3107//=================================================================================================
3108
3109//*************************************************************************************************
3111template< typename MT, bool SO, bool DF >
3112struct MaxSize< UniLowerMatrix<MT,SO,DF>, 0UL >
3113 : public MaxSize<MT,0UL>
3114{};
3115
3116template< typename MT, bool SO, bool DF >
3117struct MaxSize< UniLowerMatrix<MT,SO,DF>, 1UL >
3118 : public MaxSize<MT,1UL>
3119{};
3121//*************************************************************************************************
3122
3123
3124
3125
3126//=================================================================================================
3127//
3128// ISSQUARE SPECIALIZATIONS
3129//
3130//=================================================================================================
3131
3132//*************************************************************************************************
3134template< typename MT, bool SO, bool DF >
3135struct IsSquare< UniLowerMatrix<MT,SO,DF> >
3136 : public TrueType
3137{};
3139//*************************************************************************************************
3140
3141
3142
3143
3144//=================================================================================================
3145//
3146// ISUNILOWER SPECIALIZATIONS
3147//
3148//=================================================================================================
3149
3150//*************************************************************************************************
3152template< typename MT, bool SO, bool DF >
3153struct IsUniLower< UniLowerMatrix<MT,SO,DF> >
3154 : public TrueType
3155{};
3157//*************************************************************************************************
3158
3159
3160
3161
3162//=================================================================================================
3163//
3164// ISADAPTOR SPECIALIZATIONS
3165//
3166//=================================================================================================
3167
3168//*************************************************************************************************
3170template< typename MT, bool SO, bool DF >
3171struct IsAdaptor< UniLowerMatrix<MT,SO,DF> >
3172 : public TrueType
3173{};
3175//*************************************************************************************************
3176
3177
3178
3179
3180//=================================================================================================
3181//
3182// ISRESTRICTED SPECIALIZATIONS
3183//
3184//=================================================================================================
3185
3186//*************************************************************************************************
3188template< typename MT, bool SO, bool DF >
3189struct IsRestricted< UniLowerMatrix<MT,SO,DF> >
3190 : public TrueType
3191{};
3193//*************************************************************************************************
3194
3195
3196
3197
3198//=================================================================================================
3199//
3200// HASCONSTDATAACCESS SPECIALIZATIONS
3201//
3202//=================================================================================================
3203
3204//*************************************************************************************************
3206template< typename MT, bool SO >
3207struct HasConstDataAccess< UniLowerMatrix<MT,SO,true> >
3208 : public TrueType
3209{};
3211//*************************************************************************************************
3212
3213
3214
3215
3216//=================================================================================================
3217//
3218// ISALIGNED SPECIALIZATIONS
3219//
3220//=================================================================================================
3221
3222//*************************************************************************************************
3224template< typename MT, bool SO, bool DF >
3225struct IsAligned< UniLowerMatrix<MT,SO,DF> >
3226 : public IsAligned<MT>
3227{};
3229//*************************************************************************************************
3230
3231
3232
3233
3234//=================================================================================================
3235//
3236// ISCONTIGUOUS SPECIALIZATIONS
3237//
3238//=================================================================================================
3239
3240//*************************************************************************************************
3242template< typename MT, bool SO, bool DF >
3243struct IsContiguous< UniLowerMatrix<MT,SO,DF> >
3244 : public IsContiguous<MT>
3245{};
3247//*************************************************************************************************
3248
3249
3250
3251
3252//=================================================================================================
3253//
3254// ISPADDED SPECIALIZATIONS
3255//
3256//=================================================================================================
3257
3258//*************************************************************************************************
3260template< typename MT, bool SO, bool DF >
3261struct IsPadded< UniLowerMatrix<MT,SO,DF> >
3262 : public IsPadded<MT>
3263{};
3265//*************************************************************************************************
3266
3267
3268
3269
3270//=================================================================================================
3271//
3272// REMOVEADAPTOR SPECIALIZATIONS
3273//
3274//=================================================================================================
3275
3276//*************************************************************************************************
3278template< typename MT, bool SO, bool DF >
3279struct RemoveAdaptor< UniLowerMatrix<MT,SO,DF> >
3280{
3281 using Type = MT;
3282};
3284//*************************************************************************************************
3285
3286
3287
3288
3289//=================================================================================================
3290//
3291// ADDTRAIT SPECIALIZATIONS
3292//
3293//=================================================================================================
3294
3295//*************************************************************************************************
3297template< typename T1, typename T2 >
3298struct AddTraitEval1< T1, T2
3299 , EnableIf_t< IsMatrix_v<T1> &&
3300 IsMatrix_v<T2> &&
3301 ( ( IsUniLower_v<T1> && IsStrictlyLower_v<T2> &&
3302 !( IsUniUpper_v<T1> && IsStrictlyUpper_v<T2> ) ) ||
3303 ( IsStrictlyLower_v<T1> && IsUniLower_v<T2> &&
3304 !( IsStrictlyUpper_v<T1> && IsUniUpper_v<T2> ) ) ) &&
3305 !( IsZero_v<T1> || IsZero_v<T2> ) > >
3306{
3307 using Type = UniLowerMatrix< typename AddTraitEval2<T1,T2>::Type >;
3308};
3310//*************************************************************************************************
3311
3312
3313
3314
3315//=================================================================================================
3316//
3317// SUBTRAIT SPECIALIZATIONS
3318//
3319//=================================================================================================
3320
3321//*************************************************************************************************
3323template< typename T1, typename T2 >
3324struct SubTraitEval1< T1, T2
3325 , EnableIf_t< IsMatrix_v<T1> &&
3326 IsMatrix_v<T2> &&
3327 ( IsUniLower_v<T1> && IsStrictlyLower_v<T2> &&
3328 !( IsUniUpper_v<T1> && IsStrictlyUpper_v<T2> ) ) &&
3329 !( IsZero_v<T1> || IsZero_v<T2> ) > >
3330{
3331 using Type = UniLowerMatrix< typename SubTraitEval2<T1,T2>::Type >;
3332};
3334//*************************************************************************************************
3335
3336
3337
3338
3339//=================================================================================================
3340//
3341// SCHURTRAIT SPECIALIZATIONS
3342//
3343//=================================================================================================
3344
3345//*************************************************************************************************
3347template< typename T1, typename T2 >
3348struct SchurTraitEval1< T1, T2
3349 , EnableIf_t< IsMatrix_v<T1> &&
3350 IsMatrix_v<T2> &&
3351 ( IsUniLower_v<T1> && IsUniLower_v<T2> ) &&
3352 !( IsDiagonal_v<T1> || IsDiagonal_v<T2> ) &&
3353 !( IsZero_v<T1> || IsZero_v<T2> ) > >
3354{
3355 using Type = UniLowerMatrix< typename SchurTraitEval2<T1,T2>::Type >;
3356};
3358//*************************************************************************************************
3359
3360
3361
3362
3363//=================================================================================================
3364//
3365// MULTTRAIT SPECIALIZATIONS
3366//
3367//=================================================================================================
3368
3369//*************************************************************************************************
3371template< typename T1, typename T2 >
3372struct MultTraitEval1< T1, T2
3373 , EnableIf_t< IsMatrix_v<T1> &&
3374 IsMatrix_v<T2> &&
3375 ( IsUniLower_v<T1> && IsUniLower_v<T2> ) &&
3376 !( IsIdentity_v<T1> || IsIdentity_v<T2> ) > >
3377{
3378 using Type = UniLowerMatrix< typename MultTraitEval2<T1,T2>::Type >;
3379};
3381//*************************************************************************************************
3382
3383
3384
3385
3386//=================================================================================================
3387//
3388// KRONTRAIT SPECIALIZATIONS
3389//
3390//=================================================================================================
3391
3392//*************************************************************************************************
3394template< typename T1, typename T2 >
3395struct KronTraitEval1< T1, T2
3396 , EnableIf_t< IsMatrix_v<T1> &&
3397 IsMatrix_v<T2> &&
3398 ( IsUniLower_v<T1> && IsUniLower_v<T2> ) &&
3399 !( IsIdentity_v<T1> && IsIdentity_v<T2> ) &&
3400 !( IsZero_v<T1> || IsZero_v<T2> ) > >
3401{
3402 using Type = UniLowerMatrix< typename KronTraitEval2<T1,T2>::Type >;
3403};
3405//*************************************************************************************************
3406
3407
3408
3409
3410//=================================================================================================
3411//
3412// MAPTRAIT SPECIALIZATIONS
3413//
3414//=================================================================================================
3415
3416//*************************************************************************************************
3418template< typename T, typename OP >
3419struct UnaryMapTraitEval1< T, OP
3420 , EnableIf_t< YieldsUniLower_v<OP,T> &&
3421 !YieldsIdentity_v<OP,T> > >
3422{
3423 using Type = UniLowerMatrix< typename UnaryMapTraitEval2<T,OP>::Type, StorageOrder_v<T> >;
3424};
3426//*************************************************************************************************
3427
3428
3429//*************************************************************************************************
3431template< typename T1, typename T2, typename OP >
3432struct BinaryMapTraitEval1< T1, T2, OP
3433 , EnableIf_t< YieldsUniLower_v<OP,T1,T2> &&
3434 !YieldsIdentity_v<OP,T1,T2> > >
3435{
3436 using Type = UniLowerMatrix< typename BinaryMapTraitEval2<T1,T2,OP>::Type >;
3437};
3439//*************************************************************************************************
3440
3441
3442
3443
3444//=================================================================================================
3445//
3446// DECLSYMTRAIT SPECIALIZATIONS
3447//
3448//=================================================================================================
3449
3450//*************************************************************************************************
3452template< typename MT, bool SO, bool DF >
3453struct DeclSymTrait< UniLowerMatrix<MT,SO,DF> >
3454{
3455 using Type = IdentityMatrix< ElementType_t<MT>, SO >;
3456};
3458//*************************************************************************************************
3459
3460
3461
3462
3463//=================================================================================================
3464//
3465// DECLHERMTRAIT SPECIALIZATIONS
3466//
3467//=================================================================================================
3468
3469//*************************************************************************************************
3471template< typename MT, bool SO, bool DF >
3472struct DeclHermTrait< UniLowerMatrix<MT,SO,DF> >
3473{
3474 using Type = IdentityMatrix< ElementType_t<MT>, SO >;
3475};
3477//*************************************************************************************************
3478
3479
3480
3481
3482//=================================================================================================
3483//
3484// DECLLOWTRAIT SPECIALIZATIONS
3485//
3486//=================================================================================================
3487
3488//*************************************************************************************************
3490template< typename MT, bool SO, bool DF >
3491struct DeclLowTrait< UniLowerMatrix<MT,SO,DF> >
3492{
3493 using Type = UniLowerMatrix<MT,SO,DF>;
3494};
3496//*************************************************************************************************
3497
3498
3499
3500
3501//=================================================================================================
3502//
3503// DECLUNILOWTRAIT SPECIALIZATIONS
3504//
3505//=================================================================================================
3506
3507//*************************************************************************************************
3509template< typename MT, bool SO, bool DF >
3510struct DeclUniLowTrait< UniLowerMatrix<MT,SO,DF> >
3511{
3512 using Type = UniLowerMatrix<MT,SO,DF>;
3513};
3515//*************************************************************************************************
3516
3517
3518
3519
3520//=================================================================================================
3521//
3522// DECLSTRLOWTRAIT SPECIALIZATIONS
3523//
3524//=================================================================================================
3525
3526//*************************************************************************************************
3528template< typename MT, bool SO, bool DF >
3529struct DeclStrLowTrait< UniLowerMatrix<MT,SO,DF> >
3530{
3531 using Type = INVALID_TYPE;
3532};
3534//*************************************************************************************************
3535
3536
3537
3538
3539//=================================================================================================
3540//
3541// DECLUPPTRAIT SPECIALIZATIONS
3542//
3543//=================================================================================================
3544
3545//*************************************************************************************************
3547template< typename MT, bool SO, bool DF >
3548struct DeclUppTrait< UniLowerMatrix<MT,SO,DF> >
3549{
3550 using Type = IdentityMatrix< ElementType_t<MT>, SO >;
3551};
3553//*************************************************************************************************
3554
3555
3556
3557
3558//=================================================================================================
3559//
3560// DECLUNIUPPTRAIT SPECIALIZATIONS
3561//
3562//=================================================================================================
3563
3564//*************************************************************************************************
3566template< typename MT, bool SO, bool DF >
3567struct DeclUniUppTrait< UniLowerMatrix<MT,SO,DF> >
3568{
3569 using Type = IdentityMatrix< ElementType_t<MT>, SO >;
3570};
3572//*************************************************************************************************
3573
3574
3575
3576
3577//=================================================================================================
3578//
3579// DECLSTRUPPTRAIT SPECIALIZATIONS
3580//
3581//=================================================================================================
3582
3583//*************************************************************************************************
3585template< typename MT, bool SO, bool DF >
3586struct DeclStrUppTrait< UniLowerMatrix<MT,SO,DF> >
3587{
3588 using Type = INVALID_TYPE;
3589};
3591//*************************************************************************************************
3592
3593
3594
3595
3596//=================================================================================================
3597//
3598// DECLDIAGTRAIT SPECIALIZATIONS
3599//
3600//=================================================================================================
3601
3602//*************************************************************************************************
3604template< typename MT, bool SO, bool DF >
3605struct DeclDiagTrait< UniLowerMatrix<MT,SO,DF> >
3606{
3607 using Type = IdentityMatrix< ElementType_t<MT>, SO >;
3608};
3610//*************************************************************************************************
3611
3612
3613
3614
3615//=================================================================================================
3616//
3617// HIGHTYPE SPECIALIZATIONS
3618//
3619//=================================================================================================
3620
3621//*************************************************************************************************
3623template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
3624struct HighType< UniLowerMatrix<MT1,SO1,DF1>, UniLowerMatrix<MT2,SO2,DF2> >
3625{
3626 using Type = UniLowerMatrix< typename HighType<MT1,MT2>::Type >;
3627};
3629//*************************************************************************************************
3630
3631
3632
3633
3634//=================================================================================================
3635//
3636// LOWTYPE SPECIALIZATIONS
3637//
3638//=================================================================================================
3639
3640//*************************************************************************************************
3642template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
3643struct LowType< UniLowerMatrix<MT1,SO1,DF1>, UniLowerMatrix<MT2,SO2,DF2> >
3644{
3645 using Type = UniLowerMatrix< typename LowType<MT1,MT2>::Type >;
3646};
3648//*************************************************************************************************
3649
3650
3651
3652
3653//=================================================================================================
3654//
3655// SUBMATRIXTRAIT SPECIALIZATIONS
3656//
3657//=================================================================================================
3658
3659//*************************************************************************************************
3661template< typename MT, size_t I, size_t N >
3662struct SubmatrixTraitEval1< MT, I, I, N, N
3663 , EnableIf_t< I != inf && N != inf &&
3664 IsUniLower_v<MT> &&
3665 !IsIdentity_v<MT> > >
3666{
3667 using Type = UniLowerMatrix< typename SubmatrixTraitEval2<MT,I,I,N,N>::Type >;
3668};
3670//*************************************************************************************************
3671
3672} // namespace blaze
3673
3674#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 MaxSize type 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 YieldsUniLower type trait.
Header file for the implementation of the base template of the UniLowerMatrix.
UniLowerMatrix specialization for dense matrices.
UniLowerMatrix 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 bool YieldsUniLower_v
Auxiliary variable template for the YieldsUniLower type trait.
Definition: YieldsUniLower.h:124
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
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.