ValueIndexPair.h
Go to the documentation of this file.
1 //=================================================================================================
33 //=================================================================================================
34 
35 #ifndef _BLAZE_MATH_SPARSE_VALUEINDEXPAIR_H_
36 #define _BLAZE_MATH_SPARSE_VALUEINDEXPAIR_H_
37 
38 
39 //*************************************************************************************************
40 // Includes
41 //*************************************************************************************************
42 
49 #include <blaze/util/EnableIf.h>
50 #include <blaze/util/mpl/And.h>
51 #include <blaze/util/mpl/Not.h>
52 #include <blaze/util/Types.h>
55 
56 
57 namespace blaze {
58 
59 //=================================================================================================
60 //
61 // CLASS DEFINITION
62 //
63 //=================================================================================================
64 
65 //*************************************************************************************************
72 template< typename Type > // Type of the value element
74 {
75  public:
76  //**Type definitions****************************************************************************
77  typedef Type ValueType;
78  typedef size_t IndexType;
79  typedef Type& Reference;
80  typedef const Type& ConstReference;
81  //**********************************************************************************************
82 
83  //**Constructors********************************************************************************
84  inline ValueIndexPair();
85  inline ValueIndexPair( const Type& v, size_t i );
86  // No explicitly declared copy constructor.
87  // No explicitly declared move constructor.
88  //**********************************************************************************************
89 
90  //**Destructor**********************************************************************************
91  // No explicitly declared destructor.
92  //**********************************************************************************************
93 
94  //**Operators***********************************************************************************
97  // No explicitly declared copy assignment operator.
98  // No explicitly declared move assignment operator.
99 
100  template< typename Other >
102  operator=( const Other& rhs );
103 
104  template< typename Other >
107  operator=( Other&& rhs );
108 
109  template< typename Other >
111  operator=( const Other& v );
112 
113  template< typename Other >
115  , IsRValueReference<Other&&> >, ValueIndexPair& >
116  operator=( Other&& v );
117 
118  template< typename Other > inline ValueIndexPair& operator+=( const Other& v );
119  template< typename Other > inline ValueIndexPair& operator-=( const Other& v );
120  template< typename Other > inline ValueIndexPair& operator*=( const Other& v );
121  template< typename Other > inline ValueIndexPair& operator/=( const Other& v );
123  //**********************************************************************************************
124 
125  //**Acess functions*****************************************************************************
128  inline Reference value();
129  inline ConstReference value() const;
130  inline IndexType index() const;
132  //**********************************************************************************************
133 
134  protected:
135  //**Member variables****************************************************************************
138  Type value_;
139  size_t index_;
140 
141  //**********************************************************************************************
142 
143  private:
144  //**Friend declarations*************************************************************************
146  template< typename Other > friend class ValueIndexPair;
148  //**********************************************************************************************
149 
150  //**Compile time checks*************************************************************************
157  //**********************************************************************************************
158 };
159 //*************************************************************************************************
160 
161 
162 
163 
164 //=================================================================================================
165 //
166 // CONSTRUCTORS
167 //
168 //=================================================================================================
169 
170 //*************************************************************************************************
173 template< typename Type > // Type of the value element
175  : value_() // Value of the value-index-pair
176  , index_() // Index of the value-index-pair
177 {}
178 //*************************************************************************************************
179 
180 
181 //*************************************************************************************************
187 template< typename Type > // Type of the value element
188 inline ValueIndexPair<Type>::ValueIndexPair( const Type& v, size_t i )
189  : value_( v ) // Value of the value-index-pair
190  , index_( i ) // Index of the value-index-pair
191 {}
192 //*************************************************************************************************
193 
194 
195 
196 
197 //=================================================================================================
198 //
199 // OPERATORS
200 //
201 //=================================================================================================
202 
203 //*************************************************************************************************
213 template< typename Type > // Type of the value element
214 template< typename Other > // Data type of the right-hand side value-index-pair
217 {
218  value_ = rhs.value();
219  index_ = rhs.index();
220  return *this;
221 }
222 //*************************************************************************************************
223 
224 
225 //*************************************************************************************************
235 template< typename Type > // Type of the value element
236 template< typename Other > // Data type of the right-hand side value-index-pair
240 {
241  value_ = std::move( rhs.value() );
242  index_ = rhs.index();
243  return *this;
244 }
245 //*************************************************************************************************
246 
247 
248 //*************************************************************************************************
254 template< typename Type > // Type of the value element
255 template< typename Other > // Data type of the right-hand side value
258 {
259  value_ = v;
260  return *this;
261 }
262 //*************************************************************************************************
263 
264 
265 //*************************************************************************************************
271 template< typename Type > // Type of the value element
272 template< typename Other > // Data type of the right-hand side value
274  , IsRValueReference<Other&&> >, ValueIndexPair<Type>& >
276 {
277  value_ = std::move( v );
278  return *this;
279 }
280 //*************************************************************************************************
281 
282 
283 //*************************************************************************************************
289 template< typename Type > // Type of the value element
290 template< typename Other > // Data type of the right-hand side value
292 {
293  value_ += v;
294  return *this;
295 }
296 //*************************************************************************************************
297 
298 
299 //*************************************************************************************************
305 template< typename Type > // Type of the value element
306 template< typename Other > // Data type of the right-hand side value
308 {
309  value_ -= v;
310  return *this;
311 }
312 //*************************************************************************************************
313 
314 
315 //*************************************************************************************************
321 template< typename Type > // Type of the value element
322 template< typename Other > // Data type of the right-hand side value
324 {
325  value_ *= v;
326  return *this;
327 }
328 //*************************************************************************************************
329 
330 
331 //*************************************************************************************************
337 template< typename Type > // Type of the value element
338 template< typename Other > // Data type of the right-hand side value
340 {
341  value_ /= v;
342  return *this;
343 }
344 //*************************************************************************************************
345 
346 
347 
348 
349 //=================================================================================================
350 //
351 // ACCESS FUNCTIONS
352 //
353 //=================================================================================================
354 
355 //*************************************************************************************************
360 template< typename Type > // Type of the value element
362 {
363  return value_;
364 }
365 //*************************************************************************************************
366 
367 
368 //*************************************************************************************************
373 template< typename Type > // Type of the value element
375 {
376  return value_;
377 }
378 //*************************************************************************************************
379 
380 
381 //*************************************************************************************************
386 template< typename Type > // Type of the value element
388 {
389  return index_;
390 }
391 //*************************************************************************************************
392 
393 } // namespace blaze
394 
395 #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
size_t IndexType
The index type of the value-index-pair.
Definition: ValueIndexPair.h:78
Header file for basic type definitions.
BLAZE_ALWAYS_INLINE T1 & operator/=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Division assignment operator for the division of two SIMD packs.
Definition: BasicTypes.h:1339
Header file for the And class 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, a compilation error is created.
Definition: Volatile.h:79
BLAZE_ALWAYS_INLINE T1 & operator*=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Multiplication assignment operator for the multiplication of two SIMD packs.
Definition: BasicTypes.h:1321
const Type & ConstReference
Reference-to-const return type.
Definition: ValueIndexPair.h:80
Constraint on the data type.
Type ValueType
The value type of the value-index-pair.
Definition: ValueIndexPair.h:77
Namespace of the Blaze C++ math library.
Definition: Blaze.h:57
#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
Type & Reference
Reference return type.
Definition: ValueIndexPair.h:79
Header file for the Not class template.
Constraint on the data type.
Header file for the SparseElement base class.
size_t index_
Index of the value-index-pair.
Definition: ValueIndexPair.h:139
Header file for the EnableIf class template.
BLAZE_ALWAYS_INLINE T1 & operator+=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Addition assignment operator for the addition of two SIMD packs.
Definition: BasicTypes.h:1285
Header file for the IsRValueReference type trait.
Constraint on the data type.
#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
Constraint on the data type.
Base class for all sparse element types.The SparseElement class is the base class for all sparse elem...
Definition: SparseElement.h:57
Header file for the RemoveReference type trait.
typename EnableIf< Condition, T >::Type EnableIf_
Auxiliary alias declaration for the EnableIf class template.The EnableIf_ alias declaration provides ...
Definition: EnableIf.h:223
Header file for the IsSparseElement type trait class.
IndexType index() const
Access to the current index of the value-index-pair.
Definition: ValueIndexPair.h:387
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:73
Type value_
Value of the value-index-pair.
Definition: ValueIndexPair.h:138
Compile time type check.This class tests whether the given template parameter T is an rvalue referenc...
Definition: IsRValueReference.h:77
ValueIndexPair()
Default constructor for value-index-pairs.
Definition: ValueIndexPair.h:174
BLAZE_ALWAYS_INLINE T1 & operator-=(SIMDPack< T1 > &lhs, const SIMDPack< T2 > &rhs)
Subtraction assignment operator for the subtraction of two SIMD packs.
Definition: BasicTypes.h:1303
Size type of the Blaze library.
Reference value()
Access to the current value of the value-index-pair.
Definition: ValueIndexPair.h:361