All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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/DisableIf.h>
50 #include <blaze/util/EnableIf.h>
51 
52 
53 namespace blaze {
54 
55 //=================================================================================================
56 //
57 // CLASS DEFINITION
58 //
59 //=================================================================================================
60 
61 //*************************************************************************************************
68 template< typename Type > // Type of the value element
70 {
71  public:
72  //**Type definitions****************************************************************************
73  typedef Type ValueType;
74  typedef size_t IndexType;
75  //**********************************************************************************************
76 
77  //**Constructors********************************************************************************
78  inline ValueIndexPair();
79  inline ValueIndexPair( const Type& v, size_t i );
80  // No explicitly declared copy constructor.
81  //**********************************************************************************************
82 
83  //**Destructor**********************************************************************************
84  // No explicitly declared destructor.
85  //**********************************************************************************************
86 
87  //**Operators***********************************************************************************
90  // No explicitly declared copy assignment operator.
91 
92  template< typename Other >
93  inline typename EnableIf< IsSparseElement<Other>, ValueIndexPair& >::Type
94  operator=( const Other& rhs );
95 
96  template< typename Other >
97  inline typename DisableIf< IsSparseElement<Other>, ValueIndexPair& >::Type
98  operator=( const Other& v );
99 
100  template< typename Other > inline ValueIndexPair& operator+=( const Other& v );
101  template< typename Other > inline ValueIndexPair& operator-=( const Other& v );
102  template< typename Other > inline ValueIndexPair& operator*=( const Other& v );
103  template< typename Other > inline ValueIndexPair& operator/=( const Other& v );
105  //**********************************************************************************************
106 
107  //**Acess functions*****************************************************************************
110  inline Type& value();
111  inline const Type& value() const;
112  inline size_t index() const;
114  //**********************************************************************************************
115 
116  protected:
117  //**Member variables****************************************************************************
120  Type value_;
121  size_t index_;
122 
123  //**********************************************************************************************
124 
125  private:
126  //**Friend declarations*************************************************************************
128  template< typename Other > friend class ValueIndexPair;
130  //**********************************************************************************************
131 
132  //**Compile time checks*************************************************************************
139  //**********************************************************************************************
140 };
141 //*************************************************************************************************
142 
143 
144 
145 
146 //=================================================================================================
147 //
148 // CONSTRUCTORS
149 //
150 //=================================================================================================
151 
152 //*************************************************************************************************
155 template< typename Type > // Type of the value element
157  : value_() // Value of the value-index-pair
158  , index_() // Index of the value-index-pair
159 {}
160 //*************************************************************************************************
161 
162 
163 //*************************************************************************************************
169 template< typename Type > // Type of the value element
170 inline ValueIndexPair<Type>::ValueIndexPair( const Type& v, size_t i )
171  : value_( v ) // Value of the value-index-pair
172  , index_( i ) // Index of the value-index-pair
173 {}
174 //*************************************************************************************************
175 
176 
177 
178 
179 //=================================================================================================
180 //
181 // OPERATORS
182 //
183 //=================================================================================================
184 
185 //*************************************************************************************************
195 template< typename Type > // Type of the value element
196 template< typename Other > // Data type of the right-hand side value-index-pair
199 {
200  value_ = rhs.value();
201  index_ = rhs.index();
202  return *this;
203 }
204 //*************************************************************************************************
205 
206 
207 //*************************************************************************************************
213 template< typename Type > // Type of the value element
214 template< typename Other > // Data type of the right-hand side value
217 {
218  value_ = v;
219  return *this;
220 }
221 //*************************************************************************************************
222 
223 
224 //*************************************************************************************************
230 template< typename Type > // Type of the value element
231 template< typename Other > // Data type of the right-hand side value
233 {
234  value_ += v;
235  return *this;
236 }
237 //*************************************************************************************************
238 
239 
240 //*************************************************************************************************
246 template< typename Type > // Type of the value element
247 template< typename Other > // Data type of the right-hand side value
249 {
250  value_ -= v;
251  return *this;
252 }
253 //*************************************************************************************************
254 
255 
256 //*************************************************************************************************
262 template< typename Type > // Type of the value element
263 template< typename Other > // Data type of the right-hand side value
265 {
266  value_ *= v;
267  return *this;
268 }
269 //*************************************************************************************************
270 
271 
272 //*************************************************************************************************
278 template< typename Type > // Type of the value element
279 template< typename Other > // Data type of the right-hand side value
281 {
282  value_ /= v;
283  return *this;
284 }
285 //*************************************************************************************************
286 
287 
288 
289 
290 //=================================================================================================
291 //
292 // ACCESS FUNCTIONS
293 //
294 //=================================================================================================
295 
296 //*************************************************************************************************
301 template< typename Type > // Type of the value element
303 {
304  return value_;
305 }
306 //*************************************************************************************************
307 
308 
309 //*************************************************************************************************
314 template< typename Type > // Type of the value element
315 inline const Type& ValueIndexPair<Type>::value() const
316 {
317  return value_;
318 }
319 //*************************************************************************************************
320 
321 
322 //*************************************************************************************************
327 template< typename Type > // Type of the value element
328 inline size_t ValueIndexPair<Type>::index() const
329 {
330  return index_;
331 }
332 //*************************************************************************************************
333 
334 } // namespace blaze
335 
336 #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:116
size_t IndexType
The index type of the value-index-pair.
Definition: ValueIndexPair.h:74
#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:116
Constraint on the data type.
Header file for the DisableIf class template.
Type ValueType
The value type of the value-index-pair.
Definition: ValueIndexPair.h:73
#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:116
Constraint on the data type.
Header file for the SparseElement base class.
size_t index_
Index of the value-index-pair.
Definition: ValueIndexPair.h:121
Header file for the EnableIf class template.
Constraint on the data type.
Substitution Failure Is Not An Error (SFINAE) class.The EnableIf class template is an auxiliary tool ...
Definition: EnableIf.h:184
#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:116
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
Substitution Failure Is Not An Error (SFINAE) class.The DisableIf class template is an auxiliary tool...
Definition: DisableIf.h:184
Header file for the IsSparseElement type trait class.
size_t index() const
Access to the current index of the value-index-pair.
Definition: ValueIndexPair.h:328
Index-value-pair for sparse vectors and matrices.The ValueIndexPair class represents a single index-v...
Definition: ValueIndexPair.h:69
Type value_
Value of the value-index-pair.
Definition: ValueIndexPair.h:120
ValueIndexPair()
Default constructor for value-index-pairs.
Definition: ValueIndexPair.h:156
Type & value()
Access to the current value of the value-index-pair.
Definition: ValueIndexPair.h:302