All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SparseElement.h
Go to the documentation of this file.
1 //=================================================================================================
20 //=================================================================================================
21 
22 #ifndef _BLAZE_MATH_SPARSE_SPARSEELEMENT_H_
23 #define _BLAZE_MATH_SPARSE_SPARSEELEMENT_H_
24 
25 
26 namespace blaze {
27 
28 //=================================================================================================
29 //
30 // CLASS DEFINITION
31 //
32 //=================================================================================================
33 
34 //*************************************************************************************************
41 template< typename Type > // Type of the data element
43 {
44  public:
45  //**Type definitions****************************************************************************
46  typedef Type ValueType;
47  typedef size_t IndexType;
48  //**********************************************************************************************
49 
50  //**Constructors********************************************************************************
51  inline SparseElement();
52  inline SparseElement( const Type& v, size_t i );
53  // No explicitly declared copy constructor.
54  //**********************************************************************************************
55 
56  //**Destructor**********************************************************************************
57  // No explicitly declared destructor.
58  //**********************************************************************************************
59 
60  //**Operators***********************************************************************************
63  // No explicitly declared copy assignment operator.
64  template< typename Other > SparseElement& operator=( const SparseElement<Other>& rhs );
65 
66  inline SparseElement& operator= ( const Type& v );
67  inline SparseElement& operator+=( const Type& v );
68  inline SparseElement& operator-=( const Type& v );
69  inline SparseElement& operator*=( const Type& v );
70  inline SparseElement& operator/=( const Type& v );
72  //**********************************************************************************************
73 
74  //**Acess functions*****************************************************************************
77  inline Type& value();
78  inline const Type& value() const;
79  inline size_t index() const;
81  //**********************************************************************************************
82 
83  protected:
84  //**Member variables****************************************************************************
87  Type value_;
88  size_t index_;
89 
90  //**********************************************************************************************
91 
92  private:
93  //**Friend declarations*************************************************************************
95  template< typename Other > friend class SparseElement;
97  //**********************************************************************************************
98 };
99 //*************************************************************************************************
100 
101 
102 
103 
104 //=================================================================================================
105 //
106 // CONSTRUCTORS
107 //
108 //=================================================================================================
109 
110 //*************************************************************************************************
113 template< typename Type > // Data type of the sparse element
115  : value_() // Value of the sparse element
116  , index_() // Index of the sparse element
117 {}
118 //*************************************************************************************************
119 
120 
121 //*************************************************************************************************
127 template< typename Type > // Data type of the sparse element
128 inline SparseElement<Type>::SparseElement( const Type& v, size_t i )
129  : value_( v ) // Value of the sparse element
130  , index_( i ) // Index of the sparse element
131 {}
132 //*************************************************************************************************
133 
134 
135 
136 
137 //=================================================================================================
138 //
139 // OPERATORS
140 //
141 //=================================================================================================
142 
143 //*************************************************************************************************
149 template< typename Type > // Data type of the sparse element
150 template< typename Other > // Data type of the right-hand side sparse element
152 {
153  value_ = rhs.value_;
154  index_ = rhs.index_;
155  return *this;
156 }
157 //*************************************************************************************************
158 
159 
160 //*************************************************************************************************
166 template< typename Type > // Data type of the sparse element
168 {
169  value_ = v;
170  return *this;
171 }
172 //*************************************************************************************************
173 
174 
175 //*************************************************************************************************
181 template< typename Type > // Data type of the sparse element
183 {
184  value_ += v;
185  return *this;
186 }
187 //*************************************************************************************************
188 
189 
190 //*************************************************************************************************
196 template< typename Type > // Data type of the sparse element
198 {
199  value_ -= v;
200  return *this;
201 }
202 //*************************************************************************************************
203 
204 
205 //*************************************************************************************************
211 template< typename Type > // Data type of the sparse element
213 {
214  value_ *= v;
215  return *this;
216 }
217 //*************************************************************************************************
218 
219 
220 //*************************************************************************************************
226 template< typename Type > // Data type of the sparse element
228 {
229  value_ /= v;
230  return *this;
231 }
232 //*************************************************************************************************
233 
234 
235 
236 
237 //=================================================================================================
238 //
239 // ACCESS FUNCTIONS
240 //
241 //=================================================================================================
242 
243 //*************************************************************************************************
248 template< typename Type > // Data type of the sparse element
250 {
251  return value_;
252 }
253 //*************************************************************************************************
254 
255 
256 //*************************************************************************************************
261 template< typename Type > // Data type of the sparse element
262 inline const Type& SparseElement<Type>::value() const
263 {
264  return value_;
265 }
266 //*************************************************************************************************
267 
268 
269 //*************************************************************************************************
274 template< typename Type > // Data type of the sparse element
275 inline size_t SparseElement<Type>::index() const
276 {
277  return index_;
278 }
279 //*************************************************************************************************
280 
281 } // namespace blaze
282 
283 #endif