Blaze  3.6
ZeroVector.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SPARSE_ZEROVECTOR_H_
36 #define _BLAZE_MATH_SPARSE_ZEROVECTOR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
43 #include <blaze/math/Aliases.h>
44 #include <blaze/math/Exception.h>
47 #include <blaze/math/Forward.h>
75 #include <blaze/util/Assert.h>
80 #include <blaze/util/EnableIf.h>
83 #include <blaze/util/MaybeUnused.h>
84 #include <blaze/util/Types.h>
87 
88 
89 namespace blaze {
90 
91 //=================================================================================================
92 //
93 // CLASS DEFINITION
94 //
95 //=================================================================================================
96 
97 //*************************************************************************************************
168 template< typename Type // Data type of the vector
169  , bool TF = defaultTransposeFlag > // Transpose flag
170 class ZeroVector
171  : public Expression< SparseVector< ZeroVector<Type,TF>, TF > >
172 {
173  private:
174  //**Type definitions****************************************************************************
176  //**********************************************************************************************
177 
178  public:
179  //**Type definitions****************************************************************************
182  using ResultType = This;
184  using ElementType = Type;
185  using ReturnType = const Type&;
186  using CompositeType = const This&;
187  using Reference = const Type&;
188  using ConstReference = const Type&;
189  using Iterator = Element*;
190  using ConstIterator = const Element*;
191  //**********************************************************************************************
192 
193  //**Rebind struct definition********************************************************************
196  template< typename NewType > // Data type of the other vector
197  struct Rebind {
199  };
200  //**********************************************************************************************
201 
202  //**Resize struct definition********************************************************************
205  template< size_t NewN > // Number of elements of the other vector
206  struct Resize {
208  };
209  //**********************************************************************************************
210 
211  //**Compilation flags***************************************************************************
213 
216  static constexpr bool smpAssignable = !IsSMPAssignable_v<Type>;
217  //**********************************************************************************************
218 
219  //**Constructors********************************************************************************
222  explicit inline constexpr ZeroVector() noexcept;
223  explicit inline constexpr ZeroVector( size_t size ) noexcept;
224 
225  template< typename VT > inline ZeroVector( const Vector<VT,TF>& v );
226 
227  ZeroVector( const ZeroVector& ) = default;
228  ZeroVector( ZeroVector&& ) = default;
230  //**********************************************************************************************
231 
232  //**Destructor**********************************************************************************
235  ~ZeroVector() = default;
237  //**********************************************************************************************
238 
239  //**Data access functions***********************************************************************
242  inline constexpr ConstReference operator[]( size_t index ) const noexcept;
243  inline ConstReference at( size_t index ) const;
244  inline constexpr ConstIterator begin () const noexcept;
245  inline constexpr ConstIterator cbegin() const noexcept;
246  inline constexpr ConstIterator end () const noexcept;
247  inline constexpr ConstIterator cend () const noexcept;
249  //**********************************************************************************************
250 
251  //**Assignment operators************************************************************************
254  template< typename VT >
255  inline ZeroVector& operator=( const Vector<VT,TF>& rhs );
256 
257  ZeroVector& operator=( const ZeroVector& ) = default;
258  ZeroVector& operator=( ZeroVector&& ) = default;
260  //**********************************************************************************************
261 
262  //**Utility functions***************************************************************************
265  inline constexpr size_t size() const noexcept;
266  inline constexpr size_t capacity() const noexcept;
267  inline constexpr size_t nonZeros() const noexcept;
268  inline constexpr void clear() noexcept;
269  inline constexpr void resize( size_t n ) noexcept;
270  inline constexpr void swap( ZeroVector& v ) noexcept;
272  //**********************************************************************************************
273 
274  //**Lookup functions****************************************************************************
277  inline ConstIterator find ( size_t index ) const;
278  inline ConstIterator lowerBound( size_t index ) const;
279  inline ConstIterator upperBound( size_t index ) const;
281  //**********************************************************************************************
282 
283  //**Expression template evaluation functions****************************************************
286  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
287  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
288 
289  inline bool canSMPAssign() const noexcept;
291  //**********************************************************************************************
292 
293  private:
294  //**Member variables****************************************************************************
297  size_t size_;
298 
299  static const Type zero_;
300 
301  //**********************************************************************************************
302 
303  //**Compile time checks*************************************************************************
310  //**********************************************************************************************
311 };
312 //*************************************************************************************************
313 
314 
315 
316 
317 //=================================================================================================
318 //
319 // DEFINITION AND INITIALIZATION OF THE STATIC MEMBER VARIABLES
320 //
321 //=================================================================================================
322 
323 template< typename Type, bool TF >
324 const Type ZeroVector<Type,TF>::zero_{};
325 
326 
327 
328 
329 //=================================================================================================
330 //
331 // CONSTRUCTORS
332 //
333 //=================================================================================================
334 
335 //*************************************************************************************************
338 template< typename Type // Data type of the vector
339  , bool TF > // Transpose flag
340 inline constexpr ZeroVector<Type,TF>::ZeroVector() noexcept
341  : size_( 0UL ) // The current size/dimension of the zero vector
342 {}
343 //*************************************************************************************************
344 
345 
346 //*************************************************************************************************
351 template< typename Type // Data type of the vector
352  , bool TF > // Transpose flag
353 inline constexpr ZeroVector<Type,TF>::ZeroVector( size_t n ) noexcept
354  : size_( n ) // The current size/dimension of the zero vector
355 {}
356 //*************************************************************************************************
357 
358 
359 //*************************************************************************************************
368 template< typename Type // Data type of the vector
369  , bool TF > // Transpose flag
370 template< typename VT > // Type of the foreign zero vector
372  : size_( (~v).size() ) // The current size/dimension of the zero vector
373 {
374  if( !IsZero_v<VT> && !isZero( ~v ) ) {
375  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of zero vector" );
376  }
377 }
378 //*************************************************************************************************
379 
380 
381 
382 
383 //=================================================================================================
384 //
385 // DATA ACCESS FUNCTIONS
386 //
387 //=================================================================================================
388 
389 //*************************************************************************************************
395 template< typename Type // Data type of the vector
396  , bool TF > // Transpose flag
397 inline constexpr typename ZeroVector<Type,TF>::ConstReference
398  ZeroVector<Type,TF>::operator[]( size_t index ) const noexcept
399 {
400  MAYBE_UNUSED( index );
401 
402  BLAZE_USER_ASSERT( index < size(), "Invalid zero vector access index" );
403 
404  return zero_;
405 }
406 //*************************************************************************************************
407 
408 
409 //*************************************************************************************************
419 template< typename Type // Data type of the vector
420  , bool TF > // Transpose flag
422  ZeroVector<Type,TF>::at( size_t index ) const
423 {
424  if( index >= size_ ) {
425  BLAZE_THROW_OUT_OF_RANGE( "Invalid zero vector access index" );
426  }
427 
428  return zero_;
429 }
430 //*************************************************************************************************
431 
432 
433 //*************************************************************************************************
438 template< typename Type // Data type of the vector
439  , bool TF > // Transpose flag
440 inline constexpr typename ZeroVector<Type,TF>::ConstIterator
441  ZeroVector<Type,TF>::begin() const noexcept
442 {
443  return nullptr;
444 }
445 //*************************************************************************************************
446 
447 
448 //*************************************************************************************************
453 template< typename Type // Data type of the vector
454  , bool TF > // Transpose flag
455 inline constexpr typename ZeroVector<Type,TF>::ConstIterator
457 {
458  return nullptr;
459 }
460 //*************************************************************************************************
461 
462 
463 //*************************************************************************************************
468 template< typename Type // Data type of the vector
469  , bool TF > // Transpose flag
470 inline constexpr typename ZeroVector<Type,TF>::ConstIterator
471  ZeroVector<Type,TF>::end() const noexcept
472 {
473  return nullptr;
474 }
475 //*************************************************************************************************
476 
477 
478 //*************************************************************************************************
483 template< typename Type // Data type of the vector
484  , bool TF > // Transpose flag
485 inline constexpr typename ZeroVector<Type,TF>::ConstIterator
486  ZeroVector<Type,TF>::cend() const noexcept
487 {
488  return nullptr;
489 }
490 //*************************************************************************************************
491 
492 
493 
494 
495 //=================================================================================================
496 //
497 // ASSIGNMENT OPERATORS
498 //
499 //=================================================================================================
500 
501 //*************************************************************************************************
511 template< typename Type // Data type of the vector
512  , bool TF > // Transpose flag
513 template< typename VT > // Type of the right-hand side dense vector
514 inline ZeroVector<Type,TF>&
516 {
517  if( !IsZero_v<VT> && !isZero( ~rhs ) ) {
518  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment of zero vector" );
519  }
520 
521  size_ = (~rhs).size();
522 
523  return *this;
524 }
525 //*************************************************************************************************
526 
527 
528 
529 
530 //=================================================================================================
531 //
532 // UTILITY FUNCTIONS
533 //
534 //=================================================================================================
535 
536 //*************************************************************************************************
541 template< typename Type // Data type of the vector
542  , bool TF > // Transpose flag
543 inline constexpr size_t ZeroVector<Type,TF>::size() const noexcept
544 {
545  return size_;
546 }
547 //*************************************************************************************************
548 
549 
550 //*************************************************************************************************
555 template< typename Type // Data type of the vector
556  , bool TF > // Transpose flag
557 inline constexpr size_t ZeroVector<Type,TF>::capacity() const noexcept
558 {
559  return 0UL;
560 }
561 //*************************************************************************************************
562 
563 
564 //*************************************************************************************************
572 template< typename Type // Data type of the vector
573  , bool TF > // Transpose flag
574 inline constexpr size_t ZeroVector<Type,TF>::nonZeros() const noexcept
575 {
576  return 0UL;
577 }
578 //*************************************************************************************************
579 
580 
581 //*************************************************************************************************
588 template< typename Type // Data type of the vector
589  , bool TF > // Transpose flag
590 inline constexpr void ZeroVector<Type,TF>::clear() noexcept
591 {
592  size_ = 0UL;
593 }
594 //*************************************************************************************************
595 
596 
597 //*************************************************************************************************
607 template< typename Type // Data type of the vector
608  , bool TF > // Transpose flag
609 inline constexpr void ZeroVector<Type,TF>::resize( size_t n ) noexcept
610 {
611  size_ = n;
612 }
613 //*************************************************************************************************
614 
615 
616 //*************************************************************************************************
622 template< typename Type // Data type of the vector
623  , bool TF > // Transpose flag
624 inline constexpr void ZeroVector<Type,TF>::swap( ZeroVector& v ) noexcept
625 {
626  const size_t tmp( size_ );
627  size_ = v.size_;
628  v.size_ = tmp;
629 }
630 //*************************************************************************************************
631 
632 
633 
634 
635 //=================================================================================================
636 //
637 // LOOKUP FUNCTIONS
638 //
639 //=================================================================================================
640 
641 //*************************************************************************************************
652 template< typename Type // Data type of the vector
653  , bool TF > // Transpose flag
655  ZeroVector<Type,TF>::find( size_t index ) const
656 {
657  MAYBE_UNUSED( index );
658 
659  BLAZE_USER_ASSERT( index < size(), "Invalid zero vector access index" );
660 
661  return nullptr;
662 }
663 //*************************************************************************************************
664 
665 
666 //*************************************************************************************************
676 template< typename Type // Data type of the vector
677  , bool TF > // Transpose flag
679  ZeroVector<Type,TF>::lowerBound( size_t index ) const
680 {
681  MAYBE_UNUSED( index );
682 
683  BLAZE_USER_ASSERT( index < size(), "Invalid zero vector access index" );
684 
685  return nullptr;
686 }
687 //*************************************************************************************************
688 
689 
690 //*************************************************************************************************
700 template< typename Type // Data type of the vector
701  , bool TF > // Transpose flag
703  ZeroVector<Type,TF>::upperBound( size_t index ) const
704 {
705  MAYBE_UNUSED( index );
706 
707  BLAZE_USER_ASSERT( index < size(), "Invalid zero vector access index" );
708 
709  return nullptr;
710 }
711 //*************************************************************************************************
712 
713 
714 
715 
716 //=================================================================================================
717 //
718 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
719 //
720 //=================================================================================================
721 
722 //*************************************************************************************************
732 template< typename Type // Data type of the vector
733  , bool TF > // Transpose flag
734 template< typename Other > // Data type of the foreign expression
735 inline bool ZeroVector<Type,TF>::canAlias( const Other* alias ) const noexcept
736 {
737  MAYBE_UNUSED( alias );
738 
739  return false;
740 }
741 //*************************************************************************************************
742 
743 
744 //*************************************************************************************************
754 template< typename Type // Data type of the vector
755  , bool TF > // Transpose flag
756 template< typename Other > // Data type of the foreign expression
757 inline bool ZeroVector<Type,TF>::isAliased( const Other* alias ) const noexcept
758 {
759  MAYBE_UNUSED( alias );
760 
761  return false;
762 }
763 //*************************************************************************************************
764 
765 
766 //*************************************************************************************************
776 template< typename Type // Data type of the vector
777  , bool TF > // Transpose flag
778 inline bool ZeroVector<Type,TF>::canSMPAssign() const noexcept
779 {
780  return false;
781 }
782 //*************************************************************************************************
783 
784 
785 
786 
787 
788 
789 
790 
791 //=================================================================================================
792 //
793 // ZEROVECTOR OPERATORS
794 //
795 //=================================================================================================
796 
797 //*************************************************************************************************
800 template< typename Type, bool TF >
801 constexpr void reset( ZeroVector<Type,TF>& m ) noexcept;
802 
803 template< typename Type, bool TF >
804 constexpr void clear( ZeroVector<Type,TF>& m ) noexcept;
805 
806 template< bool RF, typename Type, bool TF >
807 constexpr bool isDefault( const ZeroVector<Type,TF>& m ) noexcept;
808 
809 template< typename Type, bool TF >
810 constexpr bool isIntact( const ZeroVector<Type,TF>& m ) noexcept;
811 
812 template< typename Type, bool TF >
813 constexpr void swap( ZeroVector<Type,TF>& a, ZeroVector<Type,TF>& b ) noexcept;
815 //*************************************************************************************************
816 
817 
818 //*************************************************************************************************
825 template< typename Type // Data type of the vector
826  , bool TF > // Transpose flag
827 inline constexpr void reset( ZeroVector<Type,TF>& v ) noexcept
828 {
829  MAYBE_UNUSED( v );
830 }
831 //*************************************************************************************************
832 
833 
834 //*************************************************************************************************
841 template< typename Type // Data type of the vector
842  , bool TF > // Transpose flag
843 inline constexpr void clear( ZeroVector<Type,TF>& v ) noexcept
844 {
845  v.clear();
846 }
847 //*************************************************************************************************
848 
849 
850 //*************************************************************************************************
874 template< bool RF // Relaxation flag
875  , typename Type // Data type of the vector
876  , bool TF > // Transpose flag
877 inline constexpr bool isDefault( const ZeroVector<Type,TF>& v ) noexcept
878 {
879  return ( v.size() == 0UL );
880 }
881 //*************************************************************************************************
882 
883 
884 //*************************************************************************************************
901 template< typename Type // Data type of the vector
902  , bool TF > // Transpose flag
903 inline constexpr bool isIntact( const ZeroVector<Type,TF>& v ) noexcept
904 {
905  MAYBE_UNUSED( v );
906 
907  return true;
908 }
909 //*************************************************************************************************
910 
911 
912 //*************************************************************************************************
920 template< typename Type // Data type of the vector
921  , bool TF > // Transpose flag
922 inline constexpr void swap( ZeroVector<Type,TF>& a, ZeroVector<Type,TF>& b ) noexcept
923 {
924  a.swap( b );
925 }
926 //*************************************************************************************************
927 
928 
929 //*************************************************************************************************
938 template< typename Type // Data type of the vector
939  , bool TF > // Transpose flag
940 inline void erase( ZeroVector<Type,TF>& v, size_t index )
941 {
942  MAYBE_UNUSED( v, index );
943 }
945 //*************************************************************************************************
946 
947 
948 //*************************************************************************************************
959 template< typename Type // Data type of the vector
960  , bool TF // Transpose flag
961  , typename Iterator > // Type of the vector iterator
962 inline Iterator erase( ZeroVector<Type,TF>& v, Iterator pos )
963 {
964  MAYBE_UNUSED( v, pos );
965 
966  return nullptr;
967 }
969 //*************************************************************************************************
970 
971 
972 //*************************************************************************************************
984 template< typename Type // Data type of the vector
985  , bool TF // Transpose flag
986  , typename Iterator > // Type of the vector iterator
987 inline Iterator erase( ZeroVector<Type,TF>& m, Iterator first, Iterator last )
988 {
989  MAYBE_UNUSED( m, first, last );
990 
991  return nullptr;
992 }
994 //*************************************************************************************************
995 
996 
997 //*************************************************************************************************
1021 template< typename Type // Data type of the vector
1022  , bool TF // Transpose flag
1023  , typename Pred > // Type of the unary predicate
1024 inline void erase( ZeroVector<Type,TF>& v, Pred predicate )
1025 {
1026  MAYBE_UNUSED( v, predicate );
1027 }
1029 //*************************************************************************************************
1030 
1031 
1032 //*************************************************************************************************
1058 template< typename Type // Data type of the vector
1059  , bool TF // Transpose flag
1060  , typename Iterator // Type of the vector iterator
1061  , typename Pred > // Type of the unary predicate
1062 inline void erase( ZeroVector<Type,TF>& m, Iterator first, Iterator last, Pred predicate )
1063 {
1064  MAYBE_UNUSED( m, first, last, predicate );
1065 }
1067 //*************************************************************************************************
1068 
1069 
1070 
1071 
1072 //=================================================================================================
1073 //
1074 // GLOBAL FUNCTIONS
1075 //
1076 //=================================================================================================
1077 
1078 //*************************************************************************************************
1104 template< typename T, bool TF = defaultTransposeFlag >
1105 inline constexpr decltype(auto) zero( size_t n ) noexcept
1106 {
1107  return ZeroVector<T,TF>( n );
1108 }
1109 //*************************************************************************************************
1110 
1111 
1112 //*************************************************************************************************
1128 template< typename VT // Type of the vector
1129  , bool TF > // Transpose flag
1130 inline ZeroVector<ElementType_t<VT>,TF>
1132 {
1134 
1135  return ZeroVector<ElementType_t<VT>,TF>( (~v).size() );
1136 }
1137 //*************************************************************************************************
1138 
1139 
1140 
1141 
1142 //=================================================================================================
1143 //
1144 // ISUNIFORM SPECIALIZATIONS
1145 //
1146 //=================================================================================================
1147 
1148 //*************************************************************************************************
1150 template< typename Type, bool TF >
1151 struct IsUniform< ZeroVector<Type,TF> >
1152  : public TrueType
1153 {};
1155 //*************************************************************************************************
1156 
1157 
1158 
1159 
1160 //=================================================================================================
1161 //
1162 // ISZERO SPECIALIZATIONS
1163 //
1164 //=================================================================================================
1165 
1166 //*************************************************************************************************
1168 template< typename Type, bool TF >
1169 struct IsZero< ZeroVector<Type,TF> >
1170  : public TrueType
1171 {};
1173 //*************************************************************************************************
1174 
1175 
1176 
1177 
1178 //=================================================================================================
1179 //
1180 // ISRESIZABLE SPECIALIZATIONS
1181 //
1182 //=================================================================================================
1183 
1184 //*************************************************************************************************
1186 template< typename Type, bool TF >
1187 struct IsResizable< ZeroVector<Type,TF> >
1188  : public TrueType
1189 {};
1191 //*************************************************************************************************
1192 
1193 
1194 
1195 
1196 //=================================================================================================
1197 //
1198 // ADDTRAIT SPECIALIZATIONS
1199 //
1200 //=================================================================================================
1201 
1202 //*************************************************************************************************
1204 template< typename T1, typename T2 >
1205 struct AddTraitEval1< T1, T2
1206  , EnableIf_t< IsVector_v<T1> &&
1207  IsVector_v<T2> &&
1208  !IsZero_v<T1> && IsZero_v<T2> > >
1209 {
1210  using Type = Rebind_t< ResultType_t<T1>, AddTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1211 };
1212 
1213 template< typename T1, typename T2 >
1214 struct AddTraitEval1< T1, T2
1215  , EnableIf_t< IsVector_v<T1> &&
1216  IsVector_v<T2> &&
1217  IsZero_v<T1> && !IsZero_v<T2> > >
1218 {
1219  using Type = Rebind_t< ResultType_t<T2>, AddTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1220 };
1221 
1222 template< typename T1, typename T2 >
1223 struct AddTraitEval1< T1, T2
1224  , EnableIf_t< IsVector_v<T1> &&
1225  IsVector_v<T2> &&
1226  IsZero_v<T1> && IsZero_v<T2> > >
1227 {
1228  using ET1 = ElementType_t<T1>;
1229  using ET2 = ElementType_t<T2>;
1230 
1231  using Type = ZeroVector< AddTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1232 };
1234 //*************************************************************************************************
1235 
1236 
1237 
1238 
1239 //=================================================================================================
1240 //
1241 // SUBTRAIT SPECIALIZATIONS
1242 //
1243 //=================================================================================================
1244 
1245 //*************************************************************************************************
1247 template< typename T1, typename T2 >
1248 struct SubTraitEval1< T1, T2
1249  , EnableIf_t< IsVector_v<T1> &&
1250  IsVector_v<T2> &&
1251  !IsZero_v<T1> && IsZero_v<T2> > >
1252 {
1253  using Type = Rebind_t< ResultType_t<T1>, SubTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1254 };
1255 
1256 template< typename T1, typename T2 >
1257 struct SubTraitEval1< T1, T2
1258  , EnableIf_t< IsVector_v<T1> &&
1259  IsVector_v<T2> &&
1260  IsZero_v<T1> && !IsZero_v<T2> > >
1261 {
1262  using Type = Rebind_t< ResultType_t<T2>, SubTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1263 };
1264 
1265 template< typename T1, typename T2 >
1266 struct SubTraitEval1< T1, T2
1267  , EnableIf_t< IsVector_v<T1> &&
1268  IsVector_v<T2> &&
1269  IsZero_v<T1> && IsZero_v<T2> > >
1270 {
1271  using ET1 = ElementType_t<T1>;
1272  using ET2 = ElementType_t<T2>;
1273 
1274  using Type = ZeroVector< SubTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1275 };
1277 //*************************************************************************************************
1278 
1279 
1280 
1281 
1282 //=================================================================================================
1283 //
1284 // MULTTRAIT SPECIALIZATIONS
1285 //
1286 //=================================================================================================
1287 
1288 //*************************************************************************************************
1290 template< typename T1, typename T2 >
1291 struct MultTraitEval1< T1, T2
1292  , EnableIf_t< IsVector_v<T1> &&
1293  IsNumeric_v<T2> &&
1294  IsZero_v<T1> > >
1295 {
1296  using ET1 = ElementType_t<T1>;
1297 
1298  using Type = ZeroVector< MultTrait_t<ET1,T2>, TransposeFlag_v<T1> >;
1299 };
1300 
1301 template< typename T1, typename T2 >
1302 struct MultTraitEval1< T1, T2
1303  , EnableIf_t< IsNumeric_v<T1> &&
1304  IsVector_v<T2> &&
1305  IsZero_v<T2> > >
1306 {
1307  using ET2 = ElementType_t<T2>;
1308 
1309  using Type = ZeroVector< MultTrait_t<T1,ET2>, TransposeFlag_v<T2> >;
1310 };
1311 
1312 template< typename T1, typename T2 >
1313 struct MultTraitEval1< T1, T2
1314  , EnableIf_t< ( ( IsRowVector_v<T1> && IsRowVector_v<T2> ) ||
1315  ( IsColumnVector_v<T1> && IsColumnVector_v<T2> ) ) &&
1316  ( IsZero_v<T1> || IsZero_v<T2> ) > >
1317 {
1318  using ET1 = ElementType_t<T1>;
1319  using ET2 = ElementType_t<T2>;
1320 
1321  using Type = ZeroVector< MultTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1322 };
1323 
1324 template< typename T1, typename T2 >
1325 struct MultTraitEval1< T1, T2
1326  , EnableIf_t< IsMatrix_v<T1> &&
1327  IsColumnVector_v<T2> &&
1328  ( IsZero_v<T1> || IsZero_v<T2> ) > >
1329 {
1330  using ET1 = ElementType_t<T1>;
1331  using ET2 = ElementType_t<T2>;
1332 
1333  using Type = ZeroVector< MultTrait_t<ET1,ET2>, false >;
1334 };
1335 
1336 template< typename T1, typename T2 >
1337 struct MultTraitEval1< T1, T2
1338  , EnableIf_t< IsRowVector_v<T1> &&
1339  IsMatrix_v<T2> &&
1340  ( IsZero_v<T1> || IsZero_v<T2> ) > >
1341 {
1342  using ET1 = ElementType_t<T1>;
1343  using ET2 = ElementType_t<T2>;
1344 
1345  using Type = ZeroVector< MultTrait_t<ET1,ET2>, true >;
1346 };
1348 //*************************************************************************************************
1349 
1350 
1351 
1352 
1353 //=================================================================================================
1354 //
1355 // KRONTRAIT SPECIALIZATIONS
1356 //
1357 //=================================================================================================
1358 
1359 //*************************************************************************************************
1361 template< typename T1, typename T2 >
1362 struct KronTraitEval1< T1, T2
1363  , EnableIf_t< IsVector_v<T1> &&
1364  IsVector_v<T2> &&
1365  ( IsZero_v<T1> ||
1366  IsZero_v<T2> ) > >
1367 {
1368  using ET1 = ElementType_t<T1>;
1369  using ET2 = ElementType_t<T2>;
1370 
1371  static constexpr bool TF = ( IsZero_v<T2> ? TransposeFlag_v<T2> : TransposeFlag_v<T1> );
1372 
1373  using Type = ZeroVector< MultTrait_t<ET1,ET2>, TF >;
1374 };
1376 //*************************************************************************************************
1377 
1378 
1379 
1380 
1381 //=================================================================================================
1382 //
1383 // DIVTRAIT SPECIALIZATIONS
1384 //
1385 //=================================================================================================
1386 
1387 //*************************************************************************************************
1389 template< typename T1, typename T2 >
1390 struct DivTraitEval1< T1, T2
1391  , EnableIf_t< IsVector_v<T1> &&
1392  IsNumeric_v<T2> &&
1393  IsZero_v<T1> > >
1394 {
1395  using ET1 = ElementType_t<T1>;
1396 
1397  using Type = ZeroVector< DivTrait_t<ET1,T2>, TransposeFlag_v<T1> >;
1398 };
1399 
1400 template< typename T1, typename T2 >
1401 struct DivTraitEval1< T1, T2
1402  , EnableIf_t< ( ( IsRowVector_v<T1> && IsRowVector_v<T2> ) ||
1403  ( IsColumnVector_v<T1> && IsColumnVector_v<T2> ) ) &&
1404  ( IsZero_v<T1> || IsZero_v<T2> ) > >
1405 {
1406  using ET1 = ElementType_t<T1>;
1407  using ET2 = ElementType_t<T2>;
1408 
1409  using Type = ZeroVector< DivTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1410 };
1412 //*************************************************************************************************
1413 
1414 
1415 
1416 
1417 //=================================================================================================
1418 //
1419 // CROSSTRAIT SPECIALIZATIONS
1420 //
1421 //=================================================================================================
1422 
1423 //*************************************************************************************************
1425 template< typename T1, typename T2 >
1426 struct CrossTraitEval1< T1, T2
1427  , EnableIf_t< IsVector_v<T1> &&
1428  IsVector_v<T2> &&
1429  ( IsZero_v<T1> || IsZero_v<T2> ) > >
1430 {
1431  using Tmp = MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >;
1432 
1433  using Type = ZeroVector< SubTrait_t<Tmp,Tmp>, TransposeFlag_v<T1> >;
1434 };
1436 //*************************************************************************************************
1437 
1438 
1439 
1440 
1441 //=================================================================================================
1442 //
1443 // MAPTRAIT SPECIALIZATIONS
1444 //
1445 //=================================================================================================
1446 
1447 //*************************************************************************************************
1449 template< typename T, typename OP >
1450 struct UnaryMapTraitEval1< T, OP
1451  , EnableIf_t< IsVector_v<T> &&
1452  YieldsZero_v<OP,T> > >
1453 {
1454  using ET = ElementType_t<T>;
1455 
1456  using Type = ZeroVector< MapTrait_t<ET,OP>, TransposeFlag_v<T> >;
1457 };
1459 //*************************************************************************************************
1460 
1461 
1462 //*************************************************************************************************
1464 template< typename T1, typename T2, typename OP >
1465 struct BinaryMapTraitEval1< T1, T2, OP
1466  , EnableIf_t< IsVector_v<T1> &&
1467  IsVector_v<T2> &&
1468  YieldsZero_v<OP,T1,T2> > >
1469 {
1470  using ET1 = ElementType_t<T1>;
1471  using ET2 = ElementType_t<T2>;
1472 
1473  using Type = ZeroVector< MapTrait_t<ET1,ET2,OP>, TransposeFlag_v<T1> >;
1474 };
1476 //*************************************************************************************************
1477 
1478 
1479 
1480 
1481 //=================================================================================================
1482 //
1483 // HIGHTYPE SPECIALIZATIONS
1484 //
1485 //=================================================================================================
1486 
1487 //*************************************************************************************************
1489 template< typename T1, bool TF, typename T2 >
1490 struct HighType< ZeroVector<T1,TF>, ZeroVector<T2,TF> >
1491 {
1492  using Type = ZeroVector< typename HighType<T1,T2>::Type, TF >;
1493 };
1495 //*************************************************************************************************
1496 
1497 
1498 
1499 
1500 //=================================================================================================
1501 //
1502 // LOWTYPE SPECIALIZATIONS
1503 //
1504 //=================================================================================================
1505 
1506 //*************************************************************************************************
1508 template< typename T1, bool TF, typename T2 >
1509 struct LowType< ZeroVector<T1,TF>, ZeroVector<T2,TF> >
1510 {
1511  using Type = ZeroVector< typename LowType<T1,T2>::Type, TF >;
1512 };
1514 //*************************************************************************************************
1515 
1516 
1517 
1518 
1519 //=================================================================================================
1520 //
1521 // SUBVECTORTRAIT SPECIALIZATIONS
1522 //
1523 //=================================================================================================
1524 
1525 //*************************************************************************************************
1527 template< typename VT, size_t I, size_t N >
1528 struct SubvectorTraitEval1< VT, I, N
1529  , EnableIf_t< IsZero_v<VT> > >
1530 {
1531  using Type = ZeroVector< RemoveConst_t< ElementType_t<VT> >, TransposeFlag_v<VT> >;
1532 };
1534 //*************************************************************************************************
1535 
1536 
1537 
1538 
1539 //=================================================================================================
1540 //
1541 // ELEMENTSTRAIT SPECIALIZATIONS
1542 //
1543 //=================================================================================================
1544 
1545 //*************************************************************************************************
1547 template< typename VT, size_t N >
1548 struct ElementsTraitEval1< VT, N
1549  , EnableIf_t< IsZero_v<VT> > >
1550 {
1551  using Type = ZeroVector< RemoveConst_t< ElementType_t<VT> >, TransposeFlag_v<VT> >;
1552 };
1554 //*************************************************************************************************
1555 
1556 
1557 
1558 
1559 //=================================================================================================
1560 //
1561 // ROWTRAIT SPECIALIZATIONS
1562 //
1563 //=================================================================================================
1564 
1565 //*************************************************************************************************
1567 template< typename MT, size_t I >
1568 struct RowTraitEval1< MT, I
1569  , EnableIf_t< IsZero_v<MT> > >
1570 {
1571  using Type = ZeroVector< RemoveConst_t< ElementType_t<MT> >, true >;
1572 };
1574 //*************************************************************************************************
1575 
1576 
1577 
1578 
1579 //=================================================================================================
1580 //
1581 // COLUMNTRAIT SPECIALIZATIONS
1582 //
1583 //=================================================================================================
1584 
1585 //*************************************************************************************************
1587 template< typename MT, size_t I >
1588 struct ColumnTraitEval1< MT, I
1589  , EnableIf_t< IsZero_v<MT> > >
1590 {
1591  using Type = ZeroVector< RemoveConst_t< ElementType_t<MT> >, false >;
1592 };
1594 //*************************************************************************************************
1595 
1596 
1597 
1598 
1599 //=================================================================================================
1600 //
1601 // BANDTRAIT SPECIALIZATIONS
1602 //
1603 //=================================================================================================
1604 
1605 //*************************************************************************************************
1607 template< typename MT, ptrdiff_t I >
1608 struct BandTraitEval1< MT, I
1609  , EnableIf_t< IsZero_v<MT> > >
1610 {
1611  using Type = ZeroVector< RemoveConst_t< ElementType_t<MT> >, defaultTransposeFlag >;
1612 };
1614 //*************************************************************************************************
1615 
1616 } // namespace blaze
1617 
1618 #endif
#define BLAZE_CONSTRAINT_MUST_NOT_BE_CONST(T)
Constraint on the data type.In case the given data type is a const-qualified type,...
Definition: Const.h:79
#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.
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.The IsMatrix_v variable template provides a c...
Definition: IsMatrix.h:138
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression,...
Definition: Assert.h:117
Header file for the subtraction trait.
Header file for basic type definitions.
constexpr ZeroVector() noexcept
The default constructor for ZeroVector.
Definition: ZeroVector.h:340
Header file for the SparseVector base class.
Header file for the row trait.
constexpr bool IsRowVector_v
Auxiliary variable template for the IsRowVector type trait.The IsRowVector_v variable template provid...
Definition: IsRowVector.h:142
Header file for the isZero shim.
Header file for the YieldsZero type trait.
ZeroVector< Type, TF > This
Type of this ZeroVector instance.
Definition: ZeroVector.h:180
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:595
const Type & Reference
Reference to a zero vector element.
Definition: ZeroVector.h:187
Header file for the IsRowVector type trait.
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: ZeroVector.h:778
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: ZeroVector.h:216
Header file for the MAYBE_UNUSED function template.
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type,...
Definition: Volatile.h:79
BoolConstant< true > TrueType
Type traits base class.The TrueType class is used as base class for type traits and value traits that...
Definition: IntegralConstant.h:132
Header file for all forward declarations of the math module.
size_t size_
The current size/dimension of the zero vector.
Definition: ZeroVector.h:297
constexpr void resize(size_t n) noexcept
Changing the size of the zero vector.
Definition: ZeroVector.h:609
Header file for the elements trait.
Header file for the band trait.
Constraint on the data type.
Header file for the IsMatrix type trait.
decltype(auto) constexpr zero(size_t m, size_t n) noexcept
Creating a zero matrix.
Definition: ZeroMatrix.h:1353
constexpr ConstIterator cbegin() const noexcept
Returns an iterator to the first non-zero element of the zero vector.
Definition: ZeroVector.h:456
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:677
typename EnableIf< Condition, T >::Type EnableIf_t
Auxiliary type for the EnableIf class template.The EnableIf_t alias declaration provides a convenient...
Definition: EnableIf.h:138
constexpr void clear() noexcept
Clearing the zero vector.
Definition: ZeroVector.h:590
Header file for the ValueIndexPair class.
Header file for the LowType type trait.
Header file for the IsUniform type trait.
Header file for the multiplication trait.
Type ElementType
Type of the zero vector elements.
Definition: ZeroVector.h:184
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
#define BLAZE_CONSTRAINT_MUST_NOT_BE_POINTER_TYPE(T)
Constraint on the data type.In case the given data type T is not a pointer type, a compilation error ...
Definition: Pointer.h:79
Header file for the IsSMPAssignable type trait.
#define BLAZE_THROW_OUT_OF_RANGE(MESSAGE)
Macro for the emission of a std::out_of_range exception.This macro encapsulates the default way of Bl...
Definition: Exception.h:331
bool canAlias(const Other *alias) const noexcept
Returns whether the vector can alias with the given address alias.
Definition: ZeroVector.h:735
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: ZeroVector.h:757
Header file for the subvector trait.
constexpr bool IsNumeric_v
Auxiliary variable template for the IsNumeric type trait.The IsNumeric_v variable template provides a...
Definition: IsNumeric.h:143
Constraint on the data type.
ZeroMatrix< ElementType_t< MT >, SO > declzero(const Matrix< MT, SO > &m)
Declares the given matrix expression m as zero matrix.
Definition: ZeroMatrix.h:1379
const Type & ConstReference
Reference to a constant zero vector element.
Definition: ZeroVector.h:188
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
Resize mechanism to obtain a ZeroVector with a different fixed number of elements.
Definition: ZeroVector.h:206
constexpr ConstIterator begin() const noexcept
Returns an iterator to the first non-zero element of the zero vector.
Definition: ZeroVector.h:441
Header file for the Kron product trait.
Header file for the TransposeFlag type trait.
constexpr ConstReference operator[](size_t index) const noexcept
Subscript operator for the direct access to the zero vector elements.
Definition: ZeroVector.h:398
Header file for the exception macros of the math module.
constexpr size_t nonZeros() const noexcept
Returns the number of non-zero elements in the zero vector.
Definition: ZeroVector.h:574
Header file for the IsVector type trait.
static const Type zero_
The zero element.
Definition: ZeroVector.h:299
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:615
constexpr bool IsZero_v
Auxiliary variable template for the IsZero type trait.The IsZero_v variable template provides a conve...
Definition: IsZero.h:166
Header file for the IsNumeric type trait.
ConstIterator upperBound(size_t index) const
Returns an iterator to the first index greater then the given index.
Definition: ZeroVector.h:703
Header file for the RemoveConst type trait.
Header file for run time assertion macros.
ConstIterator find(size_t index) const
Searches for a specific vector element.
Definition: ZeroVector.h:655
Header file for the addition trait.
Header file for the cross product trait.
Header file for the division trait.
Constraint on the data type.
constexpr size_t capacity() const noexcept
Returns the maximum capacity of the zero vector.
Definition: ZeroVector.h:557
Header file for the IsZero type trait.
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.The IsVector_v variable template provides a c...
Definition: IsVector.h:139
#define BLAZE_FUNCTION_TRACE
Function trace macro.This macro can be used to reliably trace function calls. In case function tracin...
Definition: FunctionTrace.h:94
#define BLAZE_CONSTRAINT_MUST_NOT_BE_REFERENCE_TYPE(T)
Constraint on the data type.In case the given data type T is not a reference type,...
Definition: Reference.h:79
Header file for the column trait.
void swap(DiagonalMatrix< MT, SO, DF > &a, DiagonalMatrix< MT, SO, DF > &b) noexcept
Swapping the contents of two matrices.
Definition: DiagonalMatrix.h:282
constexpr size_t size(const Matrix< MT, SO > &matrix) noexcept
Returns the total number of elements of the matrix.
Definition: Matrix.h:530
Constraint on the data type.
constexpr ConstIterator cend() const noexcept
Returns an iterator just past the last non-zero element of the zero vector.
Definition: ZeroVector.h:486
Rebind mechanism to obtain a ZeroVector with different data/element type.
Definition: ZeroVector.h:197
ConstIterator lowerBound(size_t index) const
Returns an iterator to the first index not less then the given index.
Definition: ZeroVector.h:679
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:73
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:198
Header file for the default transpose flag for all vectors of the Blaze library.
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:146
Header file for the IntegralConstant class template.
Header file for the map trait.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:264
ConstReference at(size_t index) const
Checked access to the zero vector elements.
Definition: ZeroVector.h:422
const Type & ReturnType
Return type for expression template evaluations.
Definition: ZeroVector.h:185
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:635
constexpr size_t size() const noexcept
Returns the current size/dimension of the zero vector.
Definition: ZeroVector.h:543
constexpr void swap(ZeroVector &v) noexcept
Swapping the contents of two zero vectors.
Definition: ZeroVector.h:624
constexpr ConstIterator end() const noexcept
Returns an iterator just past the last non-zero element of the zero vector.
Definition: ZeroVector.h:471
Efficient implementation of an arbitrary sized zero vector.The ZeroVector class template is the repre...
Definition: Forward.h:51
Header file for the IsColumnVector type trait.
Header file for the IsResizable type trait.
Header file for the Expression base class.
Header file for the HighType type trait.
Header file for the function trace functionality.