Subvector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_VIEWS_SUBVECTOR_H_
36 #define _BLAZE_MATH_VIEWS_SUBVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
45 #include <blaze/math/Exception.h>
75 #include <blaze/util/DisableIf.h>
76 #include <blaze/util/EnableIf.h>
79 #include <blaze/util/mpl/Or.h>
80 #include <blaze/util/TrueType.h>
81 #include <blaze/util/Types.h>
83 
84 
85 namespace blaze {
86 
87 //=================================================================================================
88 //
89 // GLOBAL FUNCTION
90 //
91 //=================================================================================================
92 
93 //*************************************************************************************************
149 template< typename VT // Type of the vector
150  , bool TF > // Transpose flag
151 inline SubvectorExprTrait_<VT,unaligned>
152  subvector( Vector<VT,TF>& vector, size_t index, size_t size )
153 {
155 
156  return subvector<unaligned>( ~vector, index, size );
157 }
158 //*************************************************************************************************
159 
160 
161 //*************************************************************************************************
217 template< typename VT // Type of the vector
218  , bool TF > // Transpose flag
219 inline const SubvectorExprTrait_<const VT,unaligned>
220  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
221 {
223 
224  return subvector<unaligned>( ~vector, index, size );
225 }
226 //*************************************************************************************************
227 
228 
229 //*************************************************************************************************
244 template< typename VT // Type of the vector
245  , bool TF > // Transpose flag
246 inline SubvectorExprTrait_<VT,unaligned>
247  subvector( Vector<VT,TF>&& vector, size_t index, size_t size )
248 {
250 
251  return subvector<unaligned>( ~vector, index, size );
252 }
253 //*************************************************************************************************
254 
255 
256 //*************************************************************************************************
327 template< bool AF // Alignment flag
328  , typename VT // Type of the dense vector
329  , bool TF > // Transpose flag
330 inline DisableIf_< Or< IsComputation<VT>, IsTransExpr<VT> >, SubvectorExprTrait_<VT,AF> >
331  subvector( Vector<VT,TF>& vector, size_t index, size_t size )
332 {
334 
335  return SubvectorExprTrait_<VT,AF>( ~vector, index, size );
336 }
337 //*************************************************************************************************
338 
339 
340 //*************************************************************************************************
409 template< bool AF // Alignment flag
410  , typename VT // Type of the dense vector
411  , bool TF > // Transpose flag
412 inline const DisableIf_< Or< IsComputation<VT>, IsTransExpr<VT> >, SubvectorExprTrait_<const VT,AF> >
413  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
414 {
416 
417  return SubvectorExprTrait_<const VT,AF>( ~vector, index, size );
418 }
419 //*************************************************************************************************
420 
421 
422 //*************************************************************************************************
439 template< bool AF // Alignment flag
440  , typename VT // Type of the dense vector
441  , bool TF > // Transpose flag
442 inline DisableIf_< Or< IsComputation<VT>, IsTransExpr<VT> >, SubvectorExprTrait_<VT,AF> >
443  subvector( Vector<VT,TF>&& vector, size_t index, size_t size )
444 {
446 
447  return SubvectorExprTrait_<VT,AF>( ~vector, index, size );
448 }
449 //*************************************************************************************************
450 
451 
452 
453 
454 //=================================================================================================
455 //
456 // GLOBAL RESTRUCTURING OPERATORS
457 //
458 //=================================================================================================
459 
460 //*************************************************************************************************
473 template< bool AF // Alignment flag
474  , typename VT // Type of the vector
475  , bool TF > // Transpose flag
476 inline const EnableIf_< IsVecVecAddExpr<VT>, SubvectorExprTrait_<VT,AF> >
477  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
478 {
480 
481  return subvector<AF>( (~vector).leftOperand() , index, size ) +
482  subvector<AF>( (~vector).rightOperand(), index, size );
483 }
485 //*************************************************************************************************
486 
487 
488 //*************************************************************************************************
501 template< bool AF // Alignment flag
502  , typename VT // Type of the vector
503  , bool TF > // Transpose flag
504 inline const EnableIf_< IsVecVecSubExpr<VT>, SubvectorExprTrait_<VT,AF> >
505  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
506 {
508 
509  return subvector<AF>( (~vector).leftOperand() , index, size ) -
510  subvector<AF>( (~vector).rightOperand(), index, size );
511 }
513 //*************************************************************************************************
514 
515 
516 //*************************************************************************************************
529 template< bool AF // Alignment flag
530  , typename VT // Type of the vector
531  , bool TF > // Transpose flag
532 inline const EnableIf_< IsVecVecMultExpr<VT>, SubvectorExprTrait_<VT,AF> >
533  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
534 {
536 
537  return subvector<AF>( (~vector).leftOperand() , index, size ) *
538  subvector<AF>( (~vector).rightOperand(), index, size );
539 }
541 //*************************************************************************************************
542 
543 
544 //*************************************************************************************************
557 template< bool AF // Alignment flag
558  , typename VT // Type of the vector
559  , bool TF > // Transpose flag
560 inline const EnableIf_< IsVecVecDivExpr<VT>, SubvectorExprTrait_<VT,AF> >
561  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
562 {
564 
565  return subvector<AF>( (~vector).leftOperand() , index, size ) /
566  subvector<AF>( (~vector).rightOperand(), index, size );
567 }
569 //*************************************************************************************************
570 
571 
572 //*************************************************************************************************
585 template< bool AF // Alignment flag
586  , typename VT // Type of the vector
587  , bool TF > // Transpose flag
588 inline const EnableIf_< IsCrossExpr<VT>, SubvectorExprTrait_<VT,unaligned> >
589  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
590 {
592 
593  return SubvectorExprTrait_<VT,unaligned>( ~vector, index, size );
594 }
596 //*************************************************************************************************
597 
598 
599 //*************************************************************************************************
612 template< bool AF // Alignment flag
613  , typename VT // Type of the vector
614  , bool TF > // Transpose flag
615 inline const EnableIf_< IsVecScalarMultExpr<VT>, SubvectorExprTrait_<VT,AF> >
616  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
617 {
619 
620  return subvector<AF>( (~vector).leftOperand(), index, size ) * (~vector).rightOperand();
621 }
623 //*************************************************************************************************
624 
625 
626 //*************************************************************************************************
639 template< bool AF // Alignment flag
640  , typename VT // Type of the vector
641  , bool TF > // Transpose flag
642 inline const EnableIf_< IsVecScalarDivExpr<VT>, SubvectorExprTrait_<VT,AF> >
643  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
644 {
646 
647  return subvector<AF>( (~vector).leftOperand(), index, size ) / (~vector).rightOperand();
648 }
650 //*************************************************************************************************
651 
652 
653 //*************************************************************************************************
666 template< bool AF // Alignment flag
667  , typename VT // Type of the vector
668  , bool TF > // Transpose flag
669 inline const EnableIf_< IsVecForEachExpr<VT>, SubvectorExprTrait_<VT,AF> >
670  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
671 {
673 
674  return forEach( subvector<AF>( (~vector).operand(), index, size ), (~vector).operation() );
675 }
677 //*************************************************************************************************
678 
679 
680 //*************************************************************************************************
693 template< bool AF // Alignment flag
694  , typename VT // Type of the vector
695  , bool TF > // Transpose flag
696 inline const EnableIf_< IsVecEvalExpr<VT>, SubvectorExprTrait_<VT,AF> >
697  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
698 {
700 
701  return eval( subvector<AF>( (~vector).operand(), index, size ) );
702 }
704 //*************************************************************************************************
705 
706 
707 //*************************************************************************************************
720 template< bool AF // Alignment flag
721  , typename VT // Type of the vector
722  , bool TF > // Transpose flag
723 inline const EnableIf_< IsVecSerialExpr<VT>, SubvectorExprTrait_<VT,AF> >
724  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
725 {
727 
728  return serial( subvector<AF>( (~vector).operand(), index, size ) );
729 }
731 //*************************************************************************************************
732 
733 
734 //*************************************************************************************************
747 template< bool AF // Alignment flag
748  , typename VT // Type of the vector
749  , bool TF > // Transpose flag
750 inline const EnableIf_< IsVecTransExpr<VT>, SubvectorExprTrait_<VT,AF> >
751  subvector( const Vector<VT,TF>& vector, size_t index, size_t size )
752 {
754 
755  return trans( subvector<AF>( (~vector).operand(), index, size ) );
756 }
758 //*************************************************************************************************
759 
760 
761 //*************************************************************************************************
773 template< bool AF1 // Required alignment flag
774  , typename VT // Type of the dense vector
775  , bool AF2 // Present alignment flag
776  , bool TF // Transpose flag
777  , bool DF > // Density flag
778 inline const Subvector<VT,AF1,TF,DF>
779  subvector( const Subvector<VT,AF2,TF,DF>& sv, size_t index, size_t size )
780 {
782 
783  if( index + size > sv.size() ) {
784  BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
785  }
786 
787  return Subvector<VT,AF1,TF,DF>( sv.vector_, sv.offset_ + index, size );
788 }
790 //*************************************************************************************************
791 
792 
793 
794 
795 //=================================================================================================
796 //
797 // SUBVECTOR OPERATORS
798 //
799 //=================================================================================================
800 
801 //*************************************************************************************************
804 template< typename VT, bool AF, bool TF, bool DF >
805 inline void reset( Subvector<VT,AF,TF,DF>& sv );
806 
807 template< typename VT, bool AF, bool TF, bool DF >
808 inline void clear( Subvector<VT,AF,TF,DF>& sv );
809 
810 template< typename VT, bool AF, bool TF, bool DF >
811 inline bool isDefault( const Subvector<VT,AF,TF,DF>& sv );
812 
813 template< typename VT, bool AF, bool TF, bool DF >
814 inline bool isIntact( const Subvector<VT,AF,TF,DF>& sv ) noexcept;
815 
816 template< typename VT, bool AF, bool TF, bool DF >
817 inline bool isSame( const Subvector<VT,AF,TF,DF>& a, const Vector<VT,TF>& b ) noexcept;
818 
819 template< typename VT, bool AF, bool TF, bool DF >
820 inline bool isSame( const Vector<VT,TF>& a, const Subvector<VT,AF,TF,DF>& b ) noexcept;
821 
822 template< typename VT, bool AF, bool TF, bool DF >
823 inline bool isSame( const Subvector<VT,AF,TF,DF>& a, const Subvector<VT,AF,TF,DF>& b ) noexcept;
825 //*************************************************************************************************
826 
827 
828 //*************************************************************************************************
835 template< typename VT // Type of the vector
836  , bool AF // Alignment flag
837  , bool TF // Transpose flag
838  , bool DF > // Density flag
839 inline void reset( Subvector<VT,AF,TF,DF>& sv )
840 {
841  sv.reset();
842 }
843 //*************************************************************************************************
844 
845 
846 //*************************************************************************************************
853 template< typename VT // Type of the vector
854  , bool AF // Alignment flag
855  , bool TF // Transpose flag
856  , bool DF > // Density flag
857 inline void clear( Subvector<VT,AF,TF,DF>& sv )
858 {
859  sv.reset();
860 }
861 //*************************************************************************************************
862 
863 
864 //*************************************************************************************************
883 template< typename VT // Type of the vector
884  , bool AF // Alignment flag
885  , bool TF // Transpose flag
886  , bool DF > // Density flag
887 inline bool isDefault( const Subvector<VT,AF,TF,DF>& sv )
888 {
889  for( size_t i=0UL; i<sv.size(); ++i )
890  if( !isDefault( sv[i] ) ) return false;
891  return true;
892 }
893 //*************************************************************************************************
894 
895 
896 //*************************************************************************************************
915 template< typename VT // Type of the sparse vector
916  , bool AF // Alignment flag
917  , bool TF > // Transpose flag
918 inline bool isDefault( const Subvector<VT,AF,TF,false>& sv )
919 {
920  typedef ConstIterator_< Subvector<VT,AF,TF,false> > ConstIterator;
921 
922  const ConstIterator end( sv.end() );
923  for( ConstIterator element=sv.begin(); element!=end; ++element )
924  if( !isDefault( element->value() ) ) return false;
925  return true;
926 }
928 //*************************************************************************************************
929 
930 
931 //*************************************************************************************************
948 template< typename VT // Type of the vector
949  , bool AF // Alignment flag
950  , bool TF // Transpose flag
951  , bool DF > // Density flag
952 inline bool isIntact( const Subvector<VT,AF,TF,DF>& sv ) noexcept
953 {
954  return ( sv.offset_ + sv.size_ <= sv.vector_.size() &&
955  isIntact( sv.vector_ ) );
956 }
957 //*************************************************************************************************
958 
959 
960 //*************************************************************************************************
972 template< typename VT // Type of the vector
973  , bool AF // Alignment flag
974  , bool TF // Transpose flag
975  , bool DF > // Density flag
976 inline bool isSame( const Subvector<VT,AF,TF,DF>& a, const Vector<VT,TF>& b ) noexcept
977 {
978  return ( isSame( a.vector_, ~b ) && ( a.size() == (~b).size() ) );
979 }
980 //*************************************************************************************************
981 
982 
983 //*************************************************************************************************
995 template< typename VT // Type of the vector
996  , bool AF // Alignment flag
997  , bool TF // Transpose flag
998  , bool DF > // Density flag
999 inline bool isSame( const Vector<VT,TF>& a, const Subvector<VT,AF,TF,DF>& b ) noexcept
1000 {
1001  return ( isSame( ~a, b.vector_ ) && ( (~a).size() == b.size() ) );
1002 }
1003 //*************************************************************************************************
1004 
1005 
1006 //*************************************************************************************************
1018 template< typename VT // Type of the vector
1019  , bool AF // Alignment flag
1020  , bool TF // Transpose flag
1021  , bool DF > // Density flag
1022 inline bool isSame( const Subvector<VT,AF,TF,DF>& a, const Subvector<VT,AF,TF,DF>& b ) noexcept
1023 {
1024  return ( isSame( a.vector_, b.vector_ ) && ( a.offset_ == b.offset_ ) && ( a.size_ == b.size_ ) );
1025 }
1026 //*************************************************************************************************
1027 
1028 
1029 //*************************************************************************************************
1044 template< typename VT1 // Type of the vector
1045  , bool AF // Alignment flag
1046  , bool TF // Transpose flag
1047  , bool DF // Density flag
1048  , typename VT2 > // Type of the right-hand side vector
1049 inline bool tryAssign( const Subvector<VT1,AF,TF,DF>& lhs, const Vector<VT2,TF>& rhs, size_t index )
1050 {
1051  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
1052  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.size() - index, "Invalid vector size" );
1053 
1054  return tryAssign( lhs.vector_, ~rhs, lhs.offset_ + index );
1055 }
1057 //*************************************************************************************************
1058 
1059 
1060 //*************************************************************************************************
1075 template< typename VT1 // Type of the vector
1076  , bool AF // Alignment flag
1077  , bool TF // Transpose flag
1078  , bool DF // Density flag
1079  , typename VT2 > // Type of the right-hand side vector
1080 inline bool tryAddAssign( const Subvector<VT1,AF,TF,DF>& lhs, const Vector<VT2,TF>& rhs, size_t index )
1081 {
1082  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
1083  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.size() - index, "Invalid vector size" );
1084 
1085  return tryAddAssign( lhs.vector_, ~rhs, lhs.offset_ + index );
1086 }
1088 //*************************************************************************************************
1089 
1090 
1091 //*************************************************************************************************
1106 template< typename VT1 // Type of the vector
1107  , bool AF // Alignment flag
1108  , bool TF // Transpose flag
1109  , bool DF // Density flag
1110  , typename VT2 > // Type of the right-hand side vector
1111 inline bool trySubAssign( const Subvector<VT1,AF,TF,DF>& lhs, const Vector<VT2,TF>& rhs, size_t index )
1112 {
1113  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
1114  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.size() - index, "Invalid vector size" );
1115 
1116  return trySubAssign( lhs.vector_, ~rhs, lhs.offset_ + index );
1117 }
1119 //*************************************************************************************************
1120 
1121 
1122 //*************************************************************************************************
1137 template< typename VT1 // Type of the vector
1138  , bool AF // Alignment flag
1139  , bool TF // Transpose flag
1140  , bool DF // Density flag
1141  , typename VT2 > // Type of the right-hand side vector
1142 inline bool tryMultAssign( const Subvector<VT1,AF,TF,DF>& lhs, const Vector<VT2,TF>& rhs, size_t index )
1143 {
1144  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
1145  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.size() - index, "Invalid vector size" );
1146 
1147  return tryMultAssign( lhs.vector_, ~rhs, lhs.offset_ + index );
1148 }
1150 //*************************************************************************************************
1151 
1152 
1153 //*************************************************************************************************
1168 template< typename VT1 // Type of the vector
1169  , bool AF // Alignment flag
1170  , bool TF // Transpose flag
1171  , bool DF // Density flag
1172  , typename VT2 > // Type of the right-hand side vector
1173 inline bool tryDivAssign( const Subvector<VT1,AF,TF,DF>& lhs, const Vector<VT2,TF>& rhs, size_t index )
1174 {
1175  BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
1176  BLAZE_INTERNAL_ASSERT( (~rhs).size() <= lhs.size() - index, "Invalid vector size" );
1177 
1178  return tryDivAssign( lhs.vector_, ~rhs, lhs.offset_ + index );
1179 }
1181 //*************************************************************************************************
1182 
1183 
1184 //*************************************************************************************************
1199 template< typename VT // Type of the vector
1200  , bool AF // Alignment flag
1201  , bool TF // Transpose flag
1202  , bool DF > // Density flag
1203 inline DerestrictTrait_< Subvector<VT,AF,TF,DF> > derestrict( Subvector<VT,AF,TF,DF>& sv )
1204 {
1205  typedef DerestrictTrait_< Subvector<VT,AF,TF,DF> > ReturnType;
1206  return ReturnType( derestrict( sv.vector_ ), sv.offset_, sv.size_ );
1207 }
1209 //*************************************************************************************************
1210 
1211 
1212 
1213 
1214 //=================================================================================================
1215 //
1216 // ISRESTRICTED SPECIALIZATIONS
1217 //
1218 //=================================================================================================
1219 
1220 //*************************************************************************************************
1222 template< typename VT, bool AF, bool TF, bool DF >
1223 struct IsRestricted< Subvector<VT,AF,TF,DF> >
1224  : public BoolConstant< IsRestricted<VT>::value >
1225 {};
1227 //*************************************************************************************************
1228 
1229 
1230 
1231 
1232 //=================================================================================================
1233 //
1234 // DERESTRICTTRAIT SPECIALIZATIONS
1235 //
1236 //=================================================================================================
1237 
1238 //*************************************************************************************************
1240 template< typename VT, bool AF, bool TF, bool DF >
1241 struct DerestrictTrait< Subvector<VT,AF,TF,DF> >
1242 {
1243  using Type = Subvector< RemoveReference_< DerestrictTrait_<VT> >, AF, TF, DF >;
1244 };
1246 //*************************************************************************************************
1247 
1248 
1249 
1250 
1251 //=================================================================================================
1252 //
1253 // HASCONSTDATAACCESS SPECIALIZATIONS
1254 //
1255 //=================================================================================================
1256 
1257 //*************************************************************************************************
1259 template< typename VT, bool AF, bool TF >
1260 struct HasConstDataAccess< Subvector<VT,AF,TF,true> >
1261  : public BoolConstant< HasConstDataAccess<VT>::value >
1262 {};
1264 //*************************************************************************************************
1265 
1266 
1267 
1268 
1269 //=================================================================================================
1270 //
1271 // HASMUTABLEDATAACCESS SPECIALIZATIONS
1272 //
1273 //=================================================================================================
1274 
1275 //*************************************************************************************************
1277 template< typename VT, bool AF, bool TF >
1278 struct HasMutableDataAccess< Subvector<VT,AF,TF,true> >
1279  : public BoolConstant< HasMutableDataAccess<VT>::value >
1280 {};
1282 //*************************************************************************************************
1283 
1284 
1285 
1286 
1287 //=================================================================================================
1288 //
1289 // ISALIGNED SPECIALIZATIONS
1290 //
1291 //=================================================================================================
1292 
1293 //*************************************************************************************************
1295 template< typename VT, bool TF >
1296 struct IsAligned< Subvector<VT,aligned,TF,true> > : public TrueType
1297 {};
1299 //*************************************************************************************************
1300 
1301 
1302 
1303 
1304 //=================================================================================================
1305 //
1306 // ADDTRAIT SPECIALIZATIONS
1307 //
1308 //=================================================================================================
1309 
1310 //*************************************************************************************************
1312 template< typename VT, bool AF, bool TF, bool DF, typename T >
1313 struct AddTrait< Subvector<VT,AF,TF,DF>, T >
1314 {
1315  using Type = AddTrait_< SubvectorTrait_<VT>, T >;
1316 };
1317 
1318 template< typename T, typename VT, bool AF, bool TF, bool DF >
1319 struct AddTrait< T, Subvector<VT,AF,TF,DF> >
1320 {
1321  using Type = AddTrait_< T, SubvectorTrait_<VT> >;
1322 };
1324 //*************************************************************************************************
1325 
1326 
1327 
1328 
1329 //=================================================================================================
1330 //
1331 // SUBTRAIT SPECIALIZATIONS
1332 //
1333 //=================================================================================================
1334 
1335 //*************************************************************************************************
1337 template< typename VT, bool AF, bool TF, bool DF, typename T >
1338 struct SubTrait< Subvector<VT,AF,TF,DF>, T >
1339 {
1340  using Type = SubTrait_< SubvectorTrait_<VT>, T >;
1341 };
1342 
1343 template< typename T, typename VT, bool AF, bool TF, bool DF >
1344 struct SubTrait< T, Subvector<VT,AF,TF,DF> >
1345 {
1346  using Type = SubTrait_< T, SubvectorTrait_<VT> >;
1347 };
1349 //*************************************************************************************************
1350 
1351 
1352 
1353 
1354 //=================================================================================================
1355 //
1356 // MULTTRAIT SPECIALIZATIONS
1357 //
1358 //=================================================================================================
1359 
1360 //*************************************************************************************************
1362 template< typename VT, bool AF, bool TF, bool DF, typename T >
1363 struct MultTrait< Subvector<VT,AF,TF,DF>, T >
1364 {
1365  using Type = MultTrait_< SubvectorTrait_<VT>, T >;
1366 };
1367 
1368 template< typename T, typename VT, bool AF, bool TF, bool DF >
1369 struct MultTrait< T, Subvector<VT,AF,TF,DF> >
1370 {
1371  using Type = MultTrait_< T, SubvectorTrait_<VT> >;
1372 };
1374 //*************************************************************************************************
1375 
1376 
1377 
1378 
1379 //=================================================================================================
1380 //
1381 // CROSSTRAIT SPECIALIZATIONS
1382 //
1383 //=================================================================================================
1384 
1385 //*************************************************************************************************
1387 template< typename VT, bool AF, bool TF, bool DF, typename T >
1388 struct CrossTrait< Subvector<VT,AF,TF,DF>, T >
1389 {
1390  using Type = CrossTrait_< SubvectorTrait_<VT>, T >;
1391 };
1392 
1393 template< typename T, typename VT, bool AF, bool TF, bool DF >
1394 struct CrossTrait< T, Subvector<VT,AF,TF,DF> >
1395 {
1396  using Type = CrossTrait_< T, SubvectorTrait_<VT> >;
1397 };
1399 //*************************************************************************************************
1400 
1401 
1402 
1403 
1404 //=================================================================================================
1405 //
1406 // DIVTRAIT SPECIALIZATIONS
1407 //
1408 //=================================================================================================
1409 
1410 //*************************************************************************************************
1412 template< typename VT, bool AF, bool TF, bool DF, typename T >
1413 struct DivTrait< Subvector<VT,AF,TF,DF>, T >
1414 {
1415  using Type = DivTrait_< SubvectorTrait_<VT>, T >;
1416 };
1417 
1418 template< typename T, typename VT, bool AF, bool TF, bool DF >
1419 struct DivTrait< T, Subvector<VT,AF,TF,DF> >
1420 {
1421  using Type = DivTrait_< T, SubvectorTrait_<VT> >;
1422 };
1424 //*************************************************************************************************
1425 
1426 
1427 
1428 
1429 //=================================================================================================
1430 //
1431 // SUBVECTORTRAIT SPECIALIZATIONS
1432 //
1433 //=================================================================================================
1434 
1435 //*************************************************************************************************
1437 template< typename VT, bool AF, bool TF, bool DF >
1438 struct SubvectorTrait< Subvector<VT,AF,TF,DF> >
1439 {
1440  using Type = SubvectorTrait_< ResultType_< Subvector<VT,AF,TF,DF> > >;
1441 };
1443 //*************************************************************************************************
1444 
1445 
1446 
1447 
1448 //=================================================================================================
1449 //
1450 // SUBVECTOREXPRTRAIT SPECIALIZATIONS
1451 //
1452 //=================================================================================================
1453 
1454 //*************************************************************************************************
1456 template< typename VT, bool AF1, bool TF, bool DF, bool AF2 >
1457 struct SubvectorExprTrait< Subvector<VT,AF1,TF,DF>, AF2 >
1458 {
1459  using Type = Subvector<VT,AF2,TF,DF>;
1460 };
1462 //*************************************************************************************************
1463 
1464 
1465 //*************************************************************************************************
1467 template< typename VT, bool AF1, bool TF, bool DF, bool AF2 >
1468 struct SubvectorExprTrait< const Subvector<VT,AF1,TF,DF>, AF2 >
1469 {
1470  using Type = Subvector<VT,AF2,TF,DF>;
1471 };
1473 //*************************************************************************************************
1474 
1475 
1476 //*************************************************************************************************
1478 template< typename VT, bool AF1, bool TF, bool DF, bool AF2 >
1479 struct SubvectorExprTrait< volatile Subvector<VT,AF1,TF,DF>, AF2 >
1480 {
1481  using Type = Subvector<VT,AF2,TF,DF>;
1482 };
1484 //*************************************************************************************************
1485 
1486 
1487 //*************************************************************************************************
1489 template< typename VT, bool AF1, bool TF, bool DF, bool AF2 >
1490 struct SubvectorExprTrait< const volatile Subvector<VT,AF1,TF,DF>, AF2 >
1491 {
1492  using Type = Subvector<VT,AF2,TF,DF>;
1493 };
1495 //*************************************************************************************************
1496 
1497 
1498 //*************************************************************************************************
1500 template< typename VT1, typename VT2, bool TF, bool AF >
1501 struct SubvectorExprTrait< DVecDVecCrossExpr<VT1,VT2,TF>, AF >
1502 {
1503  public:
1504  //**********************************************************************************************
1505  using Type = Subvector< DVecDVecCrossExpr<VT1,VT2,TF>, unaligned, TF, true >;
1506  //**********************************************************************************************
1507 };
1509 //*************************************************************************************************
1510 
1511 
1512 //*************************************************************************************************
1514 template< typename VT1, typename VT2, bool TF, bool AF >
1515 struct SubvectorExprTrait< DVecSVecCrossExpr<VT1,VT2,TF>, AF >
1516 {
1517  public:
1518  //**********************************************************************************************
1519  using Type = Subvector< DVecSVecCrossExpr<VT1,VT2,TF>, unaligned, TF, true >;
1520  //**********************************************************************************************
1521 };
1523 //*************************************************************************************************
1524 
1525 
1526 //*************************************************************************************************
1528 template< typename VT1, typename VT2, bool TF, bool AF >
1529 struct SubvectorExprTrait< SVecDVecCrossExpr<VT1,VT2,TF>, AF >
1530 {
1531  public:
1532  //**********************************************************************************************
1533  using Type = Subvector< SVecDVecCrossExpr<VT1,VT2,TF>, unaligned, TF, true >;
1534  //**********************************************************************************************
1535 };
1537 //*************************************************************************************************
1538 
1539 
1540 //*************************************************************************************************
1542 template< typename VT1, typename VT2, bool TF, bool AF >
1543 struct SubvectorExprTrait< SVecSVecCrossExpr<VT1,VT2,TF>, AF >
1544 {
1545  public:
1546  //**********************************************************************************************
1547  using Type = Subvector< SVecSVecCrossExpr<VT1,VT2,TF>, unaligned, TF, true >;
1548  //**********************************************************************************************
1549 };
1551 //*************************************************************************************************
1552 
1553 } // namespace blaze
1554 
1555 #endif
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.This macro encapsulates the default way o...
Definition: Exception.h:235
Header file for auxiliary alias declarations.
View on a specific subvector of a dense or sparse vector.The Subvector class template represents a vi...
Definition: Forward.h:50
Header file for the alignment flag values.
Header file for the subtraction trait.
BLAZE_ALWAYS_INLINE bool isSame(const Matrix< MT1, SO1 > &a, const Matrix< MT2, SO2 > &b) noexcept
Returns whether the two given matrices represent the same observable state.
Definition: Matrix.h:653
Header file for basic type definitions.
Header file for the IsVecVecMultExpr type trait class.
Header file for the IsCrossExpr type trait class.
Header file for the serial shim.
Header file for the IsVecVecSubExpr type trait class.
BLAZE_ALWAYS_INLINE size_t size(const Vector< VT, TF > &vector) noexcept
Returns the current size/dimension of the vector.
Definition: Vector.h:258
Subvector specialization for sparse vectors.
const bool aligned
Alignment flag for aligned vectors and matrices.Via this flag it is possible to specify subvectors...
Definition: AlignmentFlag.h:85
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:533
Header file for the IsVecForEachExpr type trait class.
Header file for the IsTransExpr type trait class.
const DMatSerialExpr< MT, SO > serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:723
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
Header file for the IsVecSerialExpr type trait class.
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:573
Subvector specialization for dense vectors.
Header file for the IsVecEvalExpr type trait class.
SubvectorExprTrait_< VT, unaligned > subvector(Vector< VT, TF > &vector, size_t index, size_t size)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:152
Header file for the IsVecVecAddExpr type trait class.
Header file for the DisableIf class template.
Header file for the multiplication trait.
Header file for the IsVecVecDivExpr type trait class.
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
const Element * ConstIterator
Iterator over constant elements.
Definition: CompressedMatrix.h:2647
Header file for the Or class template.
const DMatForEachExpr< MT, OP, SO > forEach(const DenseMatrix< MT, SO > &dm, OP op)
Evaluates the given custom operation on each single element of the dense matrix dm.
Definition: DMatForEachExpr.h:1046
Header file for the implementation of the Subvector base template.
typename SubvectorExprTrait< VT, AF >::Type SubvectorExprTrait_
Auxiliary alias declaration for the SubvectorExprTrait type trait.The SubvectorExprTrait_ alias decla...
Definition: SubvectorExprTrait.h:133
Header file for the subvector trait.
Header file for the IsVecScalarDivExpr type trait class.
Header file for the IsAligned type trait.
Header file for the exception macros of the math module.
BLAZE_ALWAYS_INLINE 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:254
const bool unaligned
Alignment flag for unaligned vectors and matrices.Via this flag it is possible to specify subvectors...
Definition: AlignmentFlag.h:64
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:553
Header file for the HasConstDataAccess type trait.
Header file for the IsVecTransExpr type trait class.
const Type & ReturnType
Return type for expression template evaluations.
Definition: CompressedMatrix.h:2642
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
Header file for the isDefault shim.
Header file for the HasMutableDataAccess type trait.
const DMatEvalExpr< MT, SO > eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:705
IntegralConstant< bool, B > BoolConstant
Generic wrapper for a compile time constant boolean value.The BoolConstant class template represents ...
Definition: IntegralConstant.h:100
Header file for the RemoveReference type trait.
Header file for the IsVecScalarMultExpr type trait class.
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:154
const DMatTransExpr< MT,!SO > trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:950
Header file for the IsComputation type trait class.
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:157
Header file for the IntegralConstant class template.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:240
Header file for the SubvectorExprTrait class template.
Header file for the Vector CRTP base class.
#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
Header file for the TrueType type/value trait base class.
Header file for the FunctionTrace class.