Blaze 3.9
Elements.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_MATH_VIEWS_ELEMENTS_H_
36#define _BLAZE_MATH_VIEWS_ELEMENTS_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <array>
44#include <numeric>
45#include <utility>
46#include <vector>
47#include <blaze/math/Aliases.h>
82#include <blaze/util/Assert.h>
83#include <blaze/util/EnableIf.h>
90#include <blaze/util/Types.h>
93
94
95namespace blaze {
96
97//=================================================================================================
98//
99// GLOBAL FUNCTIONS
100//
101//=================================================================================================
102
103//*************************************************************************************************
138template< size_t I // First element index
139 , size_t... Is // Remaining element indices
140 , typename VT // Type of the vector
141 , bool TF // Transpose flag
142 , typename... REAs > // Optional arguments
143inline decltype(auto) elements( Vector<VT,TF>& vector, REAs... args )
144{
146
147 using ReturnType = Elements_< VT, index_sequence<I,Is...> >;
148 return ReturnType( *vector, args... );
149}
150//*************************************************************************************************
151
152
153//*************************************************************************************************
188template< size_t I // First element index
189 , size_t... Is // Remaining element indices
190 , typename VT // Type of the vector
191 , bool TF // Transpose flag
192 , typename... REAs > // Optional arguments
193inline decltype(auto) elements( const Vector<VT,TF>& vector, REAs... args )
194{
196
197 using ReturnType = const Elements_< const VT, index_sequence<I,Is...> >;
198 return ReturnType( *vector, args... );
199}
200//*************************************************************************************************
201
202
203//*************************************************************************************************
217template< size_t I // First element index
218 , size_t... Is // Remaining element indices
219 , typename VT // Type of the vector
220 , bool TF // Transpose flag
221 , typename... REAs > // Optional arguments
222inline decltype(auto) elements( Vector<VT,TF>&& vector, REAs... args )
223{
225
226 using ReturnType = Elements_< VT, index_sequence<I,Is...> >;
227 return ReturnType( *vector, args... );
228}
229//*************************************************************************************************
230
231
232//*************************************************************************************************
271template< typename VT // Type of the vector
272 , bool TF // Transpose flag
273 , typename T // Type of the element indices
274 , typename... REAs > // Optional arguments
275inline decltype(auto) elements( Vector<VT,TF>& vector, T* indices, size_t n, REAs... args )
276{
278
279 using ReturnType = Elements_<VT>;
280 return ReturnType( *vector, indices, n, args... );
281}
282//*************************************************************************************************
283
284
285//*************************************************************************************************
324template< typename VT // Type of the vector
325 , bool TF // Transpose flag
326 , typename T // Type of the element indices
327 , typename... REAs > // Optional arguments
328inline decltype(auto) elements( const Vector<VT,TF>& vector, T* indices, size_t n, REAs... args )
329{
331
332 using ReturnType = const Elements_<const VT>;
333 return ReturnType( *vector, indices, n, args... );
334}
335//*************************************************************************************************
336
337
338//*************************************************************************************************
354template< typename VT // Type of the vector
355 , bool TF // Transpose flag
356 , typename T // Type of the element indices
357 , typename... REAs > // Optional arguments
358inline decltype(auto) elements( Vector<VT,TF>&& vector, T* indices, size_t n, REAs... args )
359{
361
362 using ReturnType = Elements_<VT>;
363 return ReturnType( *vector, indices, n, args... );
364}
365//*************************************************************************************************
366
367
368//*************************************************************************************************
405template< typename VT // Type of the vector
406 , bool TF // Transpose flag
407 , typename P // Type of the index producer
408 , typename... REAs > // Optional arguments
409inline decltype(auto) elements( Vector<VT,TF>& vector, P p, size_t n, REAs... args )
410{
412
413 using ReturnType = Elements_<VT,P>;
414 return ReturnType( *vector, p, n, args... );
415}
416//*************************************************************************************************
417
418
419//*************************************************************************************************
458template< typename VT // Type of the vector
459 , bool TF // Transpose flag
460 , typename P // Type of the index producer
461 , typename... REAs > // Optional arguments
462inline decltype(auto) elements( const Vector<VT,TF>& vector, P p, size_t n, REAs... args )
463{
465
466 using ReturnType = const Elements_<const VT,P>;
467 return ReturnType( *vector, p, n, args... );
468}
469//*************************************************************************************************
470
471
472//*************************************************************************************************
488template< typename VT // Type of the vector
489 , bool TF // Transpose flag
490 , typename P // Type of the index producer
491 , typename... REAs > // Optional arguments
492inline decltype(auto) elements( Vector<VT,TF>&& vector, P p, size_t n, REAs... args )
493{
495
496 using ReturnType = Elements_<VT,P>;
497 return ReturnType( *vector, p, n, args... );
498}
499//*************************************************************************************************
500
501
502//*************************************************************************************************
539template< typename VT // Type of the vector
540 , size_t... Is // Element indices
541 , typename... REAs > // Optional arguments
542inline decltype(auto) elements( VT&& vector, index_sequence<Is...> indices, REAs... args )
543{
545
546 MAYBE_UNUSED( indices );
547
548 return elements<Is...>( std::forward<VT>( vector ), args... );
549}
551//*************************************************************************************************
552
553
554//*************************************************************************************************
589template< typename VT // Type of the vector
590 , typename T // Type of the element indices
591 , typename... REAs > // Optional arguments
592inline decltype(auto) elements( VT&& vector, initializer_list<T> indices, REAs... args )
593{
595
596 return elements( std::forward<VT>( vector ), indices.begin(), indices.size(), args... );
597}
598//*************************************************************************************************
599
600
601//*************************************************************************************************
638template< typename VT // Type of the vector
639 , typename T // Type of the element indices
640 , size_t N // Number of indices
641 , typename... REAs > // Optional arguments
642inline decltype(auto) elements( VT&& vector, const std::array<T,N>& indices, REAs... args )
643{
645
646 return elements( std::forward<VT>( vector ), indices.data(), N, args... );
647}
648//*************************************************************************************************
649
650
651//*************************************************************************************************
688template< typename VT // Type of the vector
689 , typename T // Type of the element indices
690 , typename... REAs > // Optional arguments
691inline decltype(auto) elements( VT&& vector, const std::vector<T>& indices, REAs... args )
692{
694
695 return elements( std::forward<VT>( vector ), indices.data(), indices.size(), args... );
696}
697//*************************************************************************************************
698
699
700//*************************************************************************************************
737template< typename VT // Type of the vector
738 , typename T // Type of the element indices
739 , size_t N // Number of preallocated elements
740 , typename... REAs > // Optional arguments
741inline decltype(auto) elements( VT&& vector, const SmallArray<T,N>& indices, REAs... args )
742{
744
745 return elements( std::forward<VT>( vector ), indices.data(), indices.size(), args... );
746}
747//*************************************************************************************************
748
749
750//*************************************************************************************************
765template< typename VT // Type of the vector
766 , typename T1 // First type of the pair of arguments
767 , typename T2 // Second type of the pair of arguments
768 , typename... REAs > // Optional arguments
769inline decltype(auto) elements( VT&& vector, const std::pair<T1,T2>& pair, REAs... args )
770{
772
773 return elements( std::forward<VT>( vector ), pair.first, pair.second, args... );
774}
776//*************************************************************************************************
777
778
779
780
781//=================================================================================================
782//
783// GLOBAL RESTRUCTURING FUNCTIONS
784//
785//=================================================================================================
786
787//*************************************************************************************************
800template< size_t... CEAs // Compile time element arguments
801 , typename VT // Vector base type of the expression
802 , typename... REAs > // Runtime element arguments
803inline decltype(auto) elements( const VecVecAddExpr<VT>& vector, REAs... args )
804{
806
807 return elements<CEAs...>( (*vector).leftOperand(), args... ) +
808 elements<CEAs...>( (*vector).rightOperand(), args... );
809}
811//*************************************************************************************************
812
813
814//*************************************************************************************************
827template< size_t... CEAs // Compile time element arguments
828 , typename VT // Vector base type of the expression
829 , typename... REAs > // Runtime element arguments
830inline decltype(auto) elements( const VecVecSubExpr<VT>& vector, REAs... args )
831{
833
834 return elements<CEAs...>( (*vector).leftOperand(), args... ) -
835 elements<CEAs...>( (*vector).rightOperand(), args... );
836}
838//*************************************************************************************************
839
840
841//*************************************************************************************************
854template< size_t... CEAs // Compile time element arguments
855 , typename VT // Vector base type of the expression
856 , typename... REAs > // Runtime element arguments
857inline decltype(auto) elements( const VecVecMultExpr<VT>& vector, REAs... args )
858{
860
861 return elements<CEAs...>( (*vector).leftOperand(), args... ) *
862 elements<CEAs...>( (*vector).rightOperand(), args... );
863}
865//*************************************************************************************************
866
867
868//*************************************************************************************************
881template< size_t I // First element index
882 , size_t... Is // Remaining element indices
883 , typename VT // Vector base type of the expression
884 , typename... REAs > // Optional arguments
885inline decltype(auto) elements( const VecVecKronExpr<VT>& vector, REAs... args )
886{
888
889 decltype(auto) lhs( (*vector).leftOperand() );
890 decltype(auto) rhs( (*vector).rightOperand() );
891
892 const size_t N( rhs.size() );
893
894 const auto lhsIndices( [N]( size_t i ) {
895 constexpr size_t indices[] = { I, Is... };
896 return indices[i] / N;
897 } );
898
899 const auto rhsIndices( [N]( size_t i ) {
900 constexpr size_t indices[] = { I, Is... };
901 return indices[i] % N;
902 } );
903
904 return elements( lhs, lhsIndices, sizeof...(Is)+1UL, args... ) *
905 elements( rhs, rhsIndices, sizeof...(Is)+1UL, args... );
906}
908//*************************************************************************************************
909
910
911//*************************************************************************************************
926template< typename VT // Vector base type of the expression
927 , typename T // Type of the element indices
928 , typename... REAs > // Optional arguments
929inline decltype(auto) elements( const VecVecKronExpr<VT>& vector, T* indices, size_t n, REAs... args )
930{
932
933 decltype(auto) lhs( (*vector).leftOperand() );
934 decltype(auto) rhs( (*vector).rightOperand() );
935
936 const size_t N( rhs.size() );
937
938 SmallArray<size_t,128UL> lhsIndices;
939 lhsIndices.reserve( n );
940
941 for( size_t i=0UL; i<n; ++i ) {
942 lhsIndices.pushBack( indices[i] / N );
943 }
944
945 SmallArray<size_t,128UL> rhsIndices;
946 rhsIndices.reserve( n );
947
948 for( size_t i=0UL; i<n; ++i ) {
949 rhsIndices.pushBack( indices[i] % N );
950 }
951
952 return elements( lhs, lhsIndices, n, args... ) * elements( rhs, rhsIndices, n, args... );
953}
955//*************************************************************************************************
956
957
958//*************************************************************************************************
973template< typename VT // Vector base type of the expression
974 , typename P // Type of the index producer
975 , typename... REAs > // Optional arguments
976inline decltype(auto) elements( const VecVecKronExpr<VT>& vector, P p, size_t n, REAs... args )
977{
979
980 decltype(auto) lhs( (*vector).leftOperand() );
981 decltype(auto) rhs( (*vector).rightOperand() );
982
983 const size_t N( rhs.size() );
984
985 const auto lhsIndices( [p,N]( size_t i ) { return p(i) / N; } );
986 const auto rhsIndices( [p,N]( size_t i ) { return p(i) % N; } );
987
988 return elements( lhs, lhsIndices, n, args... ) * elements( rhs, rhsIndices, n, args... );
989}
991//*************************************************************************************************
992
993
994//*************************************************************************************************
1007template< size_t... CEAs // Compile time element arguments
1008 , typename VT // Vector base type of the expression
1009 , typename... REAs > // Runtime element arguments
1010inline decltype(auto) elements( const VecVecDivExpr<VT>& vector, REAs... args )
1011{
1013
1014 return elements<CEAs...>( (*vector).leftOperand(), args... ) /
1015 elements<CEAs...>( (*vector).rightOperand(), args... );
1016}
1018//*************************************************************************************************
1019
1020
1021//*************************************************************************************************
1034template< size_t... CEAs // Compile time element arguments
1035 , typename VT // Vector base type of the expression
1036 , typename... REAs > // Runtime element arguments
1037inline decltype(auto) elements( const VecScalarMultExpr<VT>& vector, REAs... args )
1038{
1040
1041 return elements<CEAs...>( (*vector).leftOperand(), args... ) * (*vector).rightOperand();
1042}
1044//*************************************************************************************************
1045
1046
1047//*************************************************************************************************
1060template< size_t... CEAs // Compile time element arguments
1061 , typename VT // Vector base type of the expression
1062 , typename... REAs > // Runtime element arguments
1063inline decltype(auto) elements( const VecScalarDivExpr<VT>& vector, REAs... args )
1064{
1066
1067 return elements<CEAs...>( (*vector).leftOperand(), args... ) / (*vector).rightOperand();
1068}
1070//*************************************************************************************************
1071
1072
1073//*************************************************************************************************
1086template< size_t... CEAs // Compile time element arguments
1087 , typename VT // Vector base type of the expression
1088 , typename... REAs > // Runtime element arguments
1089inline decltype(auto) elements( const VecMapExpr<VT>& vector, REAs... args )
1090{
1092
1093 return map( elements<CEAs...>( (*vector).operand(), args... ), (*vector).operation() );
1094}
1096//*************************************************************************************************
1097
1098
1099//*************************************************************************************************
1112template< size_t... CEAs // Compile time element arguments
1113 , typename VT // Vector base type of the expression
1114 , typename... REAs > // Runtime element arguments
1115inline decltype(auto) elements( const VecVecMapExpr<VT>& vector, REAs... args )
1116{
1118
1119 return map( elements<CEAs...>( (*vector).leftOperand(), args... ),
1120 elements<CEAs...>( (*vector).rightOperand(), args... ),
1121 (*vector).operation() );
1122}
1124//*************************************************************************************************
1125
1126
1127//*************************************************************************************************
1140template< size_t... CEAs // Compile time element arguments
1141 , typename VT // Vector base type of the expression
1142 , typename... REAs > // Runtime element arguments
1143inline decltype(auto) elements( const VecEvalExpr<VT>& vector, REAs... args )
1144{
1146
1147 return eval( elements<CEAs...>( (*vector).operand(), args... ) );
1148}
1150//*************************************************************************************************
1151
1152
1153//*************************************************************************************************
1166template< size_t... CEAs // Compile time element arguments
1167 , typename VT // Vector base type of the expression
1168 , typename... REAs > // Runtime element arguments
1169inline decltype(auto) elements( const VecSerialExpr<VT>& vector, REAs... args )
1170{
1172
1173 return serial( elements<CEAs...>( (*vector).operand(), args... ) );
1174}
1176//*************************************************************************************************
1177
1178
1179//*************************************************************************************************
1192template< size_t... CEAs // Compile time element arguments
1193 , typename VT // Vector base type of the expression
1194 , typename... REAs > // Runtime element arguments
1195inline decltype(auto) elements( const VecNoAliasExpr<VT>& vector, REAs... args )
1196{
1198
1199 return noalias( elements<CEAs...>( (*vector).operand(), args... ) );
1200}
1202//*************************************************************************************************
1203
1204
1205//*************************************************************************************************
1218template< size_t... CEAs // Compile time element arguments
1219 , typename VT // Vector base type of the expression
1220 , typename... REAs > // Runtime element arguments
1221inline decltype(auto) elements( const VecNoSIMDExpr<VT>& vector, REAs... args )
1222{
1224
1225 return nosimd( elements<CEAs...>( (*vector).operand(), args... ) );
1226}
1228//*************************************************************************************************
1229
1230
1231//*************************************************************************************************
1244template< size_t... CEAs // Compile time element arguments
1245 , typename VT // Vector base type of the expression
1246 , typename... REAs > // Runtime element arguments
1247inline decltype(auto) elements( const VecTransExpr<VT>& vector, REAs... args )
1248{
1250
1251 return trans( elements<CEAs...>( (*vector).operand(), args... ) );
1252}
1254//*************************************************************************************************
1255
1256
1257//*************************************************************************************************
1270template< size_t I // First element index
1271 , size_t... Is // Remaining element indices
1272 , typename VT // Vector base type of the expression
1273 , size_t... CRAs // Compile time repeater arguments
1274 , typename... REAs > // Optional element arguments
1275inline decltype(auto) elements( const VecRepeatExpr<VT,CRAs...>& vector, REAs... args )
1276{
1278
1279 if( isChecked( args... ) ) {
1280 constexpr size_t indices[] = { I, Is... };
1281 for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1282 if( (*vector).size() <= indices[i] ) {
1283 BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1284 }
1285 }
1286 }
1287
1288 auto lambda = [size=(*vector).operand().size()]( size_t i ) {
1289 constexpr size_t indices[] = { I, Is... };
1290 return indices[i] % size;
1291 };
1292
1293 return elements( (*vector).operand(), std::move(lambda), sizeof...(Is)+1UL, unchecked );
1294}
1296//*************************************************************************************************
1297
1298
1299//*************************************************************************************************
1314template< typename VT // Vector base type of the expression
1315 , size_t... CRAs // Compile time repeater arguments
1316 , typename T // Type of the element indices
1317 , typename... REAs > // Optional element arguments
1318inline decltype(auto)
1319 elements( const VecRepeatExpr<VT,CRAs...>& vector, T* indices, size_t n, REAs... args )
1320{
1322
1323 if( isChecked( args... ) ) {
1324 for( size_t i=0UL; i<n; ++i ) {
1325 if( (*vector).size() <= size_t( indices[i] ) ) {
1326 BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1327 }
1328 }
1329 }
1330
1331 SmallArray<size_t,128UL> newIndices( indices, indices+n );
1332
1333 for( size_t& index : newIndices ) {
1334 index = index % (*vector).operand().size();
1335 }
1336
1337 return elements( (*vector).operand(), newIndices, unchecked );
1338}
1340//*************************************************************************************************
1341
1342
1343//*************************************************************************************************
1358template< typename VT // Vector base type of the expression
1359 , size_t... CRAs // Compile time repeater arguments
1360 , typename P // Type of the index producer
1361 , typename... REAs > // Optional element arguments
1362inline decltype(auto)
1363 elements( const VecRepeatExpr<VT,CRAs...>& vector, P p, size_t n, REAs... args )
1364{
1366
1367 if( isChecked( args... ) ) {
1368 for( size_t i=0UL; i<n; ++i ) {
1369 if( (*vector).size() <= size_t( p(i) ) ) {
1370 BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1371 }
1372 }
1373 }
1374
1375 auto lambda = [size=(*vector).operand().size(),p]( size_t i ) {
1376 return p(i) % size;
1377 };
1378
1379 return elements( (*vector).operand(), std::move(lambda), n, unchecked );
1380}
1382//*************************************************************************************************
1383
1384
1385
1386
1387//=================================================================================================
1388//
1389// GLOBAL RESTRUCTURING FUNCTIONS (ELEMENTS)
1390//
1391//=================================================================================================
1392
1393//*************************************************************************************************
1405template< size_t I // First required element index
1406 , size_t... Is // Remaining required element indices
1407 , typename VT // Type of the vector
1408 , typename... REAs // Optional element arguments
1409 , EnableIf_t< IsElements_v< RemoveReference_t<VT> > &&
1410 RemoveReference_t<VT>::compileTimeArgs >* = nullptr >
1411inline decltype(auto) elements( VT&& e, REAs... args )
1412{
1414
1415 return elements( e.operand(), subsequence<I,Is...>( RemoveReference_t<VT>::idces() ), args... );
1416}
1418//*************************************************************************************************
1419
1420
1421//*************************************************************************************************
1434template< size_t I // First element index
1435 , size_t... Is // Remaining element indices
1436 , typename VT // Type of the vector
1437 , typename... REAs // Optional element arguments
1438 , EnableIf_t< IsElements_v< RemoveReference_t<VT> > &&
1439 !RemoveReference_t<VT>::compileTimeArgs >* = nullptr >
1440inline decltype(auto) elements( VT&& e, REAs... args )
1441{
1443
1444 if( isChecked( args... ) ) {
1445 constexpr size_t indices[] = { I, Is... };
1446 for( size_t i=0UL; i<sizeof...(Is)+1UL; ++i ) {
1447 if( e.size() <= indices[i] ) {
1448 BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1449 }
1450 }
1451 }
1452
1453 return elements( e.operand(), { e.idx(I), e.idx(Is)... }, unchecked );
1454}
1456//*************************************************************************************************
1457
1458
1459//*************************************************************************************************
1474template< typename VT // Type of the vector
1475 , typename T // Type of the element indices
1476 , typename... REAs // Optional element arguments
1477 , EnableIf_t< IsElements_v< RemoveReference_t<VT> > >* = nullptr >
1478inline decltype(auto) elements( VT&& e, T* indices, size_t n, REAs... args )
1479{
1481
1482 if( isChecked( args... ) ) {
1483 for( size_t i=0UL; i<n; ++i ) {
1484 if( e.size() <= size_t( indices[i] ) ) {
1485 BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1486 }
1487 }
1488 }
1489
1490 SmallArray<size_t,128UL> newIndices;
1491 newIndices.reserve( n );
1492
1493 for( size_t i=0UL; i<n; ++i ) {
1494 newIndices.pushBack( e.idx( indices[i] ) );
1495 }
1496
1497 return elements( e.operand(), newIndices.data(), newIndices.size(), unchecked );
1498}
1500//*************************************************************************************************
1501
1502
1503//*************************************************************************************************
1518template< typename VT // Type of the vector
1519 , typename P // Type of the index producer
1520 , typename... REAs // Optional element arguments
1521 , EnableIf_t< IsElements_v< RemoveReference_t<VT> > && !IsPointer_v<P> >* = nullptr >
1522inline decltype(auto) elements( VT&& e, P p, size_t n, REAs... args )
1523{
1525
1526 if( isChecked( args... ) ) {
1527 for( size_t i=0UL; i<n; ++i ) {
1528 if( e.size() <= size_t( p(i) ) ) {
1529 BLAZE_THROW_INVALID_ARGUMENT( "Invalid element access index" );
1530 }
1531 }
1532 }
1533
1534 SmallArray<size_t,128UL> newIndices;
1535 newIndices.reserve( n );
1536
1537 for( size_t i=0UL; i<n; ++i ) {
1538 newIndices.pushBack( e.idx( p(i) ) );
1539 }
1540
1541 return elements( e.operand(), newIndices.data(), newIndices.size(), unchecked );
1542}
1544//*************************************************************************************************
1545
1546
1547
1548
1549//=================================================================================================
1550//
1551// GLOBAL RESTRUCTURING FUNCTIONS (SUBVECTOR)
1552//
1553//=================================================================================================
1554
1555//*************************************************************************************************
1568template< AlignmentFlag AF // Alignment flag
1569 , size_t I // Index of the first subvector element
1570 , size_t N // Size of the subvector
1571 , typename VT // Type of the vector
1572 , typename... RSAs // Optional arguments
1573 , EnableIf_t< IsElements_v< RemoveReference_t<VT> > >* = nullptr >
1574inline decltype(auto) subvector( VT&& e, RSAs... args )
1575{
1577
1578 try {
1579 return elements( std::forward<VT>( e ), make_shifted_index_sequence<I,N>(), args... );
1580 }
1581 catch( ... ) {
1582 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1583 }
1584}
1586//*************************************************************************************************
1587
1588
1589//*************************************************************************************************
1604template< AlignmentFlag AF // Alignment flag
1605 , typename VT // Type of the vector
1606 , typename... RSAs // Optional arguments
1607 , EnableIf_t< IsElements_v< RemoveReference_t<VT> > >* = nullptr >
1608inline decltype(auto) subvector( VT&& e, size_t index, size_t size, RSAs... args )
1609{
1611
1612 SmallArray<size_t,128UL> indices( size );
1613 std::iota( indices.begin(), indices.end(), index );
1614
1615 try {
1616 return elements( std::forward<VT>( e ), indices.data(), indices.size(), args... );
1617 }
1618 catch( ... ) {
1619 BLAZE_THROW_INVALID_ARGUMENT( "Invalid subvector specification" );
1620 }
1621}
1623//*************************************************************************************************
1624
1625
1626
1627
1628//=================================================================================================
1629//
1630// ELEMENTS OPERATORS
1631//
1632//=================================================================================================
1633
1634//*************************************************************************************************
1660template< RelaxationFlag RF // Relaxation flag
1661 , typename VT // Type of the dense vector
1662 , bool TF // Transpose flag
1663 , typename... CEAs > // Compile time element arguments
1664inline bool isDefault( const Elements<VT,TF,true,CEAs...>& e )
1665{
1666 using blaze::isDefault;
1667
1668 for( size_t i=0UL; i<e.size(); ++i )
1669 if( !isDefault<RF>( e[i] ) ) return false;
1670 return true;
1671}
1673//*************************************************************************************************
1674
1675
1676//*************************************************************************************************
1702template< RelaxationFlag RF // Relaxation flag
1703 , typename VT // Type of the sparse vector
1704 , bool TF // Transpose flag
1705 , typename... CEAs > // Compile time element arguments
1706inline bool isDefault( const Elements<VT,TF,false,CEAs...>& e )
1707{
1708 using blaze::isDefault;
1709
1710 for( const auto& element : *e )
1711 if( !isDefault<RF>( element.value() ) ) return false;
1712 return true;
1713}
1715//*************************************************************************************************
1716
1717
1718//*************************************************************************************************
1736template< typename VT // Type of the vector
1737 , bool TF // Transpose flag
1738 , bool DF // Density flag
1739 , typename... CEAs > // Compile time element arguments
1740inline bool isIntact( const Elements<VT,TF,DF,CEAs...>& e ) noexcept
1741{
1742 return ( e.size() <= e.operand().size() && isIntact( e.operand() ) );
1743}
1745//*************************************************************************************************
1746
1747
1748//*************************************************************************************************
1762template< typename VT // Type of the vector
1763 , bool TF // Transpose flag
1764 , bool DF // Density flag
1765 , typename... CEAs > // Compile time element arguments
1766inline bool isSame( const Elements<VT,TF,DF,CEAs...>& a, const Vector<VT,TF>& b ) noexcept
1767{
1768 if( !isSame( a.operand(), *b ) || ( a.size() != (*b).size() ) )
1769 return false;
1770
1771 for( size_t i=0UL; i<a.size(); ++i ) {
1772 if( a.idx(i) != i )
1773 return false;
1774 }
1775
1776 return true;
1777}
1779//*************************************************************************************************
1780
1781
1782//*************************************************************************************************
1796template< typename VT // Type of the vector
1797 , bool TF // Transpose flag
1798 , bool DF // Density flag
1799 , typename... CEAs > // Compile time element arguments
1800inline bool isSame( const Vector<VT,TF>& a, const Elements<VT,TF,DF,CEAs...>& b ) noexcept
1801{
1802 return isSame( b, a );
1803}
1805//*************************************************************************************************
1806
1807
1808//*************************************************************************************************
1822template< typename VT1 // Type of the left-hand side vector
1823 , bool TF // Transpose flag
1824 , bool DF // Density flag
1825 , typename... CEAs // Compile time element arguments
1826 , typename VT2 // Type of the right-hand side vector
1827 , AlignmentFlag AF // Alignment flag
1828 , size_t... CSAs > // Compile time subvector arguments
1829inline bool isSame( const Elements<VT1,TF,DF,CEAs...>& a, const Subvector<VT2,AF,TF,DF,CSAs...>& b ) noexcept
1830{
1831 if( !isSame( a.operand(), b.operand() ) || ( a.size() != b.size() ) )
1832 return false;
1833
1834 for( size_t i=0UL; i<a.size(); ++i ) {
1835 if( a.idx(i) != b.offset()+i )
1836 return false;
1837 }
1838
1839 return true;
1840}
1842//*************************************************************************************************
1843
1844
1845//*************************************************************************************************
1859template< typename VT1 // Type of the left-hand side vector
1860 , AlignmentFlag AF // Alignment flag
1861 , bool TF // Transpose flag
1862 , bool DF // Density flag
1863 , size_t... CSAs // Compile time subvector arguments
1864 , typename VT2 // Type of the right-hand side vector
1865 , typename... CEAs > // Compile time element arguments
1866inline bool isSame( const Subvector<VT1,AF,TF,DF,CSAs...>& a, const Elements<VT2,TF,DF,CEAs...>& b ) noexcept
1867{
1868 return isSame( b, a );
1869}
1871//*************************************************************************************************
1872
1873
1874//*************************************************************************************************
1887template< typename VT1 // Type of the vector of the left-hand side selection of elements
1888 , bool TF1 // Transpose flag of the left-hand side selection of elements
1889 , bool DF1 // Density flag of the left-hand side selection of elements
1890 , typename... CEAs1 // Compile time element arguments of the left-hand side selection of elements
1891 , typename VT2 // Type of the vector of the right-hand side selection of elements
1892 , bool TF2 // Transpose flag of the right-hand side selection of elements
1893 , bool DF2 // Density flag of the right-hand side selection of elements
1894 , typename... CEAs2 > // Compile time element arguments of the right-hand side selection of elements
1895inline bool isSame( const Elements<VT1,TF1,DF1,CEAs1...>& a,
1896 const Elements<VT2,TF2,DF2,CEAs2...>& b ) noexcept
1897{
1898 if( !isSame( a.operand(), b.operand() ) || a.size() != b.size() )
1899 return false;
1900
1901 for( size_t i=0UL; i<a.size(); ++i ) {
1902 if( a.idx(i) != b.idx(i) )
1903 return false;
1904 }
1905
1906 return true;
1907}
1909//*************************************************************************************************
1910
1911
1912//*************************************************************************************************
1927template< typename VT // Type of the vector
1928 , bool TF // Transpose flag
1929 , bool DF // Density flag
1930 , typename... CEAs // Compile time element arguments
1931 , typename ET > // Type of the element
1932inline bool trySet( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
1933{
1934 BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
1935
1936 return trySet( e.operand(), e.idx(index), value );
1937}
1939//*************************************************************************************************
1940
1941
1942//*************************************************************************************************
1958template< typename VT // Type of the vector
1959 , bool TF // Transpose flag
1960 , bool DF // Density flag
1961 , typename... CEAs // Compile time element arguments
1962 , typename ET > // Type of the element
1964 trySet( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
1965{
1966 BLAZE_INTERNAL_ASSERT( index <= (*e).size(), "Invalid vector access index" );
1967 BLAZE_INTERNAL_ASSERT( index + size <= (*e).size(), "Invalid range size" );
1968
1969 const size_t iend( index + size );
1970
1971 for( size_t i=index; i<iend; ++i ) {
1972 if( !trySet( e.operand(), e.idx(i), value ) )
1973 return false;
1974 }
1975
1976 return true;
1977}
1979//*************************************************************************************************
1980
1981
1982//*************************************************************************************************
1997template< typename VT // Type of the vector
1998 , bool TF // Transpose flag
1999 , bool DF // Density flag
2000 , typename... CEAs // Compile time element arguments
2001 , typename ET > // Type of the element
2002inline bool tryAdd( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
2003{
2004 BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
2005
2006 return tryAdd( e.operand(), e.idx(index), value );
2007}
2009//*************************************************************************************************
2010
2011
2012//*************************************************************************************************
2028template< typename VT // Type of the vector
2029 , bool TF // Transpose flag
2030 , bool DF // Density flag
2031 , typename... CEAs // Compile time element arguments
2032 , typename ET > // Type of the element
2034 tryAdd( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
2035{
2036 BLAZE_INTERNAL_ASSERT( index <= (*e).size(), "Invalid vector access index" );
2037 BLAZE_INTERNAL_ASSERT( index + size <= (*e).size(), "Invalid range size" );
2038
2039 const size_t iend( index + size );
2040
2041 for( size_t i=index; i<iend; ++i ) {
2042 if( !tryAdd( e.operand(), e.idx(i), value ) )
2043 return false;
2044 }
2045
2046 return true;
2047}
2049//*************************************************************************************************
2050
2051
2052//*************************************************************************************************
2067template< typename VT // Type of the vector
2068 , bool TF // Transpose flag
2069 , bool DF // Density flag
2070 , typename... CEAs // Compile time element arguments
2071 , typename ET > // Type of the element
2072inline bool trySub( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
2073{
2074 BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
2075
2076 return trySub( e.operand(), e.idx(index), value );
2077}
2079//*************************************************************************************************
2080
2081
2082//*************************************************************************************************
2099template< typename VT // Type of the vector
2100 , bool TF // Transpose flag
2101 , bool DF // Density flag
2102 , typename... CEAs // Compile time element arguments
2103 , typename ET > // Type of the element
2105 trySub( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
2106{
2107 BLAZE_INTERNAL_ASSERT( index <= (*e).size(), "Invalid vector access index" );
2108 BLAZE_INTERNAL_ASSERT( index + size <= (*e).size(), "Invalid range size" );
2109
2110 const size_t iend( index + size );
2111
2112 for( size_t i=index; i<iend; ++i ) {
2113 if( !trySub( e.operand(), e.idx(i), value ) )
2114 return false;
2115 }
2116
2117 return true;
2118}
2120//*************************************************************************************************
2121
2122
2123//*************************************************************************************************
2138template< typename VT // Type of the vector
2139 , bool TF // Transpose flag
2140 , bool DF // Density flag
2141 , typename... CEAs // Compile time element arguments
2142 , typename ET > // Type of the element
2143inline bool tryMult( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
2144{
2145 BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
2146
2147 return tryMult( e.operand(), e.idx(index), value );
2148}
2150//*************************************************************************************************
2151
2152
2153//*************************************************************************************************
2169template< typename VT // Type of the vector
2170 , bool TF // Transpose flag
2171 , bool DF // Density flag
2172 , typename... CEAs // Compile time element arguments
2173 , typename ET > // Type of the element
2175 tryMult( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
2176{
2177 BLAZE_INTERNAL_ASSERT( index <= (*e).size(), "Invalid vector access index" );
2178 BLAZE_INTERNAL_ASSERT( index + size <= (*e).size(), "Invalid range size" );
2179
2180 const size_t iend( index + size );
2181
2182 for( size_t i=index; i<iend; ++i ) {
2183 if( !tryMult( e.operand(), e.idx(i), value ) )
2184 return false;
2185 }
2186
2187 return true;
2188}
2190//*************************************************************************************************
2191
2192
2193//*************************************************************************************************
2208template< typename VT // Type of the vector
2209 , bool TF // Transpose flag
2210 , bool DF // Density flag
2211 , typename... CEAs // Compile time element arguments
2212 , typename ET > // Type of the element
2213inline bool tryDiv( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
2214{
2215 BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
2216
2217 return tryDiv( e.operand(), e.idx(index), value );
2218}
2220//*************************************************************************************************
2221
2222
2223//*************************************************************************************************
2239template< typename VT // Type of the vector
2240 , bool TF // Transpose flag
2241 , bool DF // Density flag
2242 , typename... CEAs // Compile time element arguments
2243 , typename ET > // Type of the element
2245 tryDiv( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
2246{
2247 BLAZE_INTERNAL_ASSERT( index <= (*e).size(), "Invalid vector access index" );
2248 BLAZE_INTERNAL_ASSERT( index + size <= (*e).size(), "Invalid range size" );
2249
2250 const size_t iend( index + size );
2251
2252 for( size_t i=index; i<iend; ++i ) {
2253 if( !tryDiv( e.operand(), e.idx(i), value ) )
2254 return false;
2255 }
2256
2257 return true;
2258}
2260//*************************************************************************************************
2261
2262
2263//*************************************************************************************************
2278template< typename VT // Type of the vector
2279 , bool TF // Transpose flag
2280 , bool DF // Density flag
2281 , typename... CEAs > // Compile time element arguments
2282inline bool tryShift( const Elements<VT,TF,DF,CEAs...>& e, size_t index, int count )
2283{
2284 BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
2285
2286 return tryShift( e.operand(), e.idx(index), count );
2287}
2289//*************************************************************************************************
2290
2291
2292//*************************************************************************************************
2308template< typename VT // Type of the vector
2309 , bool TF // Transpose flag
2310 , bool DF // Density flag
2311 , typename... CEAs > // Compile time element arguments
2313 tryShift( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, int count )
2314{
2315 BLAZE_INTERNAL_ASSERT( index <= (*e).size(), "Invalid vector access index" );
2316 BLAZE_INTERNAL_ASSERT( index + size <= (*e).size(), "Invalid range size" );
2317
2318 const size_t iend( index + size );
2319
2320 for( size_t i=index; i<iend; ++i ) {
2321 if( !tryShift( e.operand(), e.idx(i), count ) )
2322 return false;
2323 }
2324
2325 return true;
2326}
2328//*************************************************************************************************
2329
2330
2331//*************************************************************************************************
2347template< typename VT // Type of the vector
2348 , bool TF // Transpose flag
2349 , bool DF // Density flag
2350 , typename... CEAs // Compile time element arguments
2351 , typename ET > // Type of the element
2352inline bool tryBitand( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
2353{
2354 BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
2355
2356 return tryBitand( e.operand(), e.idx(index), value );
2357}
2359//*************************************************************************************************
2360
2361
2362//*************************************************************************************************
2379template< typename VT // Type of the vector
2380 , bool TF // Transpose flag
2381 , bool DF // Density flag
2382 , typename... CEAs // Compile time element arguments
2383 , typename ET > // Type of the element
2385 tryBitand( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
2386{
2387 BLAZE_INTERNAL_ASSERT( index <= (*e).size(), "Invalid vector access index" );
2388 BLAZE_INTERNAL_ASSERT( index + size <= (*e).size(), "Invalid range size" );
2389
2390 const size_t iend( index + size );
2391
2392 for( size_t i=index; i<iend; ++i ) {
2393 if( !tryBitand( e.operand(), e.idx(i), value ) )
2394 return false;
2395 }
2396
2397 return true;
2398}
2400//*************************************************************************************************
2401
2402
2403//*************************************************************************************************
2419template< typename VT // Type of the vector
2420 , bool TF // Transpose flag
2421 , bool DF // Density flag
2422 , typename... CEAs // Compile time element arguments
2423 , typename ET > // Type of the element
2424inline bool tryBitor( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
2425{
2426 BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
2427
2428 return tryBitor( e.operand(), e.idx(index), value );
2429}
2431//*************************************************************************************************
2432
2433
2434//*************************************************************************************************
2451template< typename VT // Type of the vector
2452 , bool TF // Transpose flag
2453 , bool DF // Density flag
2454 , typename... CEAs // Compile time element arguments
2455 , typename ET > // Type of the element
2457 tryBitor( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
2458{
2459 BLAZE_INTERNAL_ASSERT( index <= (*e).size(), "Invalid vector access index" );
2460 BLAZE_INTERNAL_ASSERT( index + size <= (*e).size(), "Invalid range size" );
2461
2462 const size_t iend( index + size );
2463
2464 for( size_t i=index; i<iend; ++i ) {
2465 if( !tryBitor( e.operand(), e.idx(i), value ) )
2466 return false;
2467 }
2468
2469 return true;
2470}
2472//*************************************************************************************************
2473
2474
2475//*************************************************************************************************
2491template< typename VT // Type of the vector
2492 , bool TF // Transpose flag
2493 , bool DF // Density flag
2494 , typename... CEAs // Compile time element arguments
2495 , typename ET > // Type of the element
2496inline bool tryBitxor( const Elements<VT,TF,DF,CEAs...>& e, size_t index, const ET& value )
2497{
2498 BLAZE_INTERNAL_ASSERT( index < e.size(), "Invalid vector access index" );
2499
2500 return tryBitxor( e.operand(), e.idx(index), value );
2501}
2503//*************************************************************************************************
2504
2505
2506//*************************************************************************************************
2523template< typename VT // Type of the vector
2524 , bool TF // Transpose flag
2525 , bool DF // Density flag
2526 , typename... CEAs // Compile time element arguments
2527 , typename ET > // Type of the element
2529 tryBitxor( const Elements<VT,TF,DF,CEAs...>& e, size_t index, size_t size, const ET& value )
2530{
2531 BLAZE_INTERNAL_ASSERT( index <= (*e).size(), "Invalid vector access index" );
2532 BLAZE_INTERNAL_ASSERT( index + size <= (*e).size(), "Invalid range size" );
2533
2534 const size_t iend( index + size );
2535
2536 for( size_t i=index; i<iend; ++i ) {
2537 if( !tryBitxor( e.operand(), e.idx(i), value ) )
2538 return false;
2539 }
2540
2541 return true;
2542}
2544//*************************************************************************************************
2545
2546
2547//*************************************************************************************************
2562template< typename VT1 // Type of the vector
2563 , bool TF // Transpose flag
2564 , bool DF // Density flag
2565 , typename... CEAs // Compile time element arguments
2566 , typename VT2 > // Type of the right-hand side vector
2567inline bool tryAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2568 const Vector<VT2,TF>& rhs, size_t index )
2569{
2570 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2571 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2572
2573 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2574 if( !trySet( lhs.operand(), lhs.idx(i+index), (*rhs)[i] ) )
2575 return false;
2576 }
2577
2578 return true;
2579}
2581//*************************************************************************************************
2582
2583
2584//*************************************************************************************************
2600template< typename VT1 // Type of the vector
2601 , bool TF // Transpose flag
2602 , bool DF // Density flag
2603 , typename... CEAs // Compile time element arguments
2604 , typename VT2 > // Type of the right-hand side vector
2605inline bool tryAddAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2606 const Vector<VT2,TF>& rhs, size_t index )
2607{
2608 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2609 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2610
2611 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2612 if( !tryAdd( lhs.operand(), lhs.idx(i+index), (*rhs)[i] ) )
2613 return false;
2614 }
2615
2616 return true;
2617}
2619//*************************************************************************************************
2620
2621
2622//*************************************************************************************************
2638template< typename VT1 // Type of the vector
2639 , bool TF // Transpose flag
2640 , bool DF // Density flag
2641 , typename... CEAs // Compile time element arguments
2642 , typename VT2 > // Type of the right-hand side vector
2643inline bool trySubAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2644 const Vector<VT2,TF>& rhs, size_t index )
2645{
2646 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2647 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2648
2649 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2650 if( !trySub( lhs.operand(), lhs.idx(i+index), (*rhs)[i] ) )
2651 return false;
2652 }
2653
2654 return true;
2655}
2657//*************************************************************************************************
2658
2659
2660//*************************************************************************************************
2676template< typename VT1 // Type of the vector
2677 , bool TF // Transpose flag
2678 , bool DF // Density flag
2679 , typename... CEAs // Compile time element arguments
2680 , typename VT2 > // Type of the right-hand side vector
2681inline bool tryMultAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2682 const Vector<VT2,TF>& rhs, size_t index )
2683{
2684 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2685 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2686
2687 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2688 if( !tryMult( lhs.operand(), lhs.idx(i+index), (*rhs)[i] ) )
2689 return false;
2690 }
2691
2692 return true;
2693}
2695//*************************************************************************************************
2696
2697
2698//*************************************************************************************************
2714template< typename VT1 // Type of the vector
2715 , bool TF // Transpose flag
2716 , bool DF // Density flag
2717 , typename... CEAs // Compile time element arguments
2718 , typename VT2 > // Type of the right-hand side vector
2719inline bool tryDivAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2720 const Vector<VT2,TF>& rhs, size_t index )
2721{
2722 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2723 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2724
2725 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2726 if( !tryDiv( lhs.operand(), lhs.idx(i+index), (*rhs)[i] ) )
2727 return false;
2728 }
2729
2730 return true;
2731}
2733//*************************************************************************************************
2734
2735
2736//*************************************************************************************************
2752template< typename VT1 // Type of the vector
2753 , bool TF // Transpose flag
2754 , bool DF // Density flag
2755 , typename... CEAs // Compile time element arguments
2756 , typename VT2 > // Type of the right-hand side vector
2757inline bool tryShiftAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2758 const Vector<VT2,TF>& rhs, size_t index )
2759{
2760 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2761 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2762
2763 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2764 if( !tryShift( lhs.operand(), lhs.idx(i+index), (*rhs)[i] ) )
2765 return false;
2766 }
2767
2768 return true;
2769}
2771//*************************************************************************************************
2772
2773
2774//*************************************************************************************************
2790template< typename VT1 // Type of the vector
2791 , bool TF // Transpose flag
2792 , bool DF // Density flag
2793 , typename... CEAs // Compile time element arguments
2794 , typename VT2 > // Type of the right-hand side vector
2795inline bool tryBitandAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2796 const Vector<VT2,TF>& rhs, size_t index )
2797{
2798 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2799 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2800
2801 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2802 if( !tryBitand( lhs.operand(), lhs.idx(i+index), (*rhs)[i] ) )
2803 return false;
2804 }
2805
2806 return true;
2807}
2809//*************************************************************************************************
2810
2811
2812//*************************************************************************************************
2828template< typename VT1 // Type of the vector
2829 , bool TF // Transpose flag
2830 , bool DF // Density flag
2831 , typename... CEAs // Compile time element arguments
2832 , typename VT2 > // Type of the right-hand side vector
2833inline bool tryBitorAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2834 const Vector<VT2,TF>& rhs, size_t index )
2835{
2836 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2837 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2838
2839 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2840 if( !tryBitor( lhs.operand(), lhs.idx(i+index), (*rhs)[i] ) )
2841 return false;
2842 }
2843
2844 return true;
2845}
2847//*************************************************************************************************
2848
2849
2850//*************************************************************************************************
2866template< typename VT1 // Type of the vector
2867 , bool TF // Transpose flag
2868 , bool DF // Density flag
2869 , typename... CEAs // Compile time element arguments
2870 , typename VT2 > // Type of the right-hand side vector
2871inline bool tryBitxorAssign( const Elements<VT1,TF,DF,CEAs...>& lhs,
2872 const Vector<VT2,TF>& rhs, size_t index )
2873{
2874 BLAZE_INTERNAL_ASSERT( index <= lhs.size(), "Invalid vector access index" );
2875 BLAZE_INTERNAL_ASSERT( index + (*rhs).size() <= lhs.size(), "Invalid vector size" );
2876
2877 for( size_t i=0UL; i<(*rhs).size(); ++i ) {
2878 if( !tryBitxor( lhs.operand(), lhs.idx(i+index), (*rhs)[i] ) )
2879 return false;
2880 }
2881
2882 return true;
2883}
2885//*************************************************************************************************
2886
2887
2888//*************************************************************************************************
2903template< typename VT // Type of the vector
2904 , bool TF // Transpose flag
2905 , bool DF // Density flag
2906 , typename... CEAs > // Compile time element arguments
2907inline decltype(auto) derestrict( Elements<VT,TF,DF,CEAs...>& e )
2908{
2909 return elements( derestrict( e.operand() ), e.idces(), unchecked );
2910}
2912//*************************************************************************************************
2913
2914
2915//*************************************************************************************************
2930template< typename VT // Type of the vector
2931 , bool TF // Transpose flag
2932 , bool DF // Density flag
2933 , typename... CEAs > // Compile time element arguments
2934inline decltype(auto) derestrict( Elements<VT,TF,DF,CEAs...>&& e )
2935{
2936 return elements( derestrict( e.operand() ), e.idces(), unchecked );
2937}
2939//*************************************************************************************************
2940
2941
2942//*************************************************************************************************
2955template< typename VT // Type of the vector
2956 , bool TF // Transpose flag
2957 , bool DF // Density flag
2958 , typename... CEAs > // Compile time element arguments
2959inline decltype(auto) unview( Elements<VT,TF,DF,CEAs...>& e )
2960{
2961 return e.operand();
2962}
2964//*************************************************************************************************
2965
2966
2967//*************************************************************************************************
2981template< typename VT // Type of the vector
2982 , bool TF // Transpose flag
2983 , bool DF // Density flag
2984 , typename... CEAs > // Compile time element arguments
2985inline decltype(auto) unview( const Elements<VT,TF,DF,CEAs...>& e )
2986{
2987 return e.operand();
2988}
2990//*************************************************************************************************
2991
2992
2993
2994
2995//=================================================================================================
2996//
2997// SIZE SPECIALIZATIONS
2998//
2999//=================================================================================================
3000
3001//*************************************************************************************************
3003template< typename VT, bool TF, bool DF, size_t I, size_t... Is, typename... CEAs >
3004struct Size< Elements<VT,TF,DF,index_sequence<I,Is...>,CEAs...>, 0UL >
3005 : public Ptrdiff_t< static_cast<ptrdiff_t>( 1UL+sizeof...(Is) ) >
3006{};
3008//*************************************************************************************************
3009
3010
3011
3012
3013//=================================================================================================
3014//
3015// MAXSIZE SPECIALIZATIONS
3016//
3017//=================================================================================================
3018
3019//*************************************************************************************************
3021template< typename VT, bool TF, bool DF, size_t I, size_t... Is, typename... CEAs >
3022struct MaxSize< Elements<VT,TF,DF,index_sequence<I,Is...>,CEAs...>, 0UL >
3023 : public Ptrdiff_t< static_cast<ptrdiff_t>( 1UL+sizeof...(Is) ) >
3024{};
3026//*************************************************************************************************
3027
3028
3029
3030
3031//=================================================================================================
3032//
3033// ISRESTRICTED SPECIALIZATIONS
3034//
3035//=================================================================================================
3036
3037//*************************************************************************************************
3039template< typename VT, bool TF, bool DF, typename... CEAs >
3040struct IsRestricted< Elements<VT,TF,DF,CEAs...> >
3041 : public IsRestricted<VT>
3042{};
3044//*************************************************************************************************
3045
3046
3047
3048
3049//=================================================================================================
3050//
3051// HASCONSTDATAACCESS SPECIALIZATIONS
3052//
3053//=================================================================================================
3054
3055//*************************************************************************************************
3057template< typename VT, bool TF, typename... CEAs >
3058struct HasConstDataAccess< Elements<VT,TF,true,CEAs...> >
3059 : public HasConstDataAccess<VT>
3060{};
3062//*************************************************************************************************
3063
3064
3065
3066
3067//=================================================================================================
3068//
3069// HASMUTABLEDATAACCESS SPECIALIZATIONS
3070//
3071//=================================================================================================
3072
3073//*************************************************************************************************
3075template< typename VT, bool TF, typename... CEAs >
3076struct HasMutableDataAccess< Elements<VT,TF,true,CEAs...> >
3077 : public HasMutableDataAccess<VT>
3078{};
3080//*************************************************************************************************
3081
3082} // namespace blaze
3083
3084#endif
Header file for auxiliary alias declarations.
Header file for the alignment flag enumeration.
Header file for run time assertion macros.
Header file for the blaze::checked and blaze::unchecked instances.
Header file for the EnableIf class template.
Header file for the function trace functionality.
Header file for the HasConstDataAccess type trait.
Header file for the HasMutableDataAccess type trait.
Header file for the integer_sequence and index_sequence aliases.
Header file for the IntegralConstant class template.
Header file for the isDefault shim.
Header file for the IsElements type trait.
Header file for the IsPointer type trait.
Header file for the IsRestricted type trait.
Deactivation of problematic macros.
Header file for the MaxSize type trait.
Header file for the MAYBE_UNUSED function template.
Header file for the relaxation flag enumeration.
Header file for the RemoveReference type trait.
Header file for the SmallArray implementation.
Compile time assertion.
Implementation of a dynamic array with small array optimization.
Definition: SmallArray.h:84
Pointer data() noexcept
Low-level data access to the array elements.
Definition: SmallArray.h:531
size_t size() const noexcept
Returns the current size/dimension of the small array.
Definition: SmallArray.h:767
Base class for N-dimensional vectors.
Definition: Vector.h:82
Index sequence type of the Blaze library.
Size type of the Blaze library.
Header file for the CrossExpr base class.
Header file for the VecEvalExpr base class.
Header file for the VecMapExpr base class.
Header file for the VecNoAliasExpr base class.
Header file for the VecNoSIMDExpr base class.
Header file for the VecRepeatExpr base class.
Header file for the VecScalarDivExpr base class.
Header file for the VecScalarMultExpr base class.
Header file for the VecSerialExpr base class.
Header file for the VecTransExpr base class.
Header file for the VecVecAddExpr base class.
Header file for the VecVecDivExpr base class.
Header file for the VecVecKronExpr base class.
Header file for the VecVecMapExpr base class.
Header file for the VecVecMultExpr base class.
Header file for the VecVecSubExpr base class.
Header file for the Vector CRTP base class.
decltype(auto) noalias(const DenseMatrix< MT, SO > &dm)
Forces the non-aliased evaluation of the given dense matrix expression dm.
Definition: DMatNoAliasExpr.h:679
decltype(auto) eval(const DenseMatrix< MT, SO > &dm)
Forces the evaluation of the given dense matrix expression dm.
Definition: DMatEvalExpr.h:790
decltype(auto) trans(const DenseMatrix< MT, SO > &dm)
Calculation of the transpose of the given dense matrix.
Definition: DMatTransExpr.h:766
decltype(auto) map(const DenseMatrix< MT1, SO > &lhs, const DenseMatrix< MT2, SO > &rhs, OP op)
Elementwise evaluation of the given binary operation on each single element of the dense matrices lhs...
Definition: DMatDMatMapExpr.h:1144
decltype(auto) nosimd(const DenseMatrix< MT, SO > &dm)
Disables the SIMD evaluation of the given dense matrix expression dm.
Definition: DMatNoSIMDExpr.h:717
decltype(auto) serial(const DenseMatrix< MT, SO > &dm)
Forces the serial evaluation of the given dense matrix expression dm.
Definition: DMatSerialExpr.h:812
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:207
bool isDefault(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the given diagonal matrix is in default state.
Definition: DiagonalMatrix.h:169
decltype(auto) elements(VT &&vector, const SmallArray< T, N > &indices, REAs... args)
Creating a view on a selection of elements of the given vector.
Definition: Elements.h:741
RelaxationFlag
Relaxation flag for strict or relaxed semantics.
Definition: RelaxationFlag.h:66
AlignmentFlag
Alignment flag for (un-)aligned vectors and matrices.
Definition: AlignmentFlag.h:63
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:1424
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:676
#define BLAZE_INTERNAL_ASSERT(expr, msg)
Run time assertion macro for internal checks.
Definition: Assert.h:101
decltype(auto) subvector(Vector< VT, TF > &, RSAs...)
Creating a view on a specific subvector of the given vector.
Definition: Subvector.h:158
#define BLAZE_ALWAYS_INLINE
Platform dependent setup of an enforced inline keyword.
Definition: Inline.h:85
IntegralConstant< ptrdiff_t, N > Ptrdiff_t
Compile time integral constant wrapper for ptrdiff_t.
Definition: IntegralConstant.h:237
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
#define BLAZE_THROW_INVALID_ARGUMENT(MESSAGE)
Macro for the emission of a std::invalid_argument exception.
Definition: Exception.h:235
#define BLAZE_FUNCTION_TRACE
Function trace macro.
Definition: FunctionTrace.h:94
constexpr bool isChecked(const Ts &... args)
Extracting blaze::Check arguments from a given list of arguments.
Definition: Check.h:225
constexpr Unchecked unchecked
Global Unchecked instance.
Definition: Check.h:146
Header file for the exception macros of the math module.
Header file for the extended initializer_list functionality.
Header file for the Size type trait.
Header file for the serial shim.
Header file for basic type definitions.
Header file for the implementation of the Elements base template.
Elements specialization for dense vectors.
Elements specialization for sparse vectors.