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>
46 #include <blaze/math/Forward.h>
73 #include <blaze/util/Assert.h>
78 #include <blaze/util/EnableIf.h>
80 #include <blaze/util/TrueType.h>
81 #include <blaze/util/Types.h>
84 #include <blaze/util/Unused.h>
85 
86 
87 namespace blaze {
88 
89 //=================================================================================================
90 //
91 // CLASS DEFINITION
92 //
93 //=================================================================================================
94 
95 //*************************************************************************************************
166 template< typename Type // Data type of the vector
167  , bool TF = defaultTransposeFlag > // Transpose flag
168 class ZeroVector
169  : public SparseVector< ZeroVector<Type,TF>, TF >
170 {
171  private:
172  //**Type definitions****************************************************************************
174  //**********************************************************************************************
175 
176  public:
177  //**Type definitions****************************************************************************
180  using ResultType = This;
182  using ElementType = Type;
183  using ReturnType = const Type&;
184  using CompositeType = const This&;
185  using Reference = const Type&;
186  using ConstReference = const Type&;
187  using Iterator = Element*;
188  using ConstIterator = const Element*;
189  //**********************************************************************************************
190 
191  //**Rebind struct definition********************************************************************
194  template< typename NewType > // Data type of the other vector
195  struct Rebind {
197  };
198  //**********************************************************************************************
199 
200  //**Resize struct definition********************************************************************
203  template< size_t NewN > // Number of elements of the other vector
204  struct Resize {
206  };
207  //**********************************************************************************************
208 
209  //**Compilation flags***************************************************************************
211 
214  static constexpr bool smpAssignable = !IsSMPAssignable_v<Type>;
215  //**********************************************************************************************
216 
217  //**Constructors********************************************************************************
220  explicit inline constexpr ZeroVector() noexcept;
221  explicit inline constexpr ZeroVector( size_t size ) noexcept;
222 
223  template< typename VT > inline ZeroVector( const Vector<VT,TF>& v );
224 
225  ZeroVector( const ZeroVector& ) = default;
226  ZeroVector( ZeroVector&& ) = default;
228  //**********************************************************************************************
229 
230  //**Destructor**********************************************************************************
233  ~ZeroVector() = default;
235  //**********************************************************************************************
236 
237  //**Data access functions***********************************************************************
240  inline constexpr ConstReference operator[]( size_t index ) const noexcept;
241  inline ConstReference at( size_t index ) const;
242  inline constexpr ConstIterator begin () const noexcept;
243  inline constexpr ConstIterator cbegin() const noexcept;
244  inline constexpr ConstIterator end () const noexcept;
245  inline constexpr ConstIterator cend () const noexcept;
247  //**********************************************************************************************
248 
249  //**Assignment operators************************************************************************
252  template< typename VT >
253  inline ZeroVector& operator=( const Vector<VT,TF>& rhs );
254 
255  ZeroVector& operator=( const ZeroVector& ) = default;
256  ZeroVector& operator=( ZeroVector&& ) = default;
258  //**********************************************************************************************
259 
260  //**Utility functions***************************************************************************
263  inline constexpr size_t size() const noexcept;
264  inline constexpr size_t capacity() const noexcept;
265  inline constexpr size_t nonZeros() const noexcept;
266  inline constexpr void clear() noexcept;
267  inline constexpr void resize( size_t n ) noexcept;
268  inline constexpr void swap( ZeroVector& v ) noexcept;
270  //**********************************************************************************************
271 
272  //**Lookup functions****************************************************************************
275  inline ConstIterator find ( size_t index ) const;
276  inline ConstIterator lowerBound( size_t index ) const;
277  inline ConstIterator upperBound( size_t index ) const;
279  //**********************************************************************************************
280 
281  //**Expression template evaluation functions****************************************************
284  template< typename Other > inline bool canAlias ( const Other* alias ) const noexcept;
285  template< typename Other > inline bool isAliased( const Other* alias ) const noexcept;
286 
287  inline bool canSMPAssign() const noexcept;
289  //**********************************************************************************************
290 
291  private:
292  //**Member variables****************************************************************************
295  size_t size_;
296 
297  static const Type zero_;
298 
299  //**********************************************************************************************
300 
301  //**Compile time checks*************************************************************************
308  //**********************************************************************************************
309 };
310 //*************************************************************************************************
311 
312 
313 
314 
315 //=================================================================================================
316 //
317 // DEFINITION AND INITIALIZATION OF THE STATIC MEMBER VARIABLES
318 //
319 //=================================================================================================
320 
321 template< typename Type, bool TF >
322 const Type ZeroVector<Type,TF>::zero_{};
323 
324 
325 
326 
327 //=================================================================================================
328 //
329 // CONSTRUCTORS
330 //
331 //=================================================================================================
332 
333 //*************************************************************************************************
336 template< typename Type // Data type of the vector
337  , bool TF > // Transpose flag
338 inline constexpr ZeroVector<Type,TF>::ZeroVector() noexcept
339  : size_( 0UL ) // The current size/dimension of the zero vector
340 {}
341 //*************************************************************************************************
342 
343 
344 //*************************************************************************************************
349 template< typename Type // Data type of the vector
350  , bool TF > // Transpose flag
351 inline constexpr ZeroVector<Type,TF>::ZeroVector( size_t n ) noexcept
352  : size_( n ) // The current size/dimension of the zero vector
353 {}
354 //*************************************************************************************************
355 
356 
357 //*************************************************************************************************
366 template< typename Type // Data type of the vector
367  , bool TF > // Transpose flag
368 template< typename VT > // Type of the foreign zero vector
370  : size_( (~v).size() ) // The current size/dimension of the zero vector
371 {
372  if( !IsZero_v<VT> && !isZero( ~v ) ) {
373  BLAZE_THROW_INVALID_ARGUMENT( "Invalid setup of zero vector" );
374  }
375 }
376 //*************************************************************************************************
377 
378 
379 
380 
381 //=================================================================================================
382 //
383 // DATA ACCESS FUNCTIONS
384 //
385 //=================================================================================================
386 
387 //*************************************************************************************************
393 template< typename Type // Data type of the vector
394  , bool TF > // Transpose flag
395 inline constexpr typename ZeroVector<Type,TF>::ConstReference
396  ZeroVector<Type,TF>::operator[]( size_t index ) const noexcept
397 {
398  UNUSED_PARAMETER( index );
399 
400  BLAZE_USER_ASSERT( index < size(), "Invalid zero vector access index" );
401 
402  return zero_;
403 }
404 //*************************************************************************************************
405 
406 
407 //*************************************************************************************************
417 template< typename Type // Data type of the vector
418  , bool TF > // Transpose flag
420  ZeroVector<Type,TF>::at( size_t index ) const
421 {
422  if( index >= size_ ) {
423  BLAZE_THROW_OUT_OF_RANGE( "Invalid zero vector access index" );
424  }
425 
426  return zero_;
427 }
428 //*************************************************************************************************
429 
430 
431 //*************************************************************************************************
436 template< typename Type // Data type of the vector
437  , bool TF > // Transpose flag
438 inline constexpr typename ZeroVector<Type,TF>::ConstIterator
439  ZeroVector<Type,TF>::begin() const noexcept
440 {
441  return nullptr;
442 }
443 //*************************************************************************************************
444 
445 
446 //*************************************************************************************************
451 template< typename Type // Data type of the vector
452  , bool TF > // Transpose flag
453 inline constexpr typename ZeroVector<Type,TF>::ConstIterator
455 {
456  return nullptr;
457 }
458 //*************************************************************************************************
459 
460 
461 //*************************************************************************************************
466 template< typename Type // Data type of the vector
467  , bool TF > // Transpose flag
468 inline constexpr typename ZeroVector<Type,TF>::ConstIterator
469  ZeroVector<Type,TF>::end() const noexcept
470 {
471  return nullptr;
472 }
473 //*************************************************************************************************
474 
475 
476 //*************************************************************************************************
481 template< typename Type // Data type of the vector
482  , bool TF > // Transpose flag
483 inline constexpr typename ZeroVector<Type,TF>::ConstIterator
484  ZeroVector<Type,TF>::cend() const noexcept
485 {
486  return nullptr;
487 }
488 //*************************************************************************************************
489 
490 
491 
492 
493 //=================================================================================================
494 //
495 // ASSIGNMENT OPERATORS
496 //
497 //=================================================================================================
498 
499 //*************************************************************************************************
509 template< typename Type // Data type of the vector
510  , bool TF > // Transpose flag
511 template< typename VT > // Type of the right-hand side dense vector
512 inline ZeroVector<Type,TF>&
514 {
515  if( !IsZero_v<VT> && !isZero( ~rhs ) ) {
516  BLAZE_THROW_INVALID_ARGUMENT( "Invalid assignment of zero vector" );
517  }
518 
519  size_ = (~rhs).size();
520 
521  return *this;
522 }
523 //*************************************************************************************************
524 
525 
526 
527 
528 //=================================================================================================
529 //
530 // UTILITY FUNCTIONS
531 //
532 //=================================================================================================
533 
534 //*************************************************************************************************
539 template< typename Type // Data type of the vector
540  , bool TF > // Transpose flag
541 inline constexpr size_t ZeroVector<Type,TF>::size() const noexcept
542 {
543  return size_;
544 }
545 //*************************************************************************************************
546 
547 
548 //*************************************************************************************************
553 template< typename Type // Data type of the vector
554  , bool TF > // Transpose flag
555 inline constexpr size_t ZeroVector<Type,TF>::capacity() const noexcept
556 {
557  return 0UL;
558 }
559 //*************************************************************************************************
560 
561 
562 //*************************************************************************************************
570 template< typename Type // Data type of the vector
571  , bool TF > // Transpose flag
572 inline constexpr size_t ZeroVector<Type,TF>::nonZeros() const noexcept
573 {
574  return 0UL;
575 }
576 //*************************************************************************************************
577 
578 
579 //*************************************************************************************************
586 template< typename Type // Data type of the vector
587  , bool TF > // Transpose flag
588 inline constexpr void ZeroVector<Type,TF>::clear() noexcept
589 {
590  size_ = 0UL;
591 }
592 //*************************************************************************************************
593 
594 
595 //*************************************************************************************************
605 template< typename Type // Data type of the vector
606  , bool TF > // Transpose flag
607 inline constexpr void ZeroVector<Type,TF>::resize( size_t n ) noexcept
608 {
609  size_ = n;
610 }
611 //*************************************************************************************************
612 
613 
614 //*************************************************************************************************
620 template< typename Type // Data type of the vector
621  , bool TF > // Transpose flag
622 inline constexpr void ZeroVector<Type,TF>::swap( ZeroVector& v ) noexcept
623 {
624  const size_t tmp( size_ );
625  size_ = v.size_;
626  v.size_ = tmp;
627 }
628 //*************************************************************************************************
629 
630 
631 
632 
633 //=================================================================================================
634 //
635 // LOOKUP FUNCTIONS
636 //
637 //=================================================================================================
638 
639 //*************************************************************************************************
650 template< typename Type // Data type of the vector
651  , bool TF > // Transpose flag
653  ZeroVector<Type,TF>::find( size_t index ) const
654 {
655  UNUSED_PARAMETER( index );
656 
657  BLAZE_USER_ASSERT( index < size(), "Invalid zero vector access index" );
658 
659  return nullptr;
660 }
661 //*************************************************************************************************
662 
663 
664 //*************************************************************************************************
674 template< typename Type // Data type of the vector
675  , bool TF > // Transpose flag
677  ZeroVector<Type,TF>::lowerBound( size_t index ) const
678 {
679  UNUSED_PARAMETER( index );
680 
681  BLAZE_USER_ASSERT( index < size(), "Invalid zero vector access index" );
682 
683  return nullptr;
684 }
685 //*************************************************************************************************
686 
687 
688 //*************************************************************************************************
698 template< typename Type // Data type of the vector
699  , bool TF > // Transpose flag
701  ZeroVector<Type,TF>::upperBound( size_t index ) const
702 {
703  UNUSED_PARAMETER( index );
704 
705  BLAZE_USER_ASSERT( index < size(), "Invalid zero vector access index" );
706 
707  return nullptr;
708 }
709 //*************************************************************************************************
710 
711 
712 
713 
714 //=================================================================================================
715 //
716 // EXPRESSION TEMPLATE EVALUATION FUNCTIONS
717 //
718 //=================================================================================================
719 
720 //*************************************************************************************************
730 template< typename Type // Data type of the vector
731  , bool TF > // Transpose flag
732 template< typename Other > // Data type of the foreign expression
733 inline bool ZeroVector<Type,TF>::canAlias( const Other* alias ) const noexcept
734 {
735  UNUSED_PARAMETER( alias );
736 
737  return false;
738 }
739 //*************************************************************************************************
740 
741 
742 //*************************************************************************************************
752 template< typename Type // Data type of the vector
753  , bool TF > // Transpose flag
754 template< typename Other > // Data type of the foreign expression
755 inline bool ZeroVector<Type,TF>::isAliased( const Other* alias ) const noexcept
756 {
757  UNUSED_PARAMETER( alias );
758 
759  return false;
760 }
761 //*************************************************************************************************
762 
763 
764 //*************************************************************************************************
774 template< typename Type // Data type of the vector
775  , bool TF > // Transpose flag
776 inline bool ZeroVector<Type,TF>::canSMPAssign() const noexcept
777 {
778  return false;
779 }
780 //*************************************************************************************************
781 
782 
783 
784 
785 
786 
787 
788 
789 //=================================================================================================
790 //
791 // ZEROVECTOR OPERATORS
792 //
793 //=================================================================================================
794 
795 //*************************************************************************************************
798 template< typename Type, bool TF >
799 constexpr void reset( ZeroVector<Type,TF>& m ) noexcept;
800 
801 template< typename Type, bool TF >
802 constexpr void clear( ZeroVector<Type,TF>& m ) noexcept;
803 
804 template< bool RF, typename Type, bool TF >
805 constexpr bool isDefault( const ZeroVector<Type,TF>& m ) noexcept;
806 
807 template< typename Type, bool TF >
808 constexpr bool isIntact( const ZeroVector<Type,TF>& m ) noexcept;
809 
810 template< typename Type, bool TF >
811 constexpr void swap( ZeroVector<Type,TF>& a, ZeroVector<Type,TF>& b ) noexcept;
813 //*************************************************************************************************
814 
815 
816 //*************************************************************************************************
823 template< typename Type // Data type of the vector
824  , bool TF > // Transpose flag
825 inline constexpr void reset( ZeroVector<Type,TF>& v ) noexcept
826 {
827  UNUSED_PARAMETER( v );
828 }
829 //*************************************************************************************************
830 
831 
832 //*************************************************************************************************
839 template< typename Type // Data type of the vector
840  , bool TF > // Transpose flag
841 inline constexpr void clear( ZeroVector<Type,TF>& v ) noexcept
842 {
843  v.clear();
844 }
845 //*************************************************************************************************
846 
847 
848 //*************************************************************************************************
872 template< bool RF // Relaxation flag
873  , typename Type // Data type of the vector
874  , bool TF > // Transpose flag
875 inline constexpr bool isDefault( const ZeroVector<Type,TF>& v ) noexcept
876 {
877  return ( v.size() == 0UL );
878 }
879 //*************************************************************************************************
880 
881 
882 //*************************************************************************************************
899 template< typename Type // Data type of the vector
900  , bool TF > // Transpose flag
901 inline constexpr bool isIntact( const ZeroVector<Type,TF>& v ) noexcept
902 {
903  UNUSED_PARAMETER( v );
904 
905  return true;
906 }
907 //*************************************************************************************************
908 
909 
910 //*************************************************************************************************
918 template< typename Type // Data type of the vector
919  , bool TF > // Transpose flag
920 inline constexpr void swap( ZeroVector<Type,TF>& a, ZeroVector<Type,TF>& b ) noexcept
921 {
922  a.swap( b );
923 }
924 //*************************************************************************************************
925 
926 
927 //*************************************************************************************************
936 template< typename Type // Data type of the vector
937  , bool TF > // Transpose flag
938 inline void erase( ZeroVector<Type,TF>& v, size_t index )
939 {
940  UNUSED_PARAMETER( v, index );
941 }
943 //*************************************************************************************************
944 
945 
946 //*************************************************************************************************
957 template< typename Type // Data type of the vector
958  , bool TF // Transpose flag
959  , typename Iterator > // Type of the vector iterator
960 inline Iterator erase( ZeroVector<Type,TF>& v, Iterator pos )
961 {
962  UNUSED_PARAMETER( v, pos );
963 
964  return nullptr;
965 }
967 //*************************************************************************************************
968 
969 
970 //*************************************************************************************************
982 template< typename Type // Data type of the vector
983  , bool TF // Transpose flag
984  , typename Iterator > // Type of the vector iterator
985 inline Iterator erase( ZeroVector<Type,TF>& m, Iterator first, Iterator last )
986 {
987  UNUSED_PARAMETER( m, first, last );
988 
989  return nullptr;
990 }
992 //*************************************************************************************************
993 
994 
995 //*************************************************************************************************
1019 template< typename Type // Data type of the vector
1020  , bool TF // Transpose flag
1021  , typename Pred > // Type of the unary predicate
1022 inline void erase( ZeroVector<Type,TF>& v, Pred predicate )
1023 {
1024  UNUSED_PARAMETER( v, predicate );
1025 }
1027 //*************************************************************************************************
1028 
1029 
1030 //*************************************************************************************************
1056 template< typename Type // Data type of the vector
1057  , bool TF // Transpose flag
1058  , typename Iterator // Type of the vector iterator
1059  , typename Pred > // Type of the unary predicate
1060 inline void erase( ZeroVector<Type,TF>& m, Iterator first, Iterator last, Pred predicate )
1061 {
1062  UNUSED_PARAMETER( m, first, last, predicate );
1063 }
1065 //*************************************************************************************************
1066 
1067 
1068 
1069 
1070 //=================================================================================================
1071 //
1072 // GLOBAL FUNCTIONS
1073 //
1074 //=================================================================================================
1075 
1076 //*************************************************************************************************
1092 template< typename VT // Type of the vector
1093  , bool TF > // Transpose flag
1094 inline ZeroVector<ElementType_t<VT>,TF>
1096 {
1098 
1099  return ZeroVector<ElementType_t<VT>,TF>( (~v).size() );
1100 }
1101 //*************************************************************************************************
1102 
1103 
1104 
1105 
1106 //=================================================================================================
1107 //
1108 // ISUNIFORM SPECIALIZATIONS
1109 //
1110 //=================================================================================================
1111 
1112 //*************************************************************************************************
1114 template< typename Type, bool TF >
1115 struct IsUniform< ZeroVector<Type,TF> >
1116  : public TrueType
1117 {};
1119 //*************************************************************************************************
1120 
1121 
1122 
1123 
1124 //=================================================================================================
1125 //
1126 // ISZERO SPECIALIZATIONS
1127 //
1128 //=================================================================================================
1129 
1130 //*************************************************************************************************
1132 template< typename Type, bool TF >
1133 struct IsZero< ZeroVector<Type,TF> >
1134  : public TrueType
1135 {};
1137 //*************************************************************************************************
1138 
1139 
1140 
1141 
1142 //=================================================================================================
1143 //
1144 // ISRESIZABLE SPECIALIZATIONS
1145 //
1146 //=================================================================================================
1147 
1148 //*************************************************************************************************
1150 template< typename Type, bool TF >
1151 struct IsResizable< ZeroVector<Type,TF> >
1152  : public TrueType
1153 {};
1155 //*************************************************************************************************
1156 
1157 
1158 
1159 
1160 //=================================================================================================
1161 //
1162 // ADDTRAIT SPECIALIZATIONS
1163 //
1164 //=================================================================================================
1165 
1166 //*************************************************************************************************
1168 template< typename T1, typename T2 >
1169 struct AddTraitEval1< T1, T2
1170  , EnableIf_t< IsVector_v<T1> &&
1171  IsVector_v<T2> &&
1172  !IsZero_v<T1> && IsZero_v<T2> > >
1173 {
1174  using Type = Rebind_t< ResultType_t<T1>, AddTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1175 };
1176 
1177 template< typename T1, typename T2 >
1178 struct AddTraitEval1< T1, T2
1179  , EnableIf_t< IsVector_v<T1> &&
1180  IsVector_v<T2> &&
1181  IsZero_v<T1> && !IsZero_v<T2> > >
1182 {
1183  using Type = Rebind_t< ResultType_t<T2>, AddTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1184 };
1185 
1186 template< typename T1, typename T2 >
1187 struct AddTraitEval1< T1, T2
1188  , EnableIf_t< IsVector_v<T1> &&
1189  IsVector_v<T2> &&
1190  IsZero_v<T1> && IsZero_v<T2> > >
1191 {
1192  using ET1 = ElementType_t<T1>;
1193  using ET2 = ElementType_t<T2>;
1194 
1195  using Type = ZeroVector< AddTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1196 };
1198 //*************************************************************************************************
1199 
1200 
1201 
1202 
1203 //=================================================================================================
1204 //
1205 // SUBTRAIT SPECIALIZATIONS
1206 //
1207 //=================================================================================================
1208 
1209 //*************************************************************************************************
1211 template< typename T1, typename T2 >
1212 struct SubTraitEval1< T1, T2
1213  , EnableIf_t< IsVector_v<T1> &&
1214  IsVector_v<T2> &&
1215  !IsZero_v<T1> && IsZero_v<T2> > >
1216 {
1217  using Type = Rebind_t< ResultType_t<T1>, SubTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1218 };
1219 
1220 template< typename T1, typename T2 >
1221 struct SubTraitEval1< T1, T2
1222  , EnableIf_t< IsVector_v<T1> &&
1223  IsVector_v<T2> &&
1224  IsZero_v<T1> && !IsZero_v<T2> > >
1225 {
1226  using Type = Rebind_t< ResultType_t<T2>, SubTrait_t< ElementType_t<T1>, ElementType_t<T2> > >;
1227 };
1228 
1229 template< typename T1, typename T2 >
1230 struct SubTraitEval1< T1, T2
1231  , EnableIf_t< IsVector_v<T1> &&
1232  IsVector_v<T2> &&
1233  IsZero_v<T1> && IsZero_v<T2> > >
1234 {
1235  using ET1 = ElementType_t<T1>;
1236  using ET2 = ElementType_t<T2>;
1237 
1238  using Type = ZeroVector< SubTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1239 };
1241 //*************************************************************************************************
1242 
1243 
1244 
1245 
1246 //=================================================================================================
1247 //
1248 // MULTTRAIT SPECIALIZATIONS
1249 //
1250 //=================================================================================================
1251 
1252 //*************************************************************************************************
1254 template< typename T1, typename T2 >
1255 struct MultTraitEval1< T1, T2
1256  , EnableIf_t< IsVector_v<T1> &&
1257  IsNumeric_v<T2> &&
1258  IsZero_v<T1> > >
1259 {
1260  using ET1 = ElementType_t<T1>;
1261 
1262  using Type = ZeroVector< MultTrait_t<ET1,T2>, TransposeFlag_v<T1> >;
1263 };
1264 
1265 template< typename T1, typename T2 >
1266 struct MultTraitEval1< T1, T2
1267  , EnableIf_t< IsNumeric_v<T1> &&
1268  IsVector_v<T2> &&
1269  IsZero_v<T2> > >
1270 {
1271  using ET2 = ElementType_t<T2>;
1272 
1273  using Type = ZeroVector< MultTrait_t<T1,ET2>, TransposeFlag_v<T2> >;
1274 };
1275 
1276 template< typename T1, typename T2 >
1277 struct MultTraitEval1< T1, T2
1278  , EnableIf_t< ( ( IsRowVector_v<T1> && IsRowVector_v<T2> ) ||
1279  ( IsColumnVector_v<T1> && IsColumnVector_v<T2> ) ) &&
1280  ( IsZero_v<T1> || IsZero_v<T2> ) > >
1281 {
1282  using ET1 = ElementType_t<T1>;
1283  using ET2 = ElementType_t<T2>;
1284 
1285  using Type = ZeroVector< MultTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1286 };
1287 
1288 template< typename T1, typename T2 >
1289 struct MultTraitEval1< T1, T2
1290  , EnableIf_t< IsMatrix_v<T1> &&
1291  IsColumnVector_v<T2> &&
1292  ( IsZero_v<T1> || IsZero_v<T2> ) > >
1293 {
1294  using ET1 = ElementType_t<T1>;
1295  using ET2 = ElementType_t<T2>;
1296 
1297  using Type = ZeroVector< MultTrait_t<ET1,ET2>, false >;
1298 };
1299 
1300 template< typename T1, typename T2 >
1301 struct MultTraitEval1< T1, T2
1302  , EnableIf_t< IsRowVector_v<T1> &&
1303  IsMatrix_v<T2> &&
1304  ( IsZero_v<T1> || IsZero_v<T2> ) > >
1305 {
1306  using ET1 = ElementType_t<T1>;
1307  using ET2 = ElementType_t<T2>;
1308 
1309  using Type = ZeroVector< MultTrait_t<ET1,ET2>, true >;
1310 };
1312 //*************************************************************************************************
1313 
1314 
1315 
1316 
1317 //=================================================================================================
1318 //
1319 // DIVTRAIT SPECIALIZATIONS
1320 //
1321 //=================================================================================================
1322 
1323 //*************************************************************************************************
1325 template< typename T1, typename T2 >
1326 struct DivTraitEval1< T1, T2
1327  , EnableIf_t< IsVector_v<T1> &&
1328  IsNumeric_v<T2> &&
1329  IsZero_v<T1> > >
1330 {
1331  using ET1 = ElementType_t<T1>;
1332 
1333  using Type = ZeroVector< DivTrait_t<ET1,T2>, TransposeFlag_v<T1> >;
1334 };
1335 
1336 template< typename T1, typename T2 >
1337 struct DivTraitEval1< T1, T2
1338  , EnableIf_t< ( ( IsRowVector_v<T1> && IsRowVector_v<T2> ) ||
1339  ( IsColumnVector_v<T1> && IsColumnVector_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< DivTrait_t<ET1,ET2>, TransposeFlag_v<T1> >;
1346 };
1348 //*************************************************************************************************
1349 
1350 
1351 
1352 
1353 //=================================================================================================
1354 //
1355 // CROSSTRAIT SPECIALIZATIONS
1356 //
1357 //=================================================================================================
1358 
1359 //*************************************************************************************************
1361 template< typename T1, typename T2 >
1362 struct CrossTraitEval1< T1, T2
1363  , EnableIf_t< IsVector_v<T1> &&
1364  IsVector_v<T2> &&
1365  ( IsZero_v<T1> || IsZero_v<T2> ) > >
1366 {
1367  using Tmp = MultTrait_t< ElementType_t<T1>, ElementType_t<T2> >;
1368 
1369  using Type = ZeroVector< SubTrait_t<Tmp,Tmp>, TransposeFlag_v<T1> >;
1370 };
1372 //*************************************************************************************************
1373 
1374 
1375 
1376 
1377 //=================================================================================================
1378 //
1379 // MAPTRAIT SPECIALIZATIONS
1380 //
1381 //=================================================================================================
1382 
1383 //*************************************************************************************************
1385 template< typename T, typename OP >
1386 struct UnaryMapTraitEval1< T, OP
1387  , EnableIf_t< IsVector_v<T> &&
1388  YieldsZero_v<OP,T> > >
1389 {
1390  using ET = ElementType_t<T>;
1391 
1392  using Type = ZeroVector< MapTrait_t<ET,OP>, TransposeFlag_v<T> >;
1393 };
1395 //*************************************************************************************************
1396 
1397 
1398 //*************************************************************************************************
1400 template< typename T1, typename T2, typename OP >
1401 struct BinaryMapTraitEval1< T1, T2, OP
1402  , EnableIf_t< IsVector_v<T1> &&
1403  IsVector_v<T2> &&
1404  YieldsZero_v<OP,T1,T2> > >
1405 {
1406  using ET1 = ElementType_t<T1>;
1407  using ET2 = ElementType_t<T2>;
1408 
1409  using Type = ZeroVector< MapTrait_t<ET1,ET2,OP>, TransposeFlag_v<T1> >;
1410 };
1412 //*************************************************************************************************
1413 
1414 
1415 
1416 
1417 //=================================================================================================
1418 //
1419 // HIGHTYPE SPECIALIZATIONS
1420 //
1421 //=================================================================================================
1422 
1423 //*************************************************************************************************
1425 template< typename T1, bool TF, typename T2 >
1426 struct HighType< ZeroVector<T1,TF>, ZeroVector<T2,TF> >
1427 {
1428  using Type = ZeroVector< typename HighType<T1,T2>::Type, TF >;
1429 };
1431 //*************************************************************************************************
1432 
1433 
1434 
1435 
1436 //=================================================================================================
1437 //
1438 // LOWTYPE SPECIALIZATIONS
1439 //
1440 //=================================================================================================
1441 
1442 //*************************************************************************************************
1444 template< typename T1, bool TF, typename T2 >
1445 struct LowType< ZeroVector<T1,TF>, ZeroVector<T2,TF> >
1446 {
1447  using Type = ZeroVector< typename LowType<T1,T2>::Type, TF >;
1448 };
1450 //*************************************************************************************************
1451 
1452 
1453 
1454 
1455 //=================================================================================================
1456 //
1457 // SUBVECTORTRAIT SPECIALIZATIONS
1458 //
1459 //=================================================================================================
1460 
1461 //*************************************************************************************************
1463 template< typename VT, size_t I, size_t N >
1464 struct SubvectorTraitEval1< VT, I, N
1465  , EnableIf_t< IsZero_v<VT> > >
1466 {
1467  using Type = ZeroVector< RemoveConst_t< ElementType_t<VT> >, TransposeFlag_v<VT> >;
1468 };
1470 //*************************************************************************************************
1471 
1472 
1473 
1474 
1475 //=================================================================================================
1476 //
1477 // ELEMENTSTRAIT SPECIALIZATIONS
1478 //
1479 //=================================================================================================
1480 
1481 //*************************************************************************************************
1483 template< typename VT, size_t N >
1484 struct ElementsTraitEval1< VT, N
1485  , EnableIf_t< IsZero_v<VT> > >
1486 {
1487  using Type = ZeroVector< RemoveConst_t< ElementType_t<VT> >, TransposeFlag_v<VT> >;
1488 };
1490 //*************************************************************************************************
1491 
1492 
1493 
1494 
1495 //=================================================================================================
1496 //
1497 // ROWTRAIT SPECIALIZATIONS
1498 //
1499 //=================================================================================================
1500 
1501 //*************************************************************************************************
1503 template< typename MT, size_t I >
1504 struct RowTraitEval1< MT, I
1505  , EnableIf_t< IsZero_v<MT> > >
1506 {
1507  using Type = ZeroVector< RemoveConst_t< ElementType_t<MT> >, true >;
1508 };
1510 //*************************************************************************************************
1511 
1512 
1513 
1514 
1515 //=================================================================================================
1516 //
1517 // COLUMNTRAIT SPECIALIZATIONS
1518 //
1519 //=================================================================================================
1520 
1521 //*************************************************************************************************
1523 template< typename MT, size_t I >
1524 struct ColumnTraitEval1< MT, I
1525  , EnableIf_t< IsZero_v<MT> > >
1526 {
1527  using Type = ZeroVector< RemoveConst_t< ElementType_t<MT> >, false >;
1528 };
1530 //*************************************************************************************************
1531 
1532 
1533 
1534 
1535 //=================================================================================================
1536 //
1537 // BANDTRAIT SPECIALIZATIONS
1538 //
1539 //=================================================================================================
1540 
1541 //*************************************************************************************************
1543 template< typename MT, ptrdiff_t I >
1544 struct BandTraitEval1< MT, I
1545  , EnableIf_t< IsZero_v<MT> > >
1546 {
1547  using Type = ZeroVector< RemoveConst_t< ElementType_t<MT> >, defaultTransposeFlag >;
1548 };
1550 //*************************************************************************************************
1551 
1552 } // namespace blaze
1553 
1554 #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, a compilation error is created.
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.
#define BLAZE_USER_ASSERT(expr, msg)
Run time assertion macro for user checks.In case of an invalid run time expression, the program execution is terminated. The BLAZE_USER_ASSERT macro can be disabled by setting the BLAZE_USER_ASSERT flag to zero or by defining NDEBUG during the compilation.
Definition: Assert.h:117
Header file for the UNUSED_PARAMETER function template.
Header file for the subtraction trait.
Header file for basic type definitions.
constexpr ZeroVector() noexcept
The default constructor for ZeroVector.
Definition: ZeroVector.h:338
Header file for the SparseVector base class.
constexpr bool IsMatrix_v
Auxiliary variable template for the IsMatrix type trait.The IsMatrix_v variable template provides a c...
Definition: IsMatrix.h:139
Header file for the row trait.
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:178
void reset(const DiagonalProxy< MT > &proxy)
Resetting the represented element to the default initial values.
Definition: DiagonalProxy.h:591
const Type & Reference
Reference to a zero vector element.
Definition: ZeroVector.h:185
Header file for the IsRowVector type trait.
bool canSMPAssign() const noexcept
Returns whether the vector can be used in SMP assignments.
Definition: ZeroVector.h:776
static constexpr bool smpAssignable
Compilation flag for SMP assignments.
Definition: ZeroVector.h:214
#define BLAZE_CONSTRAINT_MUST_NOT_BE_VOLATILE(T)
Constraint on the data type.In case the given data type is a volatile-qualified type, a compilation error is created.
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: TrueType.h:61
Element * Iterator
Iterator over non-constant elements.
Definition: CompressedMatrix.h:3085
size_t size_
The current size/dimension of the zero vector.
Definition: ZeroVector.h:295
constexpr void resize(size_t n) noexcept
Changing the size of the zero vector.
Definition: ZeroVector.h:607
constexpr void UNUSED_PARAMETER(const Args &...)
Suppression of unused parameter warnings.
Definition: Unused.h:81
Header file for the elements trait.
Header file for the band trait.
Constraint on the data type.
Header file for the IsMatrix type trait.
constexpr ConstIterator cbegin() const noexcept
Returns an iterator to the first non-zero element of the zero vector.
Definition: ZeroVector.h:454
bool isZero(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is 0.
Definition: DiagonalProxy.h:673
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:588
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:182
Namespace of the Blaze C++ math library.
Definition: Blaze.h:58
Header file for all forward declarations of the math module.
#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:733
bool isAliased(const Other *alias) const noexcept
Returns whether the vector is aliased with the given address alias.
Definition: ZeroVector.h:755
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:1335
const Type & ConstReference
Reference to a constant zero vector element.
Definition: ZeroVector.h:186
Resize mechanism to obtain a ZeroVector with a different fixed number of elements.
Definition: ZeroVector.h:204
constexpr bool IsVector_v
Auxiliary variable template for the IsVector type trait.The IsVector_v variable template provides a c...
Definition: IsVector.h:140
constexpr ConstIterator begin() const noexcept
Returns an iterator to the first non-zero element of the zero vector.
Definition: ZeroVector.h:439
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:396
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:572
Header file for the IsVector type trait.
static const Type zero_
The zero element.
Definition: ZeroVector.h:297
Header file for the EnableIf class template.
void clear(const DiagonalProxy< MT > &proxy)
Clearing the represented element.
Definition: DiagonalProxy.h:611
constexpr bool IsZero_v
Auxiliary variable template for the IsZero type trait.The IsZero_v variable template provides a conve...
Definition: IsZero.h:165
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:701
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:653
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:555
Header file for the IsZero type trait.
#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, a compilation error is created.
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:281
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:484
Rebind mechanism to obtain a ZeroVector with different data/element type.
Definition: ZeroVector.h:195
ConstIterator lowerBound(size_t index) const
Returns an iterator to the first index not less then the given index.
Definition: ZeroVector.h:677
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:73
constexpr bool IsRowVector_v
Auxiliary variable template for the IsRowVector type trait.The IsRowVector_v variable template provid...
Definition: IsRowVector.h:143
Base class for N-dimensional vectors.The Vector class is a base class for all arbitrarily sized (N-di...
Definition: Forward.h:186
Header file for the default transpose flag for all vectors of the Blaze library.
static const Type zero_
Neutral element for accesses to zero elements.
Definition: CompressedMatrix.h:3295
Base class for sparse vectors.The SparseVector class is a base class for all arbitrarily sized (N-dim...
Definition: Forward.h:138
Header file for the map trait.
bool isIntact(const DiagonalMatrix< MT, SO, DF > &m)
Returns whether the invariants of the given diagonal matrix are intact.
Definition: DiagonalMatrix.h:263
ConstReference at(size_t index) const
Checked access to the zero vector elements.
Definition: ZeroVector.h:420
const Type & ReturnType
Return type for expression template evaluations.
Definition: ZeroVector.h:183
bool isDefault(const DiagonalProxy< MT > &proxy)
Returns whether the represented element is in default state.
Definition: DiagonalProxy.h:631
constexpr size_t size() const noexcept
Returns the current size/dimension of the zero vector.
Definition: ZeroVector.h:541
constexpr void swap(ZeroVector &v) noexcept
Swapping the contents of two zero vectors.
Definition: ZeroVector.h:622
constexpr ConstIterator end() const noexcept
Returns an iterator just past the last non-zero element of the zero vector.
Definition: ZeroVector.h:469
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 HighType type trait.
Header file for the TrueType type/value trait base class.
Header file for the function trace functionality.