StrictlyUpperMatrix.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_ADAPTORS_STRICTLYUPPERMATRIX_H_
36 #define _BLAZE_MATH_ADAPTORS_STRICTLYUPPERMATRIX_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
47 #include <blaze/math/Forward.h>
90 #include <blaze/util/Assert.h>
91 #include <blaze/util/EnableIf.h>
92 #include <blaze/util/TrueType.h>
94 #include <blaze/util/Unused.h>
95 
96 
97 namespace blaze {
98 
99 //=================================================================================================
100 //
101 // STRICTLYUPPERMATRIX OPERATORS
102 //
103 //=================================================================================================
104 
105 //*************************************************************************************************
108 template< typename MT, bool SO, bool DF >
109 void reset( StrictlyUpperMatrix<MT,SO,DF>& m );
110 
111 template< typename MT, bool SO, bool DF >
112 void reset( StrictlyUpperMatrix<MT,SO,DF>& m, size_t i );
113 
114 template< typename MT, bool SO, bool DF >
115 void clear( StrictlyUpperMatrix<MT,SO,DF>& m );
116 
117 template< bool RF, typename MT, bool SO, bool DF >
118 bool isDefault( const StrictlyUpperMatrix<MT,SO,DF>& m );
119 
120 template< typename MT, bool SO, bool DF >
121 bool isIntact( const StrictlyUpperMatrix<MT,SO,DF>& m );
122 
123 template< typename MT, bool SO, bool DF >
124 void swap( StrictlyUpperMatrix<MT,SO,DF>& a, StrictlyUpperMatrix<MT,SO,DF>& b ) noexcept;
126 //*************************************************************************************************
127 
128 
129 //*************************************************************************************************
136 template< typename MT // Type of the adapted matrix
137  , bool SO // Storage order of the adapted matrix
138  , bool DF > // Density flag
140 {
141  m.reset();
142 }
143 //*************************************************************************************************
144 
145 
146 //*************************************************************************************************
159 template< typename MT // Type of the adapted matrix
160  , bool SO // Storage order of the adapted matrix
161  , bool DF > // Density flag
162 inline void reset( StrictlyUpperMatrix<MT,SO,DF>& m, size_t i )
163 {
164  m.reset( i );
165 }
166 //*************************************************************************************************
167 
168 
169 //*************************************************************************************************
176 template< typename MT // Type of the adapted matrix
177  , bool SO // Storage order of the adapted matrix
178  , bool DF > // Density flag
180 {
181  m.clear();
182 }
183 //*************************************************************************************************
184 
185 
186 //*************************************************************************************************
197 template< bool RF // Relaxation flag
198  , typename MT // Type of the adapted matrix
199  , bool SO // Storage order of the adapted matrix
200  , bool DF > // Density flag
201 inline bool isDefault_backend( const StrictlyUpperMatrix<MT,SO,DF>& m, TrueType )
202 {
203  return ( m.rows() == 0UL );
204 }
206 //*************************************************************************************************
207 
208 
209 //*************************************************************************************************
220 template< bool RF // Relaxation flag
221  , typename MT // Type of the adapted matrix
222  , bool SO // Storage order of the adapted matrix
223  , bool DF > // Density flag
224 inline bool isDefault_backend( const StrictlyUpperMatrix<MT,SO,DF>& m, FalseType )
225 {
226  if( SO ) {
227  for( size_t j=1UL; j<m.columns(); ++j ) {
228  for( size_t i=0UL; i<j; ++i ) {
229  if( !isDefault<RF>( m(i,j) ) )
230  return false;
231  }
232  }
233  }
234  else {
235  for( size_t i=0UL; i<m.rows(); ++i ) {
236  for( size_t j=i+1UL; j<m.columns(); ++j ) {
237  if( !isDefault<RF>( m(i,j) ) )
238  return false;
239  }
240  }
241  }
242 
243  return true;
244 }
246 //*************************************************************************************************
247 
248 
249 //*************************************************************************************************
276 template< bool RF // Relaxation flag
277  , typename MT // Type of the adapted matrix
278  , bool SO // Storage order of the adapted matrix
279  , bool DF > // Density flag
281 {
282  return isDefault_backend<RF>( m, typename IsResizable<MT>::Type() );
283 }
284 //*************************************************************************************************
285 
286 
287 //*************************************************************************************************
308 template< typename MT // Type of the adapted matrix
309  , bool SO // Storage order of the adapted matrix
310  , bool DF > // Density flag
312 {
313  return m.isIntact();
314 }
315 //*************************************************************************************************
316 
317 
318 //*************************************************************************************************
326 template< typename MT // Type of the adapted matrix
327  , bool SO // Storage order of the adapted matrix
328  , bool DF > // Density flag
330 {
331  a.swap( b );
332 }
333 //*************************************************************************************************
334 
335 
336 //*************************************************************************************************
352 template< typename MT // Type of the adapted matrix
353  , bool SO // Storage order of the adapted matrix
354  , bool DF // Density flag
355  , typename ET > // Type of the element
356 inline bool trySet( const StrictlyUpperMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
357 {
358  BLAZE_INTERNAL_ASSERT( i < (~mat).rows(), "Invalid row access index" );
359  BLAZE_INTERNAL_ASSERT( j < (~mat).columns(), "Invalid column access index" );
360 
361  UNUSED_PARAMETER( mat );
362 
363  return ( i < j || isDefault( value ) );
364 }
366 //*************************************************************************************************
367 
368 
369 //*************************************************************************************************
385 template< typename MT // Type of the adapted matrix
386  , bool SO // Storage order of the adapted matrix
387  , bool DF // Density flag
388  , typename ET > // Type of the element
389 inline bool tryAdd( const StrictlyUpperMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
390 {
391  return trySet( mat, i, j, value );
392 }
394 //*************************************************************************************************
395 
396 
397 //*************************************************************************************************
413 template< typename MT // Type of the adapted matrix
414  , bool SO // Storage order of the adapted matrix
415  , bool DF // Density flag
416  , typename ET > // Type of the element
417 inline bool trySub( const StrictlyUpperMatrix<MT,SO,DF>& mat, size_t i, size_t j, const ET& value )
418 {
419  return trySet( mat, i, j, value );
420 }
422 //*************************************************************************************************
423 
424 
425 //*************************************************************************************************
442 template< typename MT // Type of the adapted matrix
443  , bool SO // Storage order of the adapted matrix
444  , bool DF // Density flag
445  , typename VT > // Type of the right-hand side dense vector
446 inline bool tryAssign( const StrictlyUpperMatrix<MT,SO,DF>& lhs,
447  const DenseVector<VT,false>& rhs, size_t row, size_t column )
448 {
450 
451  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
452  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
453  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
454 
455  UNUSED_PARAMETER( lhs );
456 
457  const size_t ibegin( ( column <= row )?( 0UL ):( column - row ) );
458 
459  for( size_t i=ibegin; i<(~rhs).size(); ++i ) {
460  if( !isDefault( (~rhs)[i] ) )
461  return false;
462  }
463 
464  return true;
465 }
467 //*************************************************************************************************
468 
469 
470 //*************************************************************************************************
487 template< typename MT // Type of the adapted matrix
488  , bool SO // Storage order of the adapted matrix
489  , bool DF // Density flag
490  , typename VT > // Type of the right-hand side dense vector
491 inline bool tryAssign( const StrictlyUpperMatrix<MT,SO,DF>& lhs,
492  const DenseVector<VT,true>& rhs, size_t row, size_t column )
493 {
495 
496  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
497  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
498  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
499 
500  UNUSED_PARAMETER( lhs );
501 
502  if( row < column )
503  return true;
504 
505  const size_t iend( min( row - column + 1UL, (~rhs).size() ) );
506 
507  for( size_t i=0UL; i<iend; ++i ) {
508  if( !isDefault( (~rhs)[i] ) )
509  return false;
510  }
511 
512  return true;
513 }
515 //*************************************************************************************************
516 
517 
518 //*************************************************************************************************
536 template< typename MT // Type of the adapted matrix
537  , bool SO // Storage order of the adapted matrix
538  , bool DF // Density flag
539  , typename VT // Type of the right-hand side dense vector
540  , bool TF > // Transpose flag of the right-hand side dense vector
541 inline bool tryAssign( const StrictlyUpperMatrix<MT,SO,DF>& lhs, const DenseVector<VT,TF>& rhs,
542  ptrdiff_t band, size_t row, size_t column )
543 {
545 
546  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
547  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
548  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
549  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
550 
551  UNUSED_PARAMETER( lhs, row, column );
552 
553  if( band <= 0L ) {
554  for( size_t i=0UL; i<(~rhs).size(); ++i ) {
555  if( !isDefault( (~rhs)[i] ) )
556  return false;
557  }
558  }
559 
560  return true;
561 }
563 //*************************************************************************************************
564 
565 
566 //*************************************************************************************************
583 template< typename MT // Type of the adapted matrix
584  , bool SO // Storage order of the adapted matrix
585  , bool DF // Density flag
586  , typename VT > // Type of the right-hand side sparse vector
587 inline bool tryAssign( const StrictlyUpperMatrix<MT,SO,DF>& lhs,
588  const SparseVector<VT,false>& rhs, size_t row, size_t column )
589 {
591 
592  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
593  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
594  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
595 
596  UNUSED_PARAMETER( lhs );
597 
598  const auto last( (~rhs).end() );
599  auto element( (~rhs).lowerBound( ( column <= row )?( 0UL ):( column - row ) ) );
600 
601  for( ; element!=last; ++element ) {
602  if( !isDefault( element->value() ) )
603  return false;
604  }
605 
606  return true;
607 }
609 //*************************************************************************************************
610 
611 
612 //*************************************************************************************************
629 template< typename MT // Type of the adapted matrix
630  , bool SO // Storage order of the adapted matrix
631  , bool DF // Density flag
632  , typename VT > // Type of the right-hand side sparse vector
633 inline bool tryAssign( const StrictlyUpperMatrix<MT,SO,DF>& lhs,
634  const SparseVector<VT,true>& rhs, size_t row, size_t column )
635 {
637 
638  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
639  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
640  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
641 
642  UNUSED_PARAMETER( lhs );
643 
644  if( row < column )
645  return true;
646 
647  const auto last( (~rhs).lowerBound( row - column + 1UL ) );
648 
649  for( auto element=(~rhs).begin(); element!=last; ++element ) {
650  if( !isDefault( element->value() ) )
651  return false;
652  }
653 
654  return true;
655 }
657 //*************************************************************************************************
658 
659 
660 //*************************************************************************************************
678 template< typename MT // Type of the adapted matrix
679  , bool SO // Storage order of the adapted matrix
680  , bool DF // Density flag
681  , typename VT // Type of the right-hand side sparse vector
682  , bool TF > // Transpose flag of the right-hand side sparse vector
683 inline bool tryAssign( const StrictlyUpperMatrix<MT,SO,DF>& lhs, const SparseVector<VT,TF>& rhs,
684  ptrdiff_t band, size_t row, size_t column )
685 {
687 
688  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
689  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
690  BLAZE_INTERNAL_ASSERT( row + (~rhs).size() <= lhs.rows(), "Invalid number of rows" );
691  BLAZE_INTERNAL_ASSERT( column + (~rhs).size() <= lhs.columns(), "Invalid number of columns" );
692 
693  UNUSED_PARAMETER( lhs, row, column );
694 
695  if( band <= 0L ) {
696  for( const auto& element : ~rhs ) {
697  if( !isDefault( element.value() ) )
698  return false;
699  }
700  }
701 
702  return true;
703 }
705 //*************************************************************************************************
706 
707 
708 //*************************************************************************************************
725 template< typename MT1 // Type of the adapted matrix
726  , bool SO // Storage order of the adapted matrix
727  , bool DF // Density flag
728  , typename MT2 > // Type of the right-hand side dense matrix
729 inline bool tryAssign( const StrictlyUpperMatrix<MT1,SO,DF>& lhs,
730  const DenseMatrix<MT2,false>& rhs, size_t row, size_t column )
731 {
733 
734  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
735  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
736  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
737  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
738 
739  UNUSED_PARAMETER( lhs );
740 
741  const size_t M( (~rhs).rows() );
742  const size_t N( (~rhs).columns() );
743 
744  if( column >= row + M )
745  return true;
746 
747  const size_t ibegin( ( column <= row )?( 0UL ):( column - row ) );
748 
749  for( size_t i=ibegin; i<M; ++i )
750  {
751  const size_t jend( min( row + i - column + 1UL, N ) );
752 
753  for( size_t j=0UL; j<jend; ++j ) {
754  if( !isDefault( (~rhs)(i,j) ) )
755  return false;
756  }
757  }
758 
759  return true;
760 }
762 //*************************************************************************************************
763 
764 
765 //*************************************************************************************************
782 template< typename MT1 // Type of the adapted matrix
783  , bool SO // Storage order of the adapted matrix
784  , bool DF // Density flag
785  , typename MT2 > // Type of the right-hand side dense matrix
786 inline bool tryAssign( const StrictlyUpperMatrix<MT1,SO,DF>& lhs,
787  const DenseMatrix<MT2,true>& rhs, size_t row, size_t column )
788 {
790 
791  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
792  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
793  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
794  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
795 
796  UNUSED_PARAMETER( lhs );
797 
798  const size_t M( (~rhs).rows() );
799  const size_t N( (~rhs).columns() );
800 
801  if( column >= row + M )
802  return true;
803 
804  const size_t jend( min( row + M - column, N ) );
805 
806  for( size_t j=0UL; j<jend; ++j )
807  {
808  const bool containsDiagonal( column + j >= row );
809  const size_t ibegin( ( containsDiagonal )?( column + j - row ):( 0UL ) );
810 
811  for( size_t i=ibegin; i<M; ++i ) {
812  if( !isDefault( (~rhs)(i,j) ) )
813  return false;
814  }
815  }
816 
817  return true;
818 }
820 //*************************************************************************************************
821 
822 
823 //*************************************************************************************************
840 template< typename MT1 // Type of the adapted matrix
841  , bool SO // Storage order of the adapted matrix
842  , bool DF // Density flag
843  , typename MT2 > // Type of the right-hand side sparse matrix
844 inline bool tryAssign( const StrictlyUpperMatrix<MT1,SO,DF>& lhs,
845  const SparseMatrix<MT2,false>& rhs, size_t row, size_t column )
846 {
848 
849  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
850  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
851  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
852  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
853 
854  UNUSED_PARAMETER( lhs );
855 
856  const size_t M( (~rhs).rows() );
857  const size_t N( (~rhs).columns() );
858 
859  if( column >= row + M )
860  return true;
861 
862  const size_t ibegin( ( column < row )?( 0UL ):( column - row ) );
863 
864  for( size_t i=ibegin; i<M; ++i )
865  {
866  const size_t index( row + i - column + 1UL );
867  const auto last( (~rhs).lowerBound( i, min( index, N ) ) );
868 
869  for( auto element=(~rhs).begin(i); element!=last; ++element ) {
870  if( !isDefault( element->value() ) )
871  return false;
872  }
873  }
874 
875  return true;
876 }
878 //*************************************************************************************************
879 
880 
881 //*************************************************************************************************
898 template< typename MT1 // Type of the adapted matrix
899  , bool SO // Storage order of the adapted matrix
900  , bool DF // Density flag
901  , typename MT2 > // Type of the right-hand side sparse matrix
902 inline bool tryAssign( const StrictlyUpperMatrix<MT1,SO,DF>& lhs,
903  const SparseMatrix<MT2,true>& rhs, size_t row, size_t column )
904 {
906 
907  BLAZE_INTERNAL_ASSERT( row <= lhs.rows(), "Invalid row access index" );
908  BLAZE_INTERNAL_ASSERT( column <= lhs.columns(), "Invalid column access index" );
909  BLAZE_INTERNAL_ASSERT( row + (~rhs).rows() <= lhs.rows(), "Invalid number of rows" );
910  BLAZE_INTERNAL_ASSERT( column + (~rhs).columns() <= lhs.columns(), "Invalid number of columns" );
911 
912  UNUSED_PARAMETER( lhs );
913 
914  const size_t M( (~rhs).rows() );
915  const size_t N( (~rhs).columns() );
916 
917  if( column >= row + M )
918  return true;
919 
920  const size_t jend( min( row + M - column, N ) );
921 
922  for( size_t j=0UL; j<jend; ++j )
923  {
924  const bool containsDiagonal( column + j >= row );
925  const size_t index( ( containsDiagonal )?( column + j - row ):( 0UL ) );
926 
927  const auto last( (~rhs).end(j) );
928  auto element( (~rhs).lowerBound( index, j ) );
929 
930  for( ; element!=last; ++element ) {
931  if( !isDefault( element->value() ) )
932  return false;
933  }
934  }
935 
936  return true;
937 }
939 //*************************************************************************************************
940 
941 
942 //*************************************************************************************************
959 template< typename MT // Type of the adapted matrix
960  , bool SO // Storage order of the adapted matrix
961  , bool DF // Density flag
962  , typename VT // Type of the right-hand side vector
963  , bool TF > // Transpose flag of the right-hand side vector
964 inline bool tryAddAssign( const StrictlyUpperMatrix<MT,SO,DF>& lhs,
965  const Vector<VT,TF>& rhs, size_t row, size_t column )
966 {
967  return tryAssign( lhs, ~rhs, row, column );
968 }
970 //*************************************************************************************************
971 
972 
973 //*************************************************************************************************
991 template< typename MT // Type of the adapted matrix
992  , bool SO // Storage order of the adapted matrix
993  , bool DF // Density flag
994  , typename VT // Type of the right-hand side vector
995  , bool TF > // Transpose flag of the right-hand side vector
996 inline bool tryAddAssign( const StrictlyUpperMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
997  ptrdiff_t band, size_t row, size_t column )
998 {
999  return tryAssign( lhs, ~rhs, band, row, column );
1000 }
1002 //*************************************************************************************************
1003 
1004 
1005 //*************************************************************************************************
1022 template< typename MT1 // Type of the adapted matrix
1023  , bool SO1 // Storage order of the adapted matrix
1024  , bool DF // Density flag
1025  , typename MT2 // Type of the right-hand side matrix
1026  , bool SO2 > // Storage order of the right-hand side matrix
1027 inline bool tryAddAssign( const StrictlyUpperMatrix<MT1,SO1,DF>& lhs,
1028  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
1029 {
1030  return tryAssign( lhs, ~rhs, row, column );
1031 }
1033 //*************************************************************************************************
1034 
1035 
1036 //*************************************************************************************************
1053 template< 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 vector
1057  , bool TF > // Transpose flag of the right-hand side vector
1058 inline bool trySubAssign( const StrictlyUpperMatrix<MT,SO,DF>& lhs,
1059  const Vector<VT,TF>& rhs, size_t row, size_t column )
1060 {
1061  return tryAssign( lhs, ~rhs, row, column );
1062 }
1064 //*************************************************************************************************
1065 
1066 
1067 //*************************************************************************************************
1085 template< typename MT // Type of the adapted matrix
1086  , bool SO // Storage order of the adapted matrix
1087  , bool DF // Density flag
1088  , typename VT // Type of the right-hand side vector
1089  , bool TF > // Transpose flag of the right-hand side vector
1090 inline bool trySubAssign( const StrictlyUpperMatrix<MT,SO,DF>& lhs, const Vector<VT,TF>& rhs,
1091  ptrdiff_t band, size_t row, size_t column )
1092 {
1093  return tryAssign( lhs, ~rhs, band, row, column );
1094 }
1096 //*************************************************************************************************
1097 
1098 
1099 //*************************************************************************************************
1116 template< typename MT1 // Type of the adapted matrix
1117  , bool SO1 // Storage order of the adapted matrix
1118  , bool DF // Density flag
1119  , typename MT2 // Type of the right-hand side matrix
1120  , bool SO2 > // Storage order of the right-hand side matrix
1121 inline bool trySubAssign( const StrictlyUpperMatrix<MT1,SO1,DF>& lhs,
1122  const Matrix<MT2,SO2>& rhs, size_t row, size_t column )
1123 {
1124  return tryAssign( lhs, ~rhs, row, column );
1125 }
1127 //*************************************************************************************************
1128 
1129 
1130 //*************************************************************************************************
1144 template< typename MT // Type of the adapted matrix
1145  , bool SO // Storage order of the adapted matrix
1146  , bool DF > // Density flag
1147 inline MT& derestrict( StrictlyUpperMatrix<MT,SO,DF>& m )
1148 {
1149  return m.matrix_;
1150 }
1152 //*************************************************************************************************
1153 
1154 
1155 
1156 
1157 //=================================================================================================
1158 //
1159 // SIZE SPECIALIZATIONS
1160 //
1161 //=================================================================================================
1162 
1163 //*************************************************************************************************
1165 template< typename MT, bool SO, bool DF >
1166 struct Size< StrictlyUpperMatrix<MT,SO,DF>, 0UL >
1167  : public Size<MT,0UL>
1168 {};
1169 
1170 template< typename MT, bool SO, bool DF >
1171 struct Size< StrictlyUpperMatrix<MT,SO,DF>, 1UL >
1172  : public Size<MT,1UL>
1173 {};
1175 //*************************************************************************************************
1176 
1177 
1178 
1179 
1180 //=================================================================================================
1181 //
1182 // MAXSIZE SPECIALIZATIONS
1183 //
1184 //=================================================================================================
1185 
1186 //*************************************************************************************************
1188 template< typename MT, bool SO, bool DF >
1189 struct MaxSize< StrictlyUpperMatrix<MT,SO,DF>, 0UL >
1190  : public MaxSize<MT,0UL>
1191 {};
1192 
1193 template< typename MT, bool SO, bool DF >
1194 struct MaxSize< StrictlyUpperMatrix<MT,SO,DF>, 1UL >
1195  : public MaxSize<MT,1UL>
1196 {};
1198 //*************************************************************************************************
1199 
1200 
1201 
1202 
1203 //=================================================================================================
1204 //
1205 // ISSQUARE SPECIALIZATIONS
1206 //
1207 //=================================================================================================
1208 
1209 //*************************************************************************************************
1211 template< typename MT, bool SO, bool DF >
1212 struct IsSquare< StrictlyUpperMatrix<MT,SO,DF> >
1213  : public TrueType
1214 {};
1216 //*************************************************************************************************
1217 
1218 
1219 
1220 
1221 //=================================================================================================
1222 //
1223 // ISUNIFORM SPECIALIZATIONS
1224 //
1225 //=================================================================================================
1226 
1227 //*************************************************************************************************
1229 template< typename MT, bool SO, bool DF >
1230 struct IsUniform< StrictlyUpperMatrix<MT,SO,DF> >
1231  : public IsUniform<MT>
1232 {};
1234 //*************************************************************************************************
1235 
1236 
1237 
1238 
1239 //=================================================================================================
1240 //
1241 // ISSYMMETRIC SPECIALIZATIONS
1242 //
1243 //=================================================================================================
1244 
1245 //*************************************************************************************************
1247 template< typename MT, bool SO, bool DF >
1248 struct IsSymmetric< StrictlyUpperMatrix<MT,SO,DF> >
1249  : public IsUniform<MT>
1250 {};
1252 //*************************************************************************************************
1253 
1254 
1255 
1256 
1257 //=================================================================================================
1258 //
1259 // ISHERMITIAN SPECIALIZATIONS
1260 //
1261 //=================================================================================================
1262 
1263 //*************************************************************************************************
1265 template< typename MT, bool SO, bool DF >
1266 struct IsHermitian< StrictlyUpperMatrix<MT,SO,DF> >
1267  : public IsUniform<MT>
1268 {};
1270 //*************************************************************************************************
1271 
1272 
1273 
1274 
1275 //=================================================================================================
1276 //
1277 // ISSTRICTLYLOWER SPECIALIZATIONS
1278 //
1279 //=================================================================================================
1280 
1281 //*************************************************************************************************
1283 template< typename MT, bool SO, bool DF >
1284 struct IsStrictlyLower< StrictlyUpperMatrix<MT,SO,DF> >
1285  : public IsUniform<MT>
1286 {};
1288 //*************************************************************************************************
1289 
1290 
1291 
1292 
1293 //=================================================================================================
1294 //
1295 // ISSTRICTLYUPPER SPECIALIZATIONS
1296 //
1297 //=================================================================================================
1298 
1299 //*************************************************************************************************
1301 template< typename MT, bool SO, bool DF >
1302 struct IsStrictlyUpper< StrictlyUpperMatrix<MT,SO,DF> >
1303  : public TrueType
1304 {};
1306 //*************************************************************************************************
1307 
1308 
1309 
1310 
1311 //=================================================================================================
1312 //
1313 // ISADAPTOR SPECIALIZATIONS
1314 //
1315 //=================================================================================================
1316 
1317 //*************************************************************************************************
1319 template< typename MT, bool SO, bool DF >
1320 struct IsAdaptor< StrictlyUpperMatrix<MT,SO,DF> >
1321  : public TrueType
1322 {};
1324 //*************************************************************************************************
1325 
1326 
1327 
1328 
1329 //=================================================================================================
1330 //
1331 // ISRESTRICTED SPECIALIZATIONS
1332 //
1333 //=================================================================================================
1334 
1335 //*************************************************************************************************
1337 template< typename MT, bool SO, bool DF >
1338 struct IsRestricted< StrictlyUpperMatrix<MT,SO,DF> >
1339  : public TrueType
1340 {};
1342 //*************************************************************************************************
1343 
1344 
1345 
1346 
1347 //=================================================================================================
1348 //
1349 // HASCONSTDATAACCESS SPECIALIZATIONS
1350 //
1351 //=================================================================================================
1352 
1353 //*************************************************************************************************
1355 template< typename MT, bool SO >
1356 struct HasConstDataAccess< StrictlyUpperMatrix<MT,SO,true> >
1357  : public TrueType
1358 {};
1360 //*************************************************************************************************
1361 
1362 
1363 
1364 
1365 //=================================================================================================
1366 //
1367 // ISALIGNED SPECIALIZATIONS
1368 //
1369 //=================================================================================================
1370 
1371 //*************************************************************************************************
1373 template< typename MT, bool SO, bool DF >
1374 struct IsAligned< StrictlyUpperMatrix<MT,SO,DF> >
1375  : public IsAligned<MT>
1376 {};
1378 //*************************************************************************************************
1379 
1380 
1381 
1382 
1383 //=================================================================================================
1384 //
1385 // ISCONTIGUOUS SPECIALIZATIONS
1386 //
1387 //=================================================================================================
1388 
1389 //*************************************************************************************************
1391 template< typename MT, bool SO, bool DF >
1392 struct IsContiguous< StrictlyUpperMatrix<MT,SO,DF> >
1393  : public IsContiguous<MT>
1394 {};
1396 //*************************************************************************************************
1397 
1398 
1399 
1400 
1401 //=================================================================================================
1402 //
1403 // ISPADDED SPECIALIZATIONS
1404 //
1405 //=================================================================================================
1406 
1407 //*************************************************************************************************
1409 template< typename MT, bool SO, bool DF >
1410 struct IsPadded< StrictlyUpperMatrix<MT,SO,DF> >
1411  : public IsPadded<MT>
1412 {};
1414 //*************************************************************************************************
1415 
1416 
1417 
1418 
1419 //=================================================================================================
1420 //
1421 // ISRESIZABLE SPECIALIZATIONS
1422 //
1423 //=================================================================================================
1424 
1425 //*************************************************************************************************
1427 template< typename MT, bool SO, bool DF >
1428 struct IsResizable< StrictlyUpperMatrix<MT,SO,DF> >
1429  : public IsResizable<MT>
1430 {};
1432 //*************************************************************************************************
1433 
1434 
1435 
1436 
1437 //=================================================================================================
1438 //
1439 // ISSHRINKABLE SPECIALIZATIONS
1440 //
1441 //=================================================================================================
1442 
1443 //*************************************************************************************************
1445 template< typename MT, bool SO, bool DF >
1446 struct IsShrinkable< StrictlyUpperMatrix<MT,SO,DF> >
1447  : public IsShrinkable<MT>
1448 {};
1450 //*************************************************************************************************
1451 
1452 
1453 
1454 
1455 //=================================================================================================
1456 //
1457 // REMOVEADAPTOR SPECIALIZATIONS
1458 //
1459 //=================================================================================================
1460 
1461 //*************************************************************************************************
1463 template< typename MT, bool SO, bool DF >
1464 struct RemoveAdaptor< StrictlyUpperMatrix<MT,SO,DF> >
1465 {
1466  using Type = MT;
1467 };
1469 //*************************************************************************************************
1470 
1471 
1472 
1473 
1474 //=================================================================================================
1475 //
1476 // ADDTRAIT SPECIALIZATIONS
1477 //
1478 //=================================================================================================
1479 
1480 //*************************************************************************************************
1482 template< typename T1, typename T2 >
1483 struct AddTraitEval1< T1, T2
1484  , EnableIf_t< IsMatrix_v<T1> &&
1485  IsMatrix_v<T2> &&
1486  ( IsStrictlyUpper_v<T1> && IsStrictlyUpper_v<T2> ) &&
1487  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1488 {
1489  using Type = StrictlyUpperMatrix< typename AddTraitEval2<T1,T2>::Type >;
1490 };
1492 //*************************************************************************************************
1493 
1494 
1495 
1496 
1497 //=================================================================================================
1498 //
1499 // SUBTRAIT SPECIALIZATIONS
1500 //
1501 //=================================================================================================
1502 
1503 //*************************************************************************************************
1505 template< typename T1, typename T2 >
1506 struct SubTraitEval1< T1, T2
1507  , EnableIf_t< IsMatrix_v<T1> &&
1508  IsMatrix_v<T2> &&
1509  ( ( IsUniUpper_v<T1> && IsUniUpper_v<T2> ) ||
1510  ( IsStrictlyUpper_v<T1> && IsStrictlyUpper_v<T2> ) ) &&
1511  !( IsIdentity_v<T1> && IsIdentity_v<T2> ) &&
1512  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1513 {
1514  using Type = StrictlyUpperMatrix< typename SubTraitEval2<T1,T2>::Type >;
1515 };
1517 //*************************************************************************************************
1518 
1519 
1520 
1521 
1522 //=================================================================================================
1523 //
1524 // SCHURTRAIT SPECIALIZATIONS
1525 //
1526 //=================================================================================================
1527 
1528 //*************************************************************************************************
1530 template< typename T1, typename T2 >
1531 struct SchurTraitEval1< T1, T2
1532  , EnableIf_t< IsMatrix_v<T1> &&
1533  IsMatrix_v<T2> &&
1534  ( ( IsStrictlyUpper_v<T1> && !IsLower_v<T2> ) ||
1535  ( !IsLower_v<T1> && IsStrictlyUpper_v<T2> ) ) &&
1536  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1537 {
1538  using Type = StrictlyUpperMatrix< typename SchurTraitEval2<T1,T2>::Type >;
1539 };
1541 //*************************************************************************************************
1542 
1543 
1544 
1545 
1546 //=================================================================================================
1547 //
1548 // MULTTRAIT SPECIALIZATIONS
1549 //
1550 //=================================================================================================
1551 
1552 //*************************************************************************************************
1554 template< typename T1, typename T2 >
1555 struct MultTraitEval1< T1, T2
1556  , EnableIf_t< IsMatrix_v<T1> &&
1557  IsNumeric_v<T2> &&
1558  ( IsStrictlyUpper_v<T1> && !IsUniform_v<T1> ) > >
1559 {
1560  using Type = StrictlyUpperMatrix< typename MultTraitEval2<T1,T2>::Type >;
1561 };
1562 
1563 template< typename T1, typename T2 >
1564 struct MultTraitEval1< T1, T2
1565  , EnableIf_t< IsNumeric_v<T1> &&
1566  IsMatrix_v<T2> &&
1567  ( IsStrictlyUpper_v<T2> && !IsUniform_v<T2> ) > >
1568 {
1569  using Type = StrictlyUpperMatrix< typename MultTraitEval2<T1,T2>::Type >;
1570 };
1571 
1572 template< typename T1, typename T2 >
1573 struct MultTraitEval1< T1, T2
1574  , EnableIf_t< IsMatrix_v<T1> &&
1575  IsMatrix_v<T2> &&
1576  ( ( IsStrictlyUpper_v<T1> && IsUpper_v<T2> ) ||
1577  ( IsUpper_v<T1> && IsStrictlyUpper_v<T2> ) ) &&
1578  !( IsIdentity_v<T1> || IsIdentity_v<T2> ) &&
1579  !( IsZero_v<T1> || IsZero_v<T2> ) > >
1580 {
1581  using Type = StrictlyUpperMatrix< typename MultTraitEval2<T1,T2>::Type >;
1582 };
1584 //*************************************************************************************************
1585 
1586 
1587 
1588 
1589 //=================================================================================================
1590 //
1591 // DIVTRAIT SPECIALIZATIONS
1592 //
1593 //=================================================================================================
1594 
1595 //*************************************************************************************************
1597 template< typename T1, typename T2 >
1598 struct DivTraitEval1< T1, T2
1599  , EnableIf_t< IsStrictlyUpper_v<T1> && IsNumeric_v<T2> > >
1600 {
1601  using Type = StrictlyUpperMatrix< typename DivTraitEval2<T1,T2>::Type >;
1602 };
1604 //*************************************************************************************************
1605 
1606 
1607 
1608 
1609 //=================================================================================================
1610 //
1611 // MAPTRAIT SPECIALIZATIONS
1612 //
1613 //=================================================================================================
1614 
1615 //*************************************************************************************************
1617 template< typename T, typename OP >
1618 struct UnaryMapTraitEval1< T, OP
1619  , EnableIf_t< YieldsStrictlyUpper_v<OP,T> &&
1620  !YieldsDiagonal_v<OP,T> > >
1621 {
1622  using Type = StrictlyUpperMatrix< typename UnaryMapTraitEval2<T,OP>::Type, StorageOrder_v<T> >;
1623 };
1625 //*************************************************************************************************
1626 
1627 
1628 //*************************************************************************************************
1630 template< typename T1, typename T2, typename OP >
1631 struct BinaryMapTraitEval1< T1, T2, OP
1632  , EnableIf_t< YieldsStrictlyUpper_v<OP,T1,T2> &&
1633  !YieldsDiagonal_v<OP,T1,T2> > >
1634 {
1635  using Type = StrictlyUpperMatrix< typename BinaryMapTraitEval2<T1,T2,OP>::Type >;
1636 };
1638 //*************************************************************************************************
1639 
1640 
1641 
1642 
1643 //=================================================================================================
1644 //
1645 // DECLSYMTRAIT SPECIALIZATIONS
1646 //
1647 //=================================================================================================
1648 
1649 //*************************************************************************************************
1651 template< typename MT, bool SO, bool DF >
1652 struct DeclSymTrait< StrictlyUpperMatrix<MT,SO,DF> >
1653 {
1654  using Type = ZeroMatrix< typename MT::ElementType, SO >;
1655 };
1657 //*************************************************************************************************
1658 
1659 
1660 
1661 
1662 //=================================================================================================
1663 //
1664 // DECLHERMTRAIT SPECIALIZATIONS
1665 //
1666 //=================================================================================================
1667 
1668 //*************************************************************************************************
1670 template< typename MT, bool SO, bool DF >
1671 struct DeclHermTrait< StrictlyUpperMatrix<MT,SO,DF> >
1672 {
1673  using Type = ZeroMatrix< typename MT::ElementType, SO >;
1674 };
1676 //*************************************************************************************************
1677 
1678 
1679 
1680 
1681 //=================================================================================================
1682 //
1683 // DECLLOWTRAIT SPECIALIZATIONS
1684 //
1685 //=================================================================================================
1686 
1687 //*************************************************************************************************
1689 template< typename MT, bool SO, bool DF >
1690 struct DeclLowTrait< StrictlyUpperMatrix<MT,SO,DF> >
1691 {
1692  using Type = ZeroMatrix< typename MT::ElementType, SO >;
1693 };
1695 //*************************************************************************************************
1696 
1697 
1698 
1699 
1700 //=================================================================================================
1701 //
1702 // DECLUPPTRAIT SPECIALIZATIONS
1703 //
1704 //=================================================================================================
1705 
1706 //*************************************************************************************************
1708 template< typename MT, bool SO, bool DF >
1709 struct DeclUppTrait< StrictlyUpperMatrix<MT,SO,DF> >
1710 {
1711  using Type = StrictlyUpperMatrix<MT>;
1712 };
1714 //*************************************************************************************************
1715 
1716 
1717 
1718 
1719 //=================================================================================================
1720 //
1721 // DECLDIAGTRAIT SPECIALIZATIONS
1722 //
1723 //=================================================================================================
1724 
1725 //*************************************************************************************************
1727 template< typename MT, bool SO, bool DF >
1728 struct DeclDiagTrait< StrictlyUpperMatrix<MT,SO,DF> >
1729 {
1730  using Type = ZeroMatrix< typename MT::ElementType, SO >;
1731 };
1733 //*************************************************************************************************
1734 
1735 
1736 
1737 
1738 //=================================================================================================
1739 //
1740 // HIGHTYPE SPECIALIZATIONS
1741 //
1742 //=================================================================================================
1743 
1744 //*************************************************************************************************
1746 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1747 struct HighType< StrictlyUpperMatrix<MT1,SO1,DF1>, StrictlyUpperMatrix<MT2,SO2,DF2> >
1748 {
1749  using Type = StrictlyUpperMatrix< typename HighType<MT1,MT2>::Type >;
1750 };
1752 //*************************************************************************************************
1753 
1754 
1755 
1756 
1757 //=================================================================================================
1758 //
1759 // LOWTYPE SPECIALIZATIONS
1760 //
1761 //=================================================================================================
1762 
1763 //*************************************************************************************************
1765 template< typename MT1, bool SO1, bool DF1, typename MT2, bool SO2, bool DF2 >
1766 struct LowType< StrictlyUpperMatrix<MT1,SO1,DF1>, StrictlyUpperMatrix<MT2,SO2,DF2> >
1767 {
1768  using Type = StrictlyUpperMatrix< typename LowType<MT1,MT2>::Type >;
1769 };
1771 //*************************************************************************************************
1772 
1773 
1774 
1775 
1776 //=================================================================================================
1777 //
1778 // SUBMATRIXTRAIT SPECIALIZATIONS
1779 //
1780 //=================================================================================================
1781 
1782 //*************************************************************************************************
1784 template< typename MT, size_t I, size_t N >
1785 struct SubmatrixTraitEval1< MT, I, I, N, N
1786  , EnableIf_t< IsStrictlyUpper_v<MT> > >
1787 {
1788  using Type = StrictlyUpperMatrix< typename SubmatrixTraitEval2<MT,I,I,N,N>::Type >;
1789 };
1791 //*************************************************************************************************
1792 
1793 } // namespace blaze
1794 
1795 #endif
BoolConstant< false > FalseType
Type/value traits base class.The FalseType class is used as base class for type traits and value trai...
Definition: FalseType.h:61
decltype(auto) column(Matrix< MT, SO > &matrix, RCAs... args)
Creating a view on a specific column of the given matrix.
Definition: Column.h:133
Headerfile for the generic min algorithm.
Header file for the decldiag trait.
Header file for the Schur product trait.
Header file for the UNUSED_PARAMETER function template.
Header file for the IsUniUpper type trait.
Header file for the subtraction trait.
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.The IsMatrix_v variable template provides a c...
Definition: IsMatrix.h:139
Header file for the declherm trait.
MT::Iterator begin(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator to the first element of row/column i.
Definition: Matrix.h:372
StrictlyUpperMatrix specialization for dense matrices.
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
Header file for the IsIdentity type trait.
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: TrueType.h:61
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
constexpr size_t columns(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of columns of the matrix.
Definition: Matrix.h:514
Header file for the IsMatrix type trait.
Header file for the IsSquare type trait.
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
Header file for the LowType type trait.
Header file for the IsUniform type trait.
Header file for the multiplication trait.
Header file for the IsStrictlyUpper type trait.
Header file for the IsSymmetric type trait.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Matrix adapter for strictly upper triangular matrices.
Definition: BaseTemplate.h:558
Header file for the IsShrinkable type trait.
Header file for all forward declarations of the math module.
Header file for the YieldsStrictlyUpper type trait.
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:1147
Header file for the decllow trait.
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
Header file for the IsLower type trait.
Header file for the IsAligned type trait.
StrictlyUpperMatrix specialization for sparse matrices.
MT::Iterator end(Matrix< MT, SO > &matrix, size_t i)
Returns an iterator just past the last element of row/column i.
Definition: Matrix.h:438
Header file for the RemoveAdaptor type trait.
Constraint on the data type.
Header file for the EnableIf class template.
Header file for the IsStrictlyLower type trait.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
Header file for the IsPadded type trait.
Header file for the IsAdaptor type trait.
Header file for the implementation of the base template of the StrictlyUpperMatrix.
decltype(auto) band(Matrix< MT, SO > &matrix, RBAs... args)
Creating a view on a specific band of the given matrix.
Definition: Band.h:135
Header file for the IsNumeric type trait.
Header file for the HasConstDataAccess type trait.
Compile time check for resizable data types.This type trait tests whether the given data type is a re...
Definition: IsResizable.h:75
Header file for the declupp trait.
Header file for run time assertion macros.
Header file for the addition trait.
Header file for the division trait.
Header file for the submatrix trait.
Header file for the IsContiguous type trait.
decltype(auto) row(Matrix< MT, SO > &, RRAs...)
Creating a view on a specific row of the given matrix.
Definition: Row.h:133
constexpr bool IsStrictlyUpper_v
Auxiliary variable template for the IsStrictlyUpper type trait.The IsStrictlyUpper_v variable templat...
Definition: IsStrictlyUpper.h:172
Header file for the IsZero type trait.
Header file for the declsym trait.
Header file for the isDefault shim.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:281
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
#define BLAZE_CONSTRAINT_MUST_NOT_REQUIRE_EVALUATION(T)
Constraint on the data type.In case the given data type T requires an intermediate evaluation within ...
Definition: RequiresEvaluation.h:81
constexpr size_t rows(const Matrix< MT, SO > &matrix) noexcept
Returns the current number of rows of the matrix.
Definition: Matrix.h:498
Header file for the YieldsDiagonal type trait.
Header file for the StorageOrder type trait.
Header file for the map trait.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
Header file for the IsUpper type trait.
Header file for the IsHermitian type trait.
Header file for the IsResizable type trait.
Header file for the IsRestricted type trait.
Header file for the Size type trait.
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_INTERNAL_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERTION flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:101
constexpr bool YieldsStrictlyUpper_v
Auxiliary variable template for the YieldsStrictlyUpper type trait.The YieldsStrictlyUpper_v variable...
Definition: YieldsStrictlyUpper.h:125
Header file for the HighType type trait.
Header file for the TrueType type/value trait base class.